Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions execution/stagedsync/exec3_serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/erigontech/erigon/db/consensuschain"
"github.com/erigontech/erigon/db/kv"
"github.com/erigontech/erigon/db/rawdb/rawtemporaldb"
dbstate "github.com/erigontech/erigon/db/state"
"github.com/erigontech/erigon/db/state/changeset"
"github.com/erigontech/erigon/execution/commitment"
"github.com/erigontech/erigon/execution/exec"
Expand Down Expand Up @@ -182,74 +181,35 @@ func (se *serialExecutor) exec(ctx context.Context, execStage *StageState, u Unw
if !se.isApplyingBlocks {
break
}

se.LogExecution()

//TODO: https://github.com/erigontech/erigon/issues/10724
//if executor.tx().(dbstate.HasAggTx).AggTx().(*dbstate.AggregatorRoTx).CanPrune(executor.tx(), doms.TxNum()) {
// //small prune cause MDBX_TXN_FULL
// if _, err := executor.tx().(dbstate.HasAggTx).AggTx().(*dbstate.AggregatorRoTx).PruneSmallBatches(ctx, 10*time.Hour, executor.tx()); err != nil {
// return err
// }
//}

isBatchFull := se.readState().SizeEstimate() >= se.cfg.batchSize.Bytes()
canPrune := dbstate.AggTx(se.applyTx).CanPrune(se.applyTx, se.doms.TxNum())
needCalcRoot := isBatchFull || havePartialBlock || canPrune
needCalcRoot := isBatchFull || havePartialBlock
// If we have a partial first block it may not be validated, then we should compute root hash ASAP for fail-fast

// this will only happen for the first executed block
havePartialBlock = false

if !needCalcRoot {
break
}

resetExecGauges(ctx)

ok, times, err := computeAndCheckCommitmentV3(ctx, b.HeaderNoCopy(), rwTx, se.doms, se.cfg, execStage, false, se.logger, u, se.isBlockProduction)
if err != nil {
return nil, rwTx, err
} else if !ok {
return b.HeaderNoCopy(), rwTx, nil
}

resetCommitmentGauges(ctx)

se.txExecutor.lastCommittedBlockNum = b.NumberU64()
se.txExecutor.lastCommittedTxNum = inputTxNum

timeStart := time.Now()

pruneTimeout := 250 * time.Millisecond
if initialCycle {
pruneTimeout = 10 * time.Hour

if err = rwTx.GreedyPruneHistory(ctx, kv.CommitmentDomain); err != nil {
return nil, rwTx, err
}
}

if _, err := rwTx.PruneSmallBatches(ctx, pruneTimeout); err != nil {
return nil, rwTx, err
}

se.logger.Info(
"periodic commit check",
"block", se.doms.BlockNum(),
"txNum", se.doms.TxNum(),
"step", fmt.Sprintf("%.1f", float64(se.doms.TxNum())/float64(se.agg.StepSize())),
"commitment", times.ComputeCommitment,
"prune", time.Since(timeStart),
)

if isBatchFull {
return b.HeaderNoCopy(), rwTx, &ErrLoopExhausted{From: startBlockNum, To: blockNum, Reason: "block batch is full"}
}

if canPrune {
return b.HeaderNoCopy(), rwTx, &ErrLoopExhausted{From: startBlockNum, To: blockNum, Reason: "block batch can be pruned"}
}
default:
}

Expand Down
Loading