|
| 1 | +# Pre-requisites |
| 2 | + |
| 3 | +Install move cli according to this [doc](../contracts/README.md) |
| 4 | + |
| 5 | +# Deploying from scratch |
| 6 | + |
| 7 | +Configure the `Move.toml` file accordingly. The wormhole address should be specified based on the target chain in the `Move.toml` and the pyth address should be `0x0`. |
| 8 | +We can deploy the pyth oracle and initialize it with the following command: |
| 9 | + |
| 10 | +```bash |
| 11 | +npm run cli -- deploy --private-key <private-key> --chain [sui_mainnet|sui_testnet] |
| 12 | +``` |
| 13 | + |
| 14 | +You can then add your sui contract configs to the contract manager store. |
| 15 | + |
| 16 | +You can also manually create all the price feeds available at the moment to make it easier for devs to test the oracle. |
| 17 | + |
| 18 | +```bash |
| 19 | +npm run cli -- create-all --private-key <private-key> --contract <contract-id> |
| 20 | +``` |
| 21 | + |
| 22 | +# Updating price feeds: |
| 23 | + |
| 24 | +You can use the `create` and `update-feeds` commands to create and update price feeds respectively. |
| 25 | + |
| 26 | +```bash |
| 27 | +npm run cli -- create --feed-id <feed-id> --private-key <private-key> --contract <contract-id> |
| 28 | +``` |
| 29 | + |
| 30 | +```bash |
| 31 | +npm run cli -- update-feeds --feed-id <feed-id> --private-key <private-key> --contract <contract-id> |
| 32 | +``` |
| 33 | + |
| 34 | +# Upgrade process: |
| 35 | + |
| 36 | +The following steps are needed to upgrade our sui contracts: |
| 37 | + |
| 38 | +- Contract changes: |
| 39 | + - Create a new struct for the new version and update `current_version` and `previous_version` functions in `version_control` module |
| 40 | + - Implement any custom logic needed to migrate the data from the old struct to the new one in the `migrate` module |
| 41 | + - Update dependency (e.g. wormhole) addresses if needed |
| 42 | +- Generate the digest for the new contract build |
| 43 | +- Create a governance proposal, proposing the sui package to be upgraded to this specific digest |
| 44 | +- Approve and execute the governance proposal |
| 45 | +- Run the upgrade transaction and publish the new package |
| 46 | + |
| 47 | +## Generating the new contract hash: |
| 48 | + |
| 49 | +Run the following command to generate the new hash, make sure the contract addresses are identical to the deployed ones: |
| 50 | + |
| 51 | +```bash |
| 52 | +npm run cli -- generate-digest |
| 53 | +``` |
| 54 | + |
| 55 | +## Upgrading the contract |
| 56 | + |
| 57 | +To upgrade the contract after the governance vaa was executed run: |
| 58 | + |
| 59 | +```bash |
| 60 | +npm run cli -- upgrade --private-key <private-key> --contract <contract-id> --vaa <upgrade-vaa> |
| 61 | +``` |
| 62 | + |
| 63 | +The upgrade procedure consists of 2 transactions. The first one is to upgrade the contract (sui level) and the second one is to run the `migrate` function and upgrade the version (package level). |
| 64 | +Since clients try to fetch the latest version of the package automatically, it's important to run the second transaction as soon as possible after the first one. |
| 65 | + |
| 66 | +### FAQ: |
| 67 | + |
| 68 | +- I'm seeing the error `Transaction has non recoverable errors from at least 1/3 of validators`. What should I do? |
| 69 | + Make sure you have enough funding in the wallet and try again. Usually a more descriptive error message is available in the returned value of the transaction. |
0 commit comments