Consensus messages and validator signing
Consensus messages carry proposals, votes, block data, and round progress between validators. Consensus validates these messages before they change state, while a private validator supplies signatures for proposals and votes. This page explains the message model and the local and remote signing paths; see Consensus for the wider consensus state flow.
Consensus message model
The consensus network uses typed messages for two related jobs: it shares signed decisions and it shares progress data that helps peers catch up. Messages cross a protocol boundary before they reach consensus state or the write-ahead log. That boundary rejects unknown messages and malformed nested data.
Protocol message conversion
The protocol conversion layer maps native consensus messages to wire forms and restores them for network delivery or WAL replay. Incoming messages are checked after conversion, so invalid votes, block parts, block IDs, or round-step values do not reach consensus state. The reverse mapping also preserves optional vote sets, peer identity, and the separate record types used for replay.
References: consensus/msgs.go• L18-237 consensus/msgs.go• L239-368 consensus/msgs_test.go• L22-196 consensus/msgs_test.go• L198-330
Signed decision messages
Proposal identifies the block that a proposer offers for a height and round. It can include a proof-of-lock round, called POLRound, which points to an earlier round with enough prevotes for the block. The proposer signs the proposal.
Vote records a validator decision. A prevote supports a block or nil. A precommit confirms a block or nil after the prevote stage. A vote carries its height, round, type, validator, block ID, time, and signature. A non-nil precommit can also carry application data called a vote extension when the chain enables vote extensions. The extension has its own signature.
| Message | Purpose | Signature role |
|---|---|---|
| Proposal | Names the block offered by the round proposer. | Proposer signature |
| Prevote | Reports an early validator choice for a block or nil. | Validator signature |
| Precommit | Reports the validator choice that can form a commit. | Validator signature |
| Vote extension | Carries application data with a non-nil precommit. | Separate validator signature |
References: types/proposal.go• L19-33 types/vote.go• L50-75 types/vote.go• L161-173
Consensus coordination messages
Coordination messages do not authorize a block by themselves. They tell peers about round state or about signed data that they have. This lets peers exchange missing proposals, block parts, and votes without sending all data to every peer at once.
| Message group | Purpose |
|---|---|
| NewRoundStep | Reports a height, round, and consensus step. |
| NewValidBlock | Reports a block with a proposal and enough prevotes. |
| ProposalPOL | Reports the prevote set for a proposal's proof-of-lock round. |
| BlockPart | Sends one part of a proposed block. |
| HasVote | Marks one validator vote as known to a peer. |
| VoteSetMaj23 | Claims that a block has more than two-thirds of votes. |
| VoteSetBits | Describes which votes for a block a peer has. |
The reactor routes proposal metadata and block parts through data flow. It routes votes through vote flow. A complete vote still passes vote-set checks before it changes consensus state.
References: proto/…/types.proto• L10-91 consensus/reactor.go• L177-218 consensus/reactor.go• L271-503
Proposal and vote validation
Validation has two layers. Basic validation checks that a message is well formed. Context validation then checks that it belongs to the current consensus state and that its signature matches the expected validator and chain.
Proposal validation
Proposal validation requires a valid type, height, round, proof-of-lock value, block ID, and signature. A complete block ID is required. The broader consensus rules check the timestamp because its meaning depends on the current state.
After basic checks, consensus accepts a proposal only for its current height and round. POLRound must be absent or lower than the proposal round. Consensus verifies the signature with the current round's proposer key and checks that the block part count fits the chain's block size limit. The block parts then prove the block ID as they arrive.
References: types/proposal.go• L48-79 consensus/reactor.go• L1864-1872 consensus/state.go• L2207-2279 consensus/state.go• L2282-2402
Vote validation
Vote validation requires a valid vote type, positive height, non-negative round, valid block choice, validator address, validator index, and signature. A vote for a block must use a complete block ID or nil. Vote extensions are allowed only on non-nil precommits, and an extension must have its matching signature.
The vote set binds each vote to one height, round, and type. It maps the validator index to the validator set, checks that the address matches, and verifies the signature against the chain ID and validator public key. When enabled, it also verifies the extension signature and sends the extension to the application for checks. A duplicate is ignored. A conflicting signed choice is kept as evidence of validator equivocation and is not counted as a second vote.
The resulting voting power lets consensus detect a two-thirds majority. A prevote majority can establish a proof of lock. A precommit majority for a block can move the state to commit.
References: types/vote.go• L222-275 types/vote.go• L278-355 types/vote_set.go• L146-241 types/vote_set.go• L257-326 consensus/state.go• L2440-2499 consensus/state.go• L2502-2629
Block identity and part-set matching
BlockID identifies both the block hash and the part-set header. The header describes the serialized block parts that peers must collect. Consensus therefore treats a block as matching a vote or commit only when both parts of the BlockID match.
This rule protects lock, valid-block, and commit state from a block body that has the same hash but a different serialized part set. A mismatch stops promotion or relocking. Consensus clears stale data when needed and collects the part set named by the vote or commit. It waits for a complete matching part set before finalization.
References: consensus/state.go• L1654-1794 consensus/state.go• L1830-1932 consensus/state.go• L2405-2429 consensus/state.go• L2632-2698 consensus/state.go• L3113-3119 consensus/state_partset_identity_test.go• L14-411
Proposal and vote signing bytes
Signing uses canonical message bytes. Canonicalization removes signer fields and signature fields, then adds the chain ID to bind the signature to one chain. Proposals sign proposal content. Votes sign vote content without validator identity or extension fields. A vote extension uses a separate canonical message and a separate signature.
The signed data is length-delimited protocol data. This keeps the signing contract stable for local signers, hardware devices, and key-management systems. Every verifier must use the same chain ID and canonical form as the signer.
References: types/canonical.go• L10-77 types/proposal.go• L102-118 types/vote.go• L143-173 types/signable.go• L8-23
Validator signing boundary
The types.PrivValidator interface separates consensus from the private key. Consensus asks it for the public key, a proposal signature, or a vote signature. The signer owns key access and signing safety, including the rule that a validator must not double sign.
Private-validator interface
The interface exposes four operations:
| Operation | Result | Use |
|---|---|---|
GetPubKey | Validator public key | Links the private signer to the validator set. |
SignProposal | Signed proposal | Authorizes a block proposal. |
SignVote | Signed vote and possible extension signature | Authorizes a prevote or precommit. |
SignRawBytes | Signature for caller-supplied data | Signs data outside the normal proposal and vote flow. |
Raw data uses a domain prefix, chain ID, and caller-provided unique ID. This keeps a raw-data signature separate from a consensus signature and prevents one signed message from being treated as another.
References: types/priv_validator.go• L17-34 types/priv_validator.go• L47-59
Consensus signing flow
Consensus signs only when the local public key belongs to the validator set. The proposer builds and signs a proposal in the propose step. A validator creates a prevote or precommit from its lock and proposal state. When required, it adds an application vote extension before sending the signed vote into the normal consensus path.
The following diagram shows how a local consensus decision becomes a signed message and enters consensus processing.
flowchart LR
A[Consensus round state] --> B{Local validator role}
B -->|Proposer| C[Build proposal]
B -->|Validator| D[Choose prevote or precommit]
C --> E[Private validator]
D --> E
E --> F[Signed proposal or vote]
F --> G[Local consensus message queue]
G --> H[Basic and context checks]
H --> I[Vote set or proposal state]
Before each signing request, consensus flushes and syncs its write-ahead log. This lets the signer record and the state machine use the same last-signing state after a restart. Consensus checks a returned proposal signature with the expected public key. Vote signing checks the returned vote and extension fields before the vote enters the internal queue.
References: consensus/state.go• L1355-1447 consensus/state.go• L1504-1615 consensus/state.go• L2755-2804 consensus/state.go• L2827-2864
Remote signing paths
Remote signing keeps the private key in a separate process while consensus uses the same private-validator contract. The socket path supports proposal and vote signing. The gRPC path exposes public-key lookup and raw-data signing to external clients. Both paths return structured errors instead of allowing an unsigned result into consensus.
Socket signer path
The socket path uses two endpoints. A SignerClient sits on the consensus side and requests the public key, votes, proposals, raw bytes, and connection pings. A SignerServer runs with the private validator and serves those requests through a dialer endpoint.
The listener accepts a connection from the external signer and reconnects when the link fails. Each request uses a framed protocol message and waits for one response. Read, write, connection, and unexpected-response errors stay visible to the client. This lets consensus reject an unsigned result. The client also records signing latency and failure reasons for remote operations.
References: privval/signer_client.go• L26-54 privval/signer_client.go• L105-263 privval/signer_listener_endpoint.go• L26-131 privval/signer_dialer_endpoint.go• L36-95 privval/signer_endpoint.go• L80-140 privval/signer_client_test.go• L118-142 privval/signer_client_test.go• L420-467
The remote service checks the chain ID before it calls the private validator. It forwards proposal, vote, and raw-data requests to the signing interface and returns the signed result or a structured error. RetrySignerClient can repeat failed key and signing operations. It does not retry remote signer errors or a chain-ID mismatch.
TCP dialing also uses an authenticated encrypted connection handshake. Unix dialing uses a local Unix socket. A failed TCP handshake closes the connection before the dialer reports the error. The server keeps trying to connect when the node is down, while the client can reconnect after a dropped link.
References: privval/signer_server.go• L13-116 privval/signer_requestHandler.go• L14-106 privval/retry_signer_client.go• L13-118 privval/socket_dialers.go• L18-50 privval/socket_dialers_test.go• L52-77 privval/signer_listener_endpoint_test.go• L91-129
gRPC private-validator path
The gRPC path exposes a smaller interface for clients that need the validator public key or a raw-data signature. PrivValidatorGRPCServer forwards these calls to an underlying private validator and returns a structured remote error when key conversion or signing fails. Raw-data requests must name the server's configured chain. The server rejects another chain before it calls the private validator.
The endpoint limits concurrent connections and bounds the handshake time. This stops stalled unauthenticated peers from holding all connection slots or file descriptors. The listener permits at most 16 connections, and a new connection has 10 seconds to complete its handshake in the node's normal server setup.
References: privval/grpc_listener.go• L10-24 node/node.go• L714-764 privval/grpc_listener_test.go• L20-105
This is not the socket proposal-and-vote request path. Socket signing uses SignProposal and SignVote messages. The gRPC service exposes GetPubKey and SignRawBytes, which supports external services that must not access the private key. Its optional transport setup uses mutual TLS. The server accepts only client certificates signed by the configured client CA and requires TLS 1.3 or newer.
References: privval/grpc_server.go• L13-104 privval/grpc_tls.go• L12-35 privval/grpc_tls_test.go• L23-92 proto/…/types.proto• L76-82
Write-ahead log and recovery
The consensus write-ahead log, or WAL, records messages and timeouts before the state machine consumes them. It provides a durable record of signed local decisions and lets a node replay unfinished round work after a crash without asking the validator to create a new decision.
Selective message durability
Consensus persists local signed proposals and votes with WriteSync before it processes them. Unsigned block parts use buffered writes. Peer messages and timeouts use normal WAL writes. The WAL flushes at intervals and when it stops. This gives stronger durability to signed decisions while limiting the cost of high-volume block-part data.
WAL records use the same consensus message conversion boundary for embedded messages. Timeout, lock, round-state, and height-boundary records use their own protocol variants.
References: consensus/state.go• L1034-1057 consensus/wal.go• L155-217 consensus/replay_test.go• L55-66 consensus/wal_test.go• L342-389
Crash replay
On startup, consensus finds the prior height marker and replays messages for the unfinished height. Replay applies proposals, block parts, votes, and timeouts through the normal state handlers. It does not apply the height marker as a message. It also suppresses signing-error noise because replayed signed messages can cause the private validator to reject a repeated signature.
The following diagram shows the recovery split between an unfinished consensus round and a block that was already saved or applied.
flowchart TD
A[Node restart] --> B[Read WAL]
B --> C{Unfinished consensus height?}
C -->|Yes| D[Replay messages and timeouts]
D --> E[Resume consensus state]
C -->|Block application may be incomplete| F[ABCI application handshake]
F --> G[Replay saved blocks as needed]
G --> H[Check application hash]
H --> I[Resume consensus]
If the WAL has a corrupt entry, startup makes one repair attempt by copying the damaged file and rewriting entries up to the first decode error. If corruption is in the last unfinished height, replay fails rather than silently accepting an incomplete decision record. The handshake path also checks that the application and block store agree on height and application hash.
References: consensus/replay.go• L22-29 consensus/replay.go• L92-166 consensus/state.go• L380-461 consensus/state.go• L3039-3072 consensus/wal.go• L220-283 consensus/wal.go• L355-416
Height boundary
Consensus writes a durable EndHeightMessage only after it saves the committed block. The marker tells replay that the block store contains the block. If the process stops before the marker, the application handshake applies the saved block as needed. If the marker already exists for the height being replayed, startup treats that as an invalid recovery state.
References: consensus/state.go• L2017-2057 consensus/replay.go• L100-138
Change checklist
When these files or sections are changed, remember to consider these:
- Keep proposal and vote canonical forms aligned with every local, socket, and external signer. A new message field is not signed unless its canonical form also includes it.
- Keep the full
BlockIDidentity aligned across block assembly, lock state, valid-block promotion, commit recovery, and peer part requests. Matching only the hash can pair a block with the wrong serialized body. - Keep vote-extension enablement aligned between consensus parameters, vote creation, vote-set verification, and extended commit creation.
- Keep the validator public key returned by the private signer aligned with the validator set used for proposal and vote verification.
- Keep remote protocol request and response variants aligned between the protocol schema, message wrapping, client, and request handler.
- Keep native consensus messages aligned with both directions of protocol conversion. A changed field must remain valid after conversion for both network and WAL paths.
- Keep protocol one-of variants and fixed wire encodings aligned with the conversion layer. A mapping that works in one direction can break peer delivery or WAL replay.
- Keep WAL sync before signing and before the height marker. A change in this order can make a safe signer reject a restart or leave recovery without the saved block boundary.
- Keep replay handling aligned with every WAL message type. New signed or state-progress messages need conversion and replay behavior.
- Keep the gRPC chain check, remote error response, and mutual-TLS trust rules aligned. A client that reaches the endpoint but fails the certificate or chain contract must not receive signing output.
- Keep the gRPC connection cap and handshake timeout aligned with the listener wrapper and server setup. Changes must release stalled connections while preserving access for trusted clients.
- Keep retry policy aligned with error classes. Transport failures can be retried, but remote signer errors and chain-ID mismatches must fail at once.
- Keep socket dial failure cleanup intact. A failed authenticated handshake must close its connection so repeated retries do not leak sockets.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Proposal has the wrong height, round, proof-of-lock round, proposer, or signature. | The proposal is rejected and cannot drive prevote progress. | Basic validation plus current-state and proposer-key checks. |
| A block has the committed hash but a different part-set header. | Consensus does not finalize or promote the mismatched body. | Full BlockID matching and complete-part-set checks before promotion and finalization. |
| Vote index and address do not identify the same validator. | The vote is not counted and the sender may be treated as invalid. | Validator-set lookup and address match before signature verification. |
| Vote signature or required extension signature is invalid. | The vote is not added to the vote set. | Chain-bound signature checks with extension checks when enabled. |
| A validator sends two signed choices for one height, round, and type. | The conflict is reported as evidence and is not counted as extra voting power. | Per-validator vote tracking and conflicting-vote reporting. |
| A protocol message is unknown, malformed, or outside the local type range. | The message is rejected before it affects consensus or replay. | Typed conversion, safe numeric conversion, nested-object checks, and ValidateBasic. |
| A WAL record or embedded consensus message has no supported protocol variant. | WAL writing or replay stops instead of silently dropping the record. | Explicit conversion cases and errors for nil or unknown message types. |
| Remote signer uses a different chain ID or returns an error. | No signed proposal or vote reaches the consensus queue. | Chain-ID checks on both sides and structured remote errors. |
| Remote connection is absent or times out. | Signing pauses until the signer is available. No unsigned decision is accepted. | Connection wait, retry or reconnect, read/write deadlines, and response checks. |
| A remote service returns a signature for a different proposal. | The node ignores the proposal instead of broadcasting mismatched authorization. | Verification of the returned proposal signature with the expected proposer key. |
| A TCP handshake fails and leaves its connection open. | Repeated remote signer retries can leak sockets. | Close the connection on every failed authenticated handshake. |
| A gRPC client lacks a certificate signed by the configured client CA or uses an unsupported TLS version. | The transport handshake fails before the client can request a key or raw signature. | Mutual TLS with client-certificate verification and TLS 1.3 minimum. |
| Stalled gRPC peers occupy all connection slots or do not finish the handshake. | A trusted client cannot reach the signer until a slot is released. | Listener connection cap plus handshake timeout. |
| A retry wrapper retries a permanent remote or chain-ID error. | A bad request can delay indefinitely or repeat an error without benefit. | Do not retry RemoteSignerError or ErrChainIDMismatch. |
| WAL loses a signed message before it is synced. | Restart can ask the signer for a decision that conflicts with its last recorded signature. | WriteSync for local signed messages and WAL flush before signing. |
| WAL corruption reaches the unfinished height. | Consensus cannot safely reconstruct the round and startup fails or attempts repair. | CRC and length checks, one repair attempt, and failure on corruption in the replay range. |
| A height marker exists before the committed block is saved. | Replay can skip the height boundary without a block to apply. | Save the block before syncing EndHeightMessage. |
| Application returns an unexpected application hash during handshake replay. | The node stops rather than running with state different from the application. | Application-hash checks after block replay. |
Key files
| File | Why to read it |
|---|---|
| types/proposal.go | Defines the signed proposal and its basic validity rules. |
| types/vote.go | Defines prevotes, precommits, vote extensions, and vote signing checks. |
| types/canonical.go | Defines the chain-bound data covered by proposal, vote, and extension signatures. |
| types/priv_validator.go | Defines the private-validator contract and raw-data signing boundary. |
| types/vote_set.go | Shows how valid votes become validator voting power and how conflicts are handled. |
| consensus/msgs.go | Shows the native-to-protocol conversion boundary for network and WAL messages. |
| consensus/msgs_test.go | Shows round-trip conversion, WAL conversion, invalid-input rejection, and stable wire encodings. |
| consensus/reactor.go | Shows peer message types, network channels, and the first message validation step. |
| consensus/state.go | Shows when consensus creates, signs, verifies, matches, persists, and consumes proposals and votes. |
| consensus/replay.go | Shows how WAL messages and application state are recovered after a crash. |
| consensus/wal.go | Shows the durable message boundary, height markers, encoding checks, and replay search. |
| consensus/state_partset_identity_test.go | Shows safety cases for full block identity during lock, valid-block, commit, and part recovery paths. |
| privval/signer_client.go | Shows consensus-side remote signer behavior and failure reporting. |
| privval/signer_server.go | Shows the remote signer service loop, request handling, and reconnect behavior. |
| privval/signer_requestHandler.go | Shows chain checks and request forwarding on the remote signer side. |
| privval/socket_dialers.go | Shows TCP authenticated-encryption and Unix socket connection paths. |
| privval/retry_signer_client.go | Shows which remote signing failures are retried and which fail at once. |
| privval/grpc_server.go | Shows the limited gRPC interface for public-key and raw-data signing. |
| privval/grpc_tls.go | Shows the mutual-TLS transport boundary for the gRPC private-validator service. |
| privval/grpc_listener.go | Shows the gRPC connection cap that protects the signing endpoint from stalled peers. |
| node/node.go | Shows how the node applies the gRPC handshake timeout and connection cap when it starts the signer endpoint. |
| proto/…/types.proto | Defines the wire-level consensus message groups. |
| proto/…/types.proto | Defines remote signing requests, responses, errors, and the gRPC service. |