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 2f247a3 commit f9b447d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion arbitrum/recordingdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (r *RecordingDatabase) GetOrRecreateState(ctx context.Context, header *type
returnedBlockNumber := header.Number.Uint64()
for ctx.Err() == nil {
var block *types.Block
state, block, err = AdvanceStateByBlock(ctx, r.bc, state, header, blockToRecreate, prevHash, logFunc)
state, block, err = AdvanceStateByBlock(ctx, r.bc, state, blockToRecreate, prevHash, logFunc)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions arbitrum/recreatestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type StateReleaseFunc tracers.StateReleaseFunc

var NoopStateRelease StateReleaseFunc = func() {}

type StateBuildingLogFunction func(targetHeader, header *types.Header, hasState bool)
type StateBuildingLogFunction func(header *types.Header, hasState bool)
type StateForHeaderFunction func(header *types.Header) (*state.StateDB, StateReleaseFunc, error)

// finds last available state and header checking it first for targetHeader then looking backwards
Expand Down Expand Up @@ -56,7 +56,7 @@ func FindLastAvailableState(ctx context.Context, bc *core.BlockChain, stateFor S
return nil, lastHeader, nil, err
}
if logFunc != nil {
logFunc(targetHeader, currentHeader, false)
logFunc(currentHeader, false)
}
if currentHeader.Number.Uint64() <= genesis {
return nil, lastHeader, nil, errors.Wrap(err, fmt.Sprintf("moved beyond genesis looking for state %d, genesis %d", targetHeader.Number.Uint64(), genesis))
Expand All @@ -69,7 +69,7 @@ func FindLastAvailableState(ctx context.Context, bc *core.BlockChain, stateFor S
return state, currentHeader, release, ctx.Err()
}

func AdvanceStateByBlock(ctx context.Context, bc *core.BlockChain, state *state.StateDB, targetHeader *types.Header, blockToRecreate uint64, prevBlockHash common.Hash, logFunc StateBuildingLogFunction) (*state.StateDB, *types.Block, error) {
func AdvanceStateByBlock(ctx context.Context, bc *core.BlockChain, state *state.StateDB, blockToRecreate uint64, prevBlockHash common.Hash, logFunc StateBuildingLogFunction) (*state.StateDB, *types.Block, error) {
block := bc.GetBlockByNumber(blockToRecreate)
if block == nil {
return nil, nil, fmt.Errorf("block not found while recreating: %d", blockToRecreate)
Expand All @@ -78,7 +78,7 @@ func AdvanceStateByBlock(ctx context.Context, bc *core.BlockChain, state *state.
return nil, nil, fmt.Errorf("reorg detected: number %d expectedPrev: %v foundPrev: %v", blockToRecreate, prevBlockHash, block.ParentHash())
}
if logFunc != nil {
logFunc(targetHeader, block.Header(), true)
logFunc(block.Header(), true)
}
_, _, _, err := bc.Processor().Process(block, state, vm.Config{})
if err != nil {
Expand Down

0 comments on commit f9b447d

Please sign in to comment.