[WIP] refactor(consensus): split ChainReader interface #20692#2070
[WIP] refactor(consensus): split ChainReader interface #20692#2070gzliudan wants to merge 1 commit intoXinFinOrg:dev-upgradefrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request refactors the consensus layer by splitting the ChainReader interface into two interfaces: ChainHeaderReader (header-only access) and ChainReader (extends ChainHeaderReader with full block access). This improves separation of concerns and makes it clearer when code needs full block access versus just header access.
Changes:
- Split
ChainReaderinterface intoChainHeaderReaderandChainReaderto separate header-only operations from full block access - Updated all consensus engine methods to use
ChainHeaderReaderinstead ofChainReaderwhere full blocks are not needed - Replaced
chain.GetBlock()calls withrawdb.ReadBody()where appropriate when usingChainHeaderReader
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| consensus/consensus.go | Defines new ChainHeaderReader interface and makes ChainReader extend it |
| consensus/ethash/*.go | Updates ethash consensus engine to use ChainHeaderReader; adds type assertion in VerifyUncles for block access |
| consensus/clique/*.go | Updates clique consensus engine to use ChainHeaderReader throughout |
| consensus/XDPoS/**/*.go | Updates XDPoS v1 and v2 engines to use ChainHeaderReader; includes hooks and all engine methods |
| miner/*.go | Updates miner agents to use ChainHeaderReader |
| internal/ethapi/*.go | Updates API layer to use ChainHeaderReader |
| eth/hooks/*.go | Updates consensus hooks; uses bc.GetBlock() directly when block access needed |
| eth/util/util.go | Updates utility function to use ChainHeaderReader |
| contracts/utils.go | Uses rawdb.ReadBody() instead of chain.GetBlock() with proper nil checking |
| eth/bft/*.go | Updates BFT handler and tests to use ChainHeaderReader |
| core/chain_makers.go | Updates chain maker to use ChainHeaderReader |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a79f67d to
9d29941
Compare
9d29941 to
1063c65
Compare
Proposed changes
Ref: ethereum#20692
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that