Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
fix(prover): move concurrency guard (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Jul 14, 2023
1 parent aaec1bb commit af29c95
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,36 +950,43 @@ func (p *Prover) requestProofForBlockId(blockId *big.Int, l1Height *big.Int) err
})
p.currentBlocksBeingProvenMutex.Unlock()

p.proposeConcurrencyGuard <- struct{}{}

if err := p.validProofSubmitter.RequestProof(ctx, event); err != nil {
return err
}

return nil
}

p.proposeConcurrencyGuard <- struct{}{}

go func() {
handleBlockProposedEvent := func() error {
defer func() { <-p.proposeConcurrencyGuard }()

iter, err := eventIterator.NewBlockProposedIterator(p.ctx, &eventIterator.BlockProposedIteratorConfig{
Client: p.rpc.L1,
TaikoL1: p.rpc.TaikoL1,
StartHeight: l1Height,
EndHeight: new(big.Int).Add(l1Height, common.Big1),
OnBlockProposedEvent: onBlockProposed,
FilterQuery: []*big.Int{blockId},
})
if err != nil {
return err
}

return iter.Iter()
}

go func() {
if err := backoff.Retry(
func() error {
iter, err := eventIterator.NewBlockProposedIterator(p.ctx, &eventIterator.BlockProposedIteratorConfig{
Client: p.rpc.L1,
TaikoL1: p.rpc.TaikoL1,
StartHeight: l1Height,
EndHeight: new(big.Int).Add(l1Height, common.Big1),
OnBlockProposedEvent: onBlockProposed,
FilterQuery: []*big.Int{blockId},
})
if err != nil {
return err
}

return iter.Iter()
return handleBlockProposedEvent()
},
backoff.WithMaxRetries(backoff.NewConstantBackOff(p.cfg.BackOffRetryInterval), p.cfg.BackOffMaxRetrys),
); err != nil {
p.currentBlocksBeingProvenMutex.Lock()
defer p.currentBlocksBeingProvenMutex.Unlock()
delete(p.currentBlocksBeingProven, blockId.Uint64())
log.Error("Request proof with a given block ID", "blockID", blockId, "error", err)
}
}()
Expand Down

0 comments on commit af29c95

Please sign in to comment.