Skip to content

refactor(test): add gossip screening for fees and fix breakpoint test - #830

Merged
erhant merged 9 commits into
devfrom
erhant/gossip-screen-and-breakpoint-test
Sep 4, 2026
Merged

refactor(test): add gossip screening for fees and fix breakpoint test#830
erhant merged 9 commits into
devfrom
erhant/gossip-screen-and-breakpoint-test

Conversation

@erhant

@erhant erhant commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🎯 Purpose

The #801 (fees) merge tripled nextest wall time (525s → 1530s; the unit-tests job went 24.5 min → ~53 min and started timing out): every charged transaction now runs up to three zkVM guest emulations (reserve → action → refund) and dev mode does not help (as it skips proving, not execution).

This PR takes the free wins from that investigation (kudos to @moudyellaz ):

  1. A test put_block_stores_breakpoint_in_same_batch that never needed settleable blocks was paying for ~795 guest executions.

  2. The block builder ran a full scratch-clone settlement (all three guest runs) on every mempool candidate before discovering it could not pay, and gossiped transactions entered the mempool with no fee screening at all.

⚙️ Approach

  • put_block_stores_breakpoint_in_same_batch (storage): chain produce_dummy_blocks instead of signed, settled transfer blocks — put_block never settles, so the breakpoint-batch assertions are unchanged and the test goes from ~795 guest executions to zero (327s → seconds in CI)
  • Builder: run the cheap fees::screen (static checks + one balance read, no clone, no execution) on every User/Gossip candidate before the scratch clone and settlement, so junk is dropped for a balance read instead of three guest runs
  • Gossip ingest: screen a peer's transaction through the same fees::screen before it takes a mempool slot, via a new screen-only ScreenTransaction executor message — one admission door for RPC and gossip. Deliberately advisory: the verdict never affects gossipsub mesh acceptance (admission is priced off the local head state, which drifts, so peers legitimately disagree), and a screened-out tx stays un-seen so a rebroadcast can retry once e.g. its payer is funded. Closes fees: screen gossip-ingested transactions through fee admission #797
  • Document that MAX_GAS_EXEC caps action-phase gas only; the reserve/refund invocations and the fee/clock tail run unmetered as a bounded per-transaction constant

🧪 How to Test

# The reverted test, now sub-second:
RISC0_DEV_MODE=1 cargo test -p storage put_block_stores_breakpoint_in_same_batch

# Gossip + builder paths (gossip tests use the new admit-all screen):
RISC0_DEV_MODE=1 cargo test -p sequencer_core --all-features gossip
RISC0_DEV_MODE=1 cargo test -p sequencer_core --all-features tests::

🔗 Dependencies

None

🔜 Future Work

None

📋 PR Completion Checklist

  • Complete PR description
  • Implement the core functionality
  • Add/update tests
  • Add/update documentation and inline comments

@erhant erhant self-assigned this Sep 4, 2026
@erhant
erhant requested a lite review from Copilot September 4, 2026 09:40

Copilot AI 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.

🟡 Changes recommended

The new IngestScreen type currently won’t compile due to anyhow::Result generic misuse, and the gossip driver’s inline async screening also introduces a potential responsiveness/DoS concern that should be addressed.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR reduces unit-test CI wall time and tightens fee-admission hygiene by introducing a cheap fee screen earlier in both the block builder and the gossip-ingest path, plus refactoring an expensive storage breakpoint test to avoid unnecessary zkVM guest execution.

Changes:

  • Refactors put_block_stores_breakpoint_in_same_batch to use dummy (unsettleable) blocks, eliminating zkVM execution in that test.
  • Adds a fee-admission screen (fees::screen) before scratch-clone settlement in the sequencer’s mempool candidate path.
  • Adds an advisory gossip-ingest fee screen via a new ScreenTransaction executor message and an IngestScreen hook in GossipNetwork.
File summaries
File Description
lez/storage/src/indexer/tests.rs Refactors breakpoint test to chain dummy blocks and avoid zkVM guest runs.
lez/sequencer/service/src/lib.rs Wires a gossip-ingest fee screen via the executor actor before mempool admission.
lez/sequencer/core/src/lib.rs Runs fees::screen before scratch-clone settlement for User/Gossip candidates.
lez/sequencer/core/src/gossip/tests.rs Updates gossip tests to pass an admit-all ingest screen.
lez/sequencer/core/src/gossip/network.rs Adds IngestScreen, applies it during gossip ingest, and makes swarm event handling async.
lez/sequencer/core/src/gossip/mod.rs Re-exports IngestScreen and admit_all_screen.
lez/sequencer/actors/executor/src/protocol.rs Introduces ScreenTransaction message for screen-only admission checks.
lez/sequencer/actors/executor/src/actor.rs Implements handler for ScreenTransaction to run fees::screen on head state.
lez/programs/fee/core/src/market.rs Documents that MAX_GAS_EXEC caps action-phase gas only (reserve/refund + tails unmetered).
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lez/sequencer/core/src/gossip/network.rs Outdated
Comment thread lez/sequencer/core/src/gossip/network.rs Outdated
Comment thread lez/sequencer/core/src/gossip/network.rs Outdated
@erhant
erhant force-pushed the erhant/gossip-screen-and-breakpoint-test branch from 2a476c8 to 7d956aa Compare September 4, 2026 09:58
@erhant
erhant marked this pull request as ready for review September 4, 2026 10:26

@Pravdyvy Pravdyvy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@erhant

erhant commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

#831 must be merged BEFORE this one

Comment thread lez/storage/src/indexer/tests.rs

@Arjentix Arjentix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, looking forward to make gossiper a separate actor

Comment thread lez/sequencer/core/src/lib.rs
Comment thread lez/sequencer/core/src/gossip/network.rs

@moudyellaz moudyellaz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm, thanks!

erhant and others added 8 commits September 4, 2026 17:36
put_block never settles, so the breakpoint-batch test does not need
settleable blocks; dummy blocks keep it off the zkVM entirely
(~795 guest executions to zero).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fee-screen transactions at both cheap chokepoints:

- builder: drop unfundable/fee-invalid candidates before paying for the
  scratch clone and the settlement's guest executions, for every origin
- gossip ingest: run the same screen (via the new screen-only
  ScreenTransaction executor message) before a peer's transaction takes
  a mempool slot; advisory only — the verdict never affects mesh
  acceptance, and the tx stays unseen so a rebroadcast can retry

Also document that MAX_GAS_EXEC caps action-phase gas only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@erhant
erhant force-pushed the erhant/gossip-screen-and-breakpoint-test branch from 9dcbe24 to c418e46 Compare September 4, 2026 14:37
@erhant
erhant merged commit ab2018a into dev Sep 4, 2026
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.

fees: screen gossip-ingested transactions through fee admission

5 participants