Skip to content

Commit

Permalink
Fork all prod networks in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
yorhodes committed Nov 10, 2023
1 parent 87796e2 commit be14261
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ jobs:
- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1

- name: Test ${{ matrix.environment }} ${{ matrix.module }} deployment (check, deploy, govern, check again)
run: cd typescript/infra && ./fork.sh ${{ matrix.environment }} ${{ matrix.module }}
- name: Fork test ${{ matrix.environment }} ${{ matrix.module }}
run: cd typescript/infra && ./fork-all.sh ${{ matrix.environment }} ${{ matrix.module }}

test-sol:
env:
Expand Down
18 changes: 12 additions & 6 deletions typescript/infra/config/environments/mainnet3/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,22 @@ export const core: ChainMap<CoreConfig> = objMap(owners, (local, owner) => {
owner,
};

// reusing mainnet2 proxyAdmins owned by safes (where available)
const ownerOverrides = safes[local]
? {
proxyAdmin:
local === 'arbitrum'
? // timelock on arbitrum
`0xAC98b0cD1B64EA4fe133C6D2EDaf842cE5cF4b01`
: safes[local]!,
}
: undefined;

return {
owner,
defaultIsm,
defaultHook,
requiredHook,
ownerOverrides: {
proxyAdmin:
local === 'arbitrum'
? `0xAC98b0cD1B64EA4fe133C6D2EDaf842cE5cF4b01`
: safes[local] ?? owner,
},
ownerOverrides,
};
});
8 changes: 4 additions & 4 deletions typescript/infra/config/environments/mainnet3/owners.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChainMap } from '@hyperlane-xyz/sdk';
import { Address, objMap } from '@hyperlane-xyz/utils';

export const safes: ChainMap<Address> = {
export const safes: ChainMap<Address | undefined> = {
celo: '0x1DE69322B55AC7E0999F8e7738a1428C8b130E4d',
ethereum: '0x12C5AB61Fe17dF9c65739DBa73dF294708f78d23',
avalanche: '0xDF9B28B76877f1b1B4B8a11526Eb7D8D7C49f4f3',
Expand All @@ -13,9 +13,9 @@ export const safes: ChainMap<Address> = {
gnosis: '0x36b0AA0e7d04e7b825D7E409FEa3c9A3d57E4C22',
// solana: 'EzppBFV2taxWw8kEjxNYvby6q7W1biJEqwP3iC7YgRe3',
// TODO: create gnosis safes here
base: '',
scroll: '',
polygonzkevm: '',
base: undefined,
scroll: undefined,
polygonzkevm: undefined,
};

// export const owners = safes;
Expand Down
15 changes: 15 additions & 0 deletions typescript/infra/fork-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ENVIRONMENT=$1
MODULE=$2

if [ -z "$ENVIRONMENT" ] || [ -z "$MODULE" ]; then
echo "Usage: fork-all.sh <environment> <module>"
exit 1
fi

CHAINS=`yarn ts-node ./scripts/print-chain-metadatas.ts -e mainnet3 | \
jq -r 'to_entries | map(select(.value.protocol=="ethereum")) | map(.key) ' | \
tr -d '\"[],'`

for CHAIN in $CHAINS; do
./fork.sh $ENVIRONMENT $MODULE $CHAIN
done
36 changes: 14 additions & 22 deletions typescript/infra/fork.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
ENVIRONMENT=$1
MODULE=$2
CHAIN=$3

if [ -z "$ENVIRONMENT" ]; then
echo "Usage: fork.sh <environment> <module>"
exit 1
fi

if [ "$ENVIRONMENT" == "testnet4" ]; then
FORK_CHAIN="goerli"
RPC_URL="https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
elif [ "$ENVIRONMENT" == "mainnet3" ]; then
FORK_CHAIN="arbitrum"
RPC_URL="https://arb1.arbitrum.io/rpc"
else
echo "Unknown environment $ENVIRONMENT"
if [ -z "$ENVIRONMENT" ] || [ -z "$MODULE" ] || [ -z "$CHAIN" ]; then
echo "Usage: fork.sh <environment> <module> <chain>"
exit 1
fi

Expand All @@ -23,24 +13,26 @@ trap 'jobs -p | xargs -r kill' EXIT
# exit 1 on any subsequent failures
set -e

anvil --fork-url $RPC_URL --silent > /dev/null &
RPC_URL=`yarn ts-node ./scripts/print-chain-metadatas.ts -e $ENVIRONMENT | jq -r ".$CHAIN.rpcUrls[0].http"`

anvil --fork-url $RPC_URL --silent &
ANVIL_PID=$!

while ! cast bn &> /dev/null; do
sleep 1
done

echo "=== Run $MODULE checker against forked $ENVIRONMENT ==="
yarn ts-node ./scripts/check-deploy.ts -e $ENVIRONMENT -f $FORK_CHAIN -m $MODULE
echo "=== Run $MODULE checker against forked $CHAIN ==="
yarn ts-node ./scripts/check-deploy.ts -e $ENVIRONMENT -f $CHAIN -m $MODULE

echo "=== Run $MODULE deployer against forked $ENVIRONMENT ==="
yarn ts-node ./scripts/deploy.ts -e $ENVIRONMENT -f $FORK_CHAIN -m $MODULE
echo "=== Run $MODULE deployer against forked $CHAIN ==="
yarn ts-node ./scripts/deploy.ts -e $ENVIRONMENT -f $CHAIN -m $MODULE

# build SDK to get the latest addresses
yarn --cwd ../sdk build

echo "=== Run $MODULE govern against forked $ENVIRONMENT ==="
yarn ts-node ./scripts/check-deploy.ts -e $ENVIRONMENT -f $FORK_CHAIN --govern -m $MODULE
echo "=== Run $MODULE govern against forked $CHAIN ==="
yarn ts-node ./scripts/check-deploy.ts -e $ENVIRONMENT -f $CHAIN --govern -m $MODULE

echo "=== Run $MODULE checker against forked $ENVIRONMENT after governance ==="
yarn ts-node ./scripts/check-deploy.ts -e $ENVIRONMENT -f $FORK_CHAIN -m $MODULE
echo "=== Run $MODULE checker against forked $CHAIN after governance ==="
yarn ts-node ./scripts/check-deploy.ts -e $ENVIRONMENT -f $CHAIN -m $MODULE
5 changes: 2 additions & 3 deletions typescript/infra/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ async function main() {
}
: undefined;

// prompt for confirmation
if ((environment === 'mainnet3' || environment === 'testnet4') && !fork) {
console.log(JSON.stringify(config, null, 2));
// prompt for confirmation in production environments
if (environment !== 'test' && !fork) {
const { value: confirmed } = await prompt({
type: 'confirm',
name: 'value',
Expand Down
1 change: 0 additions & 1 deletion typescript/infra/src/deployment/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export async function postDeploy<Config>(
const deployedAddresses = serializeContractsMap(deployer.deployedContracts);
const cachedAddresses = deployer.cachedAddresses;
const addresses = objMerge(deployedAddresses, cachedAddresses);
console.log(addresses);

// cache addresses of deployed contracts
writeMergedJSONAtPath(cache.addresses, addresses);
Expand Down
2 changes: 1 addition & 1 deletion typescript/sdk/src/consts/chainMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export const ethereum: ChainMetadata = {
displayName: 'Ethereum',
nativeToken: etherToken,
rpcUrls: [
{ http: 'https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161' },
{ http: 'https://ethereum.publicnode.com' },
{ http: 'https://cloudflare-eth.com' },
],
blockExplorers: [
Expand Down

0 comments on commit be14261

Please sign in to comment.