pyth-crosschain/target_chains/solana
swimricky 8202181a1b
Solana receiver decode vaa accumulator (#1145)
* feat: impl postAccumulatorUpdateVaa and postUpdates and CLI test changes

* feat: clean up

* refactor: reorganize and fix tests

* refactor: clean up

* chore: add rust-toolchain for solana target contract dir

* refactor: clean up and address feedback

* refactor: make emitter chain & post vaa program configurable

* feat: remove postAccUpdateVaa and use wh post_vaa in cli

* fix: add check for emitter address, hardcode expected emitter chain/addr for now

* chore: cleanup

* chore: clean up

* feat: address feedback, move checks from context into account, use signatureset for postupdates

* feat: use pubkey and require_keys_eq! for emitter addr check

* refactor: address feedback

add documentation and todos, revert programsimulator to use upgradable bpf loader

* feat: remove signature_set account from post_updates, update docs & readme

* test: add lazy static for setting up pyth binary but still has same invalidaccountdata issue

* chore: clean up

* refactor: remove unused errors

* feat: use UncheckedAccount for posted_vaa so owner can be checked dynamically against config
2023-11-30 16:04:41 -05:00
..
cli Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
migrations [solana] Start to implement the solana receiver contract (#557) 2023-02-15 15:43:51 +00:00
programs/pyth-solana-receiver Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
.gitignore [solana] Start to implement the solana receiver contract (#557) 2023-02-15 15:43:51 +00:00
.prettierignore [solana] Start to implement the solana receiver contract (#557) 2023-02-15 15:43:51 +00:00
Anchor.toml Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
Cargo.lock Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
Cargo.toml Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
README.md Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
program_address.json Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
program_address_orig.json Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00
rust-toolchain.toml Solana receiver decode vaa accumulator (#1145) 2023-11-30 16:04:41 -05:00

README.md

Solana program for receiving price VAA from Pythnet

The program under cli receives a VAA string from the shell, verifies the VAA with wormhole, posts the VAA on solana and then invokes the receiver program under programs. The receiver program verifies that the VAA comes from wormhole (through the owner function in state.rs) and deserializes the price information (in decode_posted_vaa function of lib.rs).

# Generate the program key
# and use the key to replace the following two places
#     "pyth-solana-receiver" in Anchor.toml
#     "declare_id!()" in programs/pyth-solana-receiver/src/lib.rs
> solana-keygen new -o program_address.json

# Build and deploy the receiver program
 > anchor build -- features devnet # use --features mainnet for mainnet
> anchor run deploy

# Build and test the cli program
> anchor run cli_build_devnet
> anchor run cli_test_devnet
# Example output
...
[1/5] Decode the VAA
[2/5] Get wormhole guardian set configuration
[3/5] Invoke wormhole on solana to verify the VAA
Transaction successful : 3VbrqQBCf1RsNLxrcvxN3aTb5fZRht4n8XDUVPM8NKniRmo84NZQUu5iFw5groAQgQYox3YCqaMjKc2WTpPU1yqV
[4/5] Post the VAA data onto a solana account
Transaction successful : 3L1vxzSHQv6B6TwtoMv2Y6m7vFGz3hzqApGHEhHSLA9Jn5dNKeWRWKv29UDPDc3vsgt1mYueamUPPt6bHGGEkbxh
[5/5] Receive and deserialize the VAA on solana
Receiver program ID is 5dXnHcDXdXaiEp9QgknCDPsEhJStSqZqJ4ATirWfEqeY
Transaction successful : u5y9Hqc18so3BnjSUvZkLZR4mvA8zkiBgzGKHSEYyWkHQhH3uQatM7xWf4kdrhjZFVGbfBLdR8RJJUmuf28ePtG

Unit tests

Run anchor run test to run the unit tests in the src/tests/ directory. Warning: do not confuse this command with anchor test, which doesn't do anything useful.