fix: point the oracle tutorial at Pragma's Miden v0.15 oracle#209
Merged
Conversation
Collaborator
Author
|
@brianseong could you give this one a review when you get a chance? 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The Pragma oracle tutorial (
oracle_data_query+oracle_reader.masm+oracle_tutorial.md) couldn't run: it pointed at Pragma's old pre-v0.15 oracle, which the v0.15 client rejects. Pragma has since redeployed on Miden 0.15 (astraly-labs/pragma-miden, miden-client 0.15.3), so this points the tutorial at the new deployment and gets it reading a live price again.Key Changes
masm/accounts/oracle_reader.masm: update the two stale hardcoded values used by theexecute_foreign_procedurecall: theget_medianprocedure MAST root and the oracle account id. The BTC/USD faucet pair (1:0) is unchanged.rust-client/src/bin/oracle_data_query.rs: default the oracle address to Pragma's current testnet oracle (mtst1apadf2szkxqkcyt7x2znuggv9qkhccam) socargo runworks with no args; a bech32 id passed as the first argument still overrides it.docs/src/rust-client/oracle_tutorial.md: update the masm block, the run command, and the expected-output transcript to match, plus a note that Pragma's addresses change between testnet iterations.Rationale
I took the new
get_medianMAST root and the oracle id felts from Pragma's ownget_median_procedure_hash()rather than hardcoding a guess, then ran it against the live oracle: it returnsis_tracked = 1and a real BTC/USD median. A wrong root would fail the foreign procedure call, not return a price.The publisher id word in the oracle's storage is laid out as
[prefix, suffix, 0, 0]with this client version, so the tutorial keeps reading[w[0], w[1]]. Pragma's ownexamples/consume-pricereads[w[3], w[2]]and currently panics (UnknownAccountIdVersion(0)) against the released miden-client, so I did not follow it there.Tests
Ran
oracle_data_queryagainst testnet:is_tracked=1, median6439689500000, exit 0.cargo test --doc(17 passed, 0 failed) andprettier --checkare green, and the doc'sno_runprogram is byte-identical to the binary.Open Questions
get_medianreturns only the raw fixed-point median; the decimals live per-entry in Pragma's feed. The raw value only makes sense for BTC at 8 decimals (about $64,396.89), so that is what the doc says, but the old feed used 6. Happy to adjust if you know the exact precision.