fix(rpc): expose PoL distributor in eth_config response#264
fix(rpc): expose PoL distributor in eth_config response#264NikhilSharmaWe wants to merge 1 commit into
Conversation
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
📝 WalkthroughWalkthroughAdds ChangesPoL Distributor System Contract
Sequence Diagram(s)sequenceDiagram
participant Caller as RPC Caller
participant config as config()
participant build as build_fork_config_inner()
participant insert as insert_berachain_system_contracts()
participant cs as BerachainChainSpec
Caller->>config: build EIP-7910 config
loop for each fork (current, next, last)
config->>build: fork + system_contracts_eval_timestamp
build->>insert: eval_timestamp
insert->>cs: active_pol_distributor_at_timestamp(eval_timestamp)
cs-->>insert: Some(address) | None
insert-->>build: conditionally insert POL_DISTRIBUTOR_SYSTEM_CONTRACT
build-->>config: ForkConfig { systemContracts, ... }
end
config-->>Caller: EIP-7910 response with per-fork systemContracts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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
This PR updates the Berachain eth_config (EIP-7910) RPC response to expose the Berachain-specific PoL distributor contract address as a chain-specific system contract, gated by Prague1 activation and sourced from the chainspec (genesis berachain.prague1.polDistributorAddress). It also bumps alloy-eips to use SystemContract::Other for non-Ethereum system contracts.
Changes:
- Add
POL_DISTRIBUTOR_ADDRESSto the EIP-7910systemContractsmap when Prague1 is active (evaluated at head timestamp for the “current” config). - Introduce
active_pol_distributor_at_timestampon the chainspec and add regression tests for Prague1 boundary behavior + serde key behavior. - Bump
alloy-eipsto1.8.3(with corresponding lockfile updates).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/rpc/config.rs |
Inserts the PoL distributor into EIP-7910 systemContracts using SystemContract::Other, with Prague1 gating and tests. |
src/chainspec/mod.rs |
Adds a Prague1-gated accessor for the PoL distributor address and tests for built-in chainspecs. |
Cargo.toml |
Updates alloy-eips dependency to 1.8.3. |
Cargo.lock |
Updates resolved dependency versions/checksums to match the alloy-eips bump. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/rpc/config.rs (1)
168-179: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueConsider removing inline comment per coding guidelines.
The comment on line 173 references BRIP-0004, which provides useful protocol context. However, the coding guidelines specify "No comments in code unless explicitly requested." Consider moving this to the doc comment above the function or removing it.
♻️ Suggested refactor
+/// Inserts Berachain-specific system contracts based on the evaluation timestamp. +/// +/// PoL distributor (BRIP-0004) is a Prague1 system contract, not part of Ethereum Prague. fn insert_berachain_system_contracts( chain_spec: &BerachainChainSpec, eval_timestamp: u64, system_contracts: &mut BTreeMap<SystemContract, Address>, ) { - // BRIP-0004: PoL distributor is a Prague1 system contract, not part of Ethereum Prague. if let Some(address) = chain_spec.active_pol_distributor_at_timestamp(eval_timestamp) { system_contracts .insert(SystemContract::Other(POL_DISTRIBUTOR_SYSTEM_CONTRACT.into()), address); } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/rpc/config.rs` around lines 168 - 179, The inline comment about BRIP-0004 and the PoL distributor being a Prague1 system contract in the insert_berachain_system_contracts function violates the coding guidelines that prohibit inline comments unless explicitly requested. Either move the comment content into the doc comment above the function or remove the inline comment entirely. If moving it to the doc comment, preserve the explanation about BRIP-0004 and the Prague1 system contract context in the function documentation.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/rpc/config.rs`:
- Around line 168-179: The inline comment about BRIP-0004 and the PoL
distributor being a Prague1 system contract in the
insert_berachain_system_contracts function violates the coding guidelines that
prohibit inline comments unless explicitly requested. Either move the comment
content into the doc comment above the function or remove the inline comment
entirely. If moving it to the doc comment, preserve the explanation about
BRIP-0004 and the Prague1 system contract context in the function documentation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: bfca736a-6036-4da6-a0ff-5f2df17854eb
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
Cargo.tomlsrc/chainspec/mod.rssrc/rpc/config.rs
|
@calbera PTAL, thanks |
Closes #168.
Summary
Exposes the Berachain PoL distributor contract in the
eth_configRPC response (EIP-7910) underPOL_DISTRIBUTOR_ADDRESS. The address is read from chainspec (berachain.prague1.polDistributorAddressin genesis), gated on Prague1 activation.Bumps
alloy-eipsto 1.8.3 to useSystemContract::Otherfor chain-specific system contracts.Test plan
test_builtin_genesis_pol_distributor- mainnet and Bepolia Prague1 boundariestest_pol_distributor_uses_head_timestamp_not_prague_fork_timestamp- Prague fork ts vs post-Prague1 head tstest_pol_distributor_system_contract_serde- JSON key serializes asPOL_DISTRIBUTOR_ADDRESSSummary by CodeRabbit
Release Notes
New Features
Chores