Skip to content

Conversation

optke3
Copy link
Contributor

@optke3 optke3 commented Mar 22, 2023

Updates

We migrate batch_price_attestation.move and state.move from Aptos-Pyth, while making adaptations for Sui, such as removing the centralized mapping LatestPriceInfo from State and use the deployer capability pattern for initializing State. State can be used as a lightweight, read-only config store that does not interfere with the updating of PriceInfo/PriceFeed, which are modeled as Sui objects.

We expect to use Sui::clock to mark the arrival time of a batch_price_attestation when it becomes available in 0.28.0. For now, we use the less granular epoch number.

batch_price_attestation.move

  • Use Wormhole bytes.move serialization/deserialization library in batch_price_attestation.move.
  • Cast values in batch_price_attestation.move to u64 as necessary
  • Use tx_context::epoch for putting a timestamp on batch price attestation arrival time, since the Sui Clock feature is not available yet. The Sui clock would allow us to generate timestamps to 1 millisecond of precision and not use a ctx parameter.

state.move

  • The struct LatestPriceInfo (Mapping of cached price information) is no longer a thing, because we no longer maintain a centralized mapping of PriceInfos. This is because we want to be able to parallelize the updating of PriceInfo (which contains the PriceFeeds).
  • Remove state:: price_info_cached, state:: get_latest_price_info. In the future, we may want to think about maintaining a lookup table for price_identifier => price_info without compromising on parallel updates.
  • Rewrite getters and setters for the State object.
  • Use deployer capability pattern for creating and sharing a State object. This is needed because the init function (called automatically upon package deployment) does not take any custom inputs. The deployer cap is granted to sender upon init. Then the sender passes it to init_and_share_state(...args) to initialize state.

Dependencies & Misc

  • Change WH dependency from sui/wormhole-cleanup to sui/integration_v2, since most recent Wormhole core bridge clean-up PR was recently merged.
  • Add TODO comments.

set.move

  • The Wormhole Set does not have the empty function, so we instead migrate the Aptos-Pyth set.move and adapt it for Sui
  • Give the set values the store ability

Integration Remaining TODOs

  • errors.move (redefine error codes, because they are done differently in Sui compared to Aptos)
  • governance (many related modules)
  • pyth.move (contains init functions and price feed update functions)
  • contract upgrade functionality

Testing

sui move test or make test

Sui version: sui 0.27.1-157ac7203

@vercel
Copy link

vercel bot commented Mar 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated
example-oracle-amm ⬜️ Ignored (Inspect) Mar 31, 2023 at 3:09PM (UTC)
xc-admin-frontend ⬜️ Ignored (Inspect) Mar 31, 2023 at 3:09PM (UTC)

@optke3 optke3 requested a review from Reisen March 22, 2023 17:51
@optke3 optke3 changed the title sui: state, batch_price_attestation, set [sui 2/x]: state, batch_price_attestation, set Mar 22, 2023
@optke3 optke3 changed the title [sui 2/x]: state, batch_price_attestation, set [sui]: state, batch_price_attestation, set Mar 22, 2023
@optke3 optke3 changed the title [sui]: state, batch_price_attestation, set [sui]: state, batch_price_attestation, set Mar 23, 2023
@optke3 optke3 changed the title [sui]: state, batch_price_attestation, set [sui 2/x]: state, batch_price_attestation, set Mar 23, 2023
@optke3 optke3 merged commit 55bc1b9 into main Mar 31, 2023
@optke3 optke3 deleted the sui/state_and_pyth branch March 31, 2023 15:10
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