Block generation
Block generation is responsible for assembling a candidate block header/body, using the current consensus best view and a packable transaction set.
Core flow
BlockGeneratorqueries the txpool for best info and packed transactions.It asks the consensus graph for the latest deferred state/blame info.
It chooses a parent and a referee set (bounded terminal hashes).
It fills a new header via
BlockHeaderBuilder.It hands the candidate to the mining loop or dev-mode auto generator.
Parent and referees
The parent is the best block hash from consensus.
Referees are selected from terminal DAG tips and filtered to exclude the parent.
choose_correct_parentmay adjust the parent/referees to satisfy consensus rules.
Header assembly details
transactions_rootis computed from the packed transactions.deferred_state_root,deferred_receipts_root,deferred_logs_bloom_hash, andblameare pulled from consensus.gas_limitis derived from target gas limit and elasticity multiplier.base_priceis computed by the txpool for EIP-1559 style pricing.customdata is set usingMachine::params().custom_prefix()for fork flags.
Mining integration
A
ProofOfWorkProblemis generated from the header's problem hash.Depending on
MiningType, the problem is sent to CPU workers or Stratum.On a solved nonce,
on_mined_blockhands the block to the sync service.
Key source files
crates/blockgen/src/lib.rscrates/mazzecore/core/src/consensus/mod.rscrates/mazzecore/core/src/transaction_pool/mod.rs
Last updated
Was this helpful?