Skip to content

chore(prague3): informational comments about prague3 validation rules#251

Open
calbera wants to merge 1 commit into
mainfrom
info-bug-bounty-prague3
Open

chore(prague3): informational comments about prague3 validation rules#251
calbera wants to merge 1 commit into
mainfrom
info-bug-bounty-prague3

Conversation

@calbera
Copy link
Copy Markdown
Contributor

@calbera calbera commented May 5, 2026

Also adds unit test for the missing case of accepts_post_prague1_proposer_pubkey

Summary by CodeRabbit

  • New Features

    • Implemented Prague3 historical-window block execution validation with checks for restricted transfers and vault-related restrictions.
  • Tests

    • Extended test coverage for protocol header validation and fork window gating.
  • Documentation

    • Added comprehensive documentation for historical protocol fixtures.

@calbera calbera requested review from a team and Copilot May 5, 2026 23:37
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

This PR implements Prague3 historical-window validation in the Berachain consensus layer. It adds post-execution checks to block validation that enforce ERC20 transfer restrictions on blocked addresses and the BEX vault, plus validates InternalBalanceChanged events. Documentation is updated and test coverage is extended for Prague1/Prague3 activation boundaries.

Changes

Prague3 Historical-Window Validation

Layer / File(s) Summary
Core Validation Logic
src/consensus/mod.rs (lines 120–154)
Implements Prague3 post-execution validation in BerachainBeaconConsensus::validate_block_post_execution, gated by Prague3 active window. Iterates block receipts/logs to identify Transfer and InternalBalanceChanged events; enforces blocking rules for blocked addresses and BEX vault transfers; surfaces validation failures as ConsensusError::Other variants.
Error Type Documentation
src/node/evm/error.rs (lines 31–60)
Reorganizes and expands doc comments for Prague3-related BerachainExecutionError variants (Prague3BlockedAddressTransfer, Prague3BexVaultEvent, Prague3BexVaultTransfer); variant signatures remain unchanged, only documentation and historical window notes are updated.
Test Fixtures & Paths
tests/e2e/prague3_empty_block_test.rs (lines 1–24)
Adds header comment documenting Prague3 historical window behavior and fixture location; updates genesis fixture path to historical location (tests/fixtures/historical/eth-genesis-prague3.json).
Helper Documentation
src/consensus/mod.rs (lines 441–444), tests/fixtures/historical/README.md
Updates validate_header doc comment wording; introduces new README documenting historical fixtures for Prague3 closed fork window, including fixture index and validation scope notes.
Test Coverage
src/consensus/mod.rs (lines 518–534)
Adds test scaffold and test_validate_header_accepts_post_prague1_proposer_pubkey() to cover pre/post-Prague1 proposer pubkey acceptance and header validation boundaries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • berachain/bera-reth#189: Overlapping Prague3/Prague4 support changes affecting consensus post-execution validation, engine commit flow, and EVM error variants.

Suggested reviewers

  • bar-bera
  • fridrik01

🐰 Prague's guards now stand so tall,
Testing transfers, blocking calls,
Historical windows sealed with care,
Vault and address rules laid bare,
Consensus strengthens—all is well! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title claims the PR adds 'informational comments' but the changes include substantial logic additions for Prague3 validation and new test coverage, not just comments. Revise the title to accurately reflect the main changes: e.g., 'feat(prague3): add Prague3 block validation and test coverage for proposer pubkey' to better represent the functional additions beyond documentation.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch info-bug-bounty-prague3

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
Contributor

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

Adds clarifying documentation around the Prague3 (historical-window) validation rules and introduces/organizes a dedicated historical genesis fixture, while also filling a missing unit-test case for Prague1 proposer pubkey validation.

Changes:

  • Added a tests/fixtures/historical/ directory with a Prague3-specific genesis fixture and README describing its intent.
  • Updated the Prague3 e2e test to reference the historical fixture and added module-level documentation explaining the scenario.
  • Expanded Prague3/Prague1 documentation in consensus/execution error definitions and added a unit test covering the “post-Prague1 proposer pubkey is accepted” case.

Reviewed changes

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

Show a summary per file
File Description
tests/fixtures/historical/README.md Documents the purpose and scope of “historical window” fixtures, including the Prague3 fixture.
tests/fixtures/historical/eth-genesis-prague3.json Adds a Prague3-oriented genesis/chain-spec fixture used by e2e coverage.
tests/e2e/prague3_empty_block_test.rs Points the Prague3 e2e test at the historical fixture and adds scenario documentation.
src/node/evm/error.rs Adds explanatory comments to Prague3 execution errors (reachability / historical context).
src/consensus/mod.rs Adds detailed Prague3 validation rationale comments and adds a missing unit test for post-Prague1 proposer pubkey acceptance.

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

Comment thread src/consensus/mod.rs
Comment on lines +128 to +131
// which returns true only inside that historical window. Outside the window
// (i.e. on the live tip post-Prague4, and pre-Prague3) the gate short-circuits
// and none of the loops run. The path remains a hard requirement for any node
// re-executing the chain from genesis.
Comment thread src/node/evm/error.rs
Comment on lines +31 to 34
/// Prague3: Block contains invalid ERC20 transfer from/to blocked address.
/// Only reachable inside the historical Prague3 window
/// `[1762164459, 1762963200)` on mainnet; see `consensus/mod.rs`.
#[error(
Comment thread src/node/evm/error.rs
Comment on lines +38 to 41
/// Prague3: Block contains InternalBalanceChanged event from BEX vault.
/// Only reachable inside the historical Prague3 window
/// `[1762164459, 1762963200)` on mainnet; see `consensus/mod.rs`.
#[error("Prague3 violation: InternalBalanceChanged event from BEX vault {vault_address}")]
Comment thread src/node/evm/error.rs
Comment on lines +43 to 46
/// Prague3: Block contains ERC20 transfer from/to BEX vault.
/// Only reachable inside the historical Prague3 window
/// `[1762164459, 1762963200)` on mainnet; see `consensus/mod.rs`.
#[error("Prague3 violation: ERC20 transfer from/to BEX vault {vault_address}")]
Comment on lines +1 to +5
//! Pins the Prague3 empty-block builder behavior that ran on Berachain mainnet
//! during the closed historical window `[1762164459, 1762963200)`. The genesis
//! fixture lives under `tests/fixtures/historical/` (see the README there) to
//! signal that it models a non-live fork window. The consensus rules being
//! exercised are documented in `src/consensus/mod.rs`.
Comment on lines +16 to +19
Models the **Prague3 emergency window**, active on Berachain mainnet for
timestamps `[1762164459, 1762963200)` — 2025-11-03 to 2025-11-12, when Prague4
ended the restrictions. Used by `tests/e2e/prague3_empty_block_test.rs` to
exercise the empty-block builder path that ran while Prague3 was the live tip.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/consensus/mod.rs (1)

120-147: 💤 Low value

Comment block clearly justifies the "not dead code" status and the scoping asymmetry.

The block usefully (a) anchors the historical window to concrete timestamps consistent with error.rs variants and the historical README, (b) explains why the gate is non-dead for genesis re-execution, and (c) documents why Transfer is intentionally unscoped while InternalBalanceChanged and the deposit parser are scoped. This is exactly the kind of "why" rationale future maintainers and bug-bounty triagers will need.

One small nit: the comment refers to deposits.rs without a path qualifier. If readers grep for it, they will likely land in src/node/evm/deposits.rs (or wherever the deposit parser lives); a relative path (e.g. node/evm/deposits.rs) would make it unambiguous, mirroring the explicit consensus/mod.rs reference used elsewhere.

🤖 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/consensus/mod.rs` around lines 120 - 147, Update the inline comment under
the "Prague3 historical-window validation" header in consensus/mod.rs to replace
the ambiguous reference "deposits.rs" with the relative path
"node/evm/deposits.rs" so readers who grep the repo land on the correct file;
keep the surrounding rationale and wording intact except for this path
clarification.
🤖 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/consensus/mod.rs`:
- Around line 120-147: Update the inline comment under the "Prague3
historical-window validation" header in consensus/mod.rs to replace the
ambiguous reference "deposits.rs" with the relative path "node/evm/deposits.rs"
so readers who grep the repo land on the correct file; keep the surrounding
rationale and wording intact except for this path clarification.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad876d1d-d856-4588-acfb-6d864057e3c4

📥 Commits

Reviewing files that changed from the base of the PR and between 06a5851 and 73b6ae9.

📒 Files selected for processing (5)
  • src/consensus/mod.rs
  • src/node/evm/error.rs
  • tests/e2e/prague3_empty_block_test.rs
  • tests/fixtures/historical/README.md
  • tests/fixtures/historical/eth-genesis-prague3.json

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.

2 participants