crypto.bi – ELI5 Cryptography, cryptocurrency and programming

avax-python Network Message Pipeline

Here’s a short overview of the avax-python Avalanche message pipeline.

We’ve followed the reference Go implementation as closely as possible, but the Python code is still in very early development, so it’s lacking a lot of details. For example, right now the Python message pipeline is synchronous, whereas the Go implementation uses asynchronous channels and parallel goroutines.

If you’re trying to learn how the Avalanche Go node implementation works, the avax-python code may actually be useful in this respect, because it’s barebones and straight to the point. The ideas are the same. Since Avalanche is a multi-blockchain platform, where new chains and DAGs can be added dynamically, the system requires a routing system which delivers messages to the correct consensus engine and VM instance.

For example, messages to/from the P-Chain must go to the blockchain based consensus engine and VM, while X-Chain messages must go to the Avalanche DAG-based subsystem. But the network interface sends and receives all messages together – after all we usually only have one pathway to the Internet. So, most the work is performed in the routing part, which requires us to correctly decode binary network data, find the correct chain ID and route the message to the right consensus subsystem.

So here’s a quick summary of the path taken by an Avalanche message arriving from the network and into the consensus sytem:

So, this is a short summary of the path taken by network messages from the wire to the consensus engines and VM’s.

If you’re trying to learn the Go implementation, this summary is pretty close to what the Golang code does. Except the Go implementation is asynchronous and uses advanced multitasking constructs like channels and parallel goroutines to achieve high throughput.

Links

avax-python Github Project Page

Reference Avalanche Golang Implementation

Exit mobile version