Skip to content

apollo_consensus_orchestrator: add SNIP-35 fee_proposals sliding window#13817

Merged
sirandreww-starkware merged 1 commit into
mainfrom
04-19-apollo_consensus_orchestrator_add_snip-35_fee_proposals_sliding_window
May 18, 2026
Merged

apollo_consensus_orchestrator: add SNIP-35 fee_proposals sliding window#13817
sirandreww-starkware merged 1 commit into
mainfrom
04-19-apollo_consensus_orchestrator_add_snip-35_fee_proposals_sliding_window

Conversation

@sirandreww-starkware
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor Author

sirandreww-starkware commented Apr 19, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@sirandreww-starkware sirandreww-starkware changed the base branch from 04-19-apollo_consensus_orchestrator_add_snip-35_metrics to graphite-base/13817 April 19, 2026 17:43
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_snip-35_fee_proposals_sliding_window branch from 69fb04b to f876e52 Compare April 19, 2026 17:43
@sirandreww-starkware sirandreww-starkware changed the base branch from graphite-base/13817 to 04-19-apollo_consensus_orchestrator_add_strk_price_oracle_field_to_deps April 19, 2026 17:43
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_strk_price_oracle_field_to_deps branch from cf971d9 to ccb5be3 Compare April 23, 2026 11:59
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_strk_price_oracle_field_to_deps branch from e0a29c8 to ec1e517 Compare May 1, 2026 15:44
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_snip-35_fee_proposals_sliding_window branch 2 times, most recently from 365c687 to c02232e Compare May 1, 2026 15:59
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_strk_price_oracle_field_to_deps branch 2 times, most recently from 9c55e10 to cb5b659 Compare May 1, 2026 17:05
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_snip-35_fee_proposals_sliding_window branch from c02232e to 500f0ce Compare May 1, 2026 17:05
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_strk_price_oracle_field_to_deps branch from cb5b659 to 01f8451 Compare May 3, 2026 07:01
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_snip-35_fee_proposals_sliding_window branch 2 times, most recently from 16af896 to ac3e7d4 Compare May 3, 2026 12:59
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_strk_price_oracle_field_to_deps branch from 32331eb to a14e00f Compare May 3, 2026 13:11
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-apollo_consensus_orchestrator_add_snip-35_fee_proposals_sliding_window branch from ac3e7d4 to 2b0cc53 Compare May 3, 2026 13:11
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 2b0cc53. 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 5 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 940 at r3 (raw file):

                        Err(e) => {
                            // Stop backfilling on the first error (likely `BlockNotFound` for
                            // heights before the chain was SNIP-35-enabled). The remaining window

if a height is before SNIP-35 you should get Ok(block with None fee proposal), not Err


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 944 at r3 (raw file):

                            // are committed, falling back to `l2_gas_price`.
                            warn!(
                                "SNIP-35 backfill stopped at block {h}: {e:?}. Window has {} / \

stopped -> failed


crates/apollo_consensus_orchestrator/src/test_utils.rs line 328 at r3 (raw file):

    }

    /// Default get_block returns NotFound for all blocks. Used by SNIP-35 backfill on startup.

If you want to simulate real life you should return a regular block here with none proposal fee


crates/apollo_consensus_orchestrator/src/snip35/mod.rs line 27 at r3 (raw file):

pub(crate) const PPT_DENOMINATOR: u128 = 1000;

/// Number of fee_proposal values used to compute fee_actual (SNIP-35).

Add TODO to consider moving this to versioned constants

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.

@matanl-starkware should also review this

@ShahakShama made 1 comment.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on sirandreww-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 made 1 comment.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 238 at r3 (raw file):

    l1_da_mode: L1DataAvailabilityMode,
    previous_proposal_init: Option<PreviousProposalInitInfo>,
    /// SNIP-35: sliding window of recent fee_proposal values (size from config).

At the moment, it's a const, and Shahak suggested making it a VC.
Either way - not config.

Code quote:

(size from config)

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 5 comments.
Reviewable status: 2 of 5 files reviewed, 4 unresolved discussions (waiting on ShahakShama).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 238 at r3 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

At the moment, it's a const, and Shahak suggested making it a VC.
Either way - not config.

Done +-


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 940 at r3 (raw file):

Previously, ShahakShama wrote…

if a height is before SNIP-35 you should get Ok(block with None fee proposal), not Err

Done.


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 944 at r3 (raw file):

Previously, ShahakShama wrote…

stopped -> failed

Done.


crates/apollo_consensus_orchestrator/src/test_utils.rs line 328 at r3 (raw file):

Previously, ShahakShama wrote…

If you want to simulate real life you should return a regular block here with none proposal fee

Done


crates/apollo_consensus_orchestrator/src/snip35/mod.rs line 27 at r3 (raw file):

Previously, ShahakShama wrote…

Add TODO to consider moving this to versioned constants

Done.

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 3 files and all commit messages, made 1 comment, and resolved 4 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on matanl-starkware and sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/test_utils.rs line 334 at r4 (raw file):

        self.state_sync_client
            .expect_get_block()
            .returning(|_| Ok(apollo_state_sync_types::state_sync_types::SyncBlock::default()));

Add use statement, and set SyncBlock's fee proposal field to None explicitly

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 5 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 919 at r4 (raw file):

                CONSENSUS_L2_GAS_PRICE.set_lossy(gas_price_u64);
            }
            // SNIP-35: on first height, backfill the window so fee_actual is available immediately.

Consider extracting this entire block into a function to avoid this (very unlikely) chunk of code path from the main flow.

Code quote:

// SNIP-35: on first height, backfill the window so fee_actual is available immediately.

crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 925 at r4 (raw file):

                let start = height.0.saturating_sub(window_size);
                for h in start..height.0 {
                    match self.deps.state_sync_client.get_block(BlockNumber(h)).await {

Are we sure all the relevant blocks are available for state_sync at this stage (up to N-1)?

Code quote:

self.deps.state_sync_client.get_block

crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 935 at r4 (raw file):

                        Err(e) => {
                            // `Err` means the block could not be retrieved (e.g., earlier than
                            // chain start); pre-V0_14_3 blocks return `Ok` with `None` above.

"e.g. earlier than chain start" - I'm not sure this particular example is relevant.

Code quote:

                            // `Err` means the block could not be retrieved (e.g., earlier than
                            // chain start); pre-V0_14_3 blocks return `Ok` with `None` above.

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 2 files and all commit messages, and resolved 3 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on sirandreww-starkware).

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 4 comments.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ShahakShama).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 919 at r4 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Consider extracting this entire block into a function to avoid this (very unlikely) chunk of code path from the main flow.

Done.


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 925 at r4 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Are we sure all the relevant blocks are available for state_sync at this stage (up to N-1)?

Good question, looking into it.
Actually, let me try something:
@cursor[bot] can you check this? keep in mind that all nodes must have the same exact window?


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 935 at r4 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

"e.g. earlier than chain start" - I'm not sure this particular example is relevant.

Done.


crates/apollo_consensus_orchestrator/src/test_utils.rs line 334 at r4 (raw file):

Previously, ShahakShama wrote…

Add use statement, and set SyncBlock's fee proposal field to None explicitly

Done

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 reviewed 3 files and all commit messages, made 3 comments, and resolved 1 discussion.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 313 at r6 (raw file):

    // consensus enters `set_height_and_round`, since blocking inside this call to retry is unsafe
    // (peers may already be voting at this height). Track and fix in a follow-up PR.
    async fn backfill_fee_proposals_window(&mut self, height: BlockNumber) {

Consider bootstrap instead of backfill


crates/apollo_consensus_orchestrator/src/test_utils.rs line 334 at r6 (raw file):

    fn setup_default_state_sync_get_block(&mut self) {
        self.state_sync_client.expect_get_block().returning(|_| {
            let mut sync_block = SyncBlock::default();

Consider

let sync_block = SyncBlock { block_header_without_hash: BlockHeaderWithoutHash { fee_proposal_fri, ..default::Default() }, ..default::Default() };

I'm debating myself what's cleaner so fill free to reject my proposal

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 reviewed 5 files and all commit messages, made 1 comment, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on sirandreww-starkware).


crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs line 313 at r6 (raw file):

Previously, ShahakShama wrote…

Consider bootstrap instead of backfill

Done

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