Skip to content

feat(internal/ethapi): implement EIP-7910 - add XDPoS_getConfig#2326

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:eth_config
Open

feat(internal/ethapi): implement EIP-7910 - add XDPoS_getConfig#2326
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:eth_config

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

@gzliudan gzliudan commented Apr 22, 2026

Proposed changes

Build the XDPoS config response from shared helpers that expose activation blocks, fork IDs, active fork labels, named precompiles, and active system contracts.

Expose the RPC through the XDPoS namespace and web3 extension, and document the response shape for current, next, and last block-based fork boundaries.

Add fork metadata, fork ID, and config snapshot tests to cover the new RPC payload and supporting chain-config helpers.

Ref: ethereum#32230

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 22, 2026 01:51
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 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: c046b3e5-0c69-4fc8-b6e3-1e0d35735d74

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

Implements the EIP-7910 eth_config RPC method to return current/next/last chain configuration metadata (fork IDs, precompile names, and active system contracts), along with supporting fork helpers and tests across params/ethapi/vm.

Changes:

  • Add eth_config RPC + Web3 extension entry and tests covering placeholder fork handling and fork ID generation.
  • Introduce params/forks fork identifiers and extend params.ChainConfig with fork/system-contract helpers and fork-height enumeration.
  • Add core/forkid (EIP-2124) implementation and expose precompile names via a new Name() method on vm.PrecompiledContract.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
params/forks/forks.go New fork identifier enum + string mapping used by config helpers.
params/config.go Adds fork/system-contract helpers and ForkBlockNumbers() enumeration used for fork IDs/config.
params/config_test.go Unit tests for fork block enumeration and latest fork stage mapping.
core/forkid/forkid.go New EIP-2124 fork ID calculator using ChainConfig.ForkBlockNumbers().
core/forkid/forkid_test.go Tests fork gathering behavior for fork ID inputs.
core/vm/contracts.go Extends precompile interface with Name() and implements it across precompiles.
core/vm/XDCx_price.go Adds Name() for XDCx price precompiles to satisfy new interface.
internal/ethapi/api.go Implements BlockChainAPI.Config (eth_config) assembling fork ID + precompile/system-contract metadata.
internal/ethapi/api_test.go Adds RPC-level test for placeholder “last” fork behavior + fork ID bytes.
internal/ethapi/override/override_test.go Updates test precompile mock to satisfy new Name() method.
internal/web3ext/web3ext.go Wires web3.eth.config() to call eth_config.

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

Comment thread params/config.go Outdated
Comment thread params/config.go Outdated
Comment thread internal/ethapi/api.go Outdated
Comment thread internal/ethapi/api_test.go Outdated
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

Implements the EIP-7910 eth_config RPC response to expose chain configuration metadata (current/next/last), including fork IDs, named precompiles, and active system contracts, backed by new fork/config helpers.

Changes:

  • Added eth_config to BlockChainAPI, plus web3 extension wiring and unit tests.
  • Introduced fork metadata helpers (ForkBlockNumbers, LatestFork, ActiveSystemContracts) and a new core/forkid package for EIP-2124 fork IDs.
  • Extended VM precompile interface with Name() and implemented names across precompiles.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
params/forks/forks.go Adds a fork identifier enum + string mapping used by config helpers.
params/config.go Adds fork/system-contract helpers and ForkBlockNumbers() aggregation logic.
params/config_test.go Tests fork block aggregation and fork->block mapping behavior.
core/forkid/forkid.go Adds EIP-2124 fork ID computation using gathered fork block numbers.
core/forkid/forkid_test.go Tests fork gathering behavior used by fork ID computation.
core/vm/contracts.go Adds Name() to PrecompiledContract and implements names for precompiles.
core/vm/XDCx_price.go Implements Name() for XDCx price precompiles.
internal/ethapi/api.go Implements eth_config response assembly, fork ID calculation, and precompile/system contract export.
internal/ethapi/api_test.go Adds tests for eth_config fork selection and fork ID behavior.
internal/web3ext/web3ext.go Exposes eth_config via the web3 extension (web3.eth.config).
internal/ethapi/override/override_test.go Updates test precompile stub to satisfy the new Name() interface method.

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

Comment thread internal/ethapi/override/override_test.go Outdated
Comment thread params/config.go Outdated
Comment thread internal/ethapi/api.go Outdated
Comment thread internal/ethapi/api.go Outdated
Comment thread internal/ethapi/api.go Outdated
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

Implements the EIP-7910 eth_config RPC method, exposing chain fork metadata (fork IDs, named precompiles, and active system contracts) for the current/next/last effective configurations.

Changes:

  • Add eth_config RPC (and web3 extension hook) returning fork-id + precompile/system-contract metadata per effective config window.
  • Introduce fork helpers on params.ChainConfig (latest modeled fork, system contracts, fork block number gathering).
  • Add core/forkid (EIP-2124) and extend precompile interface to expose stable names; add/extend unit tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
params/forks/forks.go Adds fork stage enum used by chain-config helpers.
params/config.go Adds fork stage helpers, system contract selection, and ForkBlockNumbers() aggregation.
params/config_test.go Adds tests for fork-height aggregation and fork stage → block mapping.
internal/ethapi/api.go Implements BlockChainAPI.Config (eth_config) using fork heights + forkid + named precompiles.
internal/ethapi/api_test.go Adds tests for eth_config behavior and fork-height tracking.
internal/web3ext/web3ext.go Exposes eth.config() via web3 extension.
core/forkid/forkid.go Adds EIP-2124 fork ID implementation (CRC32 over genesis + fork blocks).
core/forkid/forkid_test.go Adds unit tests for fork gathering behavior used by forkid.
core/vm/contracts.go Extends PrecompiledContract with Name() and implements names for existing precompiles.
core/vm/XDCx_price.go Implements Name() for XDCx price precompiles.
internal/ethapi/override/override_test.go Updates test precompile mock to satisfy the new Name() method.

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

Comment thread core/vm/contracts.go
Comment thread params/config.go Outdated
Comment thread core/forkid/forkid.go Outdated
Comment thread internal/ethapi/api.go Outdated
Comment thread core/vm/contracts.go
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

Implements EIP-7910 eth_config RPC response to expose current/next/last chain configuration metadata (fork IDs, named precompiles, and active system contracts), backed by new fork modeling and fork-height helpers.

Changes:

  • Add eth_config RPC method plus web3 extension wiring and API tests.
  • Introduce fork modeling helpers in params (modeled fork stages, effective fork heights, system contracts) and a new params/forks enum.
  • Add EIP-2124 fork ID implementation (core/forkid) driven by ChainConfig.ForkBlockNumbers, and extend precompile interface with Name() for named export.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
params/forks/forks.go Adds a fork enum + string names used for modeled fork stages.
params/config.go Adds modeled fork helpers, active system contracts, and ForkBlockNumbers() to produce effective fork heights.
params/config_test.go Unit tests for ForkBlockNumbers() and fork modeling behavior.
core/forkid/forkid.go Implements EIP-2124 fork ID calculation using ChainConfig.ForkBlockNumbers().
core/forkid/forkid_test.go Tests fork gathering behavior for fork ID inputs.
core/vm/contracts.go Extends PrecompiledContract with Name() and implements names for precompiles.
core/vm/XDCx_price.go Adds Name() implementations for XDCx price precompiles.
internal/ethapi/api.go Adds BlockChainAPI.Config implementing eth_config.
internal/ethapi/api_test.go Adds tests covering eth_config fork-block selection + fork ID behavior.
internal/ethapi/override/override_test.go Updates test precompile stub to satisfy new Name() interface method.
internal/web3ext/web3ext.go Exposes web3.eth.config() calling eth_config.

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

Comment thread internal/ethapi/api_test.go
Comment thread core/vm/contracts.go Outdated
Comment thread core/vm/contracts.go Outdated
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

Implements the XDPoS eth_config RPC endpoint (inspired by EIP-7910) to expose fork-boundary configuration metadata, including fork IDs, named precompiles, and active system contracts, and wires it into the Web3 extension with accompanying tests and docs.

Changes:

  • Add fork scheduling helpers to params.ChainConfig (modeled fork stages + effective fork block collection).
  • Add eth_config RPC implementation and Web3 extension wiring, plus tests for fork selection and payload content.
  • Extend VM precompile interface with Name() and implement names across built-in precompiles; introduce core/forkid for EIP-2124 fork ID calculation.

Reviewed changes

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

Show a summary per file
File Description
params/forks/forks.go Introduces a fork enum + string names used by chain config helpers.
params/config.go Adds effective fork height gathering (ForkBlockNumbers), modeled fork helpers, and system contract selection.
params/config_test.go Adds unit tests for fork height selection/deduplication/sentinel handling.
internal/ethapi/api.go Implements BlockChainAPI.Config (eth_config) response assembly.
internal/ethapi/api_test.go Adds tests validating block selection and response payload contents.
internal/web3ext/web3ext.go Exposes web3.eth.config() mapped to eth_config.
core/vm/contracts.go Extends PrecompiledContract with Name() and provides names for built-ins.
core/vm/XDCx_price.go Adds Name() for XDCx precompiles.
internal/ethapi/override/override_test.go Updates test precompile stub to satisfy new Name() interface requirement.
core/forkid/forkid.go Adds fork ID computation (EIP-2124) backed by ChainConfig.ForkBlockNumbers.
core/forkid/forkid_test.go Adds fork ID test coverage for fork gathering/deduplication and ID calculation.
docs/xdc/eth/eth.md Documents the new eth_config RPC method and response shape.

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

Comment thread internal/ethapi/api.go Outdated
Comment thread internal/ethapi/api.go Outdated
@gzliudan gzliudan force-pushed the eth_config branch 3 times, most recently from d2f1f52 to fa223a7 Compare April 22, 2026 11:36
@gzliudan gzliudan requested a review from Copilot April 22, 2026 11:36
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

Implements an XDPoS-specific XDPoS_getConfig RPC (inspired by EIP-7910 / eth_config) that reports chain configuration snapshots at the current/next/last fork boundaries, including fork IDs, active fork labels, named precompiles, and active system contracts.

Changes:

  • Add modeled fork helpers to params.ChainConfig (fork activation lookup, active fork labels, fork block boundary selection, system contracts).
  • Add config RPC builder (internal/configapi) + expose via XDPoS RPC API and web3 extension; document response shape.
  • Extend precompile contract interface with Name() and add/extend tests for fork metadata, fork ID, and config snapshots.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
params/forks/forks.go Introduces a modeled fork enum + string labels used by RPC payloads.
params/config.go Adds fork modeling helpers (ForkBlockNumbers, LatestFork, ActiveForks, BlockNumber, etc.) and fork boundary logic.
params/config_test.go Adds extensive unit tests covering fork block selection/modeling behavior.
core/forkid/forkid.go Adds forkid implementation (EIP-2124) using ChainConfig.ForkBlockNumbers().
core/forkid/forkid_test.go Adds tests for fork gathering and fork ID calculation.
internal/configapi/configapi.go Implements shared config response assembly (fork ID, active forks, precompiles, system contracts, feature flags).
internal/configapi/configapi_test.go Adds tests covering boundary selection scenarios and payload details.
consensus/XDPoS/api.go Exposes GetConfig via XDPoS RPC namespace using internal/configapi.
consensus/XDPoS/api_test.go Adds RPC-level test verifying GetConfig response.
internal/web3ext/web3ext.go Adds XDPoS.getConfig() web3 extension method.
docs/xdc/XDPoS/XDPoS.md Documents XDPoS_getConfig response schema and example.
core/vm/contracts.go Extends precompile interface with Name() and implements names for built-in precompiles.
core/vm/XDCx_price.go Adds Name() for XDCx price precompiles.
internal/ethapi/override/override_test.go Updates test precompile mock to satisfy new Name() interface requirement.

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

Comment thread params/config_test.go Outdated
Comment thread params/config_test.go Outdated
Comment thread core/forkid/forkid_test.go Outdated
Comment thread core/forkid/forkid_test.go Outdated
@gzliudan gzliudan changed the title feat(internal/ethapi): implement EIP-7910 - add eth_config #32230 feat(internal/ethapi): implement EIP-7910 - add XDPoS_getConfig Apr 24, 2026
@gzliudan gzliudan requested a review from Copilot May 7, 2026 05:22
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

Copilot reviewed 113 out of 114 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (3)

core/state_transition.go:1

  • st.evm.ChainConfig().TIPTRC21FeeBlock can be nil on configs that don't define the TRC21 fee fork (e.g., Ethereum-oriented configs used in tests/simulations). Calling Cmp on a nil *big.Int will panic during normal transaction execution. Fix by guarding the comparison (only compare when TIPTRC21FeeBlock != nil), or by providing a safe default/fallback in the chain config (e.g., canonicalize missing values to 0/MaxInt64 depending on intended behavior).
    core/state/trc21_reader.go:1
  • for i := range tokenCount relies on Go's “range over integer” feature (added in Go 1.22). If this repository/toolchain targets Go <1.22, this won’t compile. To keep compatibility across Go versions, switch to an explicit indexed loop (for i := uint64(0); i < tokenCount; i++ { ... }).
    core/rawdb/accessors_metadata.go:1
  • This performs an extra Has call after any Get error, which can double the I/O cost on the “not found” path and adds latency for repeated config reads. Consider only using Has for specific error cases (e.g., “not found”), or flipping the order (check Has first when callers expect frequent misses), or using a DB-specific ErrNotFound signal when available so a second access isn’t needed.

Comment thread common/gas.go Outdated
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

Copilot reviewed 113 out of 114 changed files in this pull request and generated 1 comment.

Comment thread core/state/trc21_reader.go
@gzliudan gzliudan force-pushed the eth_config branch 12 times, most recently from df81fd1 to 95b724d Compare May 26, 2026 15:17
Build the XDPoS config response from shared helpers that expose activation blocks, fork IDs, active fork labels, named precompiles, and active system contracts.

Expose the RPC through the XDPoS namespace and web3 extension, and document the response shape for current, next, and last block-based fork boundaries.

Add fork metadata, fork ID, and config snapshot tests to cover the new RPC payload and supporting chain-config helpers.
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.

5 participants