Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(solana-receiver-cli): Add post-twap-update cmd to CLI, update TWAP data model & validations #2180

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

tejasbadadare
Copy link
Contributor

Purpose

This PR makes changes to the Solana receiver contract, the receiver SDK, and the receiver CLI.

  • Add post-twap-update command to the CLI. This is useful for users to test the update procedure, and to see an example of how to verify start & end data from Hermes via Wormhole and post it to the receiver contract.

    • Usage: pyth-solana-receiver-cli --wormhole <WORMHOLE> post-twap-update --start-payload <START_PAYLOAD> --end-payload <END_PAYLOAD>
    • Refactored some existing functions to avoid code duplication
  • Add extra validations to calculate_twap as brought up in earlier code review.

    • Validate that the start & end messages have the same feed_id and exponent
  • Update TwapUpdate data model to remove the verification_level & posted_slot fields.

    • After a discussion with @guibescos , we decided the verification_level field is unnecessary because we don't support an "atomic" version of this instruction. It's required to verify VAAs before using post_twap_update and the instruction will error if unverified VAAs are used. Therefore all TwapUpdates produced by the program can be assumed to be fully verified.
    • We also deemed posted_slot not very useful since it's primarily used by price pushers to measure recency, which doesn't apply to our use case, unless we want to support some kind of scheduled/constantly pushed TWAP updates.

Testing

Updated unit tests for solana_receiver_sdk. The CLI doesn't have a test suite.

Copy link

vercel bot commented Dec 9, 2024

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

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 1:32am
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 1:32am
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 1:32am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Dec 11, 2024 1:32am
insights ⬜️ Ignored (Inspect) Visit Preview Dec 11, 2024 1:32am

@tejasbadadare tejasbadadare changed the title feat(solana_receiver_cli): Add post-twap-update cmd to CLI, update TWAP data model & validations feat(solana-receiver-cli): Add post-twap-update cmd to CLI, update TWAP data model & validations Dec 9, 2024
Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

I like the refactors. I left some comments which are mostly questions for me to understand your change before approving.

target_chains/solana/cli/src/main.rs Outdated Show resolved Hide resolved
target_chains/solana/cli/src/main.rs Show resolved Hide resolved
Copy link
Collaborator

@ali-bahjati ali-bahjati left a comment

Choose a reason for hiding this comment

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

Nice!

@tejasbadadare tejasbadadare merged commit 6b611c8 into main Dec 11, 2024
8 checks passed
@tejasbadadare tejasbadadare deleted the tb/solana-receiver-cli/add-twap-subcommand branch December 11, 2024 18:18
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