Skip to content

Commit

Permalink
L2 devchain fix (#11200)
Browse files Browse the repository at this point in the history
* L2 devchain fix

* fixes

* artifact fixes
  • Loading branch information
pahor167 authored Sep 12, 2024
1 parent 264b957 commit c5eff1c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ forge script \
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Total elapsed time: $ELAPSED_TIME seconds"

# Rename devchain artifact and remove unused directory
mv $ANVIL_FOLDER/state.json $TMP_FOLDER/$L1_DEVCHAIN_FILE_NAME
rm -rf $ANVIL_FOLDER
if [[ "${KEEP_DEVCHAIN_FOLDER:-}" == "true" ]]; then
cp $ANVIL_FOLDER/state.json $TMP_FOLDER/$L1_DEVCHAIN_FILE_NAME
echo "Keeping devchain folder as per flag."
else
# Rename devchain artifact and remove unused directory
mv $ANVIL_FOLDER/state.json $TMP_FOLDER/$L1_DEVCHAIN_FILE_NAME
rm -rf $ANVIL_FOLDER
fi
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ set -euo pipefail
# Read environment variables and constants
source $PWD/scripts/foundry/constants.sh

export KEEP_DEVCHAIN_FOLDER=true

# Generate and run L1 devchain
echo "Generating and running L1 devchain before activating L2..."
source $PWD/scripts/foundry/create_and_migrate_anvil_devchain.sh

# Backup L1 state before applying L2 migrations so it can be published to NPM
cp $TMP_FOLDER/$L1_DEVCHAIN_FILE_NAME $TMP_FOLDER/backup_$L1_DEVCHAIN_FILE_NAME

# Activate L2 by deploying arbitrary bytecode to the proxy admin address.
# Note: This can't be done from the migration script
ARBITRARY_BYTECODE=$(cast format-bytes32-string "L2 is activated")
Expand Down Expand Up @@ -50,12 +49,8 @@ forge script \
$NON_INTERACTIVE \
--rpc-url $ANVIL_RPC_URL || echo "L2 Migration script failed"

# Save L2 state so it can published to NPM
cp $TMP_FOLDER/$L1_DEVCHAIN_FILE_NAME $TMP_FOLDER/$L2_DEVCHAIN_FILE_NAME
# # 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"

# Restore L1 state from backup so it can be published to NPM as well
cp $TMP_FOLDER/backup_$L1_DEVCHAIN_FILE_NAME $TMP_FOLDER/$L1_DEVCHAIN_FILE_NAME

# Delete backup
rm $TMP_FOLDER/backup_$L1_DEVCHAIN_FILE_NAME
rm -rf $ANVIL_FOLDER
1 change: 1 addition & 0 deletions packages/protocol/scripts/foundry/start_anvil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ cp $PWD/migrations_sol/README.md $TMP_FOLDER/README.md
if nc -z localhost $ANVIL_PORT; then
echo "Port already used"
kill $(lsof -t -i:$ANVIL_PORT)
sleep 5
echo "Killed previous Anvil"
fi

Expand Down
2 changes: 2 additions & 0 deletions packages/protocol/test-sol/devchain/migration/Migration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "forge-std-8/console2.sol";

import { TestConstants } from "@test-sol/constants.sol";
import { MigrationsConstants } from "@migrations-sol/constants.sol";
import { CeloDistributionSchedule } from "@celo-contracts-8/common/CeloDistributionSchedule.sol";
import { FeeCurrencyDirectory } from "@celo-contracts-8/common/FeeCurrencyDirectory.sol";

import "@celo-contracts/common/interfaces/IRegistry.sol";
import "@celo-contracts/common/interfaces/IProxy.sol";
Expand Down

0 comments on commit c5eff1c

Please sign in to comment.