pub fn sanitize_chain<TxReq, H>(
blocks: Vec<SimBlock<TxReq>>,
parent: &SealedHeader<H>,
chain_id: u64,
max_simulate_blocks: u64,
) -> Result<Vec<SimBlock<TxReq>>, EthApiError>where
H: BlockHeader,Expand description
Sanitizes and gap-fills the chain of [SimBlock]s for eth_simulateV1.
Walks the provided block-state calls in order and:
- validates that each block number and timestamp strictly increases relative to the parent and prior simulated block;
- inserts empty filler blocks for every gap in block numbers, so a request like
[block at number N + k]over a parent atNexpands tok - 1empty blocks followed by the requested one (per the execution-apis spec: “If the block number is increased more than1compared to the previous block, new empty blocks are generated in between.”); - assigns default block numbers (
prev_number + 1) and timestamps (prev_timestamp + chain block time) when missing, so every returned entry has explicitnumberandtimeoverrides. The block time defaults to [Chain::average_blocktime_hint] for the chain id, falling back toSIMULATE_FALLBACK_TIMESTAMP_INCREMENTwhen no hint is registered. Sub-second chain hints are rounded up because block timestamps are second-granular; - enforces the global
max_simulate_blockscap on the total number of blocks (including generated fillers).