Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions contract_manager/scripts/check_proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
EvmSetWormholeAddress,
EvmUpgradeContract,
getProposalInstructions,
MigrateGovernanceAndWormhole,
MultisigParser,
UpdateTrustedSigner256Bit,
UpdateTrustedSigner264Bit,
Expand All @@ -25,6 +26,7 @@ import Web3 from "web3";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";

import { getDefaultDeploymentConfig } from "../src/core/base";
import {
CosmWasmChain,
EvmChain,
Expand Down Expand Up @@ -128,6 +130,128 @@ async function main() {
}
}
}
if (
instruction.governanceAction instanceof MigrateGovernanceAndWormhole
) {
const action = instruction.governanceAction;
console.log(
`Verifying MigrateGovernanceAndWormhole on ${action.targetChainId}`,
);
console.log(` wormhole address:\t${action.address}`);
console.log(
` data sources:\t\t${JSON.stringify(action.dataSources)}`,
);
console.log(
` governance emitter:\t${JSON.stringify(action.governanceDataSource)}`,
);
console.log(
` governance index:\t${action.governanceDataSourceIndex}`,
);

const proProduction = getDefaultDeploymentConfig(
"pro-compatible-production",
);
const proStaging = getDefaultDeploymentConfig(
"pro-compatible-staging",
);
const matchesProductionSources =
JSON.stringify(action.dataSources) ===
JSON.stringify(proProduction.dataSources);
const matchesStagingSources =
JSON.stringify(action.dataSources) ===
JSON.stringify(proStaging.dataSources);
if (matchesProductionSources) {
console.log(" data sources match pro-compatible-production");
} else if (matchesStagingSources) {
console.log(" data sources match pro-compatible-staging");
} else {
console.log(
" WARNING: data sources do not match pro-compatible-production or pro-compatible-staging",
);
console.log(
` expected production:\t${JSON.stringify(proProduction.dataSources)}`,
);
}

const matchesProductionGov =
JSON.stringify(action.governanceDataSource) ===
JSON.stringify(proProduction.governanceDataSource);
const matchesStagingGov =
JSON.stringify(action.governanceDataSource) ===
JSON.stringify(proStaging.governanceDataSource);
if (matchesProductionGov) {
console.log(
" governance emitter matches pro-compatible-production default",
);
} else if (matchesStagingGov) {
console.log(
" governance emitter matches pro-compatible-staging default",
);
} else {
console.log(
" WARNING: governance emitter does not match pro-compatible-production or pro-compatible-staging defaults",
);
console.log(
` expected production:\t${JSON.stringify(proProduction.governanceDataSource)}`,
);
console.log(
` expected staging:\t${JSON.stringify(proStaging.governanceDataSource)}`,
);
}

for (const chain of Object.values(DefaultStore.chains)) {
if (
!(chain instanceof EvmChain) ||
chain.wormholeChainName !== action.targetChainId
) {
continue;
}
if (chain.isMainnet() !== (cluster === "mainnet-beta")) {
continue;
}

const expectedWormholes = Object.values(
DefaultStore.wormhole_contracts,
).filter(
(c): c is EvmWormholeContract =>
c instanceof EvmWormholeContract &&
c.getChain().getId() === chain.getId() &&
(c.deploymentType === "pro-compatible-production" ||
c.deploymentType === "pro-compatible-staging"),
);

const normalizedActionAddress = action.address
.replace(/^0x/i, "")
.toLowerCase();
const matching = expectedWormholes.find(
(c) =>
c.address.replace(/^0x/i, "").toLowerCase() ===
normalizedActionAddress,
);
if (matching) {
console.log(
` ${chain.getId()}: wormhole matches store entry ${matching.getId()} (${matching.deploymentType})`,
);
} else if (expectedWormholes.length > 0) {
console.log(
` ${chain.getId()}: WARNING wormhole ${action.address} not in store; known pro wormholes:`,
);
for (const wh of expectedWormholes) {
console.log(
` ${wh.address} (${wh.deploymentType})`,
);
}
} else {
console.log(
` ${chain.getId()}: no pro-compatible wormhole in store — verify manually: ${action.address}`,
);
}
}

console.log(
" NOTE: governanceDataSourceIndex must be strictly greater than the current on-chain index",
);
}
if (instruction.governanceAction instanceof EvmUpgradeContract) {
console.log(
`Verifying EVM Upgrade Contract on ${instruction.governanceAction.targetChainId}`,
Expand Down
Loading