Commit 92310636 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

fix: geth miner timestamp bug (#836)

* l2geth: use correct timestamp protection

* chore: add changeset
parent 2479b4ab
---
'@eth-optimism/l2geth': patch
---
Prevent montonicity errors in the miner
...@@ -863,12 +863,11 @@ func (w *worker) commitNewTx(tx *types.Transaction) error { ...@@ -863,12 +863,11 @@ func (w *worker) commitNewTx(tx *types.Transaction) error {
tstart := time.Now() tstart := time.Now()
parent := w.chain.CurrentBlock() parent := w.chain.CurrentBlock()
timestamp := tx.L1Timestamp()
num := parent.Number() num := parent.Number()
// Preserve liveliness as best as possible. Must panic on L1 to L2 // Preserve liveliness as best as possible. Must panic on L1 to L2
// transactions as the timestamp cannot be malleated // transactions as the timestamp cannot be malleated
if parent.Time() > timestamp { if parent.Time() > tx.L1Timestamp() {
log.Error("Monotonicity violation", "index", num) log.Error("Monotonicity violation", "index", num)
if tx.QueueOrigin().Uint64() == uint64(types.QueueOriginSequencer) { if tx.QueueOrigin().Uint64() == uint64(types.QueueOriginSequencer) {
tx.SetL1Timestamp(parent.Time()) tx.SetL1Timestamp(parent.Time())
...@@ -898,7 +897,7 @@ func (w *worker) commitNewTx(tx *types.Transaction) error { ...@@ -898,7 +897,7 @@ func (w *worker) commitNewTx(tx *types.Transaction) error {
Number: num.Add(num, common.Big1), Number: num.Add(num, common.Big1),
GasLimit: w.config.GasFloor, GasLimit: w.config.GasFloor,
Extra: w.extra, Extra: w.extra,
Time: timestamp, Time: tx.L1Timestamp(),
} }
if err := w.engine.Prepare(w.chain, header); err != nil { if err := w.engine.Prepare(w.chain, header); err != nil {
return fmt.Errorf("Failed to prepare header for mining: %w", err) return fmt.Errorf("Failed to prepare header for mining: %w", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment