Skip to content
Open
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
26 changes: 25 additions & 1 deletion execution/execmodule/exec_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,32 @@ func (e *ExecModule) ValidateChain(ctx context.Context, blockHash common.Hash, b
ValidationStatus: ExecutionStatusBusy,
}, nil
}
defer e.semaphore.Release(1)

type validationOutcome struct {
result ValidationResult
err error
}
outcomeCh := make(chan validationOutcome, 1)
done := make(chan struct{})

go func() {
defer close(done)
defer e.semaphore.Release(1)
result, err := e.validateChainImpl(e.bacgroundCtx, blockHash, blockNumber)
outcomeCh <- validationOutcome{result, err}
}()

select {
case o := <-outcomeCh:
<-done
return o.result, o.err
case <-ctx.Done():
e.logger.Debug("treating ValidateChain as asynchronous as caller context is done")
return ValidationResult{ValidationStatus: ExecutionStatusBusy}, nil
}
}

func (e *ExecModule) validateChainImpl(ctx context.Context, blockHash common.Hash, blockNumber uint64) (ValidationResult, error) {
e.hook.LastNewBlockSeen(blockNumber) // used by eth_syncing
e.currentContext.ResetPendingUpdates()
e.forkValidator.ClearWithUnwind()
Expand Down
Loading