Skip to content

Commit 6f3dd5c

Browse files
authored
[solana-reciever] update docs (#1192)
* Docs * Fix * Do it * Address feedback
1 parent 51d23a2 commit 6f3dd5c

File tree

2 files changed

+44
-45
lines changed

2 files changed

+44
-45
lines changed

target_chains/solana/Anchor.toml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@ seeds = false
33
skip-lint = false
44

55
[programs.devnet]
6-
pyth_solana_receiver = "DvPfMBZJJwKgJsv2WJA8bFwUMn8nFd5Xpioc6foC3rse"
6+
pyth_solana_receiver = "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ"
77

88
[registry]
99
url = "https://api.apr.dev"
1010

1111
[provider]
1212
cluster = "https://api.devnet.solana.com"
1313
wallet = "~/.config/solana/id.json"
14-
15-
[scripts]
16-
deploy = "anchor deploy --program-keypair program_address.json --program-name pyth_solana_receiver"
17-
cli_build_mainnet = "cargo build --package pyth-solana-receiver-cli --features mainnet"
18-
cli_build_devnet = "cargo build --package pyth-solana-receiver-cli --features devnet"
19-
20-
21-
22-
cli_test_mainnet = "cargo run --package pyth-solana-receiver-cli --features mainnet post-and-receive-vaa -u https://api.mainnet-beta.solana.com -v UE5BVQEAAAADuAEAAAADDQAbXgddtAJnEhoLE4JAxcuyokAmnoTS4qSvkw0gJpNC+TtBZApwDqsQbCXgmYOuygk6QVsV1JpKYAUa72h95m0EAQNrHPMh1kCYvYyA/6J0qOp8nrtpzVFFoAagmMqJzKDmAV8MCVvpFuy5EPu69UO95UUnZZhX/hk4y7wdTfhedTYdAQR6SL0tbSGSlWHLSzs2wpWVx8N0RFtFULp9EkCSUnxAnma3UI/hFz/78fvtRp/qx1HT8M4/8zSEuVbwd8pdeBsvAQZoD/eilZ2nvs1eHoXKz7FhW3UxVCYUZbNnJmY/Iqc6hw6+7yIJ9sh1cKvWkI+ug1ZC9KiOK90/cxipRcbaa+9+AQd5SGi5/En6R/jIoNF+iqza6YbJht0CZ02NkcGl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7gOgaefhMVFFe43MEVmHj17tWyDgL0yymOCPbv2+vINEkfK9P9PV2cjRGbo6LDGtSN9J0l3Ni3CwKjkpFlWw7/BQawHz7u8b9zgtwpVzkzQeWZr0UeJek937S8nxcNctJ8B2JyCzUY/1ocTDJTaia64Hha+JHscLjDj+BOOt"
23-
cli_test_devnet = "cargo run --package pyth-solana-receiver-cli --features devnet post-and-receive-vaa -u https://api.devnet.solana.com -v UE5BVQEAAAAAoAEAAAAAAQA5HAnlb9c9mxJyYjaipkSXji7fWeE7kWqS/aoQJTMMx3JMn4rzJpNAWg2PzwlViNL9du9ZuXhoXFRIRxsImFJyAWVo9ZAAAAAAABrhAfrtrFhR4yubI7X5QRqMK6xKrj7U3XuBHdGnLqSqcQAAAAACWTHgAUFVV1YAAAAAAAbI/MoAACcQghjxa3eGWegyGTcRe3hb+AWtRukBAFUAY1TWhcJH8e/Db5Z2F77/ouvVqV2P/hfeRJhQXJIwZ7gAAAAACQfWxQAAAAAAAyX0////+AAAAABlaPWPAAAAAGVo9Y8AAAAACQWIsAAAAAAAAtnsClhMs4QutUVUWf4MP2TAt3s897CE7aHQfUZdDzc3hmO6uBlJrKLEkWFAnnPf5r4nDuqFf+utZwB1Rra6ludn3meRfgxsSOE1ZrlVmr+tnhIDzymPEfK5vIXvkAbVpnNpcvjGwtHSFX5Jm6HnZWITim8D9nUcvCyqjg+N0ZLekHgAUAquAkWexwpH17ArhN9LyBXgdsunmKgU/hKb63bgfc9TegVV69FX6+c8tcjrT9Kq4q9pTbHrYBNlZ8ED084lKXZ3Z9gp4z2S"
24-
test = "anchor build -- --features devnet && cargo test --features devnet -- --show-output"

target_chains/solana/README.md

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
1-
# Solana program for receiving price VAA from Pythnet
2-
3-
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`.
4-
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`).
5-
6-
```shell
7-
# Generate the program key
8-
# and use the key to replace the following two places
9-
# "pyth-solana-receiver" in Anchor.toml
10-
# "declare_id!()" in programs/pyth-solana-receiver/src/lib.rs
11-
> solana-keygen new -o program_address.json
12-
13-
# Build and deploy the receiver program
14-
> anchor build -- features devnet # use --features mainnet for mainnet
15-
> anchor run deploy
16-
17-
# Build and test the cli program
18-
> anchor run cli_build_devnet
19-
> anchor run cli_test_devnet
20-
# Example output
21-
...
22-
[1/5] Decode the VAA
23-
[2/5] Get wormhole guardian set configuration
24-
[3/5] Invoke wormhole on solana to verify the VAA
25-
Transaction successful : 3VbrqQBCf1RsNLxrcvxN3aTb5fZRht4n8XDUVPM8NKniRmo84NZQUu5iFw5groAQgQYox3YCqaMjKc2WTpPU1yqV
26-
[4/5] Post the VAA data onto a solana account
27-
Transaction successful : 3L1vxzSHQv6B6TwtoMv2Y6m7vFGz3hzqApGHEhHSLA9Jn5dNKeWRWKv29UDPDc3vsgt1mYueamUPPt6bHGGEkbxh
28-
[5/5] Receive and deserialize the VAA on solana
29-
Receiver program ID is 5dXnHcDXdXaiEp9QgknCDPsEhJStSqZqJ4ATirWfEqeY
30-
Transaction successful : u5y9Hqc18so3BnjSUvZkLZR4mvA8zkiBgzGKHSEYyWkHQhH3uQatM7xWf4kdrhjZFVGbfBLdR8RJJUmuf28ePtG
1+
# Pyth Solana Receiver
2+
3+
This folder contains:
4+
5+
- A Pyth receiver program to receive Pythnet price feeds on Solana in `programs/pyth-solana-receiver`
6+
- A Cli that acts as a simple client to interact with the Pyth receiver program in `cli/`
7+
8+
# Overview of the design
9+
10+
Receiving a price update from Pythnet involves two steps:
11+
12+
- First, verifying the VAA i.e. verifying the Wormhole guardians' signatures on the accumulator root that contains all the price updates for a given Pythnet slot. This happens in the Wormhole receiver contract (Note: this contract is in the Wormhole monorepo, we're currently using this branch https://github.com/guibescos/wormhole/tree/variable-sigs).
13+
- Second, verifying the price update by providing an inclusion proof that proves the price update is part of the accumulator root that was verified in the first step. This happens in the Pyth receiver contract.
14+
15+
The Pyth receiver program:
16+
17+
- verifies that the VAA has been verified by the Wormhole program (through the owner of the account that contains the VAA, the anchor discriminator and the field `verified_signatures`).
18+
- checks that the VAA was emitted by the right data source
19+
- checks the inclusion proof is valid
20+
- posts the price update to a `PriceUpdateV1` account
21+
22+
# Devnet deployment
23+
24+
The program is currently deployed on Devnet with addresses:
25+
26+
- `HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ` for the Wormhole receiver
27+
- `rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ` for the Pyth receiver
28+
29+
# Example flow
30+
31+
The `cli` folder contains some useful client code to interact with both the Wormhole receiver and the Pyth receiver.
32+
33+
To run the full flow of posting a price update (on devnet) please follow the following steps:
34+
35+
Get a Hermes update from Hermes stable:
36+
3137
```
38+
curl "https://hermes.pyth.network/api/latest_vaas?ids[]=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace"
3239
33-
## Unit tests
40+
```
41+
42+
Post it to devnet:
3443

35-
Run `anchor run test` to run the unit tests in the `src/tests/` directory.
36-
**Warning**: do not confuse this command with `anchor test`, which doesn't do anything useful.
44+
```
45+
cargo run --package pyth-solana-receiver-cli -- --url https://api.devnet.solana.com --keypair ${PATH_TO_KEYPAIR} --wormhole HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ post-price-update -p ${HERMES_UPDATE_IN_BASE_64}
46+
```

0 commit comments

Comments
 (0)