Skip to content

apollo_l1_gas_price_types,apollo_l1_gas_price: expose get_strk_to_usd_rate#14159

Merged
ShahakShama merged 1 commit into
mainfrom
shahak/strk_usd_oracle_03_client_trait
May 27, 2026
Merged

apollo_l1_gas_price_types,apollo_l1_gas_price: expose get_strk_to_usd_rate#14159
ShahakShama merged 1 commit into
mainfrom
shahak/strk_usd_oracle_03_client_trait

Conversation

@ShahakShama

Copy link
Copy Markdown
Collaborator

Goal: PR 3 of 6 in the stack moving the STRK/USD oracle into
L1GasPriceProvider. Surfaces the inherent method added in PR 2 on
the client trait so cross-process callers (notably the consensus
orchestrator in PR 5) can request a STRK/USD rate without holding
their own oracle.

Change summary:

  • New L1GasPriceRequest::GetStrkToUsdRate(u64) variant.
  • New L1GasPriceResponse::GetStrkToUsdRate(L1GasPriceProviderResult<u128>)
    variant.
  • New L1GasPriceProviderClient::get_strk_to_usd_rate trait method,
    implemented on the blanket impl mirroring get_rate.
  • Server-side dispatch arm in apollo_l1_gas_price::communication
    routes to L1GasPriceProvider::strk_to_usd_rate.

Decision points:

  • Did not rename the existing get_rate (which dispatches to
    GetEthToFriRate) for symmetry; out of scope per the stack plan
    and would churn unrelated call sites in consensus orchestrator.
    The trait now has slightly asymmetric naming: get_rate (ETH/FRI)
    vs get_strk_to_usd_rate. Renaming is a separate cleanup if
    desired.
  • MockL1GasPriceProviderClient is automock-generated and picks up
    the new method automatically.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

@cursor

cursor Bot commented May 24, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive API and observability following the established GetEthToFriRate pattern; no changes to auth, pricing logic, or existing call sites beyond new symbols.

Overview
Exposes STRK/USD lookup on the shared L1GasPriceProvider client so remote callers (e.g. consensus) can fetch rates without a separate oracle.

The change adds GetStrkToUsdRate to the request/response enums, L1GasPriceProviderClient::get_strk_to_usd_rate with the same handle_all_response_variants! path as get_rate (ETH/FRI), and a server dispatch arm to strk_to_usd_rate. Trait docs clarify both rates as 18-decimal fixed-point u128 values.

Dev Grafana gains client- and server-side timeseries panels for request_variant="get_strk_to_usd_rate", matching existing L1 gas price infra metrics.

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

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

ShahakShama commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 722a966 to 7def26d Compare May 25, 2026 06:19
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from 2819fb7 to 1d61ff5 Compare May 25, 2026 06:19
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from 1d61ff5 to 574ee1b Compare May 25, 2026 07:56
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 7def26d to c291368 Compare May 25, 2026 07:56
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from 574ee1b to 5fa5e1a Compare May 25, 2026 08:18
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch 2 times, most recently from 570d530 to a42b523 Compare May 25, 2026 08:53
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from 5fa5e1a to 486319b Compare May 25, 2026 08:53
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from a42b523 to e413e9a Compare May 25, 2026 11:03
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from 25184de to febf852 Compare May 25, 2026 11:04
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from e413e9a to 403c127 Compare May 25, 2026 11:04

@matanl-starkware matanl-starkware 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.

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


crates/apollo_l1_gas_price_types/src/lib.rs line 106 at r1 (raw file):

    async fn get_rate(&self, timestamp: u64) -> L1GasPriceProviderClientResult<u128>;

    async fn get_strk_to_usd_rate(&self, timestamp: u64) -> L1GasPriceProviderClientResult<u128>;

I don't understand the meaning of the u128.
Current ratio is: 1 strk => 0.04$. 1$ ~= 24.5 strk.
So either you have a big rounding error or a truncation to zero.
I think we should use fri as for eth (and the interface should reflect that).

Code quote:

u128

@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from febf852 to cc63bfd Compare May 25, 2026 14:42
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 403c127 to 8b42533 Compare May 25, 2026 14:42
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from cc63bfd to d745a8f Compare May 25, 2026 14:52
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 8b42533 to 1262c18 Compare May 25, 2026 14:52

@ShahakShama ShahakShama left a comment

Copy link
Copy Markdown
Collaborator Author

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, 1 unresolved discussion (waiting on matanl-starkware).


crates/apollo_l1_gas_price_types/src/lib.rs line 106 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

I don't understand the meaning of the u128.
Current ratio is: 1 strk => 0.04$. 1$ ~= 24.5 strk.
So either you have a big rounding error or a truncation to zero.
I think we should use fri as for eth (and the interface should reflect that).

We show the results with a fixed point decimal of 18 digits
Meaning that if 1$ ~= 24.5 strk the oracle returns 245 * 10^17

@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 1262c18 to cfcbbde Compare May 26, 2026 10:01
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from d745a8f to c997caa Compare May 26, 2026 10:01

@matanl-starkware matanl-starkware 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.

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


crates/apollo_l1_gas_price_types/src/lib.rs line 106 at r1 (raw file):

Previously, ShahakShama wrote…

We show the results with a fixed point decimal of 18 digits
Meaning that if 1$ ~= 24.5 strk the oracle returns 245 * 10^17

Should we at least document it somewhere?
Consider moving to FRI, which is a common unit we use everywhere.

@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from c997caa to bcabd9a Compare May 26, 2026 11:24
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from cfcbbde to 61d4412 Compare May 26, 2026 11:24
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_02_provider_holds_oracle branch from bcabd9a to 5950d44 Compare May 26, 2026 13:30
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 61d4412 to 266f09d Compare May 26, 2026 13:30
@graphite-app graphite-app Bot changed the base branch from shahak/strk_usd_oracle_02_provider_holds_oracle to graphite-base/14159 May 26, 2026 13:58
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 266f09d to f988b4e Compare May 26, 2026 14:24
@ShahakShama ShahakShama force-pushed the graphite-base/14159 branch from 5950d44 to dc3f241 Compare May 26, 2026 14:24
@ShahakShama ShahakShama changed the base branch from graphite-base/14159 to shahak/strk_usd_oracle_02_provider_holds_oracle May 26, 2026 14:25

@ShahakShama ShahakShama left a comment

Copy link
Copy Markdown
Collaborator Author

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: 1 of 2 files reviewed, 1 unresolved discussion (waiting on matanl-starkware).


crates/apollo_l1_gas_price_types/src/lib.rs line 106 at r1 (raw file):

Previously, matanl-starkware (Matan Lior) wrote…

Should we at least document it somewhere?
Consider moving to FRI, which is a common unit we use everywhere.

Documented. changing this means coordinating with pragma. Not sure it's worth it

@matanl-starkware matanl-starkware 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.

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

@ShahakShama ShahakShama changed the base branch from shahak/strk_usd_oracle_02_provider_holds_oracle to graphite-base/14159 May 26, 2026 15:00
@ShahakShama ShahakShama force-pushed the graphite-base/14159 branch from dc3f241 to 5c5827e Compare May 26, 2026 15:00
@ShahakShama ShahakShama force-pushed the shahak/strk_usd_oracle_03_client_trait branch from f988b4e to 330b3a9 Compare May 26, 2026 15:00
@ShahakShama ShahakShama changed the base branch from graphite-base/14159 to main May 26, 2026 15:00
@sirandreww-starkware sirandreww-starkware force-pushed the shahak/strk_usd_oracle_03_client_trait branch from 330b3a9 to d3da13d Compare May 27, 2026 07:19
…_rate

Goal: PR 3 of 6 in the stack moving the STRK/USD oracle into
L1GasPriceProvider. Surfaces the inherent method added in PR 2 on
the client trait so cross-process callers (notably the consensus
orchestrator in PR 5) can request a STRK/USD rate without holding
their own oracle.

Change summary:
- New `L1GasPriceRequest::GetStrkToUsdRate(u64)` variant.
- New `L1GasPriceResponse::GetStrkToUsdRate(L1GasPriceProviderResult<u128>)`
  variant.
- New `L1GasPriceProviderClient::get_strk_to_usd_rate` trait method,
  implemented on the blanket impl mirroring `get_rate`.
- Server-side dispatch arm in `apollo_l1_gas_price::communication`
  routes to `L1GasPriceProvider::strk_to_usd_rate`.

Decision points:
- Did not rename the existing `get_rate` (which dispatches to
  `GetEthToFriRate`) for symmetry; out of scope per the stack plan
  and would churn unrelated call sites in consensus orchestrator.
  The trait now has slightly asymmetric naming: `get_rate` (ETH/FRI)
  vs `get_strk_to_usd_rate`. Renaming is a separate cleanup if
  desired.
- `MockL1GasPriceProviderClient` is automock-generated and picks up
  the new method automatically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sirandreww-starkware sirandreww-starkware force-pushed the shahak/strk_usd_oracle_03_client_trait branch from d3da13d to a64cf51 Compare May 27, 2026 07:35

@sirandreww-starkware sirandreww-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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.

4 participants