Skip to content

Commit

Permalink
Removed unused stages (Cumulative index + Translation) (#7884)
Browse files Browse the repository at this point in the history
  • Loading branch information
Giulio2002 authored and AskAlexSharov committed Sep 6, 2023
1 parent ce23689 commit 9e938a4
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 242 deletions.
2 changes: 1 addition & 1 deletion cmd/integration/commands/state_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func loopIh(db kv.RwDB, ctx context.Context, unwind uint64, logger log.Logger) e
return err
}
defer tx.Rollback()
sync.DisableStages(stages.Snapshots, stages.Headers, stages.BlockHashes, stages.Bodies, stages.Senders, stages.Execution, stages.Translation, stages.AccountHistoryIndex, stages.StorageHistoryIndex, stages.TxLookup, stages.Finish)
sync.DisableStages(stages.Snapshots, stages.Headers, stages.BlockHashes, stages.Bodies, stages.Senders, stages.Execution, stages.AccountHistoryIndex, stages.StorageHistoryIndex, stages.TxLookup, stages.Finish)
if err = sync.Run(db, tx, false /* firstCycle */); err != nil {
return err
}
Expand Down
16 changes: 0 additions & 16 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,22 +1137,6 @@ func WriteTotalBurnt(db kv.Putter, number uint64, totalBurnt *big.Int) error {
return db.Put(kv.Issuance, append([]byte("burnt"), hexutility.EncodeTs(number)...), totalBurnt.Bytes())
}

func ReadCumulativeGasUsed(db kv.Getter, number uint64) (*big.Int, error) {
data, err := db.GetOne(kv.CumulativeGasIndex, hexutility.EncodeTs(number))
if err != nil {
return nil, err
}
if len(data) == 0 {
return big.NewInt(0), nil
}

return new(big.Int).SetBytes(data), nil
}

func WriteCumulativeGasUsed(db kv.Putter, number uint64, cumulativeGasUsed *big.Int) error {
return db.Put(kv.CumulativeGasIndex, hexutility.EncodeTs(number), cumulativeGasUsed.Bytes())
}

func ReadHeaderByNumber(db kv.Getter, number uint64) *types.Header {
hash, err := ReadCanonicalHash(db, number)
if err != nil {
Expand Down
18 changes: 1 addition & 17 deletions eth/stagedsync/default_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/ledgerwatch/log/v3"
)

func DefaultStages(ctx context.Context, snapshots SnapshotsCfg, headers HeadersCfg, cumulativeIndex CumulativeIndexCfg, blockHashCfg BlockHashesCfg, bodies BodiesCfg, senders SendersCfg, exec ExecuteBlockCfg, hashState HashStateCfg, trieCfg TrieCfg, history HistoryCfg, logIndex LogIndexCfg, callTraces CallTracesCfg, txLookup TxLookupCfg, finish FinishCfg, test bool) []*Stage {
func DefaultStages(ctx context.Context, snapshots SnapshotsCfg, headers HeadersCfg, blockHashCfg BlockHashesCfg, bodies BodiesCfg, senders SendersCfg, exec ExecuteBlockCfg, hashState HashStateCfg, trieCfg TrieCfg, history HistoryCfg, logIndex LogIndexCfg, callTraces CallTracesCfg, txLookup TxLookupCfg, finish FinishCfg, test bool) []*Stage {
return []*Stage{
{
ID: stages.Snapshots,
Expand Down Expand Up @@ -43,19 +43,6 @@ func DefaultStages(ctx context.Context, snapshots SnapshotsCfg, headers HeadersC
return HeadersPrune(p, tx, headers, ctx)
},
},
{
ID: stages.CumulativeIndex,
Description: "Write Cumulative Index",
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, logger log.Logger) error {
return SpawnStageCumulativeIndex(cumulativeIndex, s, tx, ctx, logger)
},
Unwind: func(firstCycle bool, u *UnwindState, s *StageState, tx kv.RwTx, logger log.Logger) error {
return UnwindCumulativeIndexStage(u, cumulativeIndex, tx, ctx)
},
Prune: func(firstCycle bool, p *PruneState, tx kv.RwTx, logger log.Logger) error {
return PruneCumulativeIndexStage(p, tx, ctx)
},
},
{
ID: stages.BlockHashes,
Description: "Write block hashes",
Expand Down Expand Up @@ -316,7 +303,6 @@ var DefaultForwardOrder = UnwindOrder{
// Stages below don't use Internet
stages.Senders,
stages.Execution,
stages.Translation,
stages.HashState,
stages.IntermediateHashes,
stages.CallTraces,
Expand Down Expand Up @@ -346,7 +332,6 @@ var DefaultUnwindOrder = UnwindOrder{
stages.HashState,
stages.IntermediateHashes,

stages.Translation,
stages.Execution,
stages.Senders,

Expand Down Expand Up @@ -378,7 +363,6 @@ var DefaultPruneOrder = PruneOrder{
stages.HashState,
stages.IntermediateHashes,

stages.Translation,
stages.Execution,
stages.Senders,

Expand Down
162 changes: 0 additions & 162 deletions eth/stagedsync/stage_cumulative_index.go

This file was deleted.

3 changes: 0 additions & 3 deletions turbo/jsonrpc/erigon_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ type ErigonAPI interface {
// Gets cannonical block receipt through hash. If the block is not cannonical returns error
GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash common.Hash) ([]map[string]interface{}, error)

// CumulativeChainTraffic / related to chain traffic (see ./erigon_cumulative_index.go)
CumulativeChainTraffic(ctx context.Context, blockNr rpc.BlockNumber) (ChainTraffic, error)

// NodeInfo returns a collection of metadata known about the host.
NodeInfo(ctx context.Context) ([]p2p.NodeInfo, error)
}
Expand Down
41 changes: 0 additions & 41 deletions turbo/jsonrpc/erigon_cumulative_chain_traffic.go

This file was deleted.

1 change: 0 additions & 1 deletion turbo/stages/mock_sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ func MockWithEverything(tb testing.TB, gspec *types.Genesis, key *ecdsa.PrivateK
stagedsync.DefaultStages(mock.Ctx,
stagedsync.StageSnapshotsCfg(mock.DB, *mock.ChainConfig, dirs, blockRetire, snapshotsDownloader, mock.BlockReader, mock.Notifications.Events, mock.HistoryV3, mock.agg),
stagedsync.StageHeadersCfg(mock.DB, mock.sentriesClient.Hd, mock.sentriesClient.Bd, *mock.ChainConfig, sendHeaderRequest, propagateNewBlockHashes, penalize, cfg.BatchSize, false, mock.BlockReader, blockWriter, dirs.Tmp, mock.Notifications, engine_helpers.NewForkValidatorMock(1)),
stagedsync.StageCumulativeIndexCfg(mock.DB, mock.BlockReader),
stagedsync.StageBlockHashesCfg(mock.DB, mock.Dirs.Tmp, mock.ChainConfig, blockWriter),
stagedsync.StageBodiesCfg(mock.DB, mock.sentriesClient.Bd, sendBodyRequest, penalize, blockPropagator, cfg.Sync.BodyDownloadTimeoutSeconds, *mock.ChainConfig, mock.BlockReader, cfg.HistoryV3, blockWriter),
stagedsync.StageSendersCfg(mock.DB, mock.ChainConfig, false, dirs.Tmp, prune, mock.BlockReader, mock.sentriesClient.Hd),
Expand Down
1 change: 0 additions & 1 deletion turbo/stages/stageloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ func NewDefaultStages(ctx context.Context,
return stagedsync.DefaultStages(ctx,
stagedsync.StageSnapshotsCfg(db, *controlServer.ChainConfig, dirs, blockRetire, snapDownloader, blockReader, notifications.Events, cfg.HistoryV3, agg),
stagedsync.StageHeadersCfg(db, controlServer.Hd, controlServer.Bd, *controlServer.ChainConfig, controlServer.SendHeaderRequest, controlServer.PropagateNewBlockHashes, controlServer.Penalize, cfg.BatchSize, p2pCfg.NoDiscovery, blockReader, blockWriter, dirs.Tmp, notifications, forkValidator),
stagedsync.StageCumulativeIndexCfg(db, blockReader),
stagedsync.StageBlockHashesCfg(db, dirs.Tmp, controlServer.ChainConfig, blockWriter),
stagedsync.StageBodiesCfg(db, controlServer.Bd, controlServer.SendBodyRequest, controlServer.Penalize, controlServer.BroadcastNewBlock, cfg.Sync.BodyDownloadTimeoutSeconds, *controlServer.ChainConfig, blockReader, cfg.HistoryV3, blockWriter),
stagedsync.StageSendersCfg(db, controlServer.ChainConfig, false, dirs.Tmp, cfg.Prune, blockReader, controlServer.Hd),
Expand Down

0 comments on commit 9e938a4

Please sign in to comment.