From 2564273b63cc8980e18ae929cc3b7a4e64d2611c Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Fri, 14 Jul 2023 11:09:37 -0700 Subject: [PATCH 1/3] move concurrency guard --- .../proof_submitter/valid_proof_submitter.go | 22 +++++----- prover/prover.go | 43 ++++++++++++------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/prover/proof_submitter/valid_proof_submitter.go b/prover/proof_submitter/valid_proof_submitter.go index c3a4fc2d4..e2d340888 100644 --- a/prover/proof_submitter/valid_proof_submitter.go +++ b/prover/proof_submitter/valid_proof_submitter.go @@ -134,16 +134,18 @@ func (s *ValidProofSubmitter) RequestProof(ctx context.Context, event *bindings. ParentGasUsed: parent.GasUsed(), } - if err := s.proofProducer.RequestProof( - ctx, - opts, - event.BlockId, - &event.Meta, - block.Header(), - s.resultCh, - ); err != nil { - return fmt.Errorf("failed to request proof (id: %d): %w", event.BlockId, err) - } + log.Info("opts", "opts", opts) + + // if err := s.proofProducer.RequestProof( + // ctx, + // opts, + // event.BlockId, + // &event.Meta, + // block.Header(), + // s.resultCh, + // ); err != nil { + // return fmt.Errorf("failed to request proof (id: %d): %w", event.BlockId, err) + // } metrics.ProverQueuedProofCounter.Inc(1) metrics.ProverQueuedValidProofCounter.Inc(1) diff --git a/prover/prover.go b/prover/prover.go index 780f4b9f8..19cce86b9 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -950,6 +950,12 @@ func (p *Prover) requestProofForBlockId(blockId *big.Int, l1Height *big.Int) err }) p.currentBlocksBeingProvenMutex.Unlock() + log.Info("req proof before guard") + + p.proposeConcurrencyGuard <- struct{}{} + + log.Info("req proof after guard") + if err := p.validProofSubmitter.RequestProof(ctx, event); err != nil { return err } @@ -957,29 +963,34 @@ func (p *Prover) requestProofForBlockId(blockId *big.Int, l1Height *big.Int) 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) } }() From b7c48ec4dc48dbc04c3f44ec114c8b8fa8795037 Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Fri, 14 Jul 2023 11:10:38 -0700 Subject: [PATCH 2/3] add proof uncomment --- .../proof_submitter/valid_proof_submitter.go | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/prover/proof_submitter/valid_proof_submitter.go b/prover/proof_submitter/valid_proof_submitter.go index e2d340888..c3a4fc2d4 100644 --- a/prover/proof_submitter/valid_proof_submitter.go +++ b/prover/proof_submitter/valid_proof_submitter.go @@ -134,18 +134,16 @@ func (s *ValidProofSubmitter) RequestProof(ctx context.Context, event *bindings. ParentGasUsed: parent.GasUsed(), } - log.Info("opts", "opts", opts) - - // if err := s.proofProducer.RequestProof( - // ctx, - // opts, - // event.BlockId, - // &event.Meta, - // block.Header(), - // s.resultCh, - // ); err != nil { - // return fmt.Errorf("failed to request proof (id: %d): %w", event.BlockId, err) - // } + if err := s.proofProducer.RequestProof( + ctx, + opts, + event.BlockId, + &event.Meta, + block.Header(), + s.resultCh, + ); err != nil { + return fmt.Errorf("failed to request proof (id: %d): %w", event.BlockId, err) + } metrics.ProverQueuedProofCounter.Inc(1) metrics.ProverQueuedValidProofCounter.Inc(1) From dd0e25fd6a61990fb026d10ad83f22dd11bde14a Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Fri, 14 Jul 2023 11:11:16 -0700 Subject: [PATCH 3/3] rm logs --- prover/prover.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/prover/prover.go b/prover/prover.go index 19cce86b9..b971f4d11 100644 --- a/prover/prover.go +++ b/prover/prover.go @@ -950,12 +950,8 @@ func (p *Prover) requestProofForBlockId(blockId *big.Int, l1Height *big.Int) err }) p.currentBlocksBeingProvenMutex.Unlock() - log.Info("req proof before guard") - p.proposeConcurrencyGuard <- struct{}{} - log.Info("req proof after guard") - if err := p.validProofSubmitter.RequestProof(ctx, event); err != nil { return err }