Network
Introduction#
The network layer in aelf is vital for maintaining connections and communication between nodes. It supports higher-level logic like synchronization and allows node operators to monitor and manage network operations. aelf uses gRPC for connections to keep the design simple and flexible.
Architecture#
The network consists of three layers:
aelf.OS#
This layer monitors and handles network-related events:
It also performs regular tasks:
aelf.OS.Core.Network#
This core module includes:
aelf.OS.Network.Grpc#
Implements the infrastructure layer using gRPC:
Extra functionalities include:
Protocol#
Nodes use a defined network interface protocol for normal operation and data synchronization.
Connection#
DoHandshake#
When a node connects, it exchanges handshake information. This includes chain status, current height, and more.
1rpc DoHandshake (HandshakeRequest) returns (HandshakeReply) {}
1message Handshake {2HandshakeData handshake_data = 1;3bytes signature = 2;4bytes session_id = 3;5}
1message HandshakeData {2int32 chain_id = 1;3int32 version = 2;4int32 listening_port = 3;5bytes pubkey = 4;6aelf.Hash best_chain_hash = 5;7int64 best_chain_height = 6;8aelf.Hash last_irreversible_block_hash = 7;9int64 last_irreversible_block_height = 8;10google.protobuf.Timestamp time = 9;11}
ConfirmHandshake#
Confirms the handshake with the target node.
1rpc ConfirmHandshake (ConfirmHandshakeRequest) returns (VoidReply) {}
Broadcasting#
BlockBroadcastStream#
Receives block information after packaging.
1rpc BlockBroadcastStream (stream BlockWithTransactions) returns (VoidReply) {}
TransactionBroadcastStream#
Receives forwarded transaction information.
1rpc TransactionBroadcastStream (stream aelf.Transaction) returns (VoidReply) {}
AnnouncementBroadcastStream#
Receives block announcements.
1rpc AnnouncementBroadcastStream (stream BlockAnnouncement) returns (VoidReply) {}
LibAnnouncementBroadcastStream#
Receives last irreversible block (LIB) announcements.
1rpc LibAnnouncementBroadcastStream (stream LibAnnouncement) returns (VoidReply) {}
Block Request#
RequestBlock#
Requests a single block.
1rpc RequestBlock (BlockRequest) returns (BlockReply) {}
RequestBlocks#
Requests multiple blocks.
1rpc RequestBlocks (BlocksRequest) returns (BlockList) {}
Peer Management#
Ping#
Verifies network availability.
1rpc Ping (PingRequest) returns (PongReply) {}
CheckHealth#
Performs health checks on peers.
1rpc CheckHealth (HealthCheckRequest) returns (HealthCheckReply) {}
Edited on: 14 July 2024 05:07:42 GMT+0