Skip to content
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
40 changes: 40 additions & 0 deletions sequencer-migration/common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,46 @@ wait_for_block() {
done
}

wait_for_l2reth_to_catch_up_with_l2geth() {
log_info "Waiting for L2RETH to catch up with L2GETH..."

local l2geth_info
if ! l2geth_info=$(get_latest_block_info "$L2GETH_RPC_URL"); then
log_error "Failed to get latest block info from L2GETH"
exit 1
fi

local target_block=$(echo "$l2geth_info" | awk '{print $1}')
local target_hash=$(echo "$l2geth_info" | awk '{print $2}')

if wait_for_block "L2RETH" "$L2RETH_RPC_URL" "$target_block" "$target_hash"; then
log_success "L2RETH has caught up with L2GETH at block #$target_block"
else
log_error "L2RETH failed to catch up with L2GETH"
exit 1
fi
}

wait_for_l2geth_to_catch_up_with_l2reth() {
log_info "Waiting for L2GETH to catch up with L2RETH..."

local l2reth_info
if ! l2reth_info=$(get_latest_block_info "$L2RETH_RPC_URL"); then
log_error "Failed to get latest block info from L2RETH"
exit 1
fi

local target_block=$(echo "$l2reth_info" | awk '{print $1}')
local target_hash=$(echo "$l2reth_info" | awk '{print $2}')

if wait_for_block "L2GETH" "$L2GETH_RPC_URL" "$target_block" "$target_hash"; then
log_success "L2GETH has caught up with L2RETH at block #$target_block"
else
log_error "L2GETH failed to catch up with L2RETH"
exit 1
fi
}

# Check RPC connectivity for both nodes
check_rpc_connectivity() {
log_info "Checking RPC connectivity..."
Expand Down
82 changes: 82 additions & 0 deletions sequencer-migration/send-l1-messages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# Send L1 messages
# Usage: ./send-l1-messages.sh [count]

set -euo pipefail

# Source common functions
source "$(dirname "$0")/common-functions.sh"

# Check for required arguments
if [ $# -lt 1 ]; then
log_info "usage: send-l1-messages.sh [count]"
log_info "example: send-l1-messages.sh 10"
exit 1
fi

check_script_env_vars() {
# Check the L1 private key is provided
if [[ -z "${L1_DEPLOYER_PRIVATE_KEY:-}" ]]; then
log_error "L1_DEPLOYER_PRIVATE_KEY environment variable is required"
exit 1
fi

# Check the L1 RPC URL is provided
if [[ -z "${SCROLL_L1_DEPLOYMENT_RPC:-}" ]]; then
log_error "SCROLL_L1_DEPLOYMENT_RPC environment variable is required"
exit 1
fi

# Check the L1 message queue proxy address is provided
if [[ -z "${L1_MESSAGE_QUEUE_V2_PROXY_ADDR:-}" ]]; then
log_error "L1_MESSAGE_QUEUE_V2_PROXY_ADDR environment variable is required"
exit 1
fi

# Check the L1 enforced tx gateway proxy address is provided
if [[ -z "${L1_ENFORCED_TX_GATEWAY_PROXY_ADDR:-}" ]]; then
log_error "L1_ENFORCED_TX_GATEWAY_PROXY_ADDR environment variable is required"
exit 1
fi

# Check the L1 scroll messenger proxy address is provided
if [[ -z "${L1_SCROLL_MESSENGER_PROXY_ADDR:-}" ]]; then
log_error "L1_SCROLL_MESSENGER_PROXY_ADDR environment variable is required"
exit 1
fi
}

main() {
log_info "=== SENDING L1 MESSAGES ==="

check_script_env_vars

address=$(cast wallet address "$L1_DEPLOYER_PRIVATE_KEY")
start_nonce=$(cast nonce --rpc-url "$SCROLL_L1_DEPLOYMENT_RPC" "$address")
end_nonce=$(($start_nonce + $1))

log_info "Address: $address"
log_info "Start nonce: $start_nonce"
log_info "End nonce: $end_nonce"

for (( ii = $start_nonce; ii < $end_nonce; ii += 2 )); do
log_info ""
log_info "Sending deposit tx with nonce #$ii"
cast send --async --rpc-url "$SCROLL_L1_DEPLOYMENT_RPC" --private-key "$L1_DEPLOYER_PRIVATE_KEY" --legacy --gas-price 0.1gwei --nonce "$ii" --gas-limit 200000 --value 0.001ether "$L1_SCROLL_MESSENGER_PROXY_ADDR" "sendMessage(address _to, uint256 _value, bytes memory _message, uint256 _gasLimit)" 0x0000000000000000000000000000000000000002 0x1 0x 200000

log_info ""
next_queue_index=$(cast call --rpc-url "$SCROLL_L1_DEPLOYMENT_RPC" "$L1_MESSAGE_QUEUE_V2_PROXY_ADDR" "nextCrossDomainMessageIndex()(uint256)")
log_info "Next queue index: $next_queue_index "

log_info ""
log_info "Sending enforced tx with nonce #$(( $ii + 1 ))"
cast send --async --rpc-url "$SCROLL_L1_DEPLOYMENT_RPC" --private-key "$L1_DEPLOYER_PRIVATE_KEY" --legacy --gas-price 0.1gwei --nonce "$(( $ii + 1 ))" --gas-limit 200000 --value 0.001ether "$L1_ENFORCED_TX_GATEWAY_PROXY_ADDR" "sendTransaction(address _target, uint256 _value, uint256 _gasLimit, bytes calldata _data)" 0x0000000000000000000000000000000000000001 1 200000 0x

log_info ""
next_queue_index=$(cast call --rpc-url "$SCROLL_L1_DEPLOYMENT_RPC" "$L1_MESSAGE_QUEUE_V2_PROXY_ADDR" "nextCrossDomainMessageIndex()(uint256)")
log_info "Next queue index: $next_queue_index "
done

echo "Done"
}
4 changes: 4 additions & 0 deletions sequencer-migration/sepolia.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export SCROLL_L1_DEPLOYMENT_RPC="https://0xrpc.io/sep"
export L1_MESSAGE_QUEUE_V2_PROXY_ADDR="0xA0673eC0A48aa924f067F1274EcD281A10c5f19F"
export L1_ENFORCED_TX_GATEWAY_PROXY_ADDR="0x97f421CA37889269a11ae0fef558114b984C7487"
export L1_SCROLL_MESSENGER_PROXY_ADDR="0x50c7d3e7f7c656493D1D76aaa1a836CedfCBB16A"
13 changes: 13 additions & 0 deletions sequencer-migration/switch-to-l2geth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ perform_sequencing_switch() {
log_info "--- Phase 1: Disabling L2RETH sequencing ---"
disable_l2reth_sequencing

# wait for l2geth to catch up with l2reth
log_info "-- Phase 1.5: Waiting for L2GETH to catch up with L2RETH ---"
wait_for_l2geth_to_catch_up_with_l2reth

# Phase 2: Enable L2GETH sequencing
log_info "--- Phase 2: Enabling L2GETH sequencing ---"
start_l2geth_mining
Expand All @@ -38,6 +42,15 @@ perform_sequencing_switch() {
log_error "L2GETH failed to produce new blocks after sequencing was enabled"
exit 1
fi

log_info "Verifying L2RETH is following blocks..."

if wait_for_l2reth_to_catch_up_with_l2geth; then
log_success "L2RETH is successfully following blocks"
else
log_error "L2RETH failed to follow new blocks after L2GETH sequencing was enabled"
exit 1
fi
}

main() {
Expand Down
73 changes: 73 additions & 0 deletions sequencer-migration/switch-to-l2reth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

# Switch Sequencing to L2RETH Script
# Disables L2RETH sequencing and enables L2RETH sequencing
# Usage: ./switch-to-l2reth.sh

set -euo pipefail

# Source common functions
source "$(dirname "$0")/common-functions.sh"

# Global variables to track state
START_TIME=$(date +%s)

perform_sequencing_switch() {
log_info "=== SWITCHING SEQUENCING TO L2RETH ==="

# Phase 1: Disable L2GETH sequencing
log_info "--- Phase 1: Disabling L2GETH sequencing ---"
stop_l2geth_mining

# wait for l2reth to catch up with l2geth
log_info "-- Phase 1.5: Waiting for L2RETH to catch up with L2GETH ---"
wait_for_l2reth_to_catch_up_with_l2geth

# Phase 2: Enable L2GETH sequencing
log_info "--- Phase 2: Enabling L2GETH sequencing ---"
enable_l2reth_sequencing

# Phase 3: Verify L2RETH is producing blocks
log_info "--- Phase 3: Verifying L2RETH block production ---"

# Get current block and wait for next block
local current_block=$(get_block_number "$L2RETH_RPC_URL")
local target_block=$((current_block + 1))

log_info "Current L2RETH block: #$current_block, waiting for block #$target_block..."

if wait_for_block "L2RETH" "$L2RETH_RPC_URL" "$target_block" ""; then
log_success "L2RETH is successfully producing blocks"
else
log_error "L2RETH failed to produce new blocks after sequencing was enabled"
exit 1
fi

log_info "Verifying L2GETH is following blocks..."

if wait_for_l2geth_to_catch_up_with_l2reth; then
log_success "L2GETH is successfully following blocks"
else
log_error "L2GETH failed to follow new blocks after L2RETH sequencing was enabled"
exit 1
fi
}

main() {
log_info "Starting sequencer switch: L2GETH -> L2RETH"

check_env_vars
perform_pre_flight_checks

# Final confirmation
read -p "Proceed with switching sequencing to L2RETH? (y/N): " confirm
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
log_warning "Sequencing switch cancelled by user"
exit 0
fi

perform_sequencing_switch
}

# Run main function
main "$@"
2 changes: 1 addition & 1 deletion tests/launch_rollup_node_follower.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

export RUST_LOG=sqlx=off,scroll=trace,reth=trace,rollup=trace,trace
export RUST_LOG=sqlx=off,scroll=trace,reth=info,rollup=trace,info

exec rollup-node node --chain /l2reth/l2reth-genesis-e2e.json --datadir=/l2reth --metrics=0.0.0.0:6060 \
--disable-discovery \
Expand Down
2 changes: 1 addition & 1 deletion tests/launch_rollup_node_sequencer.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo -n "0xd510c4b7c61a604f800c4f06803b1ee14b9a63de345e53426ae50425f2dbb058" > /
echo -n "01c0d9156e199d89814d4b18e9eb64e25de3927f3f6d27b778177f3ff6b610ad" > /l2reth/nodekey
# -> enode://e7f7e271f62bd2b697add14e6987419758c97e83b0478bd948f5f2d271495728e7edef5bd78ad65258ac910f28e86928ead0c42ee51f2a0168d8ca23ba939766@rollup-node-sequencer:30303

export RUST_LOG=sqlx=off,scroll=trace,reth=trace,rollup=trace,trace
export RUST_LOG=sqlx=off,scroll=trace,reth=info,rollup=trace,info

exec rollup-node node --chain /l2reth/l2reth-genesis-e2e.json --datadir=/l2reth --metrics=0.0.0.0:6060 \
--disable-discovery \
Expand Down
Loading