Skip to content
Draft
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
2 changes: 2 additions & 0 deletions op-node/rollup/derive/batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ func checkSpanBatchPrefix(ctx context.Context, cfg *rollup.Config, log log.Logge

nextTimestamp := l2SafeHead.Time + cfg.BlockTime

log.Info("checkSpanBatchPrefix", "nextTimestamp", nextTimestamp, "safe num", l2SafeHead.Number, "count", len(batch.Batches), "first", batch.Batches[0].Timestamp, "last", batch.Batches[len(batch.Batches)-1].Timestamp)

if batch.GetTimestamp() > nextTimestamp {
if cfg.IsHolocene(l1InclusionBlock.Time) {
log.Warn("dropping future span batch", "next_timestamp", nextTimestamp)
Expand Down
7 changes: 7 additions & 0 deletions test/3-op-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ sed_inplace 's/"number": 0/"number": '"$NEXT_BLOCK_NUMBER"'/' ./config-op/rollup
cp ./config-op/genesis.json ./config-op/genesis-reth.json
sed_inplace 's/"number": "0x0"/"number": "'"$NEXT_BLOCK_NUMBER_HEX"'"/' ./config-op/genesis-reth.json

CURRENT_VALUE=$(jq -r '.genesis.l2_time' ./config-op/rollup.json)
NEW_VALUE=$((CURRENT_VALUE - 200))
sed_inplace "s/\"l2_time\": $CURRENT_VALUE/\"l2_time\": $NEW_VALUE/" ./config-op/rollup.json

# Extract contract addresses from state.json and update .env file
echo "🔧 Extracting contract addresses from state.json..."
PWD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand Down Expand Up @@ -165,6 +169,7 @@ OP_GETH_RPC_DATADIR="$(pwd)/data/op-geth-rpc"
echo " 🔄 Copying database from op-geth-seq to op-geth-rpc..."
rm -rf "$OP_GETH_RPC_DATADIR"
cp -r "$OP_GETH_DATADIR" "$OP_GETH_RPC_DATADIR"
cp -r "$OP_GETH_DATADIR" "$OP_GETH_RPC_DATADIR"-bak

if [ "$CONDUCTOR_ENABLED" = "true" ]; then
if [ "$SEQ_TYPE" = "geth" ]; then
Expand All @@ -189,6 +194,8 @@ fi

echo "✅ Finished init op-$SEQ_TYPE-seq and op-$RPC_TYPE-rpc."

exit 0

# genesis.json is too large to embed in go, so we compress it now and decompress it in go code
gzip -c config-op/genesis.json > config-op/genesis.json.gz

Expand Down
100 changes: 95 additions & 5 deletions test/4-op-start-service.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
set -e
set -x

# Load environment variables early
source .env
Expand Down Expand Up @@ -73,7 +72,8 @@ sleep 5
#$SCRIPTS_DIR/add-peers.sh

if [ "$LAUNCH_RPC_NODE" = "true" ]; then
docker compose up -d op-rpc
echo ""
#docker compose up -d op-rpc
fi

# Configure op-batcher endpoints based on conductor mode
Expand All @@ -86,13 +86,103 @@ if [ "$CONDUCTOR_ENABLED" = "true" ]; then
else
echo "🔧 Configuring op-batcher for single sequencer mode..."
# Set single sequencer mode endpoints
export OP_BATCHER_L2_ETH_RPC="http://op-${SEQ_TYPE}-seq:8545"
export OP_BATCHER_ROLLUP_RPC="http://op-seq:9545"
echo "✅ op-batcher configured for single sequencer mode"
# export OP_BATCHER_L2_ETH_RPC="http://op-${SEQ_TYPE}-seq:8545"
# export OP_BATCHER_ROLLUP_RPC="http://op-seq:9545"
# echo "✅ op-batcher configured for single sequencer mode"
fi

INIT_HEIGHT=8593921
EXPECTED_WAIT_TIME=200
TARGET_SAFE_HEIGHT=$INIT_HEIGHT
START_TIME=$(date +%s)
echo "⏳ Waiting for sequencer window to expire and safe height to exceed $TARGET_SAFE_HEIGHT... (expected wait time: ~${EXPECTED_WAIT_TIME}s)"
while true; do
CURRENT_SAFE=$(cast bn -r http://localhost:8123 safe 2>/dev/null || echo "0")
if [ "$CURRENT_SAFE" -gt "$TARGET_SAFE_HEIGHT" ]; then
echo "✅ Safe height reached: $CURRENT_SAFE (target: $TARGET_SAFE_HEIGHT)"
break
fi
ELAPSED_TIME=$(($(date +%s) - START_TIME))
REMAINING_TIME=$((EXPECTED_WAIT_TIME - ELAPSED_TIME))
if [ "$REMAINING_TIME" -lt 0 ]; then
REMAINING_TIME=0
fi
echo " Current safe height: $CURRENT_SAFE, waiting for safe height > $TARGET_SAFE_HEIGHT... (elapsed: ${ELAPSED_TIME}s, remaining: ~${REMAINING_TIME}s)"
sleep 10
done

docker compose up -d op-batcher

CURRENT_SAFE=$(cast bn -r http://localhost:8123 safe 2>/dev/null || echo "0")

CHANNEL_TIMEOUT_GRANITE=50
MARGIN=50
L1_BLOCKTIME=2
EXTRA_SAFE_HEIGHT=$((CHANNEL_TIMEOUT_GRANITE * L1_BLOCKTIME + MARGIN))
TARGET_SAFE_HEIGHT=$((CURRENT_SAFE + EXTRA_SAFE_HEIGHT))
EXPECTED_WAIT_TIME=$EXTRA_SAFE_HEIGHT
START_TIME=$(date +%s)
echo "⏳ Waiting for safe height to exceed $TARGET_SAFE_HEIGHT... (expected wait time: ~${EXPECTED_WAIT_TIME}s)"
while true; do
CURRENT_SAFE=$(cast bn -r http://localhost:8123 safe 2>/dev/null || echo "0")
if [ "$CURRENT_SAFE" -gt "$TARGET_SAFE_HEIGHT" ]; then
echo "✅ Safe height reached: $CURRENT_SAFE (target: $TARGET_SAFE_HEIGHT)"
break
fi
ELAPSED_TIME=$(($(date +%s) - START_TIME))
REMAINING_TIME=$((EXPECTED_WAIT_TIME - ELAPSED_TIME))
if [ "$REMAINING_TIME" -lt 0 ]; then
REMAINING_TIME=0
fi
echo " Current safe height: $CURRENT_SAFE, waiting for safe height > $TARGET_SAFE_HEIGHT... (elapsed: ${ELAPSED_TIME}s, remaining: ~${REMAINING_TIME}s)"
sleep 10
done

# Wait for "decoded" keyword in op-seq logs
echo "⏳ Waiting for 'decoded' keyword in op-seq logs..."
while true; do
if docker logs op-seq 2>&1 | grep -q "decoded"; then
echo "✅ Found 'decoded' keyword in op-seq logs"
break
fi
echo " Waiting for 'decoded' keyword in op-seq logs..."
sleep 5
done

#sleep 20

# Wait for unsafe - safe < (seq window size * L1 blocktime)
echo "⏳ Waiting for unsafe - safe < 200..."
while true; do
CURRENT_SAFE=$(cast bn -r http://localhost:8123 safe 2>/dev/null || echo "0")
CURRENT_UNSAFE=$(cast bn -r http://localhost:8123 2>/dev/null || echo "0")
if [ "$CURRENT_SAFE" != "0" ] && [ "$CURRENT_UNSAFE" != "0" ] && [ $((CURRENT_UNSAFE - CURRENT_SAFE)) -lt 200 ]; then
echo "✅ Unsafe - safe < 200: unsafe=$CURRENT_UNSAFE, safe=$CURRENT_SAFE"
break
fi
docker compose restart op-seq
sleep 10
done

docker compose up -d op-rpc

while true; do
SAFE_8124=$(cast bn -r http://localhost:8124 safe 2>/dev/null || echo "0")
if [ "$SAFE_8124" != "0" ]; then
# Check for fork at safe height
if ! $SCRIPTS_DIR/check-fork.sh "$SAFE_8124" 2>/dev/null; then
echo "❌ Fork detected at safe height $SAFE_8124, breaking loop"
break
fi
fi
echo " ⏳ Waiting for op-rpc to fork..."
sleep 5
done

$SCRIPTS_DIR/find-fork.sh

exit 0

PWD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd $PWD_DIR
EXPORT_DIR="$PWD_DIR/data/cannon-data"
Expand Down
2 changes: 1 addition & 1 deletion test/config-op/intent.toml.bak
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ l2ContractsLocator = "file:///app/packages/contracts-bedrock/forge-artifacts"
l2GenesisBlockGasLimit = "0xbebc200"
l2GenesisBlockBaseFeePerGas = "0x3B9ACA00"
l2BlockTime = 1
sequencerWindowSize = 7200
sequencerWindowSize = 100
[chains.roles]
l1ProxyAdminOwner = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
l2ProxyAdminOwner = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
Expand Down
5 changes: 1 addition & 4 deletions test/config-op/test.geth.rpc.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ JWTSecret = "/jwt.txt"
MaxPeers = 30
DiscoveryV5 = true
# we add both geth and reth to static nodes, but only one is live
StaticNodes = [
"enode://ef8135659def07b48b54fe2de7d0368e3eaa0a080ef13dde560169357900954be1a1e890b5973a821f9158e512a2da3ff600368f44e18e725a86931eaae5ef64@op-geth-seq:30303",
"enode://ef8135659def07b48b54fe2de7d0368e3eaa0a080ef13dde560169357900954be1a1e890b5973a821f9158e512a2da3ff600368f44e18e725a86931eaae5ef64@op-reth-seq:30303"
]
StaticNodes = []

[Eth]
NetworkId = 901
Expand Down
19 changes: 10 additions & 9 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ services:
- ./entrypoint:/entrypoint
ports:
- "8124:8545"
- "8553:8552"
- "30304:30303"
- "30304:30303/udp"

Expand Down Expand Up @@ -275,7 +276,7 @@ services:
- "9091:9091" # pprof port
command:
- /app/op-node/bin/op-node
- --log.level=debug
- --log.level=info
- --l2=http://op-${SEQ_TYPE}-seq:8552
- --l2.jwt-secret=/jwt.txt
- --sequencer.enabled
Expand Down Expand Up @@ -323,7 +324,7 @@ services:
- "9555:9545"
command:
- /app/op-node/bin/op-node
- --log.level=debug
- --log.level=info
- --l2=http://op-${RPC_TYPE}-rpc:8552
- --l2.jwt-secret=/jwt.txt
- --sequencer.enabled=false
Expand All @@ -336,7 +337,7 @@ services:
- --p2p.priv.raw=604557d042fbea9ed42f46c0c95c346a932b6a5ef0c0dd07a00dbf95801a2510
- --p2p.peerstore.path=/data/p2p/opnode_peerstore_db
- --p2p.discovery.path=/data/p2p/opnode_discovery_db
- --p2p.static=/dns4/op-seq/tcp/9223/p2p/16Uiu2HAkzHdkbmS2VrCsccLibsu7MvGHpmFUMJnMTkKifrtS5m65
#- --p2p.static=/dns4/op-seq/tcp/9223/p2p/16Uiu2HAkzHdkbmS2VrCsccLibsu7MvGHpmFUMJnMTkKifrtS5m65
- --p2p.no-discovery
- --rpc.enable-admin=true
- --l1=${L1_RPC_URL_IN_DOCKER}
Expand Down Expand Up @@ -388,19 +389,19 @@ services:
container_name: op-batcher
command:
- /app/op-batcher/bin/op-batcher
- --log.level=debug
- --log.level=info
- --l2-eth-rpc=${OP_BATCHER_L2_ETH_RPC:-http://op-${SEQ_TYPE}-seq:8545}
- --rollup-rpc=${OP_BATCHER_ROLLUP_RPC:-http://op-seq:9545}
# - --txmgr.enable-cell-proofs=true
- --wait-node-sync=true
- --check-recent-txs-depth=5
- --poll-interval=5s
- --poll-interval=1s
- --batch-type=1
- --compression-algo=brotli-11
- --data-availability-type=auto
- --max-channel-duration=30
- --target-num-frames=5
- --sub-safety-margin=6
- --max-channel-duration=10
#- --target-num-frames=5
- --sub-safety-margin=10
- --num-confirmations=4
- --network-timeout=10s
- --safe-abort-nonce-too-low-count=3
Expand Down Expand Up @@ -645,7 +646,7 @@ services:
retries: 10
start_period: 3s

# Keep op-seq3 to run op-geth as default EL
# Keep op-seq3 to run op-geth as default EL
op-seq3:
image: "${OP_STACK_IMAGE_TAG}"
container_name: op-seq3
Expand Down
Loading