From d31039ef7dbd0e1d7b5beb67207740a735d5451d Mon Sep 17 00:00:00 2001 From: rian Date: Thu, 3 Oct 2024 11:42:55 +0300 Subject: [PATCH] handler db deletions on reorg --- blockchain/blockchain.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 46effbf07..27901e011 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -375,7 +375,6 @@ func (b *Blockchain) Store(block *core.Block, blockCommitments *core.BlockCommit return err } - // Todo: also handle deletion / reverts etc if err := storeL1HandlerMsgHashes(txn, block); err != nil { return err } @@ -919,7 +918,6 @@ func (b *Blockchain) revertHead(txn db.Transaction) error { } // Revert chain height and pending. - if genesisBlock { if err = txn.Delete(db.Pending.Key()); err != nil { return err @@ -962,6 +960,11 @@ func removeTxsAndReceipts(txn db.Transaction, blockNumber, numTxs uint64) error if err = txn.Delete(db.TransactionBlockNumbersAndIndicesByHash.Key(reorgedTxn.Hash().Marshal())); err != nil { return err } + if l1handler, ok := reorgedTxn.(*core.L1HandlerTransaction); ok { + if err = txn.Delete(db.L1HandlerTxnHash.Key(l1handler.MessageHash())); err != nil { + return err + } + } } return nil