mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
remove txsV3 cli flag (#7644)
This commit is contained in:
parent
ad72b7178e
commit
63c92010cd
@ -52,15 +52,14 @@ func main() {
|
||||
}
|
||||
|
||||
func blocksIO(db kv.RoDB) (services.FullBlockReader, *blockio.BlockWriter) {
|
||||
var histV3, transactionsV3 bool
|
||||
var histV3 bool
|
||||
if err := db.View(context.Background(), func(tx kv.Tx) error {
|
||||
transactionsV3, _ = kvcfg.TransactionsV3.Enabled(tx)
|
||||
histV3, _ = kvcfg.HistoryV3.Enabled(tx)
|
||||
return nil
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), transactionsV3)
|
||||
bw := blockio.NewBlockWriter(histV3, transactionsV3)
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
bw := blockio.NewBlockWriter(histV3)
|
||||
return br, bw
|
||||
}
|
||||
|
@ -192,11 +192,6 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
|
||||
return err
|
||||
}
|
||||
|
||||
config.TransactionsV3, err = kvcfg.TransactionsV3.WriteOnce(tx, config.TransactionsV3)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
isCorrectSync, useSnapshots, err := snap.EnsureNotChanged(tx, config.Snapshot)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -234,7 +229,7 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
|
||||
var (
|
||||
allSnapshots *snapshotsync.RoSnapshots
|
||||
)
|
||||
blockReader, blockWriter, allSnapshots, agg, err := setUpBlockReader(ctx, chainKv, config.Dirs, config.Snapshot, config.HistoryV3, config.TransactionsV3, logger)
|
||||
blockReader, blockWriter, allSnapshots, agg, err := setUpBlockReader(ctx, chainKv, config.Dirs, config.Snapshot, config.HistoryV3, logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -903,14 +898,14 @@ func (s *Ethereum) setUpSnapDownloader(ctx context.Context, downloaderCfg *downl
|
||||
return err
|
||||
}
|
||||
|
||||
func setUpBlockReader(ctx context.Context, db kv.RwDB, dirs datadir.Dirs, snConfig ethconfig.Snapshot, histV3, transactionsV3 bool, logger log.Logger) (services.FullBlockReader, *blockio.BlockWriter, *snapshotsync.RoSnapshots, *libstate.AggregatorV3, error) {
|
||||
func setUpBlockReader(ctx context.Context, db kv.RwDB, dirs datadir.Dirs, snConfig ethconfig.Snapshot, histV3 bool, logger log.Logger) (services.FullBlockReader, *blockio.BlockWriter, *snapshotsync.RoSnapshots, *libstate.AggregatorV3, error) {
|
||||
allSnapshots := snapshotsync.NewRoSnapshots(snConfig, dirs.Snap, logger)
|
||||
var err error
|
||||
if !snConfig.NoDownloader {
|
||||
allSnapshots.OptimisticalyReopenWithDB(db)
|
||||
}
|
||||
blockReader := snapshotsync.NewBlockReader(allSnapshots, transactionsV3)
|
||||
blockWriter := blockio.NewBlockWriter(histV3, transactionsV3)
|
||||
blockReader := snapshotsync.NewBlockReader(allSnapshots)
|
||||
blockWriter := blockio.NewBlockWriter(histV3)
|
||||
|
||||
dir.MustExist(dirs.SnapHistory)
|
||||
agg, err := libstate.NewAggregatorV3(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
|
||||
|
@ -131,16 +131,15 @@ func printCurrentBlockNumber(chaindata string) {
|
||||
}
|
||||
|
||||
func blocksIO(db kv.RoDB) (services.FullBlockReader, *blockio.BlockWriter) {
|
||||
var histV3, transactionsV3 bool
|
||||
var histV3 bool
|
||||
if err := db.View(context.Background(), func(tx kv.Tx) error {
|
||||
transactionsV3, _ = kvcfg.TransactionsV3.Enabled(tx)
|
||||
histV3, _ = kvcfg.HistoryV3.Enabled(tx)
|
||||
return nil
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), transactionsV3)
|
||||
bw := blockio.NewBlockWriter(histV3, transactionsV3)
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
bw := blockio.NewBlockWriter(histV3)
|
||||
return br, bw
|
||||
}
|
||||
|
||||
|
@ -35,19 +35,6 @@ func PruneMode(db kv.RoDB) (pm prune.Mode) {
|
||||
}
|
||||
return
|
||||
}
|
||||
func TxsV3(db kv.RoDB) (enabled bool) {
|
||||
if err := db.View(context.Background(), func(tx kv.Tx) error {
|
||||
var err error
|
||||
enabled, err = kvcfg.TransactionsV3.Enabled(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
func HistV3(db kv.RoDB) (enabled bool) {
|
||||
if err := db.View(context.Background(), func(tx kv.Tx) error {
|
||||
var err error
|
||||
|
@ -107,17 +107,13 @@ func printStages(tx kv.Tx, snapshots *snapshotsync.RoSnapshots, agg *state.Aggre
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
txs3, err := kvcfg.TransactionsV3.Enabled(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lastK, lastV, err := rawdbv3.Last(tx, kv.MaxTxNum)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, lastBlockInHistSnap, _ := rawdbv3.TxNums.FindBlockNum(tx, agg.EndTxNumMinimax())
|
||||
fmt.Fprintf(w, "history.v3: %t, txs.v3: %t, idx steps: %.02f, lastMaxTxNum=%d->%d, lastBlockInSnap=%d\n\n", h3, txs3, rawdbhelpers.IdxStepsCountV3(tx), u64or0(lastK), u64or0(lastV), lastBlockInHistSnap)
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1412,10 +1412,9 @@ var _blockWriterSingleton *blockio.BlockWriter
|
||||
func blocksIO(db kv.RoDB, logger log.Logger) (services.FullBlockReader, *blockio.BlockWriter) {
|
||||
openBlockReaderOnce.Do(func() {
|
||||
sn, _ := allSnapshots(context.Background(), db, logger)
|
||||
transactionsV3 := kvcfg.TransactionsV3.FromDB(db)
|
||||
histV3 := kvcfg.HistoryV3.FromDB(db)
|
||||
_blockReaderSingleton = snapshotsync.NewBlockReader(sn, transactionsV3)
|
||||
_blockWriterSingleton = blockio.NewBlockWriter(histV3, transactionsV3)
|
||||
_blockReaderSingleton = snapshotsync.NewBlockReader(sn)
|
||||
_blockWriterSingleton = blockio.NewBlockWriter(histV3)
|
||||
})
|
||||
return _blockReaderSingleton, _blockWriterSingleton
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ func RemoteServices(ctx context.Context, cfg httpcfg.HttpCfg, logger log.Logger,
|
||||
}()
|
||||
}
|
||||
onNewSnapshot()
|
||||
blockReader = snapshotsync.NewBlockReader(allSnapshots, ethconfig.Defaults.TransactionsV3)
|
||||
blockReader = snapshotsync.NewBlockReader(allSnapshots)
|
||||
|
||||
var histV3Enabled bool
|
||||
_ = db.View(ctx, func(tx kv.Tx) error {
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/temporal/historyv2"
|
||||
"github.com/ledgerwatch/erigon/cmd/utils"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@ -31,9 +30,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
historyfile string
|
||||
nocheck bool
|
||||
transactionsV3 bool
|
||||
historyfile string
|
||||
nocheck bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -42,7 +40,6 @@ func init() {
|
||||
withSnapshotBlocks(checkChangeSetsCmd)
|
||||
checkChangeSetsCmd.Flags().StringVar(&historyfile, "historyfile", "", "path to the file where the changesets and history are expected to be. If omitted, the same as <datadir>/erion/chaindata")
|
||||
checkChangeSetsCmd.Flags().BoolVar(&nocheck, "nocheck", false, "set to turn off the changeset checking and only execute transaction (for performance testing)")
|
||||
checkChangeSetsCmd.Flags().BoolVar(&transactionsV3, utils.TransactionV3Flag.Name, utils.TransactionV3Flag.Value, utils.TransactionV3Flag.Usage)
|
||||
rootCmd.AddCommand(checkChangeSetsCmd)
|
||||
}
|
||||
|
||||
@ -56,13 +53,13 @@ var checkChangeSetsCmd = &cobra.Command{
|
||||
logger.Error("Setting up", "error", err)
|
||||
return err
|
||||
}
|
||||
return CheckChangeSets(genesis, logger, block, chaindata, historyfile, nocheck, transactionsV3)
|
||||
return CheckChangeSets(genesis, logger, block, chaindata, historyfile, nocheck)
|
||||
},
|
||||
}
|
||||
|
||||
// CheckChangeSets re-executes historical transactions in read-only mode
|
||||
// and checks that their outputs match the database ChangeSets.
|
||||
func CheckChangeSets(genesis *types.Genesis, logger log.Logger, blockNum uint64, chaindata string, historyfile string, nocheck bool, transactionV3 bool) error {
|
||||
func CheckChangeSets(genesis *types.Genesis, logger log.Logger, blockNum uint64, chaindata string, historyfile string, nocheck bool) error {
|
||||
if len(historyfile) == 0 {
|
||||
historyfile = chaindata
|
||||
}
|
||||
@ -86,7 +83,7 @@ func CheckChangeSets(genesis *types.Genesis, logger log.Logger, blockNum uint64,
|
||||
if err := allSnapshots.ReopenFolder(); err != nil {
|
||||
return fmt.Errorf("reopen snapshot segments: %w", err)
|
||||
}
|
||||
blockReader := snapshotsync.NewBlockReader(allSnapshots, transactionV3)
|
||||
blockReader := snapshotsync.NewBlockReader(allSnapshots)
|
||||
|
||||
chainDb := db
|
||||
defer chainDb.Close()
|
||||
|
@ -241,9 +241,7 @@ func Erigon4(genesis *types.Genesis, chainConfig *chain2.Config, logger log.Logg
|
||||
if err := allSnapshots.ReopenFolder(); err != nil {
|
||||
return fmt.Errorf("reopen snapshot segments: %w", err)
|
||||
}
|
||||
//transactionsV3 := kvcfg.TransactionsV3.FromDB(db)
|
||||
transactionsV3 := false
|
||||
blockReader = snapshotsync.NewBlockReader(allSnapshots, transactionsV3)
|
||||
blockReader = snapshotsync.NewBlockReader(allSnapshots)
|
||||
engine := initConsensusEngine(chainConfig, allSnapshots, logger)
|
||||
|
||||
getHeader := func(hash libcommon.Hash, number uint64) *types.Header {
|
||||
|
@ -421,19 +421,15 @@ func OpcodeTracer(genesis *types.Genesis, blockNum uint64, chaindata string, num
|
||||
}
|
||||
defer historyTx.Rollback()
|
||||
|
||||
var historyV3, txsV3 bool
|
||||
var historyV3 bool
|
||||
chainDb.View(context.Background(), func(tx kv.Tx) (err error) {
|
||||
historyV3, err = kvcfg.HistoryV3.Enabled(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
txsV3, err = kvcfg.TransactionsV3.Enabled(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), txsV3)
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
|
||||
chainConfig := genesis.Config
|
||||
vmConfig := vm.Config{Tracer: ot, Debug: true}
|
||||
|
@ -53,16 +53,15 @@ var stateRootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func blocksIO(db kv.RoDB) (services.FullBlockReader, *blockio.BlockWriter) {
|
||||
var histV3, transactionsV3 bool
|
||||
var histV3 bool
|
||||
if err := db.View(context.Background(), func(tx kv.Tx) error {
|
||||
transactionsV3, _ = kvcfg.TransactionsV3.Enabled(tx)
|
||||
histV3, _ = kvcfg.HistoryV3.Enabled(tx)
|
||||
return nil
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), transactionsV3)
|
||||
bw := blockio.NewBlockWriter(histV3, transactionsV3)
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
bw := blockio.NewBlockWriter(histV3)
|
||||
return br, bw
|
||||
}
|
||||
|
||||
|
@ -21,16 +21,15 @@ import (
|
||||
)
|
||||
|
||||
func blocksIO(db kv.RoDB) (services.FullBlockReader, *blockio.BlockWriter) {
|
||||
var histV3, transactionsV3 bool
|
||||
var histV3 bool
|
||||
if err := db.View(context.Background(), func(tx kv.Tx) error {
|
||||
transactionsV3, _ = kvcfg.TransactionsV3.Enabled(tx)
|
||||
histV3, _ = kvcfg.HistoryV3.Enabled(tx)
|
||||
return nil
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), transactionsV3)
|
||||
bw := blockio.NewBlockWriter(histV3, transactionsV3)
|
||||
br := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
bw := blockio.NewBlockWriter(histV3)
|
||||
return br, bw
|
||||
}
|
||||
|
||||
|
@ -618,10 +618,6 @@ var (
|
||||
Name: "experimental.history.v3",
|
||||
Usage: "(also known as Erigon3) Not recommended yet: Can't change this flag after node creation. New DB and Snapshots format of history allows: parallel blocks execution, get state as of given transaction without executing whole block.",
|
||||
}
|
||||
TransactionV3Flag = cli.BoolFlag{
|
||||
Name: "experimental.transactions.v3",
|
||||
Usage: "(this flag is in testing stage) Not recommended yet: Can't change this flag after node creation. New DB table for transactions allows keeping multiple branches of block bodies in the DB simultaneously",
|
||||
}
|
||||
|
||||
CliqueSnapshotCheckpointIntervalFlag = cli.UintFlag{
|
||||
Name: "clique.checkpoint",
|
||||
@ -1502,7 +1498,6 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
|
||||
cfg.Ethstats = ctx.String(EthStatsURLFlag.Name)
|
||||
cfg.P2PEnabled = len(nodeConfig.P2P.SentryAddr) == 0
|
||||
cfg.HistoryV3 = ctx.Bool(HistoryV3Flag.Name)
|
||||
cfg.TransactionsV3 = ctx.Bool(TransactionV3Flag.Name)
|
||||
if ctx.IsSet(NetworkIdFlag.Name) {
|
||||
cfg.NetworkID = ctx.Uint64(NetworkIdFlag.Name)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
|
||||
func TestGenesisBlockHashes(t *testing.T) {
|
||||
logger := log.New()
|
||||
_, _, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(t.TempDir()), nil, logger)
|
||||
_, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(t.TempDir()), nil, logger)
|
||||
check := func(network string) {
|
||||
genesis := core.GenesisBlockByChainName(network)
|
||||
tx, err := db.BeginRw(context.Background())
|
||||
@ -74,7 +74,7 @@ func TestGenesisBlockRoots(t *testing.T) {
|
||||
|
||||
func TestCommitGenesisIdempotency(t *testing.T) {
|
||||
logger := log.New()
|
||||
_, _, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(t.TempDir()), nil, logger)
|
||||
_, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(t.TempDir()), nil, logger)
|
||||
tx, err := db.BeginRw(context.Background())
|
||||
require.NoError(t, err)
|
||||
defer tx.Rollback()
|
||||
@ -111,7 +111,7 @@ func TestAllocConstructor(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
historyV3, _, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(t.TempDir()), nil, logger)
|
||||
historyV3, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(t.TempDir()), nil, logger)
|
||||
_, _, err := core.CommitGenesisBlock(db, genSpec, "", logger)
|
||||
require.NoError(err)
|
||||
|
||||
|
@ -248,15 +248,11 @@ func write(tx kv.RwTx, g *types.Genesis, tmpDir string) (*types.Block, *state.In
|
||||
if err := config.CheckConfigForkOrder(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
transactionV3, err := kvcfg.TransactionsV3.Enabled(tx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
histV3, err := kvcfg.HistoryV3.Enabled(tx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
blockWriter := blockio.NewBlockWriter(histV3, transactionV3)
|
||||
blockWriter := blockio.NewBlockWriter(histV3)
|
||||
|
||||
if err := blockWriter.WriteBlock(tx, block); err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -32,8 +32,8 @@ type BlockWriter struct {
|
||||
txsV3 bool
|
||||
}
|
||||
|
||||
func NewBlockWriter(historyV3, txsV3 bool) *BlockWriter {
|
||||
return &BlockWriter{historyV3: historyV3, txsV3: txsV3}
|
||||
func NewBlockWriter(historyV3 bool) *BlockWriter {
|
||||
return &BlockWriter{historyV3: historyV3, txsV3: false}
|
||||
}
|
||||
|
||||
func (w *BlockWriter) TxsV3Enabled() bool { return w.txsV3 }
|
||||
|
@ -39,7 +39,7 @@ import (
|
||||
|
||||
func getBlock(tb testing.TB, transactions int, uncles int, dataSize int, tmpDir string) *types.Block {
|
||||
logger := log.New()
|
||||
_, _, db, _ := temporal.NewTestDB(tb, context.Background(), datadir.New(tmpDir), nil, logger)
|
||||
_, db, _ := temporal.NewTestDB(tb, context.Background(), datadir.New(tmpDir), nil, logger)
|
||||
var (
|
||||
aa = libcommon.HexToAddress("0x000000000000000000000000000000000000aaaa")
|
||||
// Generate a canonical chain to act as the main dataset
|
||||
|
@ -490,9 +490,8 @@ func (tx *Tx) HistoryRange(name kv.History, fromTs, toTs int, asc order.By, limi
|
||||
}
|
||||
|
||||
// TODO: need remove `gspec` param (move SystemContractCodeLookup feature somewhere)
|
||||
func NewTestDB(tb testing.TB, ctx context.Context, dirs datadir.Dirs, gspec *types.Genesis, logger log.Logger) (histV3, txsV3 bool, db kv.RwDB, agg *state.AggregatorV3) {
|
||||
HistoryV3 := ethconfig.EnableHistoryV3InTest
|
||||
TxsV3 := ethconfig.EnableTxsV3InTest
|
||||
func NewTestDB(tb testing.TB, ctx context.Context, dirs datadir.Dirs, gspec *types.Genesis, logger log.Logger) (histV3 bool, db kv.RwDB, agg *state.AggregatorV3) {
|
||||
historyV3 := ethconfig.EnableHistoryV3InTest
|
||||
|
||||
if tb != nil {
|
||||
db = memdb.NewTestDB(tb)
|
||||
@ -500,12 +499,11 @@ func NewTestDB(tb testing.TB, ctx context.Context, dirs datadir.Dirs, gspec *typ
|
||||
db = memdb.New(dirs.DataDir)
|
||||
}
|
||||
_ = db.UpdateNosync(context.Background(), func(tx kv.RwTx) error {
|
||||
_, _ = kvcfg.HistoryV3.WriteOnce(tx, HistoryV3)
|
||||
_, _ = kvcfg.TransactionsV3.WriteOnce(tx, TxsV3)
|
||||
_, _ = kvcfg.HistoryV3.WriteOnce(tx, historyV3)
|
||||
return nil
|
||||
})
|
||||
|
||||
if HistoryV3 {
|
||||
if historyV3 {
|
||||
var err error
|
||||
dir.MustExist(dirs.SnapHistory)
|
||||
agg, err = state.NewAggregatorV3(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
|
||||
@ -526,5 +524,5 @@ func NewTestDB(tb testing.TB, ctx context.Context, dirs datadir.Dirs, gspec *typ
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return HistoryV3, TxsV3, db, agg
|
||||
return historyV3, db, agg
|
||||
}
|
||||
|
@ -225,11 +225,6 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
|
||||
return err
|
||||
}
|
||||
|
||||
config.TransactionsV3, err = kvcfg.TransactionsV3.WriteOnce(tx, config.TransactionsV3)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
isCorrectSync, useSnapshots, err := snap.EnsureNotChanged(tx, config.Snapshot)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -264,7 +259,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
|
||||
logger: logger,
|
||||
}
|
||||
|
||||
blockReader, blockWriter, allSnapshots, agg, err := setUpBlockReader(ctx, chainKv, config.Dirs, config.Snapshot, config.HistoryV3, config.TransactionsV3, logger)
|
||||
blockReader, blockWriter, allSnapshots, agg, err := setUpBlockReader(ctx, chainKv, config.Dirs, config.Snapshot, config.HistoryV3, logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1030,14 +1025,14 @@ func (s *Ethereum) setUpSnapDownloader(ctx context.Context, downloaderCfg *downl
|
||||
return err
|
||||
}
|
||||
|
||||
func setUpBlockReader(ctx context.Context, db kv.RwDB, dirs datadir.Dirs, snConfig ethconfig.Snapshot, histV3, transactionsV3 bool, logger log.Logger) (services.FullBlockReader, *blockio.BlockWriter, *snapshotsync.RoSnapshots, *libstate.AggregatorV3, error) {
|
||||
func setUpBlockReader(ctx context.Context, db kv.RwDB, dirs datadir.Dirs, snConfig ethconfig.Snapshot, histV3 bool, logger log.Logger) (services.FullBlockReader, *blockio.BlockWriter, *snapshotsync.RoSnapshots, *libstate.AggregatorV3, error) {
|
||||
allSnapshots := snapshotsync.NewRoSnapshots(snConfig, dirs.Snap, logger)
|
||||
var err error
|
||||
if !snConfig.NoDownloader {
|
||||
allSnapshots.OptimisticalyReopenWithDB(db)
|
||||
}
|
||||
blockReader := snapshotsync.NewBlockReader(allSnapshots, transactionsV3)
|
||||
blockWriter := blockio.NewBlockWriter(histV3, transactionsV3)
|
||||
blockReader := snapshotsync.NewBlockReader(allSnapshots)
|
||||
blockWriter := blockio.NewBlockWriter(histV3)
|
||||
|
||||
dir.MustExist(dirs.SnapHistory)
|
||||
agg, err := libstate.NewAggregatorV3(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
|
||||
|
@ -230,9 +230,6 @@ type Config struct {
|
||||
// gRPC Address to connect to Heimdall node
|
||||
HeimdallgRPCAddress string
|
||||
|
||||
// New DB table for storing transactions allows: keeping multiple branches of block bodies in the DB simultaneously
|
||||
TransactionsV3 bool
|
||||
|
||||
// URL to connect to Heimdall node
|
||||
HeimdallURL string
|
||||
|
||||
|
@ -4,4 +4,3 @@ package ethconfig
|
||||
|
||||
const EnableHistoryV3InTest = false
|
||||
const EnableHistoryV4InTest = false
|
||||
const EnableTxsV3InTest = false
|
||||
|
@ -4,4 +4,3 @@ package ethconfig
|
||||
|
||||
const EnableHistoryV3InTest = true
|
||||
const EnableHistoryV4InTest = false
|
||||
const EnableTxsV3InTest = false
|
||||
|
@ -4,4 +4,3 @@ package ethconfig
|
||||
|
||||
const EnableHistoryV3InTest = true
|
||||
const EnableHistoryV4InTest = true
|
||||
const EnableTxsV3InTest = false
|
||||
|
@ -37,7 +37,6 @@ type BodiesCfg struct {
|
||||
blockReader services.FullBlockReader
|
||||
blockWriter *blockio.BlockWriter
|
||||
historyV3 bool
|
||||
transactionsV3 bool
|
||||
}
|
||||
|
||||
func StageBodiesCfg(db kv.RwDB, bd *bodydownload.BodyDownload,
|
||||
|
@ -79,7 +79,7 @@ func TestAccountAndStorageTrie(t *testing.T) {
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
historyV3 := false
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), false)
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
cfg := StageTrieCfg(db, false, true, false, t.TempDir(), blockReader, nil, historyV3, nil)
|
||||
_, err := RegenerateIntermediateHashes("IH", tx, cfg, libcommon.Hash{} /* expectedRootHash */, ctx, log.New())
|
||||
assert.Nil(t, err)
|
||||
@ -201,7 +201,7 @@ func TestAccountTrieAroundExtensionNode(t *testing.T) {
|
||||
hash6 := libcommon.HexToHash("0x3100000000000000000000000000000000000000000000000000000000000000")
|
||||
assert.Nil(t, tx.Put(kv.HashedAccounts, hash6[:], encoded))
|
||||
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), false)
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
_, err := RegenerateIntermediateHashes("IH", tx, StageTrieCfg(db, false, true, false, t.TempDir(), blockReader, nil, historyV3, nil), libcommon.Hash{} /* expectedRootHash */, ctx, log.New())
|
||||
assert.Nil(t, err)
|
||||
|
||||
@ -264,7 +264,7 @@ func TestStorageDeletion(t *testing.T) {
|
||||
// Populate account & storage trie DB tables
|
||||
// ----------------------------------------------------------------
|
||||
historyV3 := false
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), false)
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
cfg := StageTrieCfg(db, false, true, false, t.TempDir(), blockReader, nil, historyV3, nil)
|
||||
_, err = RegenerateIntermediateHashes("IH", tx, cfg, libcommon.Hash{} /* expectedRootHash */, ctx, log.New())
|
||||
assert.Nil(t, err)
|
||||
@ -383,7 +383,7 @@ func TestHiveTrieRoot(t *testing.T) {
|
||||
common.FromHex("02081bc16d674ec80000")))
|
||||
|
||||
historyV3 := false
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), false)
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
cfg := StageTrieCfg(db, false, true, false, t.TempDir(), blockReader, nil, historyV3, nil)
|
||||
logger := log.New()
|
||||
_, err := RegenerateIntermediateHashes("IH", tx, cfg, libcommon.Hash{} /* expectedRootHash */, ctx, logger)
|
||||
|
@ -415,8 +415,8 @@ func doRetireCommand(cliCtx *cli.Context) error {
|
||||
if err := snapshots.ReopenFolder(); err != nil {
|
||||
return err
|
||||
}
|
||||
blockReader := snapshotsync.NewBlockReader(snapshots, fromdb.TxsV3(db))
|
||||
blockWriter := blockio.NewBlockWriter(fromdb.HistV3(db), fromdb.TxsV3(db))
|
||||
blockReader := snapshotsync.NewBlockReader(snapshots)
|
||||
blockWriter := blockio.NewBlockWriter(fromdb.HistV3(db))
|
||||
|
||||
br := snapshotsync.NewBlockRetire(estimate.CompressSnapshot.Workers(), dirs.Tmp, blockReader, blockWriter, db, nil, nil, logger)
|
||||
agg, err := libstate.NewAggregatorV3(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
|
||||
|
@ -117,7 +117,6 @@ var DefaultFlags = []cli.Flag{
|
||||
&utils.GpoPercentileFlag,
|
||||
&utils.InsecureUnlockAllowedFlag,
|
||||
&utils.HistoryV3Flag,
|
||||
&utils.TransactionV3Flag,
|
||||
&utils.IdentityFlag,
|
||||
&utils.CliqueSnapshotCheckpointIntervalFlag,
|
||||
&utils.CliqueSnapshotInmemorySnapshotsFlag,
|
||||
|
@ -196,8 +196,8 @@ type BlockReader struct {
|
||||
TransactionsV3 bool
|
||||
}
|
||||
|
||||
func NewBlockReader(snapshots services.BlockSnapshots, transactionsV3 bool) *BlockReader {
|
||||
return &BlockReader{sn: snapshots.(*RoSnapshots), TransactionsV3: transactionsV3}
|
||||
func NewBlockReader(snapshots services.BlockSnapshots) *BlockReader {
|
||||
return &BlockReader{sn: snapshots.(*RoSnapshots), TransactionsV3: false}
|
||||
}
|
||||
|
||||
func (r *BlockReader) Snapshots() services.BlockSnapshots { return r.sn }
|
||||
|
@ -143,8 +143,8 @@ func TestSetupGenesis(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
_, _, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(tmpdir), nil, log.New())
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()), ethconfig.EnableTxsV3InTest)
|
||||
_, db, _ := temporal.NewTestDB(t, context.Background(), datadir.New(tmpdir), nil, log.New())
|
||||
blockReader := snapshotsync.NewBlockReader(snapshotsync.NewRoSnapshots(ethconfig.Snapshot{Enabled: false}, "", log.New()))
|
||||
config, genesis, err := test.fn(db)
|
||||
// Check the return values.
|
||||
if !reflect.DeepEqual(err, test.wantErr) {
|
||||
|
@ -99,7 +99,6 @@ type MockSentry struct {
|
||||
txPoolDB kv.RwDB
|
||||
|
||||
HistoryV3 bool
|
||||
TransactionsV3 bool
|
||||
agg *libstate.AggregatorV3
|
||||
BlockSnapshots *snapshotsync.RoSnapshots
|
||||
}
|
||||
@ -234,9 +233,8 @@ func MockWithEverything(tb testing.TB, gspec *types.Genesis, key *ecdsa.PrivateK
|
||||
|
||||
logger := log.New()
|
||||
ctx, ctxCancel := context.WithCancel(context.Background())
|
||||
histV3, txsV3, db, agg := temporal.NewTestDB(tb, ctx, dirs, gspec, logger)
|
||||
histV3, db, agg := temporal.NewTestDB(tb, ctx, dirs, gspec, logger)
|
||||
cfg.HistoryV3 = histV3
|
||||
cfg.TransactionsV3 = txsV3
|
||||
|
||||
erigonGrpcServeer := remotedbserver.NewKvServer(ctx, db, nil, nil, logger)
|
||||
allSnapshots := snapshotsync.NewRoSnapshots(ethconfig.Defaults.Snapshot, dirs.Snap, logger)
|
||||
@ -259,7 +257,6 @@ func MockWithEverything(tb testing.TB, gspec *types.Genesis, key *ecdsa.PrivateK
|
||||
PeerId: gointerfaces.ConvertHashToH512([64]byte{0x12, 0x34, 0x50}), // "12345"
|
||||
BlockSnapshots: allSnapshots,
|
||||
HistoryV3: cfg.HistoryV3,
|
||||
TransactionsV3: cfg.TransactionsV3,
|
||||
}
|
||||
if tb != nil {
|
||||
tb.Cleanup(mock.Close)
|
||||
@ -734,5 +731,5 @@ func (ms *MockSentry) HistoryV3Components() *libstate.AggregatorV3 {
|
||||
}
|
||||
|
||||
func (ms *MockSentry) NewBlocksIO() (services.FullBlockReader, *blockio.BlockWriter) {
|
||||
return snapshotsync.NewBlockReader(ms.BlockSnapshots, ms.TransactionsV3), blockio.NewBlockWriter(ms.HistoryV3, ms.TransactionsV3)
|
||||
return snapshotsync.NewBlockReader(ms.BlockSnapshots), blockio.NewBlockWriter(ms.HistoryV3)
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ func NewDefaultStages(ctx context.Context,
|
||||
logger log.Logger,
|
||||
) []*stagedsync.Stage {
|
||||
dirs := cfg.Dirs
|
||||
blockWriter := blockio.NewBlockWriter(cfg.HistoryV3, cfg.TransactionsV3)
|
||||
blockWriter := blockio.NewBlockWriter(cfg.HistoryV3)
|
||||
blockRetire := snapshotsync.NewBlockRetire(1, dirs.Tmp, blockReader, blockWriter, db, snapDownloader, notifications.Events, logger)
|
||||
|
||||
// During Import we don't want other services like header requests, body requests etc. to be running.
|
||||
@ -451,7 +451,7 @@ func NewDefaultStages(ctx context.Context,
|
||||
func NewInMemoryExecution(ctx context.Context, db kv.RwDB, cfg *ethconfig.Config, controlServer *sentry.MultiClient,
|
||||
dirs datadir.Dirs, notifications *shards.Notifications, snapshots *snapshotsync.RoSnapshots, agg *state.AggregatorV3,
|
||||
logger log.Logger) (*stagedsync.Sync, error) {
|
||||
blockReader, blockWriter := snapshotsync.NewBlockReader(snapshots, cfg.TransactionsV3), blockio.NewBlockWriter(cfg.HistoryV3, cfg.TransactionsV3)
|
||||
blockReader, blockWriter := snapshotsync.NewBlockReader(snapshots), blockio.NewBlockWriter(cfg.HistoryV3)
|
||||
|
||||
return stagedsync.New(
|
||||
stagedsync.StateStages(ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user