tempo-consensus crate implements Tempo’s consensus validation logic, extending Ethereum’s consensus rules with Tempo-specific block and transaction validation.
Installation
Core Types
TempoConsensus
Main consensus implementation for Tempo.crates/consensus/src/lib.rs:36-50
Header Validation
ImplementsHeaderValidator<TempoHeader> trait.
validate_header
Validates a sealed header against consensus rules.-
Standard Ethereum checks (via inner
EthBeaconConsensus):- Valid PoW/PoS seal
- Valid extra data size (≤ 10 KiB for Tempo)
- Valid EIP-1559 base fee
- Valid blob gas parameters
-
Timestamp validation:
- Must not be more than 3 seconds in the future
- Milliseconds part must be < 1000
-
Gas limit validation:
sharedGasLimitmust equalblockGasLimit / 10generalGasLimitmust match expected value:- Pre-T1:
(blockGasLimit - sharedGasLimit) / 2 - T1+: Fixed at 30M
- Pre-T1:
crates/consensus/src/lib.rs:53-96
validate_header_against_parent
Validates a header against its parent.-
Standard parent checks:
- Correct parent hash and number
- Valid gas limit adjustment
- Valid EIP-1559 base fee progression
- Valid EIP-4844 blob parameters
-
Timestamp progression:
- Child timestamp (with milliseconds) must be > parent timestamp
crates/consensus/src/lib.rs:98-129
Block Validation
validate_body_against_header
Validates block body against header.- Transaction root matches
- Withdrawal root matches (if present)
- Ommer root matches (always empty for Tempo)
crates/consensus/src/lib.rs:133-139
validate_block_pre_execution
Validates block before EVM execution.-
System transaction validation:
- All system transactions must be valid for the chain ID
- System transactions must have correct signature
-
End-of-block system transactions:
- Block must contain exactly 1 system transaction at the end
- System transaction must target
Address::ZERO(subblock metadata)
-
System transaction order:
- Subblock metadata system tx must be last
crates/consensus/src/lib.rs:141-183
validate_block_post_execution
Validates block after EVM execution.- Receipt root matches header
- Gas used matches header
- Blob gas used matches (if applicable)
- Requests hash matches (if applicable)
crates/consensus/src/lib.rs:186-193
Constants
ALLOWED_FUTURE_BLOCK_TIME_SECONDS
Maximum time a block timestamp can be in the future.crates/consensus/src/lib.rs:26
TEMPO_SHARED_GAS_DIVISOR
Divisor for calculating shared gas limit.crates/consensus/src/lib.rs:29-30
TEMPO_MAXIMUM_EXTRA_DATA_SIZE
Maximum size of extra data in block headers.crates/consensus/src/lib.rs:33
System Transactions
Tempo blocks must include system transactions at the end for:- Subblock Metadata (required):
- Target:
Address::ZERO - Contains validator fee recipient mappings
- Encoded as RLP list of
SubBlockMetadatastructs
- Target:
Gas Limit Rules
Pre-T1 (T0 and earlier)
Gas limits are calculated dynamically:T1 and later (TIP-1000)
General gas limit is fixed at 30M:general_gas_limit_at()
Example: Full Block Validation
Timestamp Precision
Tempo blocks include millisecond-precision timestamps:crates/consensus/src/lib.rs:121-126
Error Handling
Consensus validation returnsConsensusError:
See Also
- tempo-evm - EVM execution
- tempo-primitives - Block and transaction types
- tempo-chainspec - Chain specification
- TIP-1000 - Gas limit changes