Skip to content

Commit 0a0aea9

Browse files
committed
add simple switch to l2geth script
1 parent 0301e40 commit 0a0aea9

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
# Switch Sequencing to L2GETH Script
4+
# Disables L2RETH sequencing and enables L2GETH sequencing
5+
# Usage: ./switch-to-l2geth.sh
6+
7+
set -euo pipefail
8+
9+
# Source common functions
10+
source "$(dirname "$0")/common-functions.sh"
11+
12+
# Global variables to track state
13+
START_TIME=$(date +%s)
14+
15+
perform_sequencing_switch() {
16+
log_info "=== SWITCHING SEQUENCING TO L2GETH ==="
17+
18+
# Phase 1: Disable L2RETH sequencing
19+
log_info "--- Phase 1: Disabling L2RETH sequencing ---"
20+
disable_l2reth_sequencing
21+
22+
# Phase 2: Enable L2GETH sequencing
23+
log_info "--- Phase 2: Enabling L2GETH sequencing ---"
24+
start_l2geth_mining
25+
26+
# Phase 3: Verify L2GETH is producing blocks
27+
log_info "--- Phase 3: Verifying L2GETH block production ---"
28+
29+
# Get current block and wait for next block
30+
local current_block=$(get_block_number "$L2GETH_RPC_URL")
31+
local target_block=$((current_block + 1))
32+
33+
log_info "Current L2GETH block: #$current_block, waiting for block #$target_block..."
34+
35+
if wait_for_block "L2GETH" "$L2GETH_RPC_URL" "$target_block" ""; then
36+
log_success "L2GETH is successfully producing blocks"
37+
else
38+
log_error "L2GETH failed to produce new blocks after sequencing was enabled"
39+
exit 1
40+
fi
41+
}
42+
43+
main() {
44+
log_info "Starting sequencer switch: L2RETH -> L2GETH"
45+
46+
check_env_vars
47+
perform_pre_flight_checks
48+
49+
# Final confirmation
50+
read -p "Proceed with switching sequencing to L2GETH? (y/N): " confirm
51+
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
52+
log_warning "Sequencing switch cancelled by user"
53+
exit 0
54+
fi
55+
56+
perform_sequencing_switch
57+
}
58+
59+
# Run main function
60+
main "$@"

0 commit comments

Comments
 (0)