diff --git a/cmd/erigon-cl/stages/stages_beacon_state.go b/cmd/erigon-cl/stages/stages_beacon_state.go index 221546caa..919498f4b 100644 --- a/cmd/erigon-cl/stages/stages_beacon_state.go +++ b/cmd/erigon-cl/stages/stages_beacon_state.go @@ -3,8 +3,8 @@ package stages import ( "context" "fmt" - "github.com/ledgerwatch/erigon-lib/kv" + "github.com/ledgerwatch/erigon-lib/kv/kvcfg" "github.com/ledgerwatch/erigon/cl/clparams" "github.com/ledgerwatch/erigon/cl/cltypes" "github.com/ledgerwatch/erigon/cmd/erigon-cl/core/rawdb" @@ -105,7 +105,12 @@ func SpawnStageBeaconState(cfg StageBeaconStateCfg, s *stagedsync.StageState, tx if err := tx.ClearBucket(kv.BlockBody); err != nil { return err } - if err := tx.ClearBucket(kv.EthTx); err != nil { + ethTx := kv.EthTx + transactionsV3, _ := kvcfg.TransactionsV3.Enabled(tx) + if transactionsV3 { + ethTx = kv.EthTxV3 + } + if err := tx.ClearBucket(ethTx); err != nil { return err } if err := tx.ClearBucket(kv.Sequence); err != nil { diff --git a/cmd/integration/commands/reset_state.go b/cmd/integration/commands/reset_state.go index 5c75e40fe..dfd1591ee 100644 --- a/cmd/integration/commands/reset_state.go +++ b/cmd/integration/commands/reset_state.go @@ -103,7 +103,13 @@ func printStages(tx kv.Tx, snapshots *snapshotsync.RoSnapshots, agg *state.Aggre _, lastBlockInHistSnap, _ := rawdbv3.TxNums.FindBlockNum(tx, agg.EndTxNumMinimax()) fmt.Fprintf(w, "history.v3: %t, idx steps: %.02f, lastMaxTxNum=%d->%d, lastBlockInSnap=%d\n\n", h3, rawdbhelpers.IdxStepsCountV3(tx), u64or0(lastK), u64or0(lastV), lastBlockInHistSnap) - s1, err := tx.ReadSequence(kv.EthTx) + transactionsV3, _ := kvcfg.TransactionsV3.Enabled(tx) + var s1 uint64 + if transactionsV3 { + s1, err = tx.ReadSequence(kv.EthTxV3) + } else { + s1, err = tx.ReadSequence(kv.EthTx) + } if err != nil { return err } diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index f747b300d..9234469cb 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -770,7 +770,11 @@ func MakeBodiesCanonical(tx kv.RwTx, from uint64, ctx context.Context, logPrefix if err := rlp.DecodeBytes(data, bodyForStorage); err != nil { return err } - newBaseId, err := tx.IncrementSequence(kv.EthTx, uint64(bodyForStorage.TxAmount)) + ethTx := kv.EthTx + if transactionsV3 { + ethTx = kv.EthTxV3 + } + newBaseId, err := tx.IncrementSequence(ethTx, uint64(bodyForStorage.TxAmount)) if err != nil { return err } diff --git a/core/rawdb/rawdbreset/reset_stages.go b/core/rawdb/rawdbreset/reset_stages.go index 10a5e7edd..687a08c38 100644 --- a/core/rawdb/rawdbreset/reset_stages.go +++ b/core/rawdb/rawdbreset/reset_stages.go @@ -90,15 +90,20 @@ func ResetBlocks(tx kv.RwTx, db kv.RoDB, snapshots *snapshotsync.RoSnapshots, ag if err := tx.ForEach(kv.BlockBody, hexutility.EncodeTs(2), func(k, _ []byte) error { return tx.Delete(kv.BlockBody, k) }); err != nil { return err } + ethtx := kv.EthTx + transactionV3, _ := kvcfg.TransactionsV3.Enabled(db.(kv.Tx)) + if transactionV3 { + ethtx = kv.EthTxV3 + } if err := clearTables(context.Background(), db, tx, kv.NonCanonicalTxs, - kv.EthTx, + ethtx, kv.MaxTxNum, ); err != nil { return err } - if err := rawdb.ResetSequence(tx, kv.EthTx, 0); err != nil { + if err := rawdb.ResetSequence(tx, ethtx, 0); err != nil { return err } if err := rawdb.ResetSequence(tx, kv.NonCanonicalTxs, 0); err != nil {