Skip to content

apollo_l1_gas_price_types,apollo_l1_gas_price: expose get_strk_to_usd_rate#14159

Open
ShahakShama wants to merge 1 commit into
mainfrom
shahak/strk_usd_oracle_03_client_trait
Open

apollo_l1_gas_price_types,apollo_l1_gas_price: expose get_strk_to_usd_rate#14159
ShahakShama wants to merge 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
Copy link
Copy Markdown

cursor Bot commented May 24, 2026

PR Summary

Low Risk
Additive RPC and trait surface mirroring existing ETH/FRI rate plumbing; no auth or pricing logic changes in this diff.

Overview
Exposes STRK/USD oracle lookups through the same L1 gas price component RPC path as ETH/FRI, so remote callers (e.g. consensus) can query rates without a separate oracle client.

Adds GetStrkToUsdRate request/response variants, L1GasPriceProviderClient::get_strk_to_usd_rate on the blanket ComponentClient impl, and server dispatch to strk_to_usd_rate. Documents both rate methods as 18-decimal fixed-point u128 values; existing get_rate / GetEthToFriRate naming is unchanged.

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

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Collaborator Author

ShahakShama commented May 24, 2026

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

@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
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 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
Copy link
Copy Markdown
Collaborator Author

@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, 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
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, 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
Copy link
Copy Markdown
Collaborator Author

@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: 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

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 resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ShahakShama).

…_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>
@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
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.

3 participants