Skip to content

Commit

Permalink
Merge pull request #6 from ultrasoundmoney/mikeneuder-20230320-1
Browse files Browse the repository at this point in the history
context fix
  • Loading branch information
michaelneuder committed Mar 21, 2023
2 parents 51ed389 + 88ecf43 commit e059206
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion services/api/optimistic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestProcessOptimisticBlock(t *testing.T) {
backend.relay.blockSimRateLimiter = &MockBlockSimulationRateLimiter{
simulationError: tc.simulationError,
}
backend.relay.processOptimisticBlock(context.Background(), blockSimOptions{
backend.relay.processOptimisticBlock(blockSimOptions{
isHighPrio: true,
log: backend.relay.log,
builder: &blockBuilderCacheEntry{
Expand Down
5 changes: 3 additions & 2 deletions services/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,13 @@ func (api *RelayAPI) demoteBuilder(pubkey string, req *common.BuilderSubmitBlock

// processOptimisticBlock is called on a new goroutine when a optimistic block
// needs to be simulated.
func (api *RelayAPI) processOptimisticBlock(ctx context.Context, opts blockSimOptions) {
func (api *RelayAPI) processOptimisticBlock(opts blockSimOptions) {
api.optimisticBlocksInFlight += 1
defer func() { api.optimisticBlocksInFlight -= 1 }()
api.optimisticBlocks.Add(1)
defer api.optimisticBlocks.Done()

ctx := context.Background()
builderPubkey := opts.req.BuilderPubkey().String()
opts.log.WithFields(logrus.Fields{
"builderPubkey": builderPubkey,
Expand Down Expand Up @@ -1477,7 +1478,7 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque
builderEntry.status.IsOptimistic &&
payload.Slot() == api.optimisticSlot {
optimisticSubmission = true
go api.processOptimisticBlock(req.Context(), opts)
go api.processOptimisticBlock(opts)
} else {
// Simulate block (synchronously).
simErr = api.simulateBlock(req.Context(), opts)
Expand Down

0 comments on commit e059206

Please sign in to comment.