Skip to content

Commit

Permalink
fix start-anvil-chain command and add to makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Jun 9, 2024
1 parent 2db28c8 commit 2bff649
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ ___CONTRACTS___: ##

deploy-contracts-to-anvil-and-save-state: ##
./contracts/tests/anvil/deploy-contracts-save-anvil-state.sh

start-anvil-with-contracts-deployed: ##
./contracts/tests/anvil/start-anvil-chain-with-el-and-avs-deployed.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
#!/bin/bash

set -o errexit -o nounset -o pipefail

# cd to the directory of this script so that this can be run from anywhere
parent_path=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd -P
)
root_dir=$parent_path/../..
root_dir=$parent_path/../../..

set -a
source $parent_path/utils.sh
source $root_dir/.env
# we overwrite some variables here because should always deploy to anvil (localhost)
ETH_HTTP_URL=http://localhost:8545
set +a

# start an anvil instance in the background that has eigenlayer contracts deployed
# we start anvil in the background so that we can run the below script
start_anvil_docker $parent_path/eigenlayer-eigencert-eigenda-strategies-deployed-operators-registered-with-eigenlayer-anvil-state.json ""
docker
start_anvil_docker $parent_path/contracts-deployed-anvil-state.json ""

cd $root_dir/contracts
# we need to restart the anvil chain at the correct block, otherwise the indexRegistry has a quorumUpdate at the block number
# at which it was deployed (aka quorum was created/updated), but when we start anvil by loading state file it starts at block number 0
# so calling getOperatorListAtBlockNumber reverts because it thinks there are no quorums registered at block 0
# advancing chain manually like this is a current hack until https://github.com/foundry-rs/foundry/issues/6679 is merged
# also not that it doesn't really advance by the correct number of blocks.. not sure why, so we just forward by a bunch of blocks that should be enough
forge script script/utils/Utils.sol --sig "advanceChainByNBlocks(uint256)" 500 --rpc-url ${ETH_HTTP_URL:?} --private-key ${DEPLOYER_PRIVATE_KEY:?} --broadcast
echo "current block-number:" $(cast block-number)
cast rpc anvil_mine 200 --rpc-url http://localhost:8545 > /dev/null
echo "Anvil is ready. Advanced chain to block-number:" $(cast block-number)


docker attach anvil
2 changes: 1 addition & 1 deletion contracts/tests/anvil/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parent_path=$(
pwd -P
)

FOUNDRY_IMAGE=ghcr.io/foundry-rs/foundry:nightly-3fa02706ca732c994715ba42d923605692062375
FOUNDRY_IMAGE=ghcr.io/foundry-rs/foundry:nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a

clean_up() {
# Check if the exit status is non-zero
Expand Down

0 comments on commit 2bff649

Please sign in to comment.