github.com/MetalBlockchain/metalgo@v1.11.9/proto/p2p/p2p.proto (about) 1 syntax = "proto3"; 2 3 package p2p; 4 5 // Reference: https://developers.google.com/protocol-buffers/docs/proto3 6 option go_package = "github.com/ava-labs/avalanchego/proto/pb/p2p"; 7 8 // Represents peer-to-peer messages. 9 // Only one type can be non-null. 10 message Message { 11 reserved 1; // Until E upgrade is activated. 12 reserved 36; // Next unused field number. 13 // NOTES 14 // Use "oneof" for each message type and set rest to null if not used. 15 // That is because when the compression is enabled, we don't want to include uncompressed fields. 16 oneof message { 17 // zstd-compressed bytes of a "p2p.Message" whose "oneof" "message" field is 18 // NOT compressed_* BUT one of the message types (e.g. ping, pong, etc.). 19 // This field is only set if the message type supports compression. 20 bytes compressed_zstd = 2; 21 22 // Fields lower than 10 are reserved for other compression algorithms. 23 // TODO: support COMPRESS_SNAPPY 24 25 // Network messages: 26 Ping ping = 11; 27 Pong pong = 12; 28 Handshake handshake = 13; 29 GetPeerList get_peer_list = 35; 30 PeerList peer_list = 14; 31 32 // State-sync messages: 33 GetStateSummaryFrontier get_state_summary_frontier = 15; 34 StateSummaryFrontier state_summary_frontier = 16; 35 GetAcceptedStateSummary get_accepted_state_summary = 17; 36 AcceptedStateSummary accepted_state_summary = 18; 37 38 // Bootstrapping messages: 39 GetAcceptedFrontier get_accepted_frontier = 19; 40 AcceptedFrontier accepted_frontier = 20; 41 GetAccepted get_accepted = 21; 42 Accepted accepted = 22; 43 GetAncestors get_ancestors = 23; 44 Ancestors ancestors = 24; 45 46 // Consensus messages: 47 Get get = 25; 48 Put put = 26; 49 PushQuery push_query = 27; 50 PullQuery pull_query = 28; 51 Chits chits = 29; 52 53 // App messages: 54 AppRequest app_request = 30; 55 AppResponse app_response = 31; 56 AppGossip app_gossip = 32; 57 AppError app_error = 34; 58 } 59 } 60 61 // Ping reports a peer's perceived uptime percentage. 62 // 63 // Peers should respond to Ping with a Pong. 64 message Ping { 65 // Uptime percentage on the primary network [0, 100] 66 uint32 uptime = 1; 67 // Uptime percentage on subnets 68 repeated SubnetUptime subnet_uptimes = 2; 69 } 70 71 // SubnetUptime is a descriptor for a peer's perceived uptime on a subnet. 72 message SubnetUptime { 73 // Subnet the peer is validating 74 bytes subnet_id = 1; 75 // Uptime percentage on the subnet [0, 100] 76 uint32 uptime = 2; 77 } 78 79 // Pong is sent in response to a Ping. 80 message Pong { 81 reserved 1, 2; // Until E upgrade is activated. 82 } 83 84 // Handshake is the first outbound message sent to a peer when a connection is 85 // established to start the p2p handshake. 86 // 87 // Peers must respond to a Handshake message with a PeerList message to allow the 88 // peer to connect to other peers in the network. 89 // 90 // Peers should drop connections to peers with incompatible versions. 91 message Handshake { 92 reserved 5; // Until E upgrade is activated. 93 // Network the peer is running on (e.g local, testnet, mainnet) 94 uint32 network_id = 1; 95 // Unix timestamp when this Handshake message was created 96 uint64 my_time = 2; 97 // IP address of the peer 98 bytes ip_addr = 3; 99 // IP port of the peer 100 uint32 ip_port = 4; 101 // Timestamp of the IP 102 uint64 ip_signing_time = 6; 103 // Signature of the peer IP port pair at a provided timestamp with the TLS 104 // key. 105 bytes ip_node_id_sig = 7; 106 // Subnets the peer is tracking 107 repeated bytes tracked_subnets = 8; 108 Client client = 9; 109 repeated uint32 supported_acps = 10; 110 repeated uint32 objected_acps = 11; 111 BloomFilter known_peers = 12; 112 // Signature of the peer IP port pair at a provided timestamp with the BLS 113 // key. 114 bytes ip_bls_sig = 13; 115 } 116 117 // Metadata about a peer's P2P client used to determine compatibility 118 message Client { 119 // Client name (e.g avalanchego) 120 string name = 1; 121 // Client semantic version 122 uint32 major = 2; 123 uint32 minor = 3; 124 uint32 patch = 4; 125 } 126 127 // BloomFilter with a random salt to prevent consistent hash collisions 128 message BloomFilter { 129 bytes filter = 1; 130 bytes salt = 2; 131 } 132 133 // ClaimedIpPort contains metadata needed to connect to a peer 134 message ClaimedIpPort { 135 // X509 certificate of the peer 136 bytes x509_certificate = 1; 137 // IP address of the peer 138 bytes ip_addr = 2; 139 // IP port of the peer 140 uint32 ip_port = 3; 141 // Timestamp of the IP address + port pair 142 uint64 timestamp = 4; 143 // Signature of the IP port pair at a provided timestamp 144 bytes signature = 5; 145 // P-Chain transaction that added this peer to the validator set 146 bytes tx_id = 6; 147 } 148 149 // GetPeerList contains a bloom filter of the currently known validator IPs. 150 // 151 // GetPeerList must not be responded to until finishing the handshake. After the 152 // handshake is completed, GetPeerlist messages should be responded to with a 153 // Peerlist message containing validators that are not present in the bloom 154 // filter. 155 message GetPeerList { 156 BloomFilter known_peers = 1; 157 } 158 159 // PeerList contains network-level metadata for a set of validators. 160 // 161 // PeerList must be sent in response to an inbound Handshake message from a 162 // remote peer a peer wants to connect to. Once a PeerList is received after 163 // a Handshake message, the p2p handshake is complete and the connection is 164 // established. 165 // 166 // PeerList should be sent in response to a GetPeerlist message if the handshake 167 // has been completed. 168 message PeerList { 169 repeated ClaimedIpPort claimed_ip_ports = 1; 170 } 171 172 // GetStateSummaryFrontier requests a peer's most recently accepted state 173 // summary 174 message GetStateSummaryFrontier { 175 // Chain being requested from 176 bytes chain_id = 1; 177 // Unique identifier for this request 178 uint32 request_id = 2; 179 // Timeout (ns) for this request 180 uint64 deadline = 3; 181 } 182 183 // StateSummaryFrontier is sent in response to a GetStateSummaryFrontier request 184 message StateSummaryFrontier { 185 // Chain being responded from 186 bytes chain_id = 1; 187 // Request id of the original GetStateSummaryFrontier request 188 uint32 request_id = 2; 189 // The requested state summary 190 bytes summary = 3; 191 } 192 193 // GetAcceptedStateSummary requests a set of state summaries at a set of 194 // block heights 195 message GetAcceptedStateSummary { 196 // Chain bein requested from 197 bytes chain_id = 1; 198 // Unique identifier for this request 199 uint32 request_id = 2; 200 // Timeout (ns) for this request 201 uint64 deadline = 3; 202 // Heights being requested 203 repeated uint64 heights = 4; 204 } 205 206 // AcceptedStateSummary is sent in response to GetAcceptedStateSummary 207 message AcceptedStateSummary { 208 // Chain being responded from 209 bytes chain_id = 1; 210 // Request id of the original GetAcceptedStateSummary request 211 uint32 request_id = 2; 212 // State summary ids 213 repeated bytes summary_ids = 3; 214 } 215 216 // The consensus engine that should be used when handling a consensus request. 217 enum EngineType { 218 ENGINE_TYPE_UNSPECIFIED = 0; 219 // Only the X-Chain uses avalanche consensus 220 ENGINE_TYPE_AVALANCHE = 1; 221 ENGINE_TYPE_SNOWMAN = 2; 222 } 223 224 // GetAcceptedFrontier requests the accepted frontier from a peer. 225 // 226 // Peers should respond to GetAcceptedFrontier with AcceptedFrontier. 227 message GetAcceptedFrontier { 228 reserved 4; 229 // Chain being requested from 230 bytes chain_id = 1; 231 // Unique identifier for this request 232 uint32 request_id = 2; 233 // Timeout (ns) for this request 234 uint64 deadline = 3; 235 } 236 237 // AcceptedFrontier contains the remote peer's last accepted frontier. 238 // 239 // AcceptedFrontier is sent in response to GetAcceptedFrontier. 240 message AcceptedFrontier { 241 // Chain being responded from 242 bytes chain_id = 1; 243 // Request id of the original GetAcceptedFrontier request 244 uint32 request_id = 2; 245 // The id of the last accepted frontier 246 bytes container_id = 3; 247 } 248 249 // GetAccepted sends a request with the sender's accepted frontier to a remote 250 // peer. 251 // 252 // Peers should respond to GetAccepted with an Accepted message. 253 message GetAccepted { 254 reserved 5; 255 // Chain being requested from 256 bytes chain_id = 1; 257 // Unique identifier for this message 258 uint32 request_id = 2; 259 // Timeout (ns) for this request 260 uint64 deadline = 3; 261 // The sender's accepted frontier 262 repeated bytes container_ids = 4; 263 } 264 265 // Accepted is sent in response to GetAccepted. The sending peer responds with 266 // a subset of container ids from the GetAccepted request that the sending peer 267 // has accepted. 268 message Accepted { 269 // Chain being responded from 270 bytes chain_id = 1; 271 // Request id of the original GetAccepted request 272 uint32 request_id = 2; 273 // Subset of container ids from the GetAccepted request that the sender has 274 // accepted 275 repeated bytes container_ids = 3; 276 } 277 278 // GetAncestors requests the ancestors for a given container. 279 // 280 // The remote peer should respond with an Ancestors message. 281 message GetAncestors { 282 // Chain being requested from 283 bytes chain_id = 1; 284 // Unique identifier for this request 285 uint32 request_id = 2; 286 // Timeout (ns) for this request 287 uint64 deadline = 3; 288 // Container for which ancestors are being requested 289 bytes container_id = 4; 290 // Consensus type to handle this message 291 EngineType engine_type = 5; 292 } 293 294 // Ancestors is sent in response to GetAncestors. 295 // 296 // Ancestors contains a contiguous ancestry of containers for the requested 297 // container in order of increasing block height. 298 message Ancestors { 299 // Chain being responded from 300 bytes chain_id = 1; 301 // Request id of the original GetAncestors request 302 uint32 request_id = 2; 303 // Ancestry for the requested container 304 repeated bytes containers = 3; 305 } 306 307 // Get requests a container from a remote peer. 308 // 309 // Remote peers should respond with a Put message if they have the container. 310 message Get { 311 reserved 5; 312 // Chain being requested from 313 bytes chain_id = 1; 314 // Unique identifier for this request 315 uint32 request_id = 2; 316 // Timeout (ns) for this request 317 uint64 deadline = 3; 318 // Container being requested 319 bytes container_id = 4; 320 } 321 322 // Put is sent in response to Get with the requested block. 323 message Put { 324 // Chain being responded from 325 bytes chain_id = 1; 326 // Request id of the original Get request 327 uint32 request_id = 2; 328 // Requested container 329 bytes container = 3; 330 } 331 332 // PushQuery requests the preferences of a remote peer given a container. 333 // 334 // Remote peers should respond to a PushQuery with a Chits message 335 message PushQuery { 336 reserved 5; 337 // Chain being requested from 338 bytes chain_id = 1; 339 // Unique identifier for this request 340 uint32 request_id = 2; 341 // Timeout (ns) for this request 342 uint64 deadline = 3; 343 // Container being gossiped 344 bytes container = 4; 345 // Requesting peer's last accepted height 346 uint64 requested_height = 6; 347 } 348 349 // PullQuery requests the preferences of a remote peer given a container id. 350 // 351 // Remote peers should respond to a PullQuery with a Chits message 352 message PullQuery { 353 reserved 5; 354 // Chain being requested from 355 bytes chain_id = 1; 356 // Unique identifier for this request 357 uint32 request_id = 2; 358 // Timeout (ns) for this request 359 uint64 deadline = 3; 360 // Container id being gossiped 361 bytes container_id = 4; 362 // Requesting peer's last accepted height 363 uint64 requested_height = 6; 364 } 365 366 // Chits contains the preferences of a peer in response to a PushQuery or 367 // PullQuery message. 368 message Chits { 369 // Chain being responded from 370 bytes chain_id = 1; 371 // Request id of the original PushQuery/PullQuery request 372 uint32 request_id = 2; 373 // Currently preferred block 374 bytes preferred_id = 3; 375 // Last accepted block 376 bytes accepted_id = 4; 377 // Currently preferred block at the requested height 378 bytes preferred_id_at_height = 5; 379 } 380 381 // AppRequest is a VM-defined request. 382 // 383 // Remote peers must respond to AppRequest with a corresponding AppResponse or 384 // AppError 385 message AppRequest { 386 // Chain being requested from 387 bytes chain_id = 1; 388 // Unique identifier for this request 389 uint32 request_id = 2; 390 // Timeout (ns) for this request 391 uint64 deadline = 3; 392 // Request body 393 bytes app_bytes = 4; 394 } 395 396 // AppResponse is a VM-defined response sent in response to AppRequest 397 message AppResponse { 398 // Chain being responded from 399 bytes chain_id = 1; 400 // Request id of the original AppRequest 401 uint32 request_id = 2; 402 // Response body 403 bytes app_bytes = 3; 404 } 405 406 // AppError is a VM-defined error sent in response to AppRequest 407 message AppError { 408 // Chain the message is for 409 bytes chain_id = 1; 410 // Request id of the original AppRequest 411 uint32 request_id = 2; 412 // VM defined error code. VMs may define error codes > 0. 413 sint32 error_code = 3; 414 // VM defined error message 415 string error_message = 4; 416 } 417 418 // AppGossip is a VM-defined message 419 message AppGossip { 420 // Chain the message is for 421 bytes chain_id = 1; 422 // Message body 423 bytes app_bytes = 2; 424 }