Abstract
Upgrade the Pyth Solana Receiver on Solana to reduce compute cost on posting price updates.
Rationale
Posting price update uses a lot of compute units because it uses an expensive hash function.
Description
This upgrade will employ Solana SDK’s hashv
function which uses much less compute units.
Implementation Plan
-
The Pyth Solana Receiver contract has been deployed and tested at the
rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ
address. -
Proposal id:
BP1hfpWAVZx9Lwgn9B4fokYpbKikqhPWGGmav5SCS89A
-
Relevant commits:
-
perf: use solana hash precompile (#1400) · pyth-network/pyth-crosschain@0e6484d · GitHub
-
Verify the implementation following the guide below:
- Make sure you have the Solana CLI tools, Docker and sha256sum.
solana: installsolana
from here.
Docker: install it from here
sha256sum: if on Mac you can install it as a part of coreutils withbrew install coreutils
- Clone the
pyth-crosschain
repo (git clone https://github.com/pyth-network/pyth-crosschain.git
(or if you have already cloned it pull the latest changes withgit pull
). - Go to
pyth-crosschain/target_chains/solana/
- Run
./scripts/build_verifiable_program.sh
. This will compile the code in a reproducible way and output a hash of the bytecode obtained from the code. - In the proposal page, look at the following two important keys:
Theprogram
field should match the program we’re trying to upgrade.
Thebuffer
field is the account that contains the proposed new implementation for the program. Copy the address. - Get the hash of the proposed buffer
solana -u m program dump <buffer> temp_file && sha256sum temp_file && rm temp_file
- Make sure the hash from step 4 and from step 6 match.