Skip to content

test: cleanup tests #25641#2267

Open
gzliudan wants to merge 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:cleanup-tests
Open

test: cleanup tests #25641#2267
gzliudan wants to merge 1 commit intoXinFinOrg:dev-upgradefrom
gzliudan:cleanup-tests

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

@gzliudan gzliudan commented Apr 1, 2026

Proposed changes

Ref: ethereum#25641

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
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
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • 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 April 1, 2026 07:47
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 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.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d745cecc-1dd6-480b-be6a-6e631d4ef1be

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown

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 PR cleans up multiple test suites to run against an EIP-1559-enabled params.TestChainConfig and updates test chain generation/helpers accordingly, reducing ad-hoc per-test config mutations.

Changes:

  • Enable EIP-1559 from genesis in params.TestChainConfig and remove many test-local Eip1559Block overrides.
  • Update multiple tests to use params.TestChainConfig directly and to fund accounts / set gas pricing compatible with base fee.
  • Refactor chain maker helpers to support “with genesis” generation and adjust core chain tests to use the updated helpers.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
params/config.go Enables EIP-1559 at block 0 in TestChainConfig, aligning tests with base-fee semantics.
eth/tracers/api_test.go Removes per-test config cloning; uses params.TestChainConfig directly in tracer tests.
eth/helper_test.go Adjusts funded balance in genesis for protocol manager tests.
eth/handler_test.go Makes test tx generation base-fee aware by providing a fee value to legacy txs.
eth/filters/filter_test.go Adjusts genesis commit/chain generation flow to avoid GenerateChainWithGenesis DB behavior and uses TestChainConfig directly.
eth/filters/filter_system_test.go Updates tx gas price selection to be compatible with base fee.
eth/fetcher/fetcher_test.go Updates genesis funding and ensures legacy txs use a non-nil fee/gas price.
eth/downloader/testchain_test.go Removes local config override and uses TestChainConfig consistently for chain/signing.
eth/downloader/queue_test.go Ensures generated txs use non-nil fee/gas price derived from base fee.
eth/downloader/downloader_test.go Removes redundant Eip1559Block override in returned test config.
core/txpool/locals/tx_tracker_test.go Updates funds and gas pricing to align with base fee behavior.
core/txpool/legacypool/legacypool_test.go Removes redundant fork-block overrides now covered by TestChainConfig.
core/chain_makers.go Adds “with genesis” helper variants; threads chain config into header/block chain helpers.
core/blockchain_test.go Refactors canonical-chain test setup to return genesis spec and adjust generation/insertion paths.
core/block_validator_test.go Switches to GenerateChainWithGenesis for test chain setup and uses fresh DB for blockchain.
core/bench_test.go Switches benchmark chain generation to GenerateChainWithGenesis (separate DB from insertion DB).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to 57
func newCanonical(engine consensus.Engine, n int, full bool) (ethdb.Database, *Genesis, *BlockChain, error) {
var (
db = rawdb.NewMemoryDatabase()
gspec = &Genesis{
genesis = &Genesis{
BaseFee: big.NewInt(params.InitialBaseFee),
Config: params.AllEthashProtocolChanges,
}
genesis = gspec.MustCommit(db)
)

// Initialize a fresh chain with only a genesis block
blockchain, _ := NewBlockChain(db, nil, gspec, engine, vm.Config{})
blockchain, _ := NewBlockChain(rawdb.NewMemoryDatabase(), nil, genesis, engine, vm.Config{})

// Create and inject the requested chain
if n == 0 {
return db, blockchain, nil
return rawdb.NewMemoryDatabase(), genesis, blockchain, nil
}
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newCanonical builds the BlockChain with a fresh in-memory DB, but when n == 0 it returns a different freshly-created DB that does not contain the committed genesis state. Callers pass the returned genDb into GenerateChain/makeBlockChain, which will panic when trying to open state at parent.Root() (genesis trie nodes are missing in that returned DB).

Return the same DB that backs blockchain (or commit the genesis into the returned DB) so subsequent chain generation has access to the parent state.

Copilot uses AI. Check for mistakes.
Comment on lines 163 to 165
gspec := &Genesis{
Alloc: types.GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}},
Config: params.TestChainConfig,
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params.TestChainConfig now has EIP-1559 enabled from block 0, which means legacy transactions must have a non-nil gas price (and typically >= base fee). The benchmark generators used by benchInsertChain (e.g. genValueTx and genTxRing) still create legacy txs with gasPrice == nil, which will panic when tx.GasPrice() is evaluated during block processing.

Update the benchmark generators to always set a concrete gas price (e.g. use gen.BaseFee() with a fallback to params.InitialBaseFee) so the benchmarks run under the updated test chain config.

Suggested change
gspec := &Genesis{
Alloc: types.GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}},
Config: params.TestChainConfig,
cfg := *params.TestChainConfig
cfg.LondonBlock = nil
gspec := &Genesis{
Alloc: types.GenesisAlloc{benchRootAddr: {Balance: benchRootFunds}},
Config: &cfg,

Copilot uses AI. Check for mistakes.
@gzliudan gzliudan force-pushed the cleanup-tests branch 7 times, most recently from 5a25812 to b2b33e2 Compare April 1, 2026 16:57
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.

4 participants