Get desktop application:
View/edit binary Protocol Buffers messages
Used in:
PeerId of the node owning the account_key. Used to route the message over TIER1. TODO(gprusak): it should be possible to add support for routing messages to an account_id directly (for TIER1), instead of routing to a specific peer_id. Then this field won't be necessary. Unless we use it instead of AnnounceAccount.
required.
required.
List of nodes which - are trusted by the validator and - are connected to the validator directly - are willing to proxy traffic to the validator. It may include the validator node itself, if it has a public IP. If empty, the validator explicitly declares that it has no public IP and the TIER2 routing should be used instead (discouraged, might be disallowed in the future).
Version of the AccountData. A node can override a previous version, by broadcasting a never version.
Time of creation of this AccountData. TODO(gprusak): consider expiring the AccountData based on this field.
A payload that can be signed with account keys. Since account keys are used to sign things in independent contexts, we need this common enum to prevent message replay attacks, like this one: - messages M1 and M2 of different types happen to have the same serialized representation. - an attacker observes M1 signed by A in some context - the attacker then sends M2 with A's signature of M1 (which also matches M2, since their serialized representations match) to B, effectively impersonating A. NOTE: that proto serialization is non-unique, so the message passed around with the signature should be in serialized form. TODO: move to a separate file, probably in a separate package.
Used in:
,protobuf-serialized AccountKeyPayload, required. It is passed in serialized form, because the protobuf encoding is non-deterministic. In particular encode(decode(payload)) might not match the signature.
Signature of the payload, required.
TODO: this is a good place to add optional fields: account_id, account_public_key, in case the signer of the message is not implied by the payload, or the context. Add them if needed.
Denotes an available route to `destination` of length `distance`
Used in:
Wrapper of the borsh-encoded AnnounceAccount. https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/primitives/src/network.rs#L86
Used in:
Wrapper of the borsh-encoded NEAR chain block. https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/primitives/src/block.rs#L77
Used in:
Wrapper of the borsh-encoded BlockHeader. https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/primitives/src/block_header.rs#L325
Used in:
Request to send back headers of the NEAR chain blocks. Receiver finds in block_hashes the first hash of a block it knows about and rends back BlockHeadersResponse with block headers following that block. At most 512 block headers are returned: https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/chain/client/src/sync.rs#L38 It might happen that the receiver doesn't know some of the hashes in the list in the following cases: - sender's view of the chain forked from the receiver's view of the chain - sender's view of the chain is ahead of receiver's view of the chain.
Used in:
A collection of headers of the NEAR chain blocks.
Used in:
Request to send back a NEAR chain block with a given hash.
Used in:
NEAR chain Block. It might be send both as a response to BlockRequest, or unsolicited in case a new Block is being broadcasted.
Used in:
Wrapper of borsh-encoded Challenge https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/primitives/src/challenge.rs#L89
Used in:
sha256 hash of the borsh-encoded NEAR Block.
Used in:
, , , , , ,sha256 hash (32 bytes)
Disconnect is send by a node before closing a TCP connection. There is no guarantee that it will be sent in all circumstances.
Used in:
/ Message shared by a peer listing the distances it has to other peers / in the NEAR network. / / It includes a collection of signed edges forming a spanning tree / which verifiably achieves the advertised routing distances. / / The distances in the tree may be the same or better than the advertised / distances; see routing::graph_v2::tests::inconsistent_peers.
Used in:
PeerId of the node sending the message.
List of distances the root has to other peers in the network.
Spanning tree of signed edges achieving the claimed distances (or better).
Wrapper of borsh-encoded Edge. https://cs.github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/chain/network-primitives/src/network_protocol/edge.rs#L32
Used in:
, , ,Used in:
(message has no fields)
Used in:
Unique identifier of the NEAR chain.
Used in:
,Name of the chain (for example "mainnet").
Hash of the genesis block(?) of the NEAR chain.
Handshake is the first message exchanged after establishing a TCP connection. If A opened a connection B, then 1. A sends Handshake to B. 2a. If B accepts the handshake, it sends Handshake to A and connection is established. 2b. If B rejects the handshake, it sends HandshakeFailure to A. A may retry the Handshake with a different payload.
Used in:
The protocol_version that the sender wants to use for communication. Currently NEAR protocol and NEAR network protocol are versioned together (it may change in the future), however peers may communicate with the newer version of the NEAR network protocol, than the NEAR protocol version approved by the quorum of the validators. If B doesn't support protocol_version, it sends back HandshakeFailure with reason ProtocolVersionMismatch.
Oldest version of the NEAR network protocol that the peer supports.
PeerId of the sender.
PeerId of the receiver that the sender expects. In case of mismatch, receiver sends back HandshakeFailure with reason InvalidTarget.
TCP port on which sender is listening for inbound connections.
Basic info about the NEAR chain that the sender belongs to. Sender expects receiver to belong to the same chain. In case of mismatch, receiver sends back HandshakeFailure with reason GenesisMismatch.
Edge (sender,receiver) signed by sender, which once signed by receiver may be broadcasted to the network to prove that the connection has been established. In case receiver accepts the Handshake, it sends back back a Handshake containing his signature in this field. WARNING: this field contains a signature of (sender_peer_id,target_peer_id,nonce) tuple, which currently the only thing that we have as a substitute for a real authentication. TODO(gprusak): for TIER1 authentication is way more important than for TIER2, so this thing should be replaced with sth better.
See description of OwnedAccount.
optional
Response to Handshake, in case the Handshake was rejected.
Used in:
Reason for rejecting the Handshake.
Data about the peer.
GenesisId of the NEAR chain that the peer belongs to.
Newest NEAR network version supported by the peer.
Oldest NEAR network version supported by the peer.
Used in:
Peer doesn't support protocol_version indicated in the handshake.
Peer doesn't belong to the chain indicated in the handshake.
target_id doesn't match the id of the peer.
TODO: document it.
Used in:
Used in:
Proof that a given peer owns the account key. Included in every handshake sent by a validator node. Note: sign AccountKeyPayload, rather than OwnedAccount directly.
Used in:
required
PeerId of the node owning the account_key.
required
Timestamp indicates the date of signing - we do not assume the nodes' clocks to be synchronized, but for security if the timestamp deviation is too large, the handshake will be rejected. TODO(gprusak): an alternative would be a 3-way handshake with a random challenge to sign, or even better: just use some standard asymmetric encryption.
required
Wrapper of the borsh-encoded PartialEdgeInfo. https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/chain/network-primitives/src/network_protocol/edge.rs#L11
Used in:
,Used in:
required
required
Basic information about the chain view maintained by a peer.
Used in:
Height of the highest NEAR chain block known to a peer.
Shards of the NEAR chain tracked by the peer.
Whether the peer is an archival node.
Wrapper of borsh-encoded PeerInfo. https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/chain/network-primitives/src/network_protocol/mod.rs#L30
Used in:
,PeerMessage is a wrapper of all message types exchanged between NEAR nodes. The wire format of a single message M consists of len(M)+4 bytes: <len(M)> : 4 bytes : little endian uint32 <M> : N bytes : binary encoded protobuf PeerMessage M
Inter-process tracing information.
Handshakes for different network tiers explicitly use different PeerMessage variants. This way we avoid accidental connections, such that one end thinks it is a TIER2 connection and the other thinks it is a TIER1 connection. Currently the same PeerActor handles all types of connections, hence the contents are identical for all types of connections. If we ever decide to separate the handshake implementations, we can copy the Handshake message type definition and make it evolve differently for different tiers.
Request to send a list of known healthy peers (i.e. considered honest and available by the receiver). max_peers limits the number of peers to send back. max_direct_peers limits the number of direct peers to send back. See PeersResponse below for the response.
Used in:
Response to PeersRequest
Used in:
Peers drawn from the PeerStore of the responding node, which includes peers learned transitively from other peers
Peers directly connected to the responding node
Wrapper of borsh-encoded PublicKey. https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/crypto/src/signature.rs#L201
Used in:
, , , , , ,Wrapper of borsh-encoded RoutedMessage https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/chain/network-primitives/src/network_protocol/mod.rs#L295
Used in:
Timestamp of creating the Routed message by its original author.
Number of peers this routed message traveled through. Doesn't include the peer that created the message.
Wrapper of borsh-encoded RoutingSyncV2 https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/chain/network/src/network_protocol.rs#L225
Message sent whenever the sender learns about new connections between the peers in the network (I think). It provides a view of the whole NEAR network to each peer. Edges constitute a graph between PeerIds, signed by both of the peers. This is one of the first messages sent after Handshake. First RoutingTableUpdate contains the whole graph known to peer. Afterwards only the graph delta (changed edges) are included. Accounts provides a mapping AccountId -> PeerId, providing knowledge about which NEAR peer controls which NEAR account.
Used in:
list of known NEAR validator accounts
Wrapper of borsh-encoded Signature. TODO: link to the rust Signature type.
Used in:
, ,Wrapper of borsh-encoded SignedTransaction https://github.com/near/nearcore/blob/1a4edefd0116f7d1e222bc96569367a02fe64199/core/primitives/src/transaction.rs#L218
Used in:
Used in:
Used in:
IPv4 (4 bytes) or IPv6 (16 bytes) in network byte order.
TCP port (actually uint16, however uint32 is smallest supported protobuf type).
Used in:
Used in:
Used in:
Wrapper of the borsh-encoded StateResponseInfo.
Used in:
SyncAccountData message can represent: - incremental sync (incremental = true, requesting_full_sync = false) - full sync request (incremental = false, requesting_full_sync = true) - full sync response (incremental = false, requesting_full_sync = false)
Used in:
Data about the (important) accounts, which should be broadcasted to the whole network. Contains AccountKeyPayload.account_data.
Indicates whether this message is an incremental sync (true), or a full sync (false). Useful for tracking time since the last full sync.
Indicates that sender requests a full sync message in return. Useful for soliciting a full sync periodically.
Used in:
Information about peers in the network hosting state snapshots
Inter-process tracing information.
Used in:
16 bytes representing TraceId: https://docs.rs/opentelemetry/latest/opentelemetry/trace/struct.TraceId.html
8 bytes representing SpanId: https://docs.rs/opentelemetry/latest/opentelemetry/trace/struct.SpanId.html
Used in:
TODO: document it.
Used in:
Deprecated. Use SyncRoutingTable instead.
Used in: