upgrade script by VAA for core relayer

This commit is contained in:
chase-45 2023-01-09 01:10:32 -05:00 committed by Joe Howarth
parent 5bd7ba46ab
commit 12a09d8b24
2 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,59 @@
import { tryNativeToHexString } from "@certusone/wormhole-sdk"
import {
deployCoreRelayerImplementation,
deployCoreRelayerLibrary,
} from "../helpers/deployments"
import {
init,
loadChains,
ChainInfo,
getCoreRelayer,
getRelayProviderAddress,
getCoreRelayerAddress,
writeOutputFiles,
} from "../helpers/env"
import {
createRegisterChainVAA,
createDefaultRelayProviderVAA,
createCoreRelayerUpgradeVAA,
} from "../helpers/vaa"
const processName = "upgradeCoreRelayerSelfSign"
init()
const chains = loadChains()
async function run() {
console.log("Start!")
const output: any = {
coreRelayerImplementations: [],
coreRelayerLibraries: [],
}
for (let i = 0; i < chains.length; i++) {
const coreRelayerLibrary = await deployCoreRelayerLibrary(chains[i])
const coreRelayerImplementation = await deployCoreRelayerImplementation(
chains[i],
coreRelayerLibrary.address
)
await upgradeCoreRelayer(chains[i], coreRelayerImplementation.address)
output.coreRelayerImplementations.push(coreRelayerImplementation)
output.coreRelayerLibraries.push(coreRelayerLibrary)
}
writeOutputFiles(output, processName)
}
async function upgradeCoreRelayer(chain: ChainInfo, newImplementationAddress: string) {
console.log("upgradeCoreRelayer " + chain.chainId)
const coreRelayer = getCoreRelayer(chain)
await coreRelayer.submitContractUpgrade(
createCoreRelayerUpgradeVAA(chain, newImplementationAddress)
)
console.log("Successfully upgraded the core relayer contract on " + chain.chainId)
}
run().then(() => console.log("Done! " + processName))

View File

@ -16,6 +16,27 @@ const governanceContract =
const coreRelayerModule =
"0x000000000000000000000000000000000000000000436f726552656c61796572"
export function createCoreRelayerUpgradeVAA(chain: ChainInfo, newAddress: string) {
/*
bytes32 module;
uint8 action;
uint16 chain;
bytes32 newContract; //listed as address in the struct, but is actually bytes32 inside the VAA
*/
const payload = ethers.utils.solidityPack(
["bytes32", "uint8", "uint16", "bytes32"],
[
coreRelayerModule,
1,
chain.chainId,
"0x" + tryNativeToHexString(newAddress, "ethereum"),
]
)
return encodeAndSignGovernancePayload(payload)
}
export function createDefaultRelayProviderVAA(chain: ChainInfo) {
/*
bytes32 module;