[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)) { for (const chain of Object.values(DefaultStore.chains)) {
if ( if (
chain instanceof CosmWasmChain && chain instanceof CosmWasmChain &&
chain.isMainnet() === (cluster === "mainnet-beta") &&
chain.wormholeChainName === chain.wormholeChainName ===
instruction.governanceAction.targetChainId instruction.governanceAction.targetChainId
) { ) {

View File

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

View File

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

View File

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

View File

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