Forráskód Böngészése

[xc-admin] Governance continue proposal (#993)

* Add ability to continue constructing a proposal

* Bugfix on cosmwasm proposal checking
Mohammad Amin Khashkhashi Moghaddam 2 éve
szülő
commit
49fe0c96e6

+ 0 - 1
contract_manager/scripts/check_proposal.ts

@@ -81,7 +81,6 @@ async function main() {
         for (const chain of Object.values(DefaultStore.chains)) {
           if (
             chain instanceof CosmWasmChain &&
-            chain.isMainnet() === (cluster === "mainnet-beta") &&
             chain.wormholeChainName ===
               instruction.governanceAction.targetChainId
           ) {

+ 4 - 2
contract_manager/src/governance.ts

@@ -320,7 +320,8 @@ export class Vault extends Storable {
   }
 
   public async proposeWormholeMessage(
-    payloads: Buffer[]
+    payloads: Buffer[],
+    proposalAddress?: PublicKey
   ): Promise<WormholeMultiSigTransaction> {
     const squad = this.getSquadOrThrow();
     const multisigVault = new MultisigVault(
@@ -332,7 +333,8 @@ export class Vault extends Storable {
     const txAccount =
       await multisigVault.proposeWormholeMultipleMessagesWithPayer(
         payloads,
-        squad.wallet.publicKey
+        squad.wallet.publicKey,
+        proposalAddress
       );
     return new WormholeMultiSigTransaction(txAccount, squad, this.cluster);
   }

+ 1 - 0
contract_manager/store/chains/CosmWasmChain/injective.yaml

@@ -1,3 +1,4 @@
+querierEndpoint: https://injective-rpc.quickapi.com:443
 id: injective
 wormholeChainName: injective
 mainnet: true

+ 1 - 0
contract_manager/store/chains/CosmWasmChain/injective_testnet.yaml

@@ -1,3 +1,4 @@
+querierEndpoint: https://k8s.testnet.tm.injective.network:443
 id: injective_testnet
 wormholeChainName: injective_testnet
 mainnet: false

+ 21 - 12
governance/xc_admin/packages/xc_admin_common/src/propose.ts

@@ -17,7 +17,7 @@ import {
   deriveFeeCollectorKey,
 } from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole";
 import { ExecutePostedVaa } from "./governance_payload/ExecutePostedVaa";
-import { getOpsKey, PRICE_FEED_OPS_KEY } from "./multisig";
+import { getOpsKey, getProposalInstructions } from "./multisig";
 import { PythCluster } from "@pythnetwork/client/lib/cluster";
 import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
 import SquadsMesh, { getIxAuthorityPDA, getTxPDA } from "@sqds/mesh";
@@ -203,29 +203,38 @@ export class MultisigVault {
    * will have `this.getVaultAuthorityPda()` as its emitter address.
    * @param payloads array of the bytes to send as the wormhole message's payload.
    * @param messagePayer key used as the payer for the wormhole message instruction
+   * @param proposalAddress the proposal address to use. If not provided, a new proposal will be created. This is useful when because of RPC issues the script can not run until the end successfully.
    * @returns the newly created proposal's public key
    */
   public async proposeWormholeMultipleMessagesWithPayer(
     payloads: Buffer[],
-    messagePayer: PublicKey
+    messagePayer: PublicKey,
+    proposalAddress?: PublicKey
   ): Promise<PublicKey> {
     const msAccount = await this.getMultisigAccount();
 
     let ixToSend: TransactionInstruction[] = [];
-    const [proposalIx, newProposalAddress] = await this.createProposalIx(
-      msAccount.transactionIndex + 1
-    );
-    ixToSend.push(proposalIx);
+    let startingIndex = 0;
+    if (proposalAddress === undefined) {
+      const [proposalIx, newProposalAddress] = await this.createProposalIx(
+        msAccount.transactionIndex + 1
+      );
+      ixToSend.push(proposalIx);
+      proposalAddress = newProposalAddress;
+    } else {
+      const transaction = await this.squad.getTransaction(proposalAddress);
+      startingIndex = transaction.instructionIndex;
+    }
     if (payloads.length > MAX_INSTRUCTIONS_PER_PROPOSAL)
       throw new Error(
         "Too many messages in proposal, multiple proposal not supported yet"
       );
 
-    for (let i = 0; i < payloads.length; i++) {
+    for (let i = startingIndex; i < payloads.length; i++) {
       const instructionToPropose = await getPostMessageInstruction(
         this.squad,
         this.vault,
-        newProposalAddress,
+        proposalAddress,
         1 + i,
         this.wormholeAddress()!,
         payloads[i],
@@ -234,7 +243,7 @@ export class MultisigVault {
       ixToSend.push(
         await this.squad.buildAddInstruction(
           this.vault,
-          newProposalAddress,
+          proposalAddress,
           instructionToPropose.instruction,
           1 + i,
           instructionToPropose.authorityIndex,
@@ -243,8 +252,8 @@ export class MultisigVault {
         )
       );
     }
-    ixToSend.push(await this.activateProposalIx(newProposalAddress));
-    ixToSend.push(await this.approveProposalIx(newProposalAddress));
+    ixToSend.push(await this.activateProposalIx(proposalAddress));
+    ixToSend.push(await this.approveProposalIx(proposalAddress));
 
     const txToSend = batchIntoTransactions(ixToSend);
     for (let i = 0; i < txToSend.length; i += SIZE_OF_SIGNED_BATCH) {
@@ -254,7 +263,7 @@ export class MultisigVault {
         })
       );
     }
-    return newProposalAddress;
+    return proposalAddress;
   }
 
   /**