Skip to content

apollo_l1_gas_price_types: currency pair and rate kind - #14979

Open
asaf-sw wants to merge 1 commit into
asaf/batcher-view-call-in-flight-boundfrom
asaf/l1-oracle-a3-currency-pair
Open

apollo_l1_gas_price_types: currency pair and rate kind#14979
asaf-sw wants to merge 1 commit into
asaf/batcher-view-call-in-flight-boundfrom
asaf/l1-oracle-a3-currency-pair

Conversation

@asaf-sw

@asaf-sw asaf-sw commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Adds the currency-pair vocabulary the Chainlink oracle work is built on, as the leaf of that stack. No behavior change: nothing constructs or reads these types yet, and config_schema.json is untouched.

Two artifacts, both pub in apollo_l1_gas_price_types:

CurrencyPair (EthUsd, StrkUsd, EthStrk) names which pair a reading, rate or guard trip belongs to. Without it a stale ETH/USD leg and a stale STRK/USD leg are indistinguishable, since the ETH/STRK rate reads both. EthStrk has no Chainlink feed on Starknet, so it is derived from the two USD pairs. It carries two accessors with distinct consumers:

  • labels() returns the snake_case strum name under LABEL_NAME_CURRENCY_PAIR, read by the per-pair guard counters in the oracle metrics PR.
  • pair_name() returns the display form (ETH/USD) used in guard error messages and as the per-pair key for the rate bounds in the rate-bounds PR.

RateKind with the marker types EthToFri and StrkToUsd carries the pair a rate quotes as a type parameter rather than a field, so a client cannot be handed another rate's config and a pair with no impl fails to compile rather than at runtime. The rate arithmetic PR is generic over RateKind; the Chainlink client PR instantiates it per marker.

Each artifact carries a [Temporary comment] naming its consumer, to be dropped as the consumers land.

strum with the derive feature was already a dependency, so Cargo.toml is unchanged.

Tests

New crates/apollo_l1_gas_price_types/src/test.rs, the crate's first tests:

  • pair_name_is_distinct_per_variant: every pair_name arm is a string literal, so a copy-paste between them compiles and passes every other test in the stack. Distinctness is what catches it.
  • labels_yield_snake_case_variant_name: pins the label values the metrics PR will register permutations against.
  • enum_iter_and_variant_names_cover_all_variants: pins the EnumIter order and the VariantNames list, so a new pair added later cannot silently skip a consumer that iterates.
  • rate_kind_markers_map_to_their_pair: pins each marker's PAIR, since a transposed mapping compiles and passes every other test.

Verification

  • ./scripts/rust_fmt.sh: clean.
  • RUSTFLAGS="-D warnings" cargo clippy -p apollo_l1_gas_price_types --all-targets --all-features: clean.
  • SEED=0 cargo nextest run -p apollo_l1_gas_price_types: 4 tests run, 4 passed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

asaf-sw commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

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.

2 participants