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

* Add ability to continue constructing a proposal

* Bugfix on cosmwasm proposal checking
This commit is contained in:
Mohammad Amin Khashkhashi Moghaddam 2023-07-28 16:41:19 +02:00 committed by GitHub
parent 61e29ac166
commit 49fe0c96e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 15 deletions

View File

@ -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
) {

View File

@ -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);
}

View File

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

View File

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

View File

@ -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[] = [];
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;
}
/**