Skip to content

apollo_consensus_orchestrator: add SNIP-35 module#13854

Merged
sirandreww-starkware merged 1 commit into
mainfrom
04-20-apollo_consensus_orchestrator_add_snip-35_module
May 11, 2026
Merged

apollo_consensus_orchestrator: add SNIP-35 module#13854
sirandreww-starkware merged 1 commit into
mainfrom
04-20-apollo_consensus_orchestrator_add_snip-35_module

Conversation

@sirandreww-starkware
Copy link
Copy Markdown
Contributor

No description provided.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

This was referenced Apr 23, 2026
Copy link
Copy Markdown
Contributor Author

sirandreww-starkware commented Apr 23, 2026

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

Comment thread crates/apollo_consensus_orchestrator/src/snip35/mod.rs Outdated
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-starknet_api_add_fee_proposal_to_block_hash_calculator branch from 59d2ec9 to c649130 Compare May 1, 2026 15:59
@sirandreww-starkware sirandreww-starkware force-pushed the 04-20-apollo_consensus_orchestrator_add_snip-35_module branch from bf2a6d7 to 09938eb Compare May 1, 2026 15:59
Comment thread crates/apollo_consensus_orchestrator/src/snip35/mod.rs Outdated
@sirandreww-starkware sirandreww-starkware force-pushed the 04-20-apollo_consensus_orchestrator_add_snip-35_module branch from 09938eb to 3549582 Compare May 1, 2026 17:05
@sirandreww-starkware sirandreww-starkware force-pushed the 04-19-starknet_api_add_fee_proposal_to_block_hash_calculator branch from c649130 to 4eeb26d Compare May 1, 2026 17:05
@sirandreww-starkware sirandreww-starkware force-pushed the 04-20-apollo_consensus_orchestrator_add_snip-35_module branch from 3549582 to c665a80 Compare May 1, 2026 17:45
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 8 comments.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on sirandreww-starkware).


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

//! SNIP-35 dynamic L2 gas pricing primitives.

Please link here SNIP-35


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

//!
//! This module implements the consensus-level fee mechanism described in SNIP-35:
//! - `compute_fee_actual`: median of recent `fee_proposal` values (sliding window).

Let's improve the doc here. Something like:

  • compute_fee_actual: The actual fee taken into account for this block
  • compute_fee_target: The fee we would like to have for this block, based on STRK/USD oracle
  • compute_fee_proposal: The target fee, clamped by a fixed percentage rate from the actual fee

compute_fee_actual is computed based on a median of the last fee_proposal values


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

/// Returns `None` if fewer than `window_size` proposals are available.
pub fn compute_fee_actual(proposals: &[GasPrice], window_size: usize) -> Option<GasPrice> {
    if proposals.len() < window_size || window_size < 2 {

why 2? why not 1?


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

        return None;
    }
    let window = &proposals[proposals.len() - window_size..];

Use a non panicking slice getter and use ? on it. See https://github.com/starkware-industries/code-quality/blob/main/style_guide/rust_style_guide.md#unnecessary-panics


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

    }
    let window = &proposals[proposals.len() - window_size..];
    let mut sorted: Vec<u128> = window.iter().map(|p| p.0).collect();

Remove this map and add derive ord to GasPrice (break the gas price only in the sorted[mid - 1] + (sorted[mid] - sorted[mid - 1]) / 2 line)


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

/// Compute the fee target from STRK/USD price and a USD cost target (SNIP-35).
/// `target_atto_usd_per_l2_gas` is in atto-USD (18-decimal fixed-point).

What is atto?


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

/// Geometric bounds for SNIP-35 fee_proposal: `(lower, upper)` where
/// `upper = fee_actual * (1 + margin)` and `lower = fee_actual / (1 + margin)`,

lower is equal to upper here. Is this a typo?


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

/// `fee_actual` and `margin_ppt`. Saturates to `u128::MAX` on the (unreachable in practice)
/// upper-end overflow.
pub(crate) fn fee_proposal_bounds(fee_actual: GasPrice, margin_ppt: u128) -> (u128, u128) {

Put this below compute_fee_proposal. See https://github.com/starkware-industries/code-quality/blob/main/style_guide/rust_style_guide.md#top-down-ordering

@sirandreww-starkware sirandreww-starkware changed the base branch from 04-19-starknet_api_add_fee_proposal_to_block_hash_calculator to graphite-base/13854 May 3, 2026 12:59
@sirandreww-starkware sirandreww-starkware force-pushed the 04-20-apollo_consensus_orchestrator_add_snip-35_module branch from c665a80 to 7234dce Compare May 3, 2026 12:59
@sirandreww-starkware sirandreww-starkware changed the base branch from graphite-base/13854 to 04-30-apollo_storage_add_fee_proposal_fri_migrator_and_bump_blocks_version_to_6.1 May 3, 2026 13:00
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 7234dce. Configure here.

Comment thread crates/apollo_consensus_orchestrator/src/snip35/mod.rs Outdated
@sirandreww-starkware sirandreww-starkware force-pushed the 04-30-apollo_storage_add_fee_proposal_fri_migrator_and_bump_blocks_version_to_6.1 branch from 794c669 to 77b0397 Compare May 3, 2026 13:11
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 8 comments.
Reviewable status: 1 of 2 files reviewed, 8 unresolved discussions (waiting on ShahakShama).


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

Previously, ShahakShama wrote…

Please link here SNIP-35

Done.


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

Previously, ShahakShama wrote…

Let's improve the doc here. Something like:

  • compute_fee_actual: The actual fee taken into account for this block
  • compute_fee_target: The fee we would like to have for this block, based on STRK/USD oracle
  • compute_fee_proposal: The target fee, clamped by a fixed percentage rate from the actual fee

compute_fee_actual is computed based on a median of the last fee_proposal values

Done


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

Previously, ShahakShama wrote…

why 2? why not 1?

Remainder from previous version that assumed window size was even


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

Previously, ShahakShama wrote…

Use a non panicking slice getter and use ? on it. See https://github.com/starkware-industries/code-quality/blob/main/style_guide/rust_style_guide.md#unnecessary-panics

Done


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

Previously, ShahakShama wrote…

Remove this map and add derive ord to GasPrice (break the gas price only in the sorted[mid - 1] + (sorted[mid] - sorted[mid - 1]) / 2 line)

Done


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

Previously, ShahakShama wrote…

What is atto?

10^(-18)


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

Previously, ShahakShama wrote…

lower is equal to upper here. Is this a typo?

one has multiplication and one division, not a typo


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

Previously, ShahakShama wrote…

Put this below compute_fee_proposal. See https://github.com/starkware-industries/code-quality/blob/main/style_guide/rust_style_guide.md#top-down-ordering

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


crates/apollo_consensus_orchestrator/src/snip35/mod.rs line 5 at r5 (raw file):

//! Spec: <https://community.starknet.io/t/snip-35-automatically-adjust-base-fee-to-strk-price/116168>
//!
//! - `compute_fee_actual`: the consensus-anchored fee for this block — the median of the most

Remove consensus-anchored. "The fee that we'll actually take for this block - calculated from the median ..."

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


crates/apollo_consensus_orchestrator/src/snip35/mod.rs line 5 at r5 (raw file):

Previously, ShahakShama wrote…

Remove consensus-anchored. "The fee that we'll actually take for this block - calculated from the median ..."

Done, although your wording is not accurate, it is the base fee and not the actual fee

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

@github-actions
Copy link
Copy Markdown

Artifacts upload workflows:

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 10, 2026

Merge activity

  • May 10, 11:20 AM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • May 10, 11:20 AM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..

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

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.

3 participants