Skip to content

Commit

Permalink
Fix resequence (#1607)
Browse files Browse the repository at this point in the history
* fix resequencing

* fix

* Add nonce check in resequence test
  • Loading branch information
cffls authored Jan 8, 2025
1 parent 7b47ba3 commit 7490690
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
12 changes: 11 additions & 1 deletion .github/scripts/test_resequence.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ kurtosis service exec cdk-v1 cdk-erigon-sequencer-001 "nohup cdk-erigon --pprof=
# Wait for cdk-erigon to start
sleep 30

num_requests=2000

echo "Running loadtest using polycli"
/usr/local/bin/polycli loadtest --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-rpc-001 rpc)" --private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" --verbosity 600 --requests 2000 --rate-limit 500 --mode uniswapv3 --legacy
/usr/local/bin/polycli loadtest --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-rpc-001 rpc)" --private-key "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625" --verbosity 600 --requests $num_requests --rate-limit 500 --mode uniswapv3 --legacy

echo "Waiting for batch virtualization"
if ! wait_for_l1_batch 600 "virtual"; then
Expand Down Expand Up @@ -193,6 +195,14 @@ else
exit 1
fi

echo "Check the nonce of the account is > 2000"
nonce=$(cast nonce "0xE34aaF64b29273B7D567FCFc40544c014EEe9970" --rpc-url "$(kurtosis port print cdk-v1 cdk-erigon-rpc-001 rpc)")
echo "Nonce: $nonce"
if [ "$nonce" -lt $num_requests ]; then
echo "Nonce $nonce is less than $num_requests, which means some txns were not resequenced successfully"
exit 1
fi

echo "Waiting for batch verification"
if ! wait_for_l1_batch 1200 "verified"; then
echo "Failed to wait for batch verification"
Expand Down
11 changes: 6 additions & 5 deletions zk/stages/stage_sequence_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func SpawnSequencingStage(
return err
}

if lastSequence != nil && lastBatch < lastSequence.BatchNo && !cfg.zk.IsL1Recovery() {
if lastSequence != nil && lastBatch < lastSequence.BatchNo && !(cfg.zk.IsL1Recovery() || cfg.zk.SequencerResequence) {
panic(fmt.Sprintf("lastBatch %d < lastSequence.BatchNo %d", lastBatch, lastSequence.BatchNo))
}

Expand All @@ -58,10 +58,11 @@ func SpawnSequencingStage(
}

if lastBatch < highestBatchInDs {
if err = cfg.dataStreamServer.UnwindToBatchStart(lastBatch + 1); err != nil {
return err
}
if !cfg.zk.IsL1Recovery() {
if !cfg.zk.SequencerResequence {
if err = cfg.dataStreamServer.UnwindToBatchStart(lastBatch + 1); err != nil {
return err
}
} else {
return resequence(s, u, ctx, cfg, historyCfg, lastBatch, highestBatchInDs)
}
}
Expand Down
4 changes: 4 additions & 0 deletions zk/stages/stage_sequence_execute_resequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func resequence(
return err
}

if err = cfg.dataStreamServer.UnwindToBatchStart(lastBatch + 1); err != nil {
return err
}

log.Info(fmt.Sprintf("[%s] Resequence from batch %d to %d in data stream", s.LogPrefix(), lastBatch+1, highestBatchInDs))
for _, batch := range batches {
batchJob := NewResequenceBatchJob(batch)
Expand Down

0 comments on commit 7490690

Please sign in to comment.