From aa7b9bbe6418d02560c268e619d7e8cd81bef235 Mon Sep 17 00:00:00 2001 From: Leszek Stachowski Date: Wed, 25 Sep 2024 15:00:20 +0200 Subject: [PATCH] Fix anvil devchain generation (#11226) --- packages/protocol/scripts/foundry/constants.sh | 1 + .../scripts/foundry/create_and_migrate_anvil_devchain.sh | 2 +- .../scripts/foundry/create_and_migrate_anvil_l2_devchain.sh | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/protocol/scripts/foundry/constants.sh b/packages/protocol/scripts/foundry/constants.sh index 4ecf41ad136..d44bdfce4ac 100755 --- a/packages/protocol/scripts/foundry/constants.sh +++ b/packages/protocol/scripts/foundry/constants.sh @@ -28,6 +28,7 @@ export L2_DEVCHAIN_FILE_NAME="l2-devchain.json" # Name of the file that will be export TMP_FOLDER="$PWD/.tmp" export TEMP_DIR="$PWD/.tmp/libraries" export ANVIL_FOLDER="$TMP_FOLDER/devchain" +export SLEEP_DURATION=20 # Contract addresses export REGISTRY_ADDRESS="0x000000000000000000000000000000000000ce10" diff --git a/packages/protocol/scripts/foundry/create_and_migrate_anvil_devchain.sh b/packages/protocol/scripts/foundry/create_and_migrate_anvil_devchain.sh index a77c48f81ff..1310cc63307 100755 --- a/packages/protocol/scripts/foundry/create_and_migrate_anvil_devchain.sh +++ b/packages/protocol/scripts/foundry/create_and_migrate_anvil_devchain.sh @@ -80,7 +80,7 @@ ELAPSED_TIME=$(($SECONDS - $START_TIME)) echo "Migration script total elapsed time: $ELAPSED_TIME seconds" # this helps to make sure that devchain state is actually being saved -sleep 1 +sleep $SLEEP_DURATION if [[ "${KEEP_DEVCHAIN_FOLDER:-}" == "true" ]]; then cp $ANVIL_FOLDER/state.json $TMP_FOLDER/$L1_DEVCHAIN_FILE_NAME diff --git a/packages/protocol/scripts/foundry/create_and_migrate_anvil_l2_devchain.sh b/packages/protocol/scripts/foundry/create_and_migrate_anvil_l2_devchain.sh index 4f00d37dd7f..25f2ee31a37 100755 --- a/packages/protocol/scripts/foundry/create_and_migrate_anvil_l2_devchain.sh +++ b/packages/protocol/scripts/foundry/create_and_migrate_anvil_l2_devchain.sh @@ -50,6 +50,9 @@ forge script \ $NON_INTERACTIVE \ --rpc-url $ANVIL_RPC_URL || { echo "Migration script failed"; exit 1; } +# Give anvil enough time to save the state +sleep $SLEEP_DURATION + # # Save L2 state so it can published to NPM mv $ANVIL_FOLDER/state.json $TMP_FOLDER/$L2_DEVCHAIN_FILE_NAME echo "Saved anvil L2 state to $TMP_FOLDER/$L2_DEVCHAIN_FILE_NAME"