-
Notifications
You must be signed in to change notification settings - Fork 69
all: expose block number information to statedb #27753 #1936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-upgrade
Are you sure you want to change the base?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request exposes block number information to the state database by adding a block parameter to the StateDB.Commit() and Database.Update() methods. This provides chain context to state commitment operations. Additionally, it refactors state object methods to remove the redundant Database parameter by accessing the database through the parent StateDB instance.
Key Changes:
- Added
block uint64parameter toStateDB.Commit()method with comprehensive documentation - Added
block uint64parameter to trieDatabase.Update()method - Refactored state object methods (GetState, SetState, Code, CodeSize, getTrie, etc.) to remove Database parameter
- Updated all call sites throughout the codebase to pass block numbers appropriately
- Enhanced cmd/evm/runner to use genesis configuration for block context
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| core/state/statedb.go | Added block parameter to Commit() method with documentation; updated state object method calls |
| core/state/state_object.go | Refactored methods to access database through parent StateDB instead of parameter |
| core/state/dump.go | Updated state object method calls to use new signatures |
| trie/database.go | Added block parameter to Update() method |
| trie/trie.go | Updated UpdateDb() to pass block number to database |
| core/blockchain.go | Updated Commit() call to pass actual block number |
| core/chain_makers.go | Updated Commit() call to pass header block number |
| core/genesis.go | Updated Commit() call (with issue: should use g.Number instead of 0) |
| eth/state_accessor.go | Updated Commit() call to pass actual block number |
| cmd/evm/runner.go | Enhanced with genesis config support and proper block context |
| tests/state_test_util.go | Updated test Commit() calls with block numbers |
| core/state/*_test.go | Updated test Commit() calls to use 0 for test context |
| trie/*_test.go | Updated test Update() calls to use 0 for test context |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| statedb.Commit(false) | ||
| statedb.Commit(0, false) |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The block number parameter should be g.Number instead of hardcoded 0. The Genesis struct supports non-zero Number values for consensus tests (as documented in the struct comments), and ToBlock should respect this value when committing state. Using a hardcoded 0 will cause incorrect block context for consensus tests that use non-zero genesis block numbers.
| statedb.Commit(0, false) | |
| statedb.Commit(g.Number, false) |
Proposed changes
Ref: ethereum#27753
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