Peer network protocol
The peer network protocol connects NEAR nodes and carries chain data, consensus traffic, peer discovery, and state-sync requests. It checks peer identity and chain compatibility before use, selects a common wire format, separates traffic by purpose, and gives client and chain services a request-and-event interface instead of direct socket access. Read Peer-to-peer networking for the broader network model.
Network role and traffic tiers
The network uses three logical tiers over TCP. A tier is a class of peer connection with its own trust, route, and message rules. TIER1 carries time-sensitive validator traffic. TIER2 forms the general peer network. TIER3 provides direct paths for large state-sync responses.
| Tier | Purpose | Connection pattern |
|---|---|---|
| TIER1 | BFT consensus and validator work | Direct validator or proxy connections. |
| TIER2 | Gossip, peer discovery, chain data, transactions, and routed requests | A multi-hop network built from shared peer and edge knowledge. |
| TIER3 | Large state-sync data | Short-lived direct connections created for a request. |
TIER2 bootstraps TIER1. Validators publish signed account data that names their peer and trusted proxy addresses. Other nodes use that data to find a direct validator connection or a proxy. TIER1 can then stay focused on consensus traffic rather than general gossip.
References: chain/…/mod.rs• L201-243 chain/…/mod.rs• L724-733 chain/…/tier1.rs• L214-267
Connection lifecycle
The connection lifecycle turns a TCP stream into a usable peer only after the handshake and registration checks succeed. The peer manager owns connection choice and capacity. The peer actor owns one stream and its state. Shared network state records the peer in the route and business views.
This diagram shows the normal path from a dial or an inbound connection to message delivery and later cleanup.
flowchart TD
A[Inbound TCP connection or outbound dial] --> B[Peer actor starts]
B --> C[Handshake exchange and encoding selection]
C -->|accepted| D[Validate peer and edge]
D --> E[Insert into tier pool]
E --> F[Update peer and route state]
F --> G[Ready for messages]
G --> H[Route or dispatch messages]
H --> I[Graceful close, error, or ban]
I --> J[Remove connection and update records]
C -->|rejected or timeout| I
D -->|rejected| I
E -->|pool rejects| I
Registration is split into pure validation, transport admission, and business state update. The manager first checks whether the peer may join the selected tier. It inserts the connection into the transport pool before it updates connected-peer state, edges, and peer records. This order avoids partial registration when a pool rejects a connection. On disconnect, the transport pool and business views are cleared together so a closed socket does not remain visible as a route.
TIER2 outbound connections also feed a bounded store of recent, stable connections. The store loads its entries when network state starts. It keeps connections that remained active long enough to be useful reconnect candidates and removes entries when a close reason says that reconnect is not wanted. This state lets normal failures trigger reconnect work without retrying peers that were banned or otherwise rejected for good.
TIER3 uses two connection directions. A requester can open a connection for a direct state request. A host can also open a TIER3 connection back to a requester after receiving a routed TIER2 request. Pending-request state admits the second case, while a bounded requester pool protects the first case. Host response connections do not consume requester capacity. TIER3 connections close after an idle period because they serve individual large transfers.
References: chain/…/peer_actor.rs• L805-969 chain/…/peer_actor.rs• L1600-1661 chain/…/mod.rs• L432-611 chain/…/mod.rs• L1622-1631 chain/…/mod.rs• L16-145 chain/…/tcp_transport.rs• L90-116 chain/…/connection_pool.rs• L20-169
Peer monitoring
Peer monitoring keeps the TIER2 network within its target shape and removes paths that no longer support reliable chain traffic. The peer manager discovers peers, restores useful outbound connections, removes excess connections, and avoids peers that are too far behind the local chain for new routes.
The manager protects a set of useful connections while reducing excess capacity. It keeps whitelisted peers, enough outbound peers, required archival peers, and recently active peers before it chooses another connection to close. It also removes idle TIER3 connections and cleans up state-sync requests that did not lead to a response connection.
When a peer closes, the connection store decides whether it should be tried again. It keeps a bounded, peer-unique list of recent outbound connections and refreshes entries from outbound TIER2 connections that have stayed active for the required minimum time. Reconnect attempts use a bounded retry loop. The manager also checks that local TIER2 edges and ready connections agree, then repairs the edge or closes the connection when they remain out of sync. A TIER2 peer that falls too far behind the local chain is removed from new routes until it recovers.
The peer store supplies known peer addresses and connection status for this work. It assigns more trust to information learned from a signed connection than to an address learned indirectly. It also keeps bans, expiry, address uniqueness, and the bounded set of peers that can be selected for a new connection.
References: chain/…/peer_manager_actor.rs• L445-689 chain/…/mod.rs• L551-643 chain/…/mod.rs• L613-643 chain/…/mod.rs• L1622-1631 chain/…/mod.rs• L68-145 chain/…/mod.rs• L32-76 chain/…/mod.rs• L236-294
Handshake behavior
The handshake is the first protocol message after a TCP connection opens. It proves which peer sent the message, names the intended receiver and chain, reports the sender's chain view, and carries a signed partial edge that can become a shared record of the connection. It also selects the encoding for all later messages on that connection.
Both sides check the values that matter for safe communication:
- The protocol version must overlap. An outbound peer can retry with the common version when the other side reports a version mismatch.
- The genesis identifier must match. A different chain is rejected.
- The target peer ID must match the receiver on inbound connections. An outbound connection must also receive the expected sender ID.
- The connection tier and edge nonce must match the expected connection.
- The edge signatures, optional validator account proof, account ownership, and account-proof time must be valid.
- The peer's advertised tracked-shard list must stay within its pre-authentication safety limit.
After the handshake, the peer manager applies tier-specific admission rules. TIER1 inbound peers must prove that they represent a known validator account key. TIER2 inbound peers must fit the connection policy unless they are whitelisted. TIER3 inbound peers must match a recent state-sync request from this node, or must fit the bounded pool for a peer requesting state from this node. On success, the peer returns the signed edge, records chain metadata such as block height and tracked shards, and enters the ready state. A failed TIER3 edge check does not consume the pending request, so a later valid host connection can still answer it. On failure, the protocol sends a typed handshake failure where possible, or closes the connection. Invalid signatures and other signs of peer abuse can cause a ban rather than a retry.
During the encoding transition, a node sends the first handshake in each encoding that it accepts. The first form that the peer can read selects the connection encoding. A peer that selects Borsh ignores the extra protobuf handshake copy, while an older protobuf-only peer continues with protobuf. Later messages use only the selected encoding.
Validator account announcements and ownership proofs use signed payloads. The receiver parses the signed bytes and checks that they describe the same account data or owned account carried by the message. This prevents a valid signature from being reused with changed peer or proxy data.
References: chain/…/mod.rs• L384-547 chain/…/handshake.rs• L62-150 chain/…/account_key.rs• L75-110 chain/…/peer_actor.rs• L507-727 chain/…/peer_actor.rs• L582-727 chain/…/mod.rs• L432-493
Message framing and admission
Each wire message is framed with length prefixes and uses the connection encoding selected during the handshake. In Borsh mode, a small message-kind header comes before the body. The receiver can use that header to apply the body limit before it reads the body. In protobuf mode, the message remains one body frame. Legacy routed messages are converted to the current internal routed form so the network can preserve message meaning during a format transition.
Incoming data passes through several admission gates before business handling:
- The stream rejects frames above the global message limit and limits the memory held by concurrent reads.
- In Borsh mode, the stream checks the message-kind body limit before reading the body. The peer actor then checks that the header kind matches the decoded body kind.
- Transaction, routed, and snapshot-host payloads are checked against decode-time body or list limits before nested data is materialized.
- Per-peer message limits prevent one connection from consuming an unfair share of processing time.
- The actor checks that the message is allowed on the connection's tier.
- Routed messages undergo signature, duplicate, response, and time-to-live checks before forwarding or dispatch.
Transaction and routed bodies have their own decode-time size limits. The network checks these limits before it builds nested values, so a large encoded body cannot force a large allocation during parsing. A malformed frame or a Borsh header/body mismatch closes the stream as a protocol error.
The same path protects outgoing queues. A global byte limit bounds data waiting for all sockets, and a full per-connection write buffer reports a stream failure. Per-message limits slow high-cost or high-volume message classes. These limits make overload visible as dropped messages or closed connections instead of unbounded memory growth.
References: chain/…/mod.rs• L86-113 chain/…/mod.rs• L656-720 chain/…/peer_message.rs• L25-36 chain/…/peer_message.rs• L442-569 chain/…/peer_actor.rs• L1701-1837
Forwarded transaction admission
Forwarded transaction admission protects consensus work from a burst of TIER2 transactions. A shared counter covers all peer actors and resets when a block message arrives, so the limit applies across the node rather than to each connection.
The admission policy treats signed transactions and execution-cost transactions (ECCs) as one total stream. ECCs also have a smaller share limit. A rejected ECC does not consume a slot in the total count, while an accepted ECC does. This keeps the network focused on block progress when peers send more forwarded work than the node should process between blocks.
| Item | Network behavior |
|---|---|
| Forwarded transactions | Limited to a shared budget between block messages. |
| Forwarded ECCs | Limited to a smaller budget and counted in the total. |
| New block message | Starts a new forwarded-transaction budget. |
| Limit exceeded | Drops the forwarded message and records the drop reason. |
References: chain/…/peer_actor.rs• L1091-1123 chain/…/peer_actor.rs• L1428-1469 chain/…/forwarded_txs.rs• L1-45
Routing and peer knowledge
TIER2 routing uses a graph of signed edges. An edge represents a known connection between two peer IDs. Routing updates spread new edges, removed edges, and validator account announcements so each node can choose the next hop toward a peer without a direct socket.
The graph accepts only current, signed edge data. It rejects remote self-loops, old edges, edges with nonces too far in the future, and updates that exceed graph or per-source limits. An oversized routing update drops its excess edges but does not by itself end a healthy connection. It removes unreachable paths and avoids peers marked unreliable before it recomputes next hops. These checks keep route calculation bounded and reduce the effect of forged or excessive topology updates.
For a routed message, the sender names a peer ID or a response hash. The network finds the next hop for a peer target. A response hash uses a short-lived route-back record created when the request entered the network. A request record can also name the expected responder and response kind, so a guessed hash cannot make an unrelated reply look valid. Each forwarding hop lowers the time-to-live value and raises the hop count. The message is dropped when the time-to-live reaches zero or no route exists.
The network keeps two forms of duplicate control. A connection-local cache drops a recently repeated signed message from the same path. A shared cache records messages that reached this node through another tier, which lets the node measure delivery paths without dispatching the same body twice. Peers that fall too far behind the local chain are excluded from new routes until they recover.
References: chain/…/mod.rs• L646-815 chain/…/mod.rs• L1126-1187 chain/…/peer_actor.rs• L1428-1527 chain/…/peer_actor.rs• L1539-1567
Account and proxy routing
Account routing maps a chain account to the peer that acts for it. Signed account data supplies the account key, owning peer, and optional TIER1 proxies. The network prefers a direct TIER1 connection. If none exists and the message is allowed on TIER1, it uses a connected trusted proxy. Other messages use the TIER2 graph.
This split lets callers address a validator by account ID while the network selects the peer and tier. Unknown accounts and unavailable routes return a failure result instead of sending to an arbitrary node. Messages sent to the local account are handled locally only for message types that allow that behavior.
TIER1 connection management follows the same account view. A validator connects to the proxies of other validators and advertises only the proxies it can reach. Direct validator connections take priority over proxy paths. Nodes that are not validators can accept inbound TIER1 connections so they can act as proxies.
Account data is exchanged over TIER2. Newer data is relayed to connected peers, and a full-sync request returns the current view. This lets TIER2 establish the account-to-peer map before TIER1 carries validator traffic.
References: chain/…/mod.rs• L201-243 chain/…/mod.rs• L817-907 chain/…/mod.rs• L1365-1480 chain/…/tier1.rs• L34-199
Snapshot host discovery and state transfer
Snapshot host discovery gives state sync a shared view of peers that serve a specific state snapshot. A snapshot host announcement names the peer, snapshot hash, epoch, covered shards, and, in the current form, the address for direct TIER3 access. The host signs the data so relays cannot change the destination or the state it claims to serve.
The announcement has two compatible forms. V2 signs the address together with the snapshot data and can carry a legacy signature for older nodes. A node that only understands V1 can relay the older fields. The cache keeps the freshest announcement for each peer, rejects duplicate peer entries and invalid signatures, and drops announcements with no useful shards. It bounds the shard list before decoding and verification.
State sync uses the cache in two ways:
- Header requests choose any known host for the required snapshot and shard.
- Part requests use a shared peer priority and request count so repeated attempts spread across available hosts. The selector resets after a part is received or when the active snapshot changes.
The cache removes announcements outside its epoch retention window and removes their shard mappings at the same time. New valid announcements are flooded to TIER2 peers. Stale or invalid data is not relayed.
This diagram shows how a local snapshot request becomes a routed control message or a direct request, followed by a state response.
sequenceDiagram
participant Client as Client state sync
participant Network as Peer manager
participant Hosts as Snapshot host cache
participant Host as Snapshot host
Client->>Network: Request header or part
Network->>Hosts: Select host for snapshot and shard
Hosts-->>Network: Peer ID and optional address
alt Host advertises an address
Network->>Host: Direct TIER3 state request
Host-->>Network: TIER3 acknowledgement and response
else Legacy host address is unknown
Network->>Host: Signed TIER2 request with requester address
Host-->>Network: TIER2 acknowledgement
Host->>Network: TIER3 state response
end
Network-->>Client: Acknowledgement and state response
Direct requests do not need the requester's public address or a TIER2 route to the host. Legacy routed requests do need a usable local public address so the host can connect back. The host always sends an acknowledgement. It sends a large response on TIER3 when it can answer.
References: chain/…/peer_message.rs• L110-184 chain/…/peer_manager_actor.rs• L791-931 chain/…/peer_manager_actor.rs• L1607-1747 chain/…/snapshot_hosts.rs• L167-301 chain/…/tier3.rs• L496-578 chain/…/tier3.rs• L734-881
Public address discovery
Public address discovery determines where other nodes can open a TIER3 connection to this node. TIER2 peers report the address at which they see the node. The network combines those reports into a vote instead of trusting one peer. A configured TIER3 address takes priority over learned reports.
The vote counts one report per peer network group. It ignores addresses that are not reachable from the public internet or that use an address family the listener cannot accept. This limits the effect of one faulty peer and avoids advertising an address that state-sync hosts cannot use. Local test networks can allow private addresses through configuration.
The selected address is used in routed state-sync requests and in signed snapshot-host announcements. If the node has no usable address, it does not send a request that needs a direct response and does not advertise a new snapshot host. A requester that uses a host's signed address can still open a direct TIER3 connection without knowing its own public address.
References: chain/…/mod.rs• L1634-1680 chain/…/peer_manager_actor.rs• L1090-1147 chain/…/snapshot_hosts.rs• L629-692
Chain and client service interfaces
The peer manager exposes an actor message interface to chain services. Callers submit a NetworkRequests value through the peer manager adapter. The network chooses direct delivery, broadcast, account routing, or peer routing. A request returns a small NetworkResponses result when the caller needs to know whether a route or destination was selected.
The network sends received work to the service that owns its meaning. The main handoffs are:
| Network data | Downstream service or result |
|---|---|
| Blocks, headers, transaction status, approvals, and forwarded transactions | Client service. |
| Partial encoded chunks and chunk requests or responses | Shards manager. |
| State witnesses, contract access, contract code, and contract deploy data | Partial-witness service. |
| Spice partial data, endorsements, and contract distribution | Spice data distribution and chain services. |
| State snapshot requests and acknowledgements | Client state-sync service through TIER2 control and TIER3 data. |
| Snapshot host announcements | Peer manager snapshot-host state. |
| Network and peer state | Client network-info view. |
The receive path keeps the message's memory permit with the downstream handler when work is asynchronous. A state-sync request can arrive directly on TIER3 or as a signed routed TIER2 request. The host sends an acknowledgement in both cases. It sends the large response on TIER3 when it can answer.
The network-info view provides connected-peer chain data and routing information. Client sync logic builds its own candidate set for ordinary peer sync, while snapshot sync uses the network's signed snapshot-host view. This keeps peer selection with the service or cache that has the needed chain context.
References: chain/…/mod.rs• L1189-1363 chain/…/peer_manager_actor.rs• L948-1125 chain/…/peer_manager_actor.rs• L1150-1506 chain/…/peer_manager_actor.rs• L712-762
Peer manager and transport boundary
NetworkTransport is the boundary between network decisions and message delivery. Network state asks this interface to send to a peer, broadcast on TIER2, connect, disconnect, or shut down. The production TCP transport implements it with one connection pool per tier. Test transports can implement the same boundary without changing routing or service logic.
The transport reports pending outbound work and per-peer transport statistics. The peer manager joins these values with connected-peer metadata and the routing graph to publish a network snapshot to the client. This is an observation interface. It does not make the client manage sockets.
The transport and peer manager also expose connection, message, route, public-address, and dropped-message metrics. These metrics show whether a problem comes from peer admission, routing, queue pressure, or downstream delivery without changing the service interface.
The test harness exposes handshake, connection, routing, account-data, and snapshot-host events. Its checks compare ready connections with peer-store and graph state. State-sync tests cover requester limits, pending host connections, acknowledgements, direct responses, concurrent direct requests, idle cleanup, and failed connection reporting. Communication tests cover both supported encodings for handshake and message delivery. Recent protocol checks also keep versioned state-witness messages on the correct TIER1 and routed paths, preserve their wire labels, and ensure the Borsh message header matches the decoded body. Snapshot-host checks keep the address covered by the newer signed form while allowing older nodes to relay the legacy form. The peer actor closes a ready connection when a second handshake arrives or when a Borsh header is missing or names a different body.
References: chain/…/network_transport.rs• L14-143 chain/…/tcp_transport.rs• L27-54 chain/…/tcp_transport.rs• L118-205 chain/…/tcp_transport.rs• L207-323 chain/…/peer_manager_actor.rs• L127-161 chain/…/connection_pool.rs• L255-367 chain/…/tests.rs• L87-249 chain/…/tests.rs• L500-633 chain/…/tests.rs• L636-757 chain/…/peer_actor.rs• L1186-1192 chain/…/peer_actor.rs• L1702-1762
Change checklist
When these files or sections are changed, remember to consider these:
- A new or changed wire message needs matching protobuf, Borsh header and body, conversion, size, and tier-admission rules. The sender and receiver must keep the same message variant meaning. Legacy and current routed encodings must still map to the same internal body.
- Changes to the first handshake must preserve encoding selection. A dual-encoding sender must not send later messages before the peer selects an encoding. A Borsh header must continue to match its decoded body.
- A new routed body needs the tier wrapper, routing conversion, signature and size treatment, and a downstream receive handler. Account-targeted messages also need account-to-peer or proxy behavior.
- Routed request and response bodies must keep their response kind, route-back hash, expected responder, and target semantics aligned. Otherwise valid replies can be dropped or unrelated replies can be accepted.
- Handshake fields affect version overlap, genesis checks, edge signing, tracked-shard limits, and connection registration. Changes must preserve compatibility with peers that use the supported protocol range.
- Signed account data must keep the signed payload equal to the account data that the receiver parses. Changes to account keys, proxy addresses, ownership proofs, or timestamps must preserve both signing and verification paths.
- Connection registration and removal update both the transport pool and business peer state. A new peer field must have a clear source during handshake and a clear cleanup path.
- Outbound connection retention and close-reason changes must preserve the distinction between retryable and terminal closes. The recent connection cache must stay bounded, deduplicate by peer, and admit only sufficiently long-lived outbound connections.
- TIER3 state-sync changes must preserve both request directions: direct requester connections and host connections admitted by a pending routed request. Keep the acknowledgement path, response path, public address, and connection limits aligned.
- TIER3 admission changes must not consume a pending host request before edge and connection validation succeeds. Concurrent requester handshakes must remain within the inbound requester limit.
- Snapshot host changes must preserve the V1 and V2 signature contract. The address must remain covered by the V2 signature, and the legacy signature must remain available while older nodes need it.
- Changes to snapshot-host cache freshness or retention must update shard-specific host mappings and part-selection state together. A stale host must not remain selectable after its announcement is removed.
- Changes to account announcements or proxy data must update direct TIER1 lookup, proxy selection, and the routing graph view together.
- Changes to peer selection must preserve the connection limits for inbound and outbound peers. They must also preserve the rule that lagging peers are not used for new routes.
- Changes to outgoing queue limits must keep validated configuration, transport buffers, and pre-acquired message permits aligned.
- Changes to edge acceptance must preserve signature checks, nonce freshness, graph caps, source attribution, and the rule that remote self-loops are invalid.
- Changes to protobuf fields, Borsh fields, or binary payloads must preserve conversion errors, decode-time size gates, reserved fields, and the supported routed-message compatibility path.
- Changes to versioned witness or other tiered bodies must preserve their wire discriminants, tier mapping, self-delivery rules, and message labels during a format rollout.
- Changes to public-address reports must preserve network-group voting, address-family checks, private-address filtering, and the configured TIER3 address override.
- Changes to message-rate buckets must keep legacy and versioned forms of the same business message on one budget during a wire-format rollout.
- Changes to forwarded transaction handling must preserve the shared node-wide counter, its reset at block arrival, the total transaction budget, and the smaller ECC budget.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Genesis, target peer, tier, or protocol version mismatch | Handshake fails and no ready connection is registered. | Handshake validation and common-version retry. |
| The first frame cannot be read in an accepted encoding | The connection closes before message exchange. | Encoding allow-list and first-frame detection. |
| A Borsh header is missing or names a different message kind than the body | The connection closes as a protocol error. | Header/body kind check. |
| Invalid edge or account ownership signature | Connection closes. A bad signature can ban the peer. | Edge verification and signed account proof checks. |
| Tracked-shard data exceeds its handshake limit | The unauthenticated handshake is rejected before the peer can create a large allocation. | Pre-authentication tracked-shard cap. |
| Snapshot host address or snapshot data has an invalid signature | The announcement is rejected and is not relayed. | V2 address signature plus legacy signature verification. |
| TIER3 peer opens a connection without a pending state-sync request | The inbound connection is rejected. | Pending TIER3 request tracking after edge verification. |
| Too many peers request state over inbound TIER3 connections | The later handshake is rejected even when its peer identity and edge are valid. | Bounded inbound TIER3 requester pool. |
| A ready TIER3 connection receives a second handshake | The connection closes as a disallowed-message failure instead of being refreshed. | Handshake messages are admitted only while the connection is connecting. |
| A pending TIER3 host request arrives with an invalid edge | The attempted connection is rejected, but a later valid host connection can still answer the request. | Validate the edge before consuming the pending request. |
| An outbound connection closes for a terminal reason | The peer is removed from reconnect candidates and is not retried. | Close-reason handling removes the outbound entry from the connection store. |
| Peer sends a message that the connection tier does not allow | Connection closes as a disallowed-message failure. | Per-tier admission rules. |
| Frame, typed message, transaction, routed body, or snapshot shard list exceeds its limit | The message is dropped or the connection is closed for an abusive frame. | Global, per-type, and pre-deserialization size limits. |
| Routed target has no next hop, route-back entry, or remaining time-to-live | Message is dropped and the caller can receive a route failure. | Graph lookup, route-back cache, and TTL checks. |
| Routed response has the wrong author or response kind | The response is dropped even when its route-back hash is known. | Expected responder and response-kind checks. |
| Routed peer falls more than the local chain reliability horizon behind | New messages avoid that peer and may have no usable route. | Peer-height monitoring and unreliable-peer exclusion. |
| State-sync destination or local public address is unavailable | No state-sync request is sent. | Snapshot-host selection and public-address checks. |
| Peer reports only unusable or conflicting public addresses | The node cannot advertise a usable TIER3 destination until a valid report or override exists. | Network-group vote, address-family filtering, private-address filtering, and configured override. |
| A snapshot announcement is older than the retention window | The host is removed from selection for the active sync. | Epoch-based cache pruning and shard-map cleanup. |
| Outgoing queues reach their byte limit | New messages are dropped or a connection reports overflow. | Global queue permits, per-connection write-buffer limits, and response reservations. |
| Client sync selection receives incomplete connected-peer chain data | The client has fewer usable sync candidates and may delay or fail a sync request. | Handshake chain metadata and periodic network-info publication. |
| Two ready connections use the same validator account key | The connection pool rejects the later connection and records a validator setup error. | One ready connection per owned account key. |
| Forwarded transaction or ECC count reaches its between-block limit | The later routed transaction is dropped until a block message starts the next count. | Shared forwarded-transaction counters with separate total and ECC budgets. |
Key files
| File | Why to read it |
|---|---|
| chain/…/mod.rs | Defines the handshake, wire message families, tiered bodies, routed response rules, and high-level routing rules. |
| chain/…/account_key.rs | Shows how validator account announcements and ownership proofs are encoded, signed, decoded, and checked as one payload. |
| chain/…/handshake.rs | Defines the wire form and validation limits for chain identity, tracked shards, peer identity, and signed ownership data. |
| chain/…/peer_message.rs | Shows conversion between wire messages and internal messages, including decode-time size gates and snapshot-host compatibility handling. |
| chain/…/peer_actor.rs | Shows the per-connection state machine, handshake and encoding checks, admission path, forwarding, dispatch, and close behavior. |
| chain/…/peer_manager_actor.rs | Shows peer monitoring, network-info publication, public-address use, snapshot-host selection, and TIER3 coordination. |
| chain/…/mod.rs | Connects admission, lifecycle state, routing, service adapters, account delivery, response checks, reconnect decisions, and routed-message handling. |
| chain/…/mod.rs | Defines the bounded durable set of stable outbound connections used to decide whether a peer remains a reconnect candidate. |
| chain/…/tests.rs | Demonstrates reload, replacement, bounded eviction, and time-change behavior for stored outbound connections. |
| chain/…/tier1.rs | Explains validator account data, trusted proxies, and TIER1 connection selection. |
| chain/…/network_transport.rs | Defines the transport contract used by production and test network implementations. |
| chain/…/tcp_transport.rs | Shows how the production transport owns tier pools, accepts TCP streams, starts peer actors, and exposes transport state. |
| chain/…/mod.rs | Explains peer discovery, address trust, bans, expiry, and connection candidate selection. |
| chain/…/testonly.rs | Shows the observable network events, transport-aware test controls, and state consistency checks used by the protocol test harness. |
| chain/…/tests.rs | Demonstrates signed-data compatibility, size caps, routing conversions, witness version rollout, snapshot-host signature compatibility, and wire-format checks. |
| chain/…/connection_pool.rs | Demonstrates handshake admission, account-key uniqueness, edge validation, and pending TIER3 request behavior in both encodings. |
| chain/…/accounts_data.rs | Demonstrates account-data gossip, full sync, rate limits, release transitions, and validator restart behavior. |
| chain/…/snapshot_hosts.rs | Demonstrates snapshot-host validation, bounded shard lists, freshness, propagation, and public-address requirements. |
| chain/…/tier1.rs | Demonstrates direct validator connections, proxy routing, account-key changes, and TIER1 cleanup. |
| chain/…/tier3.rs | Demonstrates TIER3 requester limits, direct and routed state requests, acknowledgements, responses, concurrent direct requests, idle cleanup, and failed connection reporting. |