From 6cdcff6275df9f8422712eb54410d3fca906bb85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Tue, 10 Sep 2024 14:59:42 +0300 Subject: [PATCH] fix: reuse timestamp for blocks failing CCC (#1031) we assume that same height wont trigger multiple reorgs to be able to put an upper bound on the reorg depth. We rely on the fact that AsyncChecker executes transactions one-by-one and tells worker the safe set of transactions to include in the replacement block that wont trigger another error on the same block. If worker changes the timestamp and that causes significant changes to the execution flow of included transactions; we might have a height where multiple reorgs happen. --- miner/scroll_worker.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/miner/scroll_worker.go b/miner/scroll_worker.go index b79c706be534..1a2673a80586 100644 --- a/miner/scroll_worker.go +++ b/miner/scroll_worker.go @@ -440,6 +440,13 @@ func (w *worker) newWork(now time.Time, parentHash common.Hash, reorgReason erro Time: uint64(now.Unix()), } + if reorgReason != nil { + // if we are replacing a failing block, reuse the timestamp to make sure + // the information we get from AsyncChecker is reliable. Changing timestamp + // might alter execution flow of reorged transactions. + header.Time = w.chain.GetHeaderByNumber(header.Number.Uint64()).Time + } + parentState, err := w.chain.StateAt(parent.Root()) if err != nil { return fmt.Errorf("failed to fetch parent state: %w", err)