Browse Source

Aptos improvements (#1079)

* More documentation on the upgrade procedure and mainnet init

* Add profiling utility for aptos

* Reuse contract manager logic to sync guardian sets

* Add documentation for sui gas profiling
Amin Moghaddam 2 năm trước cách đây
mục cha
commit
f224486ae2

+ 53 - 0
target_chains/aptos/cli/README.md

@@ -46,6 +46,22 @@ npm run cli init-pyth -- <seed> -n testnet \
 --data-source-emitter-addresses e101faedac5851e32b9b23b5f9411a8c2bac4aae3ed4dd7b811dd1a72ea4aa71
 ```
 
+The following is a sample mainnet config:
+
+```bash
+npm run cli init-pyth -- <seed> -n mainnet \
+--stale-price-threshold 60 \
+--update-fee 1 \
+--governance-emitter-chain-id 1 \
+--governance-emitter-address 5635979a221c34931e32620b9293a463065555ea71fe97cd6237ade875b12e9e \
+--data-source-chain-ids 1 \
+--data-source-chain-ids 26 \
+--data-source-chain-ids 26 \
+--data-source-emitter-addresses 6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25 \
+--data-source-emitter-addresses f8cd23c2ab91237730770bbea08d61005cdda0984348f3f6eecb559638c0bba0 \
+--data-source-emitter-addresses e101faedac5851e32b9b23b5f9411a8c2bac4aae3ed4dd7b811dd1a72ea4aa71
+```
+
 Note that the `data-source-chain-ids` are paired with `data-source-emitter-addresses` and their order matters.
 
 # Upgrade process:
@@ -55,6 +71,7 @@ The following steps are needed to upgrade our aptos contracts:
 - Generate the hash for the new contract build
 - Create a governance proposal, proposing the aptos package to be upgraded to this specific hash
 - Approve and execute the governance proposal
+- Submit the created wormhole VAA to the contract to allow an upgrade with the specified hash.
 - Run the upgrade transaction and publish the new package
 
 ## Generating the new contract hash:
@@ -65,6 +82,42 @@ Run the following command to generate the new hash, this will assume the default
 npm run cli hash-contracts -- ../contracts
 ```
 
+## Creating a proposal
+
+Here are sample steps you can take to create a proposal via the contract manager shell (`npm run shell` in contract manager package):
+
+```js
+let wallet = await loadHotWallet("/path/to/solana/wallet.json");
+let vault =
+  DefaultStore.vaults.devnet_6baWtW1zTUVMSJHJQVxDUXWzqrQeYBr6mu31j3bTKwY3;
+await vault.connect(wallet);
+let payload =
+  DefaultStore.chains.aptos_testnet.generateGovernanceUpgradePayload(
+    "CONTRACT_HASH_TO_USE"
+  );
+await vault.proposeWormholeMessage([payload]);
+```
+
+## VAA submission
+
+After the approval process, you can fetch the VAA for the transaction and execute it by running:
+
+```js
+import { SubmittedWormholeMessage } from "./src/governance";
+let msg = await SubmittedWormholeMessage.fromTransactionSignature(
+  "tx_signature",
+  "devnet or mainnet-beta"
+);
+let vaa = await msg.fetchVaa();
+let contract =
+  DefaultStore.contracts
+    .aptos_testnet_0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387;
+await contract.executeGovernanceInstruction(
+  "private-key-of-account-inaptos",
+  vaa
+);
+```
+
 ## Upgrading the contract
 
 To upgrade the contract after the governance vaa was executed run:

+ 12 - 0
target_chains/aptos/profiling/Move.toml

@@ -0,0 +1,12 @@
+[package]
+name = "Profiler"
+version = "0.0.1"
+upgrade_policy = "compatible"
+
+[dependencies]
+Pyth = { git = "https://github.com/pyth-network/pyth-crosschain.git", addr_subst = { "pyth" = "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387" }, subdir = "target_chains/aptos/contracts", rev = "main" }
+
+[addresses]
+pyth = "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387"
+deployer = "0xb31e712b26fd295357355f6845e77c888298636609e93bc9b05f0f604049f434"
+wormhole = "0x5bc11445584a763c1fa7ed39081f1b920954da14e04b32440cba863d03e19625"

+ 11 - 0
target_chains/aptos/profiling/README.md

@@ -0,0 +1,11 @@
+# Gas Profiling Utilities
+
+You can compile and run a simple script in this package to profile gas consumption on a deployed pyth contract.
+Here are the steps:
+
+1. Run `aptos move compile` to compile the script
+2. Run the following to simulate the transaction and create a gas profile:
+   ```
+   aptos move run-script --compiled-script-path build/Profiler/bytecode_scripts/main.mv --args hex:<update_data_payload_in_hex> --profile-gas
+   ```
+3. Open the created svg files in the `gas-profiling` folder to inspect gas consumption by each module and function

+ 9 - 0
target_chains/aptos/profiling/sources/test.move

@@ -0,0 +1,9 @@
+script {
+    use pyth::pyth;
+
+
+    fun main(src: &signer, payload:vector<u8>) {
+        let payload:vector<vector<u8>> = vector[payload];
+        pyth::update_price_feeds_with_funder(src,payload);
+    }
+}

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 9
target_chains/ethereum/contracts/scripts/receiverSubmitGuardianSetUpgrades.js


+ 11 - 0
target_chains/sui/contracts/README.md

@@ -5,3 +5,14 @@ Contracts are compiled with sui cli version `sui 1.0.0-09b208149` that can be in
 ```commandline
 cargo install --locked --git https://github.com/MystenLabs/sui.git --rev 09b2081498366df936abae26eea4b2d5cafb2788 sui sui-faucet
 ```
+
+## Gas Profiling
+
+Using the [`sui-tool` binary](https://github.com/MystenLabs/sui/pull/12680), you can profile gas usage of transactions by running:
+
+```bash
+env MOVE_VM_PROFILE=1  ./sui-tool replay --rpc https://fullnode.mainnet.sui.io:443 tx -t <tx-signature>
+```
+
+`sui-tool` gas profiling works only when built with debug profile and should be compiled by your own (you can't use the precompiled binary).
+We suggest benchmarking on mainnet or where the number of wormhole signature checks is the same as on mainnet.

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác