apollo_consensus_orchestrator: add SNIP-35 module#13854
Conversation
6019314 to
d3c3966
Compare
59d2ec9 to
c649130
Compare
bf2a6d7 to
09938eb
Compare
09938eb to
3549582
Compare
c649130 to
4eeb26d
Compare
3549582 to
c665a80
Compare
ShahakShama
left a comment
There was a problem hiding this comment.
@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
c665a80 to
7234dce
Compare
4eeb26d to
794c669
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
794c669 to
77b0397
Compare
sirandreww-starkware
left a comment
There was a problem hiding this comment.
@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
ShahakShama
left a comment
There was a problem hiding this comment.
@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 ..."
ShahakShama
left a comment
There was a problem hiding this comment.
@ShahakShama reviewed all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on sirandreww-starkware).
sirandreww-starkware
left a comment
There was a problem hiding this comment.
@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
ShahakShama
left a comment
There was a problem hiding this comment.
@ShahakShama reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on sirandreww-starkware).
|
Artifacts upload workflows: |
Merge activity
|
sirandreww-starkware
left a comment
There was a problem hiding this comment.
@sirandreww-starkware reviewed 2 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on sirandreww-starkware).


No description provided.