Skip to content

Commit

Permalink
StateBuildingLogFunction shouldn't take targetHeader as an arg
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Oct 29, 2024
1 parent ab7ad52 commit c2ccab5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion blocks_reexecutor/blocks_reexecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (s *BlocksReExecutor) advanceStateUpToBlock(ctx context.Context, state *sta
var block *types.Block
var err error
for ctx.Err() == nil {
state, block, err = arbitrum.AdvanceStateByBlock(ctx, s.blockchain, state, targetHeader, blockToRecreate, prevHash, nil)
state, block, err = arbitrum.AdvanceStateByBlock(ctx, s.blockchain, state, blockToRecreate, prevHash, nil)
if err != nil {
return err
}
Expand Down
32 changes: 17 additions & 15 deletions execution/gethexec/block_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,21 @@ func NewBlockRecorder(config *BlockRecorderConfig, execEngine *ExecutionEngine,
return recorder
}

func stateLogFunc(targetHeader, header *types.Header, hasState bool) {
if targetHeader == nil || header == nil {
return
}
gap := targetHeader.Number.Int64() - header.Number.Int64()
step := int64(500)
stage := "computing state"
if !hasState {
step = 3000
stage = "looking for full block"
}
if (gap >= step) && (gap%step == 0) {
log.Info("Setting up validation", "stage", stage, "current", header.Number, "target", targetHeader.Number)
func stateLogFunc(targetHeader *types.Header) arbitrum.StateBuildingLogFunction {
return func(header *types.Header, hasState bool) {
if targetHeader == nil || header == nil {
return
}
gap := targetHeader.Number.Int64() - header.Number.Int64()
step := int64(500)
stage := "computing state"
if !hasState {
step = 3000
stage = "looking for full block"
}
if (gap >= step) && (gap%step == 0) {
log.Info("Setting up validation", "stage", stage, "current", header.Number, "target", targetHeader.Number)
}
}
}

Expand All @@ -109,7 +111,7 @@ func (r *BlockRecorder) RecordBlockCreation(
}
}

recordingdb, chaincontext, recordingKV, err := r.recordingDatabase.PrepareRecording(ctx, prevHeader, stateLogFunc)
recordingdb, chaincontext, recordingKV, err := r.recordingDatabase.PrepareRecording(ctx, prevHeader, stateLogFunc(prevHeader))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -321,7 +323,7 @@ func (r *BlockRecorder) PrepareForRecord(ctx context.Context, start, end arbutil
log.Warn("prepareblocks asked for non-found block", "hdrNum", hdrNum)
break
}
_, err := r.recordingDatabase.GetOrRecreateState(ctx, header, stateLogFunc)
_, err := r.recordingDatabase.GetOrRecreateState(ctx, header, stateLogFunc(header))
if err != nil {
log.Warn("prepareblocks failed to get state for block", "hdrNum", hdrNum, "err", err)
break
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum

0 comments on commit c2ccab5

Please sign in to comment.