Skip to content

Commit

Permalink
fix anvil scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Jun 12, 2024
1 parent 21ba88a commit 13abf24
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "contracts/lib/eigenlayer-middleware"]
path = contracts/lib/eigenlayer-middleware
url = [email protected]:Layr-Labs/eigenlayer-middleware.git
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = [email protected]/foundry-rs/forge-std
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ lint: ## runs all linters
___CONTRACTS___: ##

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

start-anvil-with-contracts-deployed: ##
./contracts/tests/anvil/start-anvil-chain-with-el-and-avs-deployed.sh
./contracts/anvil/start-anvil-chain-with-el-and-avs-deployed.sh
2 changes: 1 addition & 1 deletion contracts/anvil/contracts-deployed-anvil-state.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions contracts/anvil/deploy-contracts-save-anvil-state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ clean_up() {
trap 'clean_up $LINENO "$BASH_COMMAND"' EXIT

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

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

# start an empty anvil chain in the background and dump its state to a json file upon exit
start_anvil_docker "" $parent_path/contracts-deployed-anvil-state.json
start_anvil_docker "" $anvil_dir/contracts-deployed-anvil-state.json
sleep 1

CHAIN_ID=$(cast chain-id)
Expand All @@ -42,7 +42,7 @@ CHAIN_ID=$(cast chain-id)
# forge create src/ContractsRegistry.sol:ContractsRegistry --rpc-url ${ETH_HTTP_URL:?} --private-key ${DEPLOYER_PRIVATE_KEY:?}

# DEPLOY EIGENLAYER
EIGEN_CONTRACTS_DIR=$parent_path/../../lib/eigenlayer-middleware/lib/eigenlayer-contracts
EIGEN_CONTRACTS_DIR=$root_dir/contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts
DEVNET_OUTPUT_DIR=$EIGEN_CONTRACTS_DIR/script/output/devnet
# deployment overwrites this file, so we save it as backup, because we want that output in our local files, and not in the eigenlayer-contracts submodule files
mv $DEVNET_OUTPUT_DIR/M2_from_scratch_deployment_data.json $DEVNET_OUTPUT_DIR/M2_from_scratch_deployment_data.json.bak
Expand Down
8 changes: 4 additions & 4 deletions contracts/anvil/start-anvil-chain-with-el-and-avs-deployed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
set -o errexit -o nounset -o pipefail

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

set -a
source $parent_path/utils.sh
source $anvil_dir/utils.sh
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/contracts-deployed-anvil-state.json ""
start_anvil_docker $anvil_dir/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
Expand Down
4 changes: 1 addition & 3 deletions contracts/anvil/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ start_anvil_docker() {
LOAD_STATE_ANVIL_ARG=$([[ -z $LOAD_STATE_FILE ]] && echo "" || echo "--load-state /load-state.json")
DUMP_STATE_ANVIL_ARG=$([[ -z $DUMP_STATE_FILE ]] && echo "" || echo "--dump-state /dump-state.json")

echo $LOAD_STATE_VOLUME_DOCKER_ARG $DUMP_STATE_VOLUME_DOCKER_ARG
echo $LOAD_STATE_ANVIL_ARG $DUMP_STATE_ANVIL_ARG
trap 'docker stop anvil' EXIT
trap 'docker stop anvil 2>/dev/null || true' EXIT
set -o xtrace
docker run --rm -d --name anvil -p 8545:8545 $LOAD_STATE_VOLUME_DOCKER_ARG $DUMP_STATE_VOLUME_DOCKER_ARG \
--entrypoint anvil \
Expand Down

0 comments on commit 13abf24

Please sign in to comment.