feat(internal/ethapi): implement EIP-7910 - add XDPoS_getConfig#2326
feat(internal/ethapi): implement EIP-7910 - add XDPoS_getConfig#2326gzliudan wants to merge 1 commit into
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 ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 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
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_configRPC + Web3 extension entry and tests covering placeholder fork handling and fork ID generation. - Introduce
params/forksfork identifiers and extendparams.ChainConfigwith fork/system-contract helpers and fork-height enumeration. - Add
core/forkid(EIP-2124) implementation and expose precompile names via a newName()method onvm.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.
There was a problem hiding this comment.
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_configtoBlockChainAPI, plus web3 extension wiring and unit tests. - Introduced fork metadata helpers (
ForkBlockNumbers,LatestFork,ActiveSystemContracts) and a newcore/forkidpackage 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.
There was a problem hiding this comment.
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_configRPC (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.
There was a problem hiding this comment.
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_configRPC method plus web3 extension wiring and API tests. - Introduce fork modeling helpers in
params(modeled fork stages, effective fork heights, system contracts) and a newparams/forksenum. - Add EIP-2124 fork ID implementation (
core/forkid) driven byChainConfig.ForkBlockNumbers, and extend precompile interface withName()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.
There was a problem hiding this comment.
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_configRPC 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; introducecore/forkidfor 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.
d2f1f52 to
fa223a7
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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().TIPTRC21FeeBlockcan benilon configs that don't define the TRC21 fee fork (e.g., Ethereum-oriented configs used in tests/simulations). CallingCmpon a nil*big.Intwill panic during normal transaction execution. Fix by guarding the comparison (only compare whenTIPTRC21FeeBlock != nil), or by providing a safe default/fallback in the chain config (e.g., canonicalize missing values to0/MaxInt64depending on intended behavior).
core/state/trc21_reader.go:1for i := range tokenCountrelies 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
Hascall after anyGeterror, which can double the I/O cost on the “not found” path and adds latency for repeated config reads. Consider only usingHasfor specific error cases (e.g., “not found”), or flipping the order (checkHasfirst when callers expect frequent misses), or using a DB-specificErrNotFoundsignal when available so a second access isn’t needed.
df81fd1 to
95b724d
Compare
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.
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 applyImpacted Components
Which parts of the codebase does this PR touch?
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