Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a proposal pool for handling not-yet-confirmed blocks and integrates it with the blockchain, along with a block preparer to asynchronously mint new blocks. Key changes include:
- Adding new modules for block preparation (blockpreparer.go and blockpreparer_test.go).
- Implementing a proposal pool to manage draft blocks and forks (proposalpool.go and proposalpool_test.go).
- Enhancing the blockchain integration to support asynchronous block preparation and a pending block mechanism.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| blockchain/blockpreparer_test.go | Adds tests for asynchronous block minting. |
| blockchain/blockpreparer.go | Implements async block minting using a channel and mutex. |
| blockchain/proposalpool_test.go | Covers proposal pool behaviors for adding, retrieving, and fork management. |
| blockchain/proposalpool.go | Implements logic for managing draft blocks and forks. |
| blockchain/blockchain.go | Integrates block preparer and proposal pool into blockchain operations and block production. |
| test/mock/mock_blockchain/mock_blockchain.go | Updates mock definitions to include new methods. |
Comments suppressed due to low confidence (2)
blockchain/blockchain.go:519
- Comparing the prepared block's timestamp for equality with the provided timestamp may be brittle due to possible precision or slight delay differences. Consider using additional fields (like block height or hash) or a tolerance range when checking if the draft block corresponds to the intended block.
if pblk != nil && pblk.Timestamp() == timestamp {
blockchain/blockchain.go:602
- In tipInfo, when tipHeight exceeds daoHeight the function attempts to fetch a draft header from the proposal pool and wraps db.ErrNotExist if not found. This logic might hide the root issue; consider clarifying the error handling to better distinguish between a missing confirmed block and an unprepared draft.
if tipHeight > daoHeight {
|
if we change the implementation of |
f64c120 to
fa2f44b
Compare
|
| consensusCfg := consensusfsm.NewConsensusConfig(builder.cfg.Consensus.RollDPoS.FSM, builder.cfg.DardanellesUpgrade, builder.cfg.Genesis, builder.cfg.Consensus.RollDPoS.Delay) | ||
| dao := builder.cs.BlockDAO() | ||
| builder.cs.blockTimeCalculator, err = blockutil.NewBlockTimeCalculator(consensusCfg.BlockInterval, builder.cs.Blockchain().TipHeight, func(height uint64) (time.Time, error) { | ||
| builder.cs.blockTimeCalculator, err = blockutil.NewBlockTimeCalculator(consensusCfg.BlockInterval, func() uint64 { |
There was a problem hiding this comment.
Fix the bug: the tipHeight() will be called during check indexers at startup, but at that time the blockchain has not yet been fully initialized


Description
The blockchain introduces a proposal pool to store blocks that are being processed but have not yet been confirmed.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: