Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add make pr command #27

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
__CONTRACTS__: ##

start-anvil-chain-with-contracts-deployed: ##
./crates/contracts/anvil/start-anvil-chain-with-el-and-avs-deployed.sh

__CONTRACTS__: ##
deploy-contracts-to-anvil-and-save-state: ##
./crates/contracts/anvil/deploy-eigenlayer-save-anvil-state.sh

start-anvil-with-contracts-deployed: ##
./crates/contracts/anvil/start_anvil_chain_with_el_and_avs_deployed.sh
start-anvil: ##
./crates/contracts/anvil/start-anvil.sh

stop-anvil: ##
./crates/contracts/anvil/stop-anvil.sh

deploy-contracts-to-anvil-and-save-state: ##
./crates/contracts/anvil/deploy_contracts_save_anvil_state.sh
__TESTING__: ##

pr: ##
$(MAKE) start-anvil-chain-with-contracts-deployed
$(MAKE) start-anvil
cargo test --workspace
cargo +nightly fmt -- --check
$(MAKE) stop-anvil

3 changes: 2 additions & 1 deletion crates/contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ out/
docs/

# Dotenv file
.env
.env

35 changes: 35 additions & 0 deletions crates/contracts/anvil/deploy-eigenlayer-save-anvil-state.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# cd to the directory of this script so that this can be run from anywhere
parent_path=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd -P
)
# At this point we are in tests/anvil
cd "$parent_path"

set -a
source ./utils.sh
set +a

cleanup() {
echo "Executing cleanup function..."
set +e
docker rm -f anvil
exit_status=$?
if [ $exit_status -ne 0 ]; then
echo "Script exited due to set -e on line $1 with command '$2'. Exit status: $exit_status"
fi
}
trap 'cleanup $LINENO "$BASH_COMMAND"' EXIT

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

cd ../../contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts
# 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 script/output/devnet/M2_from_scratch_deployment_data.json script/output/devnet/M2_from_scratch_deployment_data.json.bak
# M2_Deploy_From_Scratch.s.sol prepends "script/testing/" to the configFile passed as input (M2_deploy_from_scratch.anvil.config.json)
forge script script/deploy/devnet/M2_Deploy_From_Scratch.s.sol --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast --sig "run(string memory configFile)" -- M2_deploy_from_scratch.anvil.config.json
mv script/output/devnet/M2_from_scratch_deployment_data.json ../../../../script/output/31337/eigenlayer_deployment_output.json
mv script/output/devnet/M2_from_scratch_deployment_data.json.bak script/output/devnet/M2_from_scratch_deployment_data.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
#!/bin/bash

set -o errexit -o nounset -o pipefail
RPC_URL=http://localhost:8545

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

set -a
source $anvil_dir/utils.sh
source ./utils.sh
set +a

cleanup() {
echo "Executing cleanup function..."
set +e
docker rm -f anvil
exit_status=$?
if [ $exit_status -ne 0 ]; then
echo "Script exited due to set -e on line $1 with command '$2'. Exit status: $exit_status"
fi
}
trap 'cleanup $LINENO "$BASH_COMMAND"' EXIT

# 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 $anvil_dir/contracts_deployed_anvil_state.json ""
# anvil --load-state avs-and-eigenlayer-deployed-anvil-state.json &
# FIXME: bug in latest foundry version, so we use this pinned version instead of latest
start_anvil_docker $parent_path/eigenlayer-deployed-anvil-state.json ""

cd $root_dir/contracts
cd ../../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
Expand Down
3 changes: 3 additions & 0 deletions crates/contracts/anvil/start-anvil.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker start anvil
3 changes: 3 additions & 0 deletions crates/contracts/anvil/stop-anvil.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker stop anvil
22 changes: 16 additions & 6 deletions crates/contracts/anvil/utils.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/bin/bash


# pinning at old foundry commit because of https://github.com/foundry-rs/foundry/issues/7502
FOUNDRY_IMAGE=ghcr.io/foundry-rs/foundry:nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a

set -e -o nounset

parent_path=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd -P
)

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

clean_up() {
# Check if the exit status is non-zero
exit_status=$?
Expand All @@ -20,6 +22,7 @@ clean_up() {
trap 'clean_up $LINENO "$BASH_COMMAND"' ERR

# start_anvil_docker $LOAD_STATE_FILE $DUMP_STATE_FILE
# this function will also take care of stopping the anvil container when the script exits
start_anvil_docker() {
LOAD_STATE_FILE=$1
DUMP_STATE_FILE=$2
Expand All @@ -29,11 +32,18 @@ start_anvil_docker() {
DUMP_STATE_ANVIL_ARG=$([[ -z $DUMP_STATE_FILE ]] && echo "" || echo "--dump-state /dump-state.json")

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 \
docker run -d --name anvil -p 8545:8545 $LOAD_STATE_VOLUME_DOCKER_ARG $DUMP_STATE_VOLUME_DOCKER_ARG \
--entrypoint anvil \
$FOUNDRY_IMAGE \
$LOAD_STATE_ANVIL_ARG $DUMP_STATE_ANVIL_ARG --host 0.0.0.0
set +o xtrace
sleep 2
}
}









Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"addresses": {
"avsDirectory": "0x0165878A594ca255338adfa4d48449f69242Eb8F",
"avsDirectoryImplementation": "0x9A676e781A523b5d0C0e43731313A708CB607508",
"baseStrategyImplementation": "0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f",
"delayedWithdrawalRouter": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
"delayedWithdrawalRouterImplementation": "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE",
"delegation": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
"delegationImplementation": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
"eigenLayerPauserReg": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
"eigenLayerProxyAdmin": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"eigenPodBeacon": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"eigenPodImplementation": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
"eigenPodManager": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
"eigenPodManagerImplementation": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"emptyContract": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"slasher": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"slasherImplementation": "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
"avsDirectory": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"avsDirectoryImplementation": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"baseStrategyImplementation": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44",
"delayedWithdrawalRouter": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
"delayedWithdrawalRouterImplementation": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"delegation": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"delegationImplementation": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"eigenLayerPauserReg": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"eigenLayerProxyAdmin": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"eigenPodBeacon": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
"eigenPodImplementation": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
"eigenPodManager": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"eigenPodManagerImplementation": "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
"emptyContract": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
"slasher": "0x0165878A594ca255338adfa4d48449f69242Eb8F",
"slasherImplementation": "0x9A676e781A523b5d0C0e43731313A708CB607508",
"strategies": "",
"strategyManager": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"strategyManagerImplementation": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82"
"strategyManager": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
"strategyManagerImplementation": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0"
},
"chainInfo": {
"chainId": 31337,
"deploymentBlock": 1
"deploymentBlock": 0
},
"parameters": {
"executorMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
Expand Down
Loading