Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx committed Nov 22, 2024
1 parent 5d1cc08 commit 3404670
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
20 changes: 10 additions & 10 deletions core/state/rw_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,16 @@ func (rs *StateV3) ApplyState4(ctx context.Context, txTask *TxTask) error {
return fmt.Errorf("StateV3.ApplyLogsAndTraces: %w", err)
}

if (txTask.TxNum+1)%rs.domains.StepSize() == 0 /*&& txTask.TxNum > 0 */ {
// We do not update txNum before commitment cuz otherwise committed state will be in the beginning of next file, not in the latest.
// That's why we need to make txnum++ on SeekCommitment to get exact txNum for the latest committed state.
//fmt.Printf("[commitment] running due to txNum reached aggregation step %d\n", txNum/rs.domains.StepSize())
_, err := rs.domains.ComputeCommitment(ctx, true, txTask.BlockNum,
fmt.Sprintf("applying step %d", txTask.TxNum/rs.domains.StepSize()))
if err != nil {
return fmt.Errorf("StateV3.ComputeCommitment: %w", err)
}
}
//if (txTask.TxNum+1)%rs.domains.StepSize() == 0 /*&& txTask.TxNum > 0 */ {
// // We do not update txNum before commitment cuz otherwise committed state will be in the beginning of next file, not in the latest.
// // That's why we need to make txnum++ on SeekCommitment to get exact txNum for the latest committed state.
// //fmt.Printf("[commitment] running due to txNum reached aggregation step %d\n", txNum/rs.domains.StepSize())
// _, err := rs.domains.ComputeCommitment(ctx, true, txTask.BlockNum,
// fmt.Sprintf("applying step %d", txTask.TxNum/rs.domains.StepSize()))
// if err != nil {
// return fmt.Errorf("StateV3.ComputeCommitment: %w", err)
// }
//}

txTask.ReadLists, txTask.WriteLists = nil, nil
return nil
Expand Down
18 changes: 11 additions & 7 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ Loop:
start := time.Now()
doms.SetChangesetAccumulator(nil) // Make sure we don't have an active changeset accumulator
// First compute and commit the progress done so far
if _, err := doms.ComputeCommitment(ctx, true, blockNum, execStage.LogPrefix()); err != nil {
return err
}
//if _, err := doms.ComputeCommitment(ctx, true, blockNum, execStage.LogPrefix()); err != nil {
// return err
//}
ts += time.Since(start)
aggTx.RestrictSubsetFileDeletions(false)
shouldGenerateChangesets = true // now we can generate changesets for the safety net
Expand Down Expand Up @@ -687,9 +687,9 @@ Loop:
aggTx := applyTx.(state2.HasAggTx).AggTx().(*state2.AggregatorRoTx)
aggTx.RestrictSubsetFileDeletions(true)
start := time.Now()
if _, err := doms.ComputeCommitment(ctx, true, blockNum, execStage.LogPrefix()); err != nil {
return err
}
//if _, err := doms.ComputeCommitment(ctx, true, blockNum, execStage.LogPrefix()); err != nil {
// return err
//}
ts += time.Since(start)
aggTx.RestrictSubsetFileDeletions(false)
doms.SavePastChangesetAccumulator(b.Hash(), blockNum, changeset)
Expand Down Expand Up @@ -923,13 +923,17 @@ func flushAndCheckCommitmentV3(ctx context.Context, header *types.Header, applyT
return false, errors.New("header is nil")
}

if dbg.DiscardCommitment() && header.Number.Uint64() != 0 {
if dbg.DiscardCommitment() {
return true, nil
}
if doms.BlockNum() != header.Number.Uint64() {
panic(fmt.Errorf("%d != %d", doms.BlockNum(), header.Number.Uint64()))
}

if header.Number.Uint64() != 0 {
return true, nil
}

rh, err := doms.ComputeCommitment(ctx, true, header.Number.Uint64(), e.LogPrefix())
if err != nil {
return false, fmt.Errorf("StateV3.Apply: %w", err)
Expand Down

0 comments on commit 3404670

Please sign in to comment.