Skip to content

Conversation

@gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Jan 9, 2026

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 apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Copilot AI review requested due to automatic review settings January 9, 2026 05:25
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a 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 uint64 parameter to StateDB.Commit() method with comprehensive documentation
  • Added block uint64 parameter to trie Database.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)
Copy link

Copilot AI Jan 9, 2026

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.

Suggested change
statedb.Commit(0, false)
statedb.Commit(g.Number, false)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant