Skip to content

Commit

Permalink
Merge branch 'store_less_history_on_chain_tip' into e3_dbg_bor_retire
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed May 28, 2024
2 parents fbc45b3 + f93813b commit e5af9b5
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,6 @@ func ExecV3(ctx context.Context,
chainConfig, genesis := cfg.chainConfig, cfg.genesis
blocksFreezeCfg := cfg.blockReader.FreezingCfg()

if initialCycle {
agg.SetCollateAndBuildWorkers(min(2, estimate.StateV3Collate.Workers()))
agg.SetCompressWorkers(estimate.CompressSnapshot.Workers())
defer agg.DiscardHistory(kv.CommitmentDomain).EnableHistory(kv.CommitmentDomain)
} else {
agg.SetCompressWorkers(1)
agg.SetCollateAndBuildWorkers(1)
}

applyTx := txc.Tx
useExternalTx := applyTx != nil
if !useExternalTx {
Expand Down Expand Up @@ -295,6 +286,18 @@ func ExecV3(ctx context.Context,
"from", blockNum, "to", maxBlockNum, "fromTxNum", doms.TxNum(), "offsetFromBlockBeginning", offsetFromBlockBeginning, "initialCycle", initialCycle, "useExternalTx", useExternalTx)
}

if initialCycle {
agg.SetCollateAndBuildWorkers(min(2, estimate.StateV3Collate.Workers()))
agg.SetCompressWorkers(estimate.CompressSnapshot.Workers())
if blockNum < cfg.blockReader.FrozenBlocks() {
defer agg.DiscardHistory(kv.CommitmentDomain).EnableHistory(kv.CommitmentDomain)
defer agg.LimitRecentHistoryWithoutFiles(0).LimitRecentHistoryWithoutFiles(agg.StepSize() / 10)
}
} else {
agg.SetCompressWorkers(1)
agg.SetCollateAndBuildWorkers(1)
}

if blocksFreezeCfg.Produce {
//log.Info(fmt.Sprintf("[snapshots] db has steps amount: %s", agg.StepsRangeInDBAsStr(applyTx)))
agg.BuildFilesInBackground(outputTxNum.Load())
Expand Down Expand Up @@ -561,10 +564,6 @@ func ExecV3(ctx context.Context,
})
}

if useExternalTx && blockNum < cfg.blockReader.FrozenBlocks() {
defer agg.LimitRecentHistoryWithoutFiles(0).LimitRecentHistoryWithoutFiles(agg.StepSize() / 2)
}

getHeaderFunc := func(hash common.Hash, number uint64) (h *types.Header) {
var err error
if parallel {
Expand Down

0 comments on commit e5af9b5

Please sign in to comment.