From 26249e5eb0d523d105b9f2927a5bc0f5d3880b9d Mon Sep 17 00:00:00 2001 From: dailinsubjam Date: Mon, 4 Aug 2025 23:17:27 +0000 Subject: [PATCH 1/6] version works for me --- espresso/scripts/prepare-allocs.sh | 2 +- espresso/scripts/reshape-allocs.jq | 1 - flake.nix | 10 +++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/espresso/scripts/prepare-allocs.sh b/espresso/scripts/prepare-allocs.sh index fada7be6aec47..b19d9ef3fc66c 100755 --- a/espresso/scripts/prepare-allocs.sh +++ b/espresso/scripts/prepare-allocs.sh @@ -89,7 +89,7 @@ kill $ANVIL_PID sleep 1 -"${OP_ROOT}/espresso/scripts/reshape-allocs.jq" \ +jq -S -f "${OP_ROOT}/espresso/scripts/reshape-allocs.jq" \ <(jq .accounts "${ANVIL_STATE_FILE}") \ | jq '{ "alloc": map_values(.state) }' \ > "${DEPLOYMENT_DIR}/deployer_allocs.json" diff --git a/espresso/scripts/reshape-allocs.jq b/espresso/scripts/reshape-allocs.jq index f8a775beffc7a..a092f8fd92b52 100755 --- a/espresso/scripts/reshape-allocs.jq +++ b/espresso/scripts/reshape-allocs.jq @@ -1,4 +1,3 @@ -#!/usr/bin/env jq -S -f # Converts output of espresso-dev-node launched with # 'ESPRESSO_DEV_NODE_L1_DEPLOYMENT=dump' to form suitable # for e2e testing harness. diff --git a/flake.nix b/flake.nix index 89cc04dc4b689..2b55da8e39f4b 100644 --- a/flake.nix +++ b/flake.nix @@ -15,12 +15,12 @@ ]; pkgs = import inputs.nixpkgs { inherit overlays system; }; - go_1_22_7 = pkgs.go_1_22.overrideAttrs (oldAttrs: { - version = "1.22.7"; + go_1_22_10 = pkgs.go_1_22.overrideAttrs (oldAttrs: { + version = "1.22.10"; src = pkgs.fetchurl { - url = "https://go.dev/dl/go1.22.7.src.tar.gz"; - sha256 = "sha256-ZkMth9heDPrD7f/mN9WTD8Td9XkzE/4R5KDzMwI8h58="; + url = "https://go.dev/dl/go1.22.10.src.tar.gz"; + sha256 = "sha256-HpT9SL51DR+vtNmztt0xpunSc10zm/JGK8l7ZMpMEDc="; }; }); @@ -123,7 +123,7 @@ enclaver eth-beacon-genesis eth2-val-tools - go_1_22_7 + go_1_22_10 pkgs.awscli2 pkgs.cargo From 122f1fb649758e3aea45fb8ac8699189d092dfe3 Mon Sep 17 00:00:00 2001 From: dailinsubjam Date: Wed, 6 Aug 2025 00:28:12 +0000 Subject: [PATCH 2/6] able to deploy contracts --- espresso/.env | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/espresso/.env b/espresso/.env index 9bd0cd4fc3ee6..8b8c33d64a9f1 100644 --- a/espresso/.env +++ b/espresso/.env @@ -34,3 +34,8 @@ OPERATOR_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 L1_CHAIN_ID=11155111 L2_CHAIN_ID=22266222 + +# Espresso contract addresses +ESPRESSO_TEE_VERIFIER_ADDRESS=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 +BATCH_AUTHENTICATOR_ADDRESS=0x0165878A594ca255338adfa4d48449f69242Eb8F +BATCH_INBOX_ADDRESS=0xa513E6E4b8f2a923D98304ec87F64353C4D5C853 From 593e49e3f9a0828910a7fd25ac55b058a6a4bc46 Mon Sep 17 00:00:00 2001 From: dailinsubjam Date: Wed, 6 Aug 2025 04:57:57 +0000 Subject: [PATCH 3/6] working script --- espresso/.env | 6 +- espresso/scripts/deploy-espresso-contracts.sh | 206 ++++++++++++++++++ kurtosis-devnet/justfile | 22 ++ 3 files changed, 231 insertions(+), 3 deletions(-) create mode 100755 espresso/scripts/deploy-espresso-contracts.sh diff --git a/espresso/.env b/espresso/.env index 8b8c33d64a9f1..401d2ca773a14 100644 --- a/espresso/.env +++ b/espresso/.env @@ -36,6 +36,6 @@ L1_CHAIN_ID=11155111 L2_CHAIN_ID=22266222 # Espresso contract addresses -ESPRESSO_TEE_VERIFIER_ADDRESS=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707 -BATCH_AUTHENTICATOR_ADDRESS=0x0165878A594ca255338adfa4d48449f69242Eb8F -BATCH_INBOX_ADDRESS=0xa513E6E4b8f2a923D98304ec87F64353C4D5C853 +ESPRESSO_TEE_VERIFIER_ADDRESS=0x9A676e781A523b5d0C0e43731313A708CB607508 +BATCH_AUTHENTICATOR_ADDRESS=0x0B306BF915C4d645ff596e518fAf3F9669b97016 +BATCH_INBOX_ADDRESS=0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1 diff --git a/espresso/scripts/deploy-espresso-contracts.sh b/espresso/scripts/deploy-espresso-contracts.sh new file mode 100755 index 0000000000000..4f57f7bd27749 --- /dev/null +++ b/espresso/scripts/deploy-espresso-contracts.sh @@ -0,0 +1,206 @@ +#!/usr/bin/env bash +set -euo pipefail + +# This script deploys Espresso contracts to a kurtosis devnet `celo-isthmus-devnet` + +# Function to get L1 RPC port from kurtosis +get_l1_rpc_port() { + kurtosis enclave inspect celo-isthmus-devnet | grep -A 10 "el-1-geth-teku" | grep "rpc: " | grep -v "engine-rpc" | sed -n 's/.*127.0.0.1:\([0-9]*\).*/\1/p' +} + +# Function to get user key from devnet descriptor +get_user_key() { + # Clean up any existing directory + rm -rf devnet-descriptor-0 + + # Download the devnet descriptor + kurtosis files download celo-isthmus-devnet devnet-descriptor-0 >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Error: Failed to download devnet descriptor" >&2 + return 1 + fi + + # Fix line endings and validate JSON + dos2unix devnet-descriptor-0/env.json >/dev/null 2>&1 + if ! jq empty devnet-descriptor-0/env.json >/dev/null 2>&1; then + echo "Error: Invalid JSON file" >&2 + rm -rf devnet-descriptor-0 + return 1 + fi + + # Extract the user key from env.json + local user_key + user_key=$(jq -r '.l1.wallets."user-key-12".private_key' devnet-descriptor-0/env.json) + if [ -z "$user_key" ] || [ "$user_key" = "null" ]; then + echo "Error: Could not find user key in devnet descriptor" >&2 + rm -rf devnet-descriptor-0 + return 1 + fi + + # Clean up the downloaded files + rm -rf devnet-descriptor-0 + + # Return the user key + echo "$user_key" + return 0 +} + +# Default L1 RPC URL for kurtosis devnet +L1_RPC_PORT=$(get_l1_rpc_port) +if [ -z "$L1_RPC_PORT" ]; then + echo "Error: Could not get L1 RPC port from kurtosis. Please ensure the devnet is running." + exit 1 +fi +echo "Using L1 RPC Port: $L1_RPC_PORT" +L1_RPC_URL=${L1_RPC_URL:-"http://localhost:$L1_RPC_PORT"} + +# Get the project root directory +PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")/../..") +ENV_FILE="$PROJECT_ROOT/espresso/.env" + +# Load environment variables if .env exists +if [ -f "$ENV_FILE" ]; then + source "$ENV_FILE" +fi + +# Function to get balance in ETH +get_balance() { + local address=$1 + cast balance --rpc-url "$L1_RPC_URL" "$address" | cast --from-wei +} + +# Function to transfer ETH +transfer_eth() { + local from_key=$1 + local to_address=$2 + local amount=$3 + cast send --rpc-url "$L1_RPC_URL" --private-key "$from_key" "$to_address" --value "${amount}eth" + echo "✓ Transferred $amount ETH to $to_address" +} + +# Check if OPERATOR_PRIVATE_KEY is set in .env +if [ -z "${OPERATOR_PRIVATE_KEY:-}" ]; then + echo "Error: OPERATOR_PRIVATE_KEY not found in .env file" + exit 1 +fi + +# Use the operator's private key from .env +PRIVATE_KEY=$OPERATOR_PRIVATE_KEY + +# Get operator's address +OPERATOR_ADDRESS=$(cast wallet address --private-key "$PRIVATE_KEY") +echo "Using operator address: $OPERATOR_ADDRESS" + +# Check operator balance and transfer funds if needed +OPERATOR_BALANCE=$(get_balance "$OPERATOR_ADDRESS") +echo "Operator balance: $OPERATOR_BALANCE ETH" + +# Convert balance to a number that can be compared +OPERATOR_BALANCE_NUM=$(echo "$OPERATOR_BALANCE" | bc) +if (( $(echo "$OPERATOR_BALANCE_NUM < 5" | bc -l) )); then + echo "Operator balance is less than 5 ETH. Transferring funds..." + # Get user key from devnet descriptor + USER_KEY=$(get_user_key) + if [ $? -ne 0 ]; then + echo "Error: Failed to get user key from devnet descriptor" >&2 + exit 1 + fi + # Remove 0x prefix if present + USER_KEY=${USER_KEY#0x} + cast send --private-key "$USER_KEY" --rpc-url "$L1_RPC_URL" "$OPERATOR_ADDRESS" --value 2ether + if [ $? -ne 0 ]; then + echo "Error: Failed to transfer funds to operator" >&2 + exit 1 + fi + echo "Successfully transferred 2 ETH to operator" +fi + +# Function to validate contract deployment +validate_contract() { + local address=$1 + local name=$2 + echo "Validating $name at $address..." + # Check if address exists on chain + if ! cast code "$address" --rpc-url "$L1_RPC_URL" > /dev/null 2>&1; then + echo "Error: $name contract not found at $address" + exit 1 + fi + echo "✓ $name contract validated" +} + +# Function to update .env file +update_env() { + local name=$1 + local address=$2 + # Remove existing line if it exists + sed -i "/$name=/d" "$ENV_FILE" + # Add new line + echo "$name=$address" >> "$ENV_FILE" + echo "✓ Updated $name in .env" +} + +# Ensure we're in the contracts directory +cd "$PROJECT_ROOT/packages/contracts-bedrock" + +# First, deploy the EspressoTEEVerifier +echo "Deploying EspressoTEEVerifier..." +TEE_VERIFIER_RESULT=$(forge create \ + --rpc-url "$L1_RPC_URL" \ + --private-key "$PRIVATE_KEY" \ + --broadcast \ + lib/espresso-tee-contracts/src/EspressoTEEVerifier.sol:EspressoTEEVerifier \ + --constructor-args "$ESPRESSO_SEQUENCER_PLONK_VERIFIER_ADDRESS" "$ESPRESSO_SEQUENCER_PLONK_VERIFIER_V2_ADDRESS") + +# Extract EspressoTEEVerifier address +TEE_VERIFIER_ADDRESS=$(echo "$TEE_VERIFIER_RESULT" | grep "Deployed to:" | awk '{print $3}') +echo "EspressoTEEVerifier deployed to: $TEE_VERIFIER_ADDRESS" + +# Validate EspressoTEEVerifier deployment +validate_contract "$TEE_VERIFIER_ADDRESS" "EspressoTEEVerifier" + +# Deploy BatchAuthenticator with TEE verifier +echo "Deploying BatchAuthenticator..." +AUTHENTICATOR_RESULT=$(forge create \ + --rpc-url "$L1_RPC_URL" \ + --private-key "$PRIVATE_KEY" \ + --broadcast \ + src/L1/BatchAuthenticator.sol:BatchAuthenticator \ + --constructor-args "$TEE_VERIFIER_ADDRESS" "$OPERATOR_ADDRESS") + +# Extract BatchAuthenticator address +AUTHENTICATOR_ADDRESS=$(echo "$AUTHENTICATOR_RESULT" | grep "Deployed to:" | awk '{print $3}') +echo "BatchAuthenticator deployed to: $AUTHENTICATOR_ADDRESS" + +# Validate BatchAuthenticator deployment +validate_contract "$AUTHENTICATOR_ADDRESS" "BatchAuthenticator" + +# Deploy BatchInbox with BatchAuthenticator address +echo "Deploying BatchInbox..." +INBOX_RESULT=$(forge create \ + --rpc-url "$L1_RPC_URL" \ + --private-key "$PRIVATE_KEY" \ + --broadcast \ + src/L1/BatchInbox.sol:BatchInbox \ + --constructor-args "$AUTHENTICATOR_ADDRESS") + +# Extract BatchInbox address +INBOX_ADDRESS=$(echo "$INBOX_RESULT" | grep "Deployed to:" | awk '{print $3}') +echo "BatchInbox deployed to: $INBOX_ADDRESS" + +# Validate BatchInbox deployment +validate_contract "$INBOX_ADDRESS" "BatchInbox" + +# Update .env file with new contract addresses +echo "Updating .env file with contract addresses..." +update_env "ESPRESSO_TEE_VERIFIER_ADDRESS" "$TEE_VERIFIER_ADDRESS" +update_env "BATCH_AUTHENTICATOR_ADDRESS" "$AUTHENTICATOR_ADDRESS" +update_env "BATCH_INBOX_ADDRESS" "$INBOX_ADDRESS" + +echo "Deployment complete! Contract addresses have been added to $ENV_FILE" + +# Output addresses in a format suitable for environment variables +echo "" +echo "Added these to your .env file:" +echo "ESPRESSO_TEE_VERIFIER_ADDRESS=$TEE_VERIFIER_ADDRESS" +echo "BATCH_AUTHENTICATOR_ADDRESS=$AUTHENTICATOR_ADDRESS" +echo "BATCH_INBOX_ADDRESS=$INBOX_ADDRESS" diff --git a/kurtosis-devnet/justfile b/kurtosis-devnet/justfile index c1718faf9cf15..ad223129a5129 100644 --- a/kurtosis-devnet/justfile +++ b/kurtosis-devnet/justfile @@ -144,3 +144,25 @@ external-batcher-parameters: echo "$parameter2" echo "$parameter3" echo "$parameter4" + +external-batcher-celo: + #!/usr/bin/env sh + function external_url () { + kurtosis service inspect celo-isthmus-devnet "${1}" | yq .Ports."${2}" | sed -E 's#.*->\s+(.*\/)?#http://#' + } + batcher="$(pwd)/../op-batcher/bin/op-batcher" + command="${batcher} "\ + "--l2-eth-rpc=$(external_url 'op-el-1-op-geth-op-node-op-kurtosis' 'rpc') "\ + "--rollup-rpc=$(external_url 'op-cl-1-op-node-op-geth-op-kurtosis' 'http') "\ + "--l1-eth-rpc=$(external_url 'el-1-geth-teku' 'rpc') "\ + "--espresso-url=http://localhost:24000,http://localhost:24000 "\ + "--espresso-light-client-addr=0x703848f4c85f18e3acd8196c8ec91eb0b7bd0797 "\ + "--testing-espresso-batcher-private-key=0xb3d2d558e3491a3709b7c451100a0366b5872520c7aa020c17a0e7fa35b6a8df "\ + "--poll-interval=1s --sub-safety-margin=6 --num-confirmations=1 --safe-abort-nonce-too-low-count=3 "\ + "--resubmission-timeout=30s --rpc.addr=0.0.0.0 --rpc.port=8548 --rpc.enable-admin "\ + "--max-channel-duration=1 --private-key=0xb3d2d558e3491a3709b7c451100a0366b5872520c7aa020c17a0e7fa35b6a8df "\ + "--data-availability-type=calldata --metrics.enabled --metrics.addr=0.0.0.0 --metrics.port=9001 "\ + "--log.level=debug" + echo "Running batcher:" + echo "$command" + $command From e7039ee5549e82b7d921dadf4ed9474d3d55b0a8 Mon Sep 17 00:00:00 2001 From: dailinsubjam Date: Wed, 6 Aug 2025 05:08:58 +0000 Subject: [PATCH 4/6] update migration steps with deploy contracts --- README_ESPRESSO.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README_ESPRESSO.md b/README_ESPRESSO.md index 40cd4c5703929..b81e5e8dac2c9 100644 --- a/README_ESPRESSO.md +++ b/README_ESPRESSO.md @@ -115,6 +115,39 @@ To run a subset of the tests above (fast): kurtosis clean -a ``` +### Migration from Celo's kurtosis devnet to Celo-Espesso devnet + +To do the migration, you need to start Celo's kurtosis devnet first. + +```console +git checkout Kourin1996/celo-rebase-13-devnet +cd kurtosis-devnet && just celo-isthmus-devnet +``` + +Then get back to the original branch. +```console +git checkout - +``` + +Deploy Espresso's contracts to the devnet. +```console +./espresso/scripts/deploy-espresso-contracts.sh +``` + +Stop the old batcher. +```console +kurtosis service stop celo-isthmus-devnet op-batcher-op-kurtosis +``` + + + +Start the new batcher. +```console +cd op-batcher/ && just && cd - +cd kurtosis-devnet && just external-batcher-celo +``` + + ### Misc commands @@ -338,7 +371,7 @@ docker compose down -v docker volume prune -a ``` -* If you have changed OP contracts, you will have to start the devnet fresh and re-generate +* If you have changed OP contracts, you will have to start the devnet fresh and re-generate the genesis allocations by running `prepare-allocs.sh` From c4d7d767d76e754748fe8e096839d72b983d0d27 Mon Sep 17 00:00:00 2001 From: dailinsubjam Date: Wed, 6 Aug 2025 05:09:14 +0000 Subject: [PATCH 5/6] typo --- README_ESPRESSO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_ESPRESSO.md b/README_ESPRESSO.md index b81e5e8dac2c9..07e770781c0bf 100644 --- a/README_ESPRESSO.md +++ b/README_ESPRESSO.md @@ -147,7 +147,7 @@ cd op-batcher/ && just && cd - cd kurtosis-devnet && just external-batcher-celo ``` - + ### Misc commands From 233cbff9fdc4a8f3ccaafe75c059f63e962fe5b7 Mon Sep 17 00:00:00 2001 From: dailinsubjam Date: Wed, 6 Aug 2025 05:19:59 +0000 Subject: [PATCH 6/6] cleanup --- espresso/.env | 5 ----- flake.nix | 10 +++++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/espresso/.env b/espresso/.env index 401d2ca773a14..9bd0cd4fc3ee6 100644 --- a/espresso/.env +++ b/espresso/.env @@ -34,8 +34,3 @@ OPERATOR_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 L1_CHAIN_ID=11155111 L2_CHAIN_ID=22266222 - -# Espresso contract addresses -ESPRESSO_TEE_VERIFIER_ADDRESS=0x9A676e781A523b5d0C0e43731313A708CB607508 -BATCH_AUTHENTICATOR_ADDRESS=0x0B306BF915C4d645ff596e518fAf3F9669b97016 -BATCH_INBOX_ADDRESS=0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1 diff --git a/flake.nix b/flake.nix index 2b55da8e39f4b..89cc04dc4b689 100644 --- a/flake.nix +++ b/flake.nix @@ -15,12 +15,12 @@ ]; pkgs = import inputs.nixpkgs { inherit overlays system; }; - go_1_22_10 = pkgs.go_1_22.overrideAttrs (oldAttrs: { - version = "1.22.10"; + go_1_22_7 = pkgs.go_1_22.overrideAttrs (oldAttrs: { + version = "1.22.7"; src = pkgs.fetchurl { - url = "https://go.dev/dl/go1.22.10.src.tar.gz"; - sha256 = "sha256-HpT9SL51DR+vtNmztt0xpunSc10zm/JGK8l7ZMpMEDc="; + url = "https://go.dev/dl/go1.22.7.src.tar.gz"; + sha256 = "sha256-ZkMth9heDPrD7f/mN9WTD8Td9XkzE/4R5KDzMwI8h58="; }; }); @@ -123,7 +123,7 @@ enclaver eth-beacon-genesis eth2-val-tools - go_1_22_10 + go_1_22_7 pkgs.awscli2 pkgs.cargo