Skip to content

refactor: execute PoL in normal transaction pipeline#272

Open
NikhilSharmaWe wants to merge 3 commits into
berachain:mainfrom
NikhilSharmaWe:refactor/pol-tx-pipeline
Open

refactor: execute PoL in normal transaction pipeline#272
NikhilSharmaWe wants to merge 3 commits into
berachain:mainfrom
NikhilSharmaWe:refactor/pol-tx-pipeline

Conversation

@NikhilSharmaWe

@NikhilSharmaWe NikhilSharmaWe commented Jul 3, 2026

Copy link
Copy Markdown

Closes #64

Summary

PoL was previously executed in apply_pre_execution_changes, then handled again during import with dummy results and commit skips, and injected into the block during assembly. That required extra workarounds, including BerachainBlockBuilder and fix_pol_senders (#129).

This PR moves PoL into the normal transaction pipeline:

  • Execute PoL as tx #0 via execute_transaction during payload building
  • Remove PoL special-casing from the executor
  • Stop injecting PoL in the assembler; only validate it is present at index 0
  • Remove BerachainBlockBuilder and fix_pol_senders
  • Zero gas for PoL on revert/halt in transact_raw

Test plan

  • cargo build
  • cargo +nightly clippy --all-targets --all-features -- -D warnings
  • cargo nextest run --locked

Summary by CodeRabbit

  • New Features

    • Prague1 blocks now process Proof-of-Liquidity (PoL) through the standard transaction execution flow.
    • When Prague1 is active, block production requires non-empty receipts and validates that the first transaction is the PoL transaction.
  • Bug Fixes

    • PoL transaction execution now correctly reports zero gas usage even when execution reverts or halts.
    • Improved PoL validation and error reporting, including clearer failures for PoL before Prague1 activation and when the required proposer information is missing.

Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Copilot AI review requested due to automatic review settings July 3, 2026 13:32
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f6b76101-1f5d-4237-b8df-c01258964054

📥 Commits

Reviewing files that changed from the base of the PR and between 8b4bbe4 and 68bfb24.

📒 Files selected for processing (1)
  • src/transaction/pol.rs
✅ Files skipped from review due to trivial changes (1)
  • src/transaction/pol.rs

📝 Walkthrough

Walkthrough

PoL execution now happens in the payload builder as transaction #0 after Prague1 activation. The executor, EVM accounting, and assembler were updated to treat PoL consistently, and the Berachain block-builder wrapper was removed.

Changes

PoL transaction execution relocation

Layer / File(s) Summary
Payload builder executes PoL as tx #0
src/engine/builder.rs
default_berachain_payload now checks Prague1 activation, requires prev_proposer_pubkey, builds a PoL transaction with the current block number and base fee, and executes it signed by SYSTEM_ADDRESS.
Executor and POL accounting updates
src/evm/mod.rs, src/node/evm/executor.rs, src/transaction/pol.rs
POL Revert and Halt results now report zero gas, POL-specific execution shortcuts are removed from the node executor, proposer pubkey validation is added to pre-execution changes, and SYSTEM_ADDRESS imports now come from alloy_eips::eip7002.
Assembler validates PoL placement and block builder wiring
src/node/evm/assembler.rs, src/node/evm/config.rs, src/node/evm/mod.rs
assemble_block now validates that transaction 0 is a Berachain transaction instead of injecting PoL, create_block_builder returns a plain BasicBlockBuilder, and the internal builder module declaration is removed.
POL error variant update
src/node/evm/error.rs
The POL error set replaces the invalid-type variant with a before-Prague1 variant.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: fridrik01

🚥 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 title is concise and accurately describes the main change: executing PoL through the normal transaction pipeline.
Linked Issues check ✅ Passed The PR satisfies #64 by moving PoL execution into the core transaction path and updating block builder behavior accordingly.
Out of Scope Changes check ✅ Passed No clearly unrelated changes are present; the edits support the PoL execution refactor and associated builder/executor updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

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

Refactors Proof-of-Liquidity (PoL) execution so it runs as the first transaction (tx #0) in the normal block transaction pipeline during payload building, eliminating prior special-casing and assembly-time injection workarounds.

Changes:

  • Executes PoL as tx #0 during payload building and removes executor-side PoL bypass/skip logic.
  • Updates block assembly to validate PoL presence at index 0 (post-Prague1) instead of injecting it.
  • Removes the custom block builder wrapper previously used to patch sender/transaction mismatches from PoL injection, and ensures PoL gas-used is zero even on revert/halt.

Reviewed changes

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

Show a summary per file
File Description
src/node/evm/mod.rs Removes the now-unneeded builder module wiring.
src/node/evm/executor.rs Drops PoL system-call execution + receipt forging and removes PoL commit-skips/dummy results.
src/node/evm/error.rs Removes an error variant tied to the deleted PoL execution path.
src/node/evm/config.rs Stops wrapping BasicBlockBuilder with BerachainBlockBuilder; returns the basic builder directly.
src/node/evm/builder.rs Deletes the PoL injection sender-fix wrapper and its tests.
src/node/evm/assembler.rs Stops injecting PoL; validates PoL is present at index 0 post-Prague1.
src/evm/mod.rs Forces PoL gas used to 0 even on revert/halt in the PoL execution path.
src/engine/builder.rs Executes PoL as tx #0 during payload building (post-Prague1).

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

Comment thread src/engine/builder.rs
transaction::{BerachainTxEnvelope, pol::create_pol_transaction},
};
use alloy_consensus::Transaction;
use alloy_eips::eip7002::SYSTEM_ADDRESS;
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
@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.

refactor: Move PoL Execution out of apply_pre_execution_changes

2 participants