Skip to content

apollo_consensus_orchestrator: introduce BTreeMap-keyed SNIP-35 fee_proposals window#14083

Merged
sirandreww-starkware merged 1 commit into
mainfrom
05-19-apollo_consensus_orchestrator_rework_snip-35_fee_proposals_window_for_state_sync_resilience
May 20, 2026
Merged

apollo_consensus_orchestrator: introduce BTreeMap-keyed SNIP-35 fee_proposals window#14083
sirandreww-starkware merged 1 commit into
mainfrom
05-19-apollo_consensus_orchestrator_rework_snip-35_fee_proposals_window_for_state_sync_resilience

Conversation

@sirandreww-starkware
Copy link
Copy Markdown
Contributor

No description provided.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

sirandreww-starkware commented May 19, 2026

@sirandreww-starkware sirandreww-starkware self-assigned this May 19, 2026
@sirandreww-starkware sirandreww-starkware marked this pull request as ready for review May 19, 2026 09:33
@cursor
Copy link
Copy Markdown

cursor Bot commented May 19, 2026

PR Summary

Medium Risk
Touches consensus fee-proposal tracking used for SNIP-35 gas pricing; incorrect window contents or pruning could skew fee_actual and affect block building/validation behavior across nodes.

Overview
Switches the SNIP-35 fee_proposals_window from a FIFO VecDeque to a BTreeMap<BlockNumber, Option<GasPrice>>, explicitly recording a (possibly None) fee proposal per height (including pre-V0_14_3).

Adds deterministic window maintenance: bootstrapping from state sync now records entries by height, window pruning is performed on each new height via a cutoff split, and sync/decision paths consistently call record_fee_proposal. Includes new unit tests covering prune behavior (drop below cutoff, empty, saturating underflow, no-op).

Reviewed by Cursor Bugbot for commit a6145b3. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs Outdated
@sirandreww-starkware sirandreww-starkware force-pushed the 05-19-apollo_consensus_orchestrator_rework_snip-35_fee_proposals_window_for_state_sync_resilience branch from 0bc637c to f9ec526 Compare May 19, 2026 09:56
Copy link
Copy Markdown
Collaborator

@matanl-starkware matanl-starkware left a comment

Choose a reason for hiding this comment

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

@matanl-starkware reviewed 1 file and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ShahakShama and sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 302 at r2 (raw file):

            u64::try_from(FEE_PROPOSAL_WINDOW_SIZE).expect("FEE_PROPOSAL_WINDOW_SIZE fits in u64");
        let cutoff = BlockNumber(current_height.0.saturating_sub(window_size));
        self.fee_proposals_window = self.fee_proposals_window.split_off(&cutoff);

Please add some tests to verify only what you wanted is left in the tree after the split.

Code quote:

self.fee_proposals_window.split_off(&cutoff);

crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 332 at r2 (raw file):

                        "SNIP-35 bootstrap failed at block {h}: {e:?}. Window has {} / \
                         {FEE_PROPOSAL_WINDOW_SIZE} entries.",
                        self.fee_proposals_window.len()

Consider fixing this, to count only non-None entries

Code quote:

self.fee_proposals_window.len()

@ShahakShama
Copy link
Copy Markdown
Collaborator

crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 332 at r2 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Consider fixing this, to count only non-None entries

IMO you shouldn't fix this. None entry is a valid entry for a 0.14.2 block

Copy link
Copy Markdown
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

@ShahakShama reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on matanl-starkware and sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 302 at r2 (raw file):

            u64::try_from(FEE_PROPOSAL_WINDOW_SIZE).expect("FEE_PROPOSAL_WINDOW_SIZE fits in u64");
        let cutoff = BlockNumber(current_height.0.saturating_sub(window_size));
        self.fee_proposals_window = self.fee_proposals_window.split_off(&cutoff);

Please add a comment stating if split_off is inclusive or exclusive (and explain the meaning of inclusive/exclusive 😅 )

Copy link
Copy Markdown
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

@ShahakShama made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on matanl-starkware and sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 302 at r2 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Please add some tests to verify only what you wanted is left in the tree after the split.

+1

@sirandreww-starkware sirandreww-starkware force-pushed the 05-19-apollo_consensus_orchestrator_rework_snip-35_fee_proposals_window_for_state_sync_resilience branch from f9ec526 to 0d8de9c Compare May 20, 2026 07:10
Copy link
Copy Markdown
Contributor Author

@sirandreww-starkware sirandreww-starkware left a comment

Choose a reason for hiding this comment

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

@sirandreww-starkware made 3 comments.
Reviewable status: 0 of 2 files reviewed, 3 unresolved discussions (waiting on matanl-starkware and ShahakShama).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 302 at r2 (raw file):

Previously, ShahakShama wrote…

+1

Done.


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 302 at r2 (raw file):

Previously, ShahakShama wrote…

Please add a comment stating if split_off is inclusive or exclusive (and explain the meaning of inclusive/exclusive 😅 )

Done.


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 332 at r2 (raw file):

Previously, ShahakShama wrote…

IMO you shouldn't fix this. None entry is a valid entry for a 0.14.2 block

Correct, this function is removed entirely in the next PR anyway

@sirandreww-starkware sirandreww-starkware force-pushed the 05-19-apollo_consensus_orchestrator_rework_snip-35_fee_proposals_window_for_state_sync_resilience branch from 0d8de9c to 441da6b Compare May 20, 2026 07:24
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 441da6b. Configure here.

Comment thread crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs Outdated
Copy link
Copy Markdown
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

@ShahakShama reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on matanl-starkware and sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 302 at r2 (raw file):

Previously, sirandreww-starkware (Andrew Luka) wrote…

Done.

This is good, but what I meant is to have a code comment that "copies and summarizes" the documentation of split_off from std

@sirandreww-starkware sirandreww-starkware force-pushed the 05-19-apollo_consensus_orchestrator_rework_snip-35_fee_proposals_window_for_state_sync_resilience branch from 441da6b to a6145b3 Compare May 20, 2026 09:08
Copy link
Copy Markdown
Contributor Author

@sirandreww-starkware sirandreww-starkware left a comment

Choose a reason for hiding this comment

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

@sirandreww-starkware made 2 comments and resolved 1 discussion.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on matanl-starkware and ShahakShama).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 302 at r2 (raw file):

Previously, ShahakShama wrote…

This is good, but what I meant is to have a code comment that "copies and summarizes" the documentation of split_off from std

I think Done?

Comment thread crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs Outdated
Copy link
Copy Markdown
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

@ShahakShama reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on matanl-starkware).

Copy link
Copy Markdown
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

:lgtm:

@ShahakShama made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on matanl-starkware).

Copy link
Copy Markdown
Collaborator

@matanl-starkware matanl-starkware left a comment

Choose a reason for hiding this comment

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

@matanl-starkware partially reviewed 2 files and all commit messages, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on sirandreww-starkware).

@sirandreww-starkware sirandreww-starkware added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit 3973cd0 May 20, 2026
18 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants