Skip to content

Commit

Permalink
rename aggv3 to agg (#10011)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Apr 22, 2024
1 parent addda2e commit 3af5c35
Show file tree
Hide file tree
Showing 28 changed files with 1,885 additions and 1,884 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewTestSimulatedBackendWithConfig(t *testing.T, alloc types.GenesisAlloc, c
return b
}
func (b *SimulatedBackend) DB() kv.RwDB { return b.m.DB }
func (b *SimulatedBackend) Agg() *state2.AggregatorV3 { return b.m.HistoryV3Components() }
func (b *SimulatedBackend) Agg() *state2.Aggregator { return b.m.HistoryV3Components() }
func (b *SimulatedBackend) HistoryV3() bool { return b.m.HistoryV3 }
func (b *SimulatedBackend) Engine() consensus.Engine { return b.m.Engine }
func (b *SimulatedBackend) BlockReader() services.FullBlockReader { return b.m.BlockReader }
Expand Down
2 changes: 1 addition & 1 deletion cmd/capcli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func (d *DownloadSnapshots) Run(ctx *Context) error {
if err != nil {
return err
}
s, err := state2.NewAggregatorV3(ctx, dirs.Tmp, dirs.Tmp, 200000, db, log.Root())
s, err := state2.NewAggregator(ctx, dirs.Tmp, dirs.Tmp, 200000, db, log.Root())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/integration/commands/reset_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func init() {
rootCmd.AddCommand(cmdClearBadBlocks)
}

func printStages(tx kv.Tx, snapshots *freezeblocks.RoSnapshots, borSn *freezeblocks.BorRoSnapshots, agg *state.AggregatorV3) error {
func printStages(tx kv.Tx, snapshots *freezeblocks.RoSnapshots, borSn *freezeblocks.BorRoSnapshots, agg *state.Aggregator) error {
var err error
var progress uint64
w := new(tabwriter.Writer)
Expand Down
6 changes: 3 additions & 3 deletions cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -1442,9 +1442,9 @@ func removeMigration(db kv.RwDB, ctx context.Context) error {
var openSnapshotOnce sync.Once
var _allSnapshotsSingleton *freezeblocks.RoSnapshots
var _allBorSnapshotsSingleton *freezeblocks.BorRoSnapshots
var _aggSingleton *libstate.AggregatorV3
var _aggSingleton *libstate.Aggregator

func allSnapshots(ctx context.Context, db kv.RoDB, logger log.Logger) (*freezeblocks.RoSnapshots, *freezeblocks.BorRoSnapshots, *libstate.AggregatorV3) {
func allSnapshots(ctx context.Context, db kv.RoDB, logger log.Logger) (*freezeblocks.RoSnapshots, *freezeblocks.BorRoSnapshots, *libstate.Aggregator) {
openSnapshotOnce.Do(func() {
var useSnapshots bool
_ = db.View(context.Background(), func(tx kv.Tx) error {
Expand All @@ -1459,7 +1459,7 @@ func allSnapshots(ctx context.Context, db kv.RoDB, logger log.Logger) (*freezebl
_allBorSnapshotsSingleton = freezeblocks.NewBorRoSnapshots(snapCfg, dirs.Snap, 0, logger)

var err error
_aggSingleton, err = libstate.NewAggregatorV3(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
_aggSingleton, err = libstate.NewAggregator(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func EmbeddedServices(ctx context.Context,
func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger, rootCancel context.CancelFunc) (
db kv.RoDB, eth rpchelper.ApiBackend, txPool txpool.TxpoolClient, mining txpool.MiningClient,
stateCache kvcache.Cache, blockReader services.FullBlockReader, engine consensus.EngineReader,
ff *rpchelper.Filters, agg *libstate.AggregatorV3, err error) {
ff *rpchelper.Filters, agg *libstate.Aggregator, err error) {
if !cfg.WithDatadir && cfg.PrivateApiAddr == "" {
return nil, nil, nil, nil, nil, nil, nil, ff, nil, fmt.Errorf("either remote db or local db must be specified")
}
Expand Down Expand Up @@ -384,7 +384,7 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
allSnapshots.LogStat("remote")
allBorSnapshots.LogStat("remote")

if agg, err = libstate.NewAggregatorV3(ctx, cfg.Dirs.SnapHistory, cfg.Dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger); err != nil {
if agg, err = libstate.NewAggregator(ctx, cfg.Dirs.SnapHistory, cfg.Dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger); err != nil {
return nil, nil, nil, nil, nil, nil, nil, ff, nil, fmt.Errorf("create aggregator: %w", err)
}
_ = agg.OpenFolder()
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/rawdbreset/reset_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ResetState(db kv.RwDB, ctx context.Context, chain string, tmpDir string, lo
return nil
}

func ResetBlocks(tx kv.RwTx, db kv.RoDB, agg *state.AggregatorV3,
func ResetBlocks(tx kv.RwTx, db kv.RoDB, agg *state.Aggregator,
br services.FullBlockReader, bw *blockio.BlockWriter, dirs datadir.Dirs, cc chain.Config, engine consensus.Engine, logger log.Logger) error {
// keep Genesis
if err := rawdb.TruncateBlocks(context.Background(), tx, 1); err != nil {
Expand Down
10 changes: 5 additions & 5 deletions core/state/rw_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (rs *StateV3) CommitTxNum(sender *common.Address, txNum uint64, in *exec22.
return count
}

func (rs *StateV3) writeStateHistory(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.AggregatorV3) error {
func (rs *StateV3) writeStateHistory(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.Aggregator) error {
rs.lock.RLock()
defer rs.lock.RUnlock()

Expand Down Expand Up @@ -401,7 +401,7 @@ func (rs *StateV3) writeStateHistory(roTx kv.Tx, txTask *exec22.TxTask, agg *lib
return nil
}

func (rs *StateV3) applyState(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.AggregatorV3) error {
func (rs *StateV3) applyState(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.Aggregator) error {
emptyRemoval := txTask.Rules.IsSpuriousDragon
rs.lock.Lock()
defer rs.lock.Unlock()
Expand Down Expand Up @@ -449,7 +449,7 @@ func (rs *StateV3) applyState(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.A
return nil
}

func (rs *StateV3) ApplyState(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.AggregatorV3) error {
func (rs *StateV3) ApplyState(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.Aggregator) error {
defer agg.BatchHistoryWriteStart().BatchHistoryWriteEnd()

agg.SetTxNum(txTask.TxNum)
Expand All @@ -467,7 +467,7 @@ func (rs *StateV3) ApplyState(roTx kv.Tx, txTask *exec22.TxTask, agg *libstate.A
return nil
}

func (rs *StateV3) ApplyHistory(txTask *exec22.TxTask, agg *libstate.AggregatorV3) error {
func (rs *StateV3) ApplyHistory(txTask *exec22.TxTask, agg *libstate.Aggregator) error {
if dbg.DiscardHistory() {
return nil
}
Expand Down Expand Up @@ -521,7 +521,7 @@ func recoverCodeHashPlain(acc *accounts.Account, db kv.Tx, key []byte) {
}
}

func (rs *StateV3) Unwind(ctx context.Context, tx kv.RwTx, blockUnwindTo, txUnwindTo uint64, agg *libstate.AggregatorV3, accumulator *shards.Accumulator) error {
func (rs *StateV3) Unwind(ctx context.Context, tx kv.RwTx, blockUnwindTo, txUnwindTo uint64, agg *libstate.Aggregator, accumulator *shards.Accumulator) error {
agg.SetTx(tx)
var currentInc uint64
handle := func(k, v []byte, table etl.CurrentTableReader, next etl.LoadNextFunc) error {
Expand Down
14 changes: 7 additions & 7 deletions core/state/temporal/kv_temporal.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type tParseIncarnation func(v []byte) (uint64, error)

type DB struct {
kv.RwDB
agg *state.AggregatorV3
agg *state.Aggregator

convertV3toV2 tConvertAccount
convertV2toV3 tConvertAccount
Expand All @@ -74,7 +74,7 @@ type DB struct {
systemContractLookup map[common.Address][]common.CodeRecord
}

func New(db kv.RwDB, agg *state.AggregatorV3, systemContractLookup map[common.Address][]common.CodeRecord) (*DB, error) {
func New(db kv.RwDB, agg *state.Aggregator, systemContractLookup map[common.Address][]common.CodeRecord) (*DB, error) {
if !kvcfg.HistoryV3.FromDB(db) {
panic("not supported")
}
Expand All @@ -101,8 +101,8 @@ func New(db kv.RwDB, agg *state.AggregatorV3, systemContractLookup map[common.Ad
systemContractLookup: systemContractLookup,
}, nil
}
func (db *DB) Agg() *state.AggregatorV3 { return db.agg }
func (db *DB) InternalDB() kv.RwDB { return db.RwDB }
func (db *DB) Agg() *state.Aggregator { return db.agg }
func (db *DB) InternalDB() kv.RwDB { return db.RwDB }

func (db *DB) BeginTemporalRo(ctx context.Context) (kv.TemporalTx, error) {
kvTx, err := db.RwDB.BeginRo(ctx) //nolint:gocritic
Expand Down Expand Up @@ -194,7 +194,7 @@ type Tx struct {
}

func (tx *Tx) AggCtx() *state.AggregatorRoTx { return tx.aggCtx }
func (tx *Tx) Agg() *state.AggregatorV3 { return tx.db.agg }
func (tx *Tx) Agg() *state.Aggregator { return tx.db.agg }
func (tx *Tx) Rollback() {
tx.autoClose()
tx.MdbxTx.Rollback()
Expand Down Expand Up @@ -447,7 +447,7 @@ 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, dirs datadir.Dirs, gspec *types.Genesis) (histV3 bool, db kv.RwDB, agg *state.AggregatorV3) {
func NewTestDB(tb testing.TB, dirs datadir.Dirs, gspec *types.Genesis) (histV3 bool, db kv.RwDB, agg *state.Aggregator) {
historyV3 := ethconfig.EnableHistoryV3InTest
logger := log.New()
ctx := context.Background()
Expand All @@ -465,7 +465,7 @@ func NewTestDB(tb testing.TB, dirs datadir.Dirs, gspec *types.Genesis) (histV3 b
if historyV3 {
var err error
dir.MustExist(dirs.SnapHistory)
agg, err = state.NewAggregatorV3(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
agg, err = state.NewAggregator(ctx, dirs.SnapHistory, dirs.Tmp, ethconfig.HistoryV3AggregationStep, db, logger)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 3af5c35

Please sign in to comment.