mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
Truncate bor receipts on unwind (#4033)
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
parent
93ab7f5d82
commit
e0d7998eb0
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/common/dbutils"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
"github.com/ledgerwatch/erigon/rlp"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
@ -147,3 +148,13 @@ func ReadBorTransaction(db kv.Tx, hash common.Hash) (*types.Transaction, common.
|
||||
var tx types.Transaction = types.NewBorTransaction()
|
||||
return &tx, blockHash, *blockNumber, uint64(bodyForStorage.TxAmount), nil
|
||||
}
|
||||
|
||||
// TruncateBorReceipts removes all bor receipt for given block number or newer
|
||||
func TruncateBorReceipts(db kv.RwTx, number uint64) error {
|
||||
if err := db.ForEach(kv.BorReceipts, dbutils.EncodeBlockNumber(number), func(k, _ []byte) error {
|
||||
return db.Delete(kv.BorReceipts, k, nil)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -520,10 +520,13 @@ func unwindExecutionStage(u *UnwindState, s *StageState, tx kv.RwTx, quit <-chan
|
||||
}
|
||||
|
||||
if err := rawdb.TruncateReceipts(tx, u.UnwindPoint+1); err != nil {
|
||||
return fmt.Errorf("walking receipts: %w", err)
|
||||
return fmt.Errorf("truncate receipts: %w", err)
|
||||
}
|
||||
if err := rawdb.TruncateBorReceipts(tx, u.UnwindPoint+1); err != nil {
|
||||
return fmt.Errorf("truncate bor receipts: %w", err)
|
||||
}
|
||||
if err := rawdb.DeleteNewerEpochs(tx, u.UnwindPoint+1); err != nil {
|
||||
return fmt.Errorf("walking epoch: %w", err)
|
||||
return fmt.Errorf("delete newer epochs: %w", err)
|
||||
}
|
||||
|
||||
// Truncate CallTraceSet
|
||||
|
Loading…
Reference in New Issue
Block a user