Skip to content

fix(rpc): expose PoL distributor in eth_config response#264

Open
NikhilSharmaWe wants to merge 1 commit into
berachain:mainfrom
NikhilSharmaWe:fix/eth-config-pol-distributor
Open

fix(rpc): expose PoL distributor in eth_config response#264
NikhilSharmaWe wants to merge 1 commit into
berachain:mainfrom
NikhilSharmaWe:fix/eth-config-pol-distributor

Conversation

@NikhilSharmaWe

@NikhilSharmaWe NikhilSharmaWe commented Jun 22, 2026

Copy link
Copy Markdown

Closes #168.

Summary

Exposes the Berachain PoL distributor contract in the eth_config RPC response (EIP-7910) under POL_DISTRIBUTOR_ADDRESS. The address is read from chainspec (berachain.prague1.polDistributorAddress in genesis), gated on Prague1 activation.

Bumps alloy-eips to 1.8.3 to use SystemContract::Other for chain-specific system contracts.

Test plan

  • test_builtin_genesis_pol_distributor - mainnet and Bepolia Prague1 boundaries
  • test_pol_distributor_uses_head_timestamp_not_prague_fork_timestamp - Prague fork ts vs post-Prague1 head ts
  • test_pol_distributor_system_contract_serde - JSON key serializes as POL_DISTRIBUTOR_ADDRESS

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced PoL distributor contract injection with timestamp-based Prague1 activation evaluation in RPC configuration.
  • Chores

    • Updated alloy-eips dependency to version 1.8.3.

Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Copilot AI review requested due to automatic review settings June 22, 2026 19:28
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds active_pol_distributor_at_timestamp to BerachainChainSpec, returning the PoL distributor address only when Prague1 is active and the address is non-zero. The EIP-7910 RPC fork-config builder is extended with a system_contracts_eval_timestamp parameter and a new insert_berachain_system_contracts helper, which is called at all three fork-config construction sites. alloy-eips is bumped from 1.6.3 to 1.8.3.

Changes

PoL Distributor System Contract

Layer / File(s) Summary
ChainSpec PoL distributor query method
src/chainspec/mod.rs
Adds BerachainChainSpec::active_pol_distributor_at_timestamp returning Some(address) when Prague1 is active at the given timestamp and the address is non-zero, plus unit tests asserting the None/Some boundary for both mainnet and bepolia.
RPC fork-config PoL distributor injection
src/rpc/config.rs, Cargo.toml
Adds POL_DISTRIBUTOR_SYSTEM_CONTRACT constant and insert_berachain_system_contracts helper; modifies the fork-config builder to accept system_contracts_eval_timestamp; updates all three config() call sites to pass their per-fork evaluation timestamps; bumps alloy-eips to 1.8.3; adds tests for insertion timing and SystemContract serialization.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • berachain/bera-reth#175: Modifies the same src/rpc/config.rs fork-config building logic and evaluation-time computation that this PR extends to inject the PoL distributor system contract.

Suggested reviewers

  • bar-bera
  • fridrik01

Poem

🐇 Hop, hop, through the Prague1 gate,
A PoL distributor seals its fate—
Zero address? Return a None!
Non-zero at the fork? We're done.
Each fork gets its timestamp true,
System contracts fresh and new! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: exposing the PoL distributor in the eth_config RPC response, which aligns with the primary objective of the pull request.
Linked Issues check ✅ Passed All requirements from issue #168 are met: the PoL distributor address is exposed in the eth_config response via system contracts, gated behind Prague1 fork activation, and includes appropriate test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing PoL distributor exposure in eth_config: dependency bump for SystemContract support, chainspec helper for Prague1 gating, and RPC handler updates with tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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_ADDRESS to the EIP-7910 systemContracts map when Prague1 is active (evaluated at head timestamp for the “current” config).
  • Introduce active_pol_distributor_at_timestamp on the chainspec and add regression tests for Prague1 boundary behavior + serde key behavior.
  • Bump alloy-eips to 1.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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/rpc/config.rs (1)

168-179: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Consider 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9352f11 and a3cb67e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • Cargo.toml
  • src/chainspec/mod.rs
  • src/rpc/config.rs

@NikhilSharmaWe

Copy link
Copy Markdown
Author

@calbera PTAL, thanks

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.

feat: add PoLDistributorAddress to eth_config response

2 participants