-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds VAA self signing logic and updates implementation addresses (#42)
* evm: remove obsolete packages. * evm: fixes shebang for shell scripts. * evm: forward arguments in deploy shell scripts. * evm: adjustments in `tsconfig.json` * evm: adds script to self sign testnet upgrade. * evm: yarn.lock update * evm: Adds registrations to circle integration initializer temporarily. * evm: fixes env var for RPC URLs * evm: rename environment files. * evm: adds RPC URLs for arbitrum and eth testnets * evm: updates the CircleIntegration implementation addresses. * evm: switches to ESM. * evm: yarn.lock update * evm: reverts testnet hardcoded cross registrations. * evm: removes `ts-node` in favour of `tsx` * minor fixes to submit_testnet_registraion script * adds base deployment configuration * fix env variable on base mainnet deployment * base mainnet configuration --------- Co-authored-by: solanoe <[email protected]>
- Loading branch information
1 parent
2e0831c
commit 105ad59
Showing
33 changed files
with
1,649 additions
and
1,238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export CONFIGURE_CCTP_RPC="https://base.publicnode.com" | ||
|
||
### Contract addresses | ||
export RELEASE_WORMHOLE_ADDRESS=0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6 | ||
export RELEASE_CIRCLE_BRIDGE_ADDRESS=0x1682Ae6375C4E4A97e4B583BC394c861A46D8962 # token messenger | ||
export RELEASE_WORMHOLE_FINALITY=1 | ||
|
||
### Deployed Circle Integration addresses | ||
export CIRCLE_INTEGRATION_IMPLEMENTATION="0x2703483B1a5a7c577e8680de9Df8Be03c6f30e3c" | ||
export CIRCLE_INTEGRATION_SETUP="0xD73aFD826D6bDD4D2fEF326DF5091451A5d8130a" | ||
export CIRCLE_INTEGRATION_PROXY="0x03faBB06Fa052557143dC28eFCFc63FC12843f1D" | ||
|
||
# Used in verification scripts | ||
export RELEASE_EVM_CHAIN_ID=8453 |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
evm/env/testnet/arbitrum-testnet.env → evm/env/testnet/arbitrum.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export CONFIGURE_CCTP_RPC="https://goerli.base.org" | ||
|
||
### Contract addresses | ||
export RELEASE_WORMHOLE_ADDRESS=0x23908A62110e21C04F3A4e011d24F901F911744A | ||
export RELEASE_CIRCLE_BRIDGE_ADDRESS=0x877b8e8c9e2383077809787ED6F279ce01CB4cc8 | ||
export RELEASE_WORMHOLE_FINALITY=1 | ||
|
||
|
||
### Deployed Circle Integration addresses | ||
export CIRCLE_INTEGRATION_IMPLEMENTATION=0xD73aFD826D6bDD4D2fEF326DF5091451A5d8130a | ||
export CIRCLE_INTEGRATION_SETUP=0xC5180b274Ead8aC34131B6dDa0323e403d671De7 | ||
export CIRCLE_INTEGRATION_PROXY=0x2703483B1a5a7c577e8680de9Df8Be03c6f30e3c | ||
|
||
# Used in verification scripts | ||
export RELEASE_EVM_CHAIN_ID=84531 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
evm/env/testnet/optimism-testnet.env → evm/env/testnet/optimism.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
forge script $(dirname $0)/../forge-scripts/deploy_contracts.sol \ | ||
--rpc-url $RPC \ | ||
--private-key $PRIVATE_KEY \ | ||
--broadcast --slow | ||
--rpc-url $CONFIGURE_CCTP_RPC \ | ||
--broadcast --slow $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
forge script $(dirname $0)/../forge-scripts/deploy_implementation_only.sol \ | ||
-vv \ | ||
--rpc-url $RPC \ | ||
--private-key $PRIVATE_KEY \ | ||
--broadcast --slow | ||
--rpc-url $CONFIGURE_CCTP_RPC \ | ||
--broadcast --slow $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
SRC=$(dirname $0)/../out | ||
DST=$(dirname $0)/../ts/src/ethers-contracts | ||
|
||
typechain --target=ethers-v5 --out-dir=$DST $SRC/*/*.json | ||
typechain --target=ethers-v5 --node16-modules --out-dir=$DST $SRC/*/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
pgrep anvil > /dev/null | ||
if [ $? -eq 0 ]; then | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
ts-node $(dirname $0)/../ts/scripts/upgrade_proxy.ts $@ | ||
npx tsx $(dirname $0)/../ts/scripts/upgrade_proxy.ts $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#/usr/bin/env bash | ||
#!/usr/bin/env bash | ||
|
||
etherscan_key=$1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#/usr/bin/env bash | ||
#!/usr/bin/env bash | ||
|
||
etherscan_key=$1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#/usr/bin/env bash | ||
#!/usr/bin/env bash | ||
|
||
etherscan_key=$1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { ethers } from "ethers"; | ||
import { tryNativeToHexString } from "@certusone/wormhole-sdk"; | ||
import { signAsync } from "@noble/secp256k1"; | ||
|
||
const circleIntegrationModule = | ||
"0x000000000000000000000000000000436972636c65496e746567726174696f6e"; | ||
const GOVERNANCE_UPGRADE_ACTION = 3; | ||
const governanceChainId = 1; | ||
const governanceContract = | ||
"0x0000000000000000000000000000000000000000000000000000000000000004"; | ||
|
||
export interface Guardian { | ||
/** | ||
* Private key in hexadecimal string 0x encoded. | ||
*/ | ||
key: string; | ||
/** | ||
* Index of the public key in the current Guardian set. | ||
*/ | ||
index: number; | ||
} | ||
|
||
export interface GuardianSet { | ||
guardians: Guardian[]; | ||
id: number; | ||
} | ||
|
||
export function doubleKeccak256(body: ethers.BytesLike) { | ||
return ethers.utils.keccak256(ethers.utils.keccak256(body)); | ||
} | ||
|
||
export function createCircleIntegrationUpgradeVAA( | ||
chainId: number, | ||
newAddress: string, | ||
guardianSet: GuardianSet, | ||
) { | ||
/* | ||
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"], | ||
[ | ||
circleIntegrationModule, | ||
GOVERNANCE_UPGRADE_ACTION, | ||
chainId, | ||
"0x" + tryNativeToHexString(newAddress, "ethereum"), | ||
], | ||
); | ||
|
||
return encodeAndSignGovernancePayload(payload, guardianSet); | ||
} | ||
|
||
export async function encodeAndSignGovernancePayload( | ||
payload: string, | ||
guardianSet: GuardianSet, | ||
): Promise<string> { | ||
const timestamp = Math.floor(Date.now() / 1000); | ||
const nonce = 1; | ||
const sequence = 1; | ||
const consistencyLevel = 1; | ||
const vaaVersion = 1; | ||
|
||
const encodedVAABody = ethers.utils.solidityPack( | ||
["uint32", "uint32", "uint16", "bytes32", "uint64", "uint8", "bytes"], | ||
[ | ||
timestamp, | ||
nonce, | ||
governanceChainId, | ||
governanceContract, | ||
sequence, | ||
consistencyLevel, | ||
payload, | ||
], | ||
); | ||
|
||
const hash = doubleKeccak256(encodedVAABody).substring(2); | ||
|
||
const signatures = (await Promise.all(guardianSet.guardians | ||
.map(async ({ key, index }) => { | ||
const signature = await signAsync(hash, key); | ||
if (signature.recovery === undefined) | ||
throw new Error(`Failed to sign message: missing recovery id`); | ||
|
||
// Remember that each signature is accompanied by the guardian index. | ||
const packSig = ethers.utils.solidityPack( | ||
["uint8", "bytes32", "bytes32", "uint8"], | ||
[ | ||
index, | ||
ethers.utils.hexZeroPad(ethers.utils.hexlify(signature.r), 32), | ||
ethers.utils.hexZeroPad(ethers.utils.hexlify(signature.s), 32), | ||
signature.recovery, | ||
], | ||
); | ||
return packSig.substring(2); | ||
}))) | ||
.join(""); | ||
|
||
const vm = [ | ||
ethers.utils | ||
.solidityPack( | ||
["uint8", "uint32", "uint8"], | ||
[ | ||
vaaVersion, | ||
// guardianSetIndex | ||
guardianSet.id, | ||
// number of signers | ||
guardianSet.guardians.length, | ||
], | ||
) | ||
.substring(2), | ||
signatures, | ||
encodedVAABody.substring(2), | ||
].join(""); | ||
|
||
return "0x" + vm; | ||
} |
Oops, something went wrong.