check for TransactionsV3 flag (#6988)

This commit is contained in:
nanevardanyan 2023-03-01 06:13:12 +04:00 committed by GitHub
parent f97550c48f
commit cf9ee425ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 6 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {