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

Commit

Permalink
feat(prover): add onProvingWindowExpired
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Oct 6, 2023
1 parent 4dd63c3 commit 994b2e4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ func (p *Prover) eventLoop() {
if err := p.onTransitionProved(p.ctx, e); err != nil {
log.Error("Handle TransitionProved event error", "error", err)
}
case e := <-p.proofWindowExpiredCh:
if err := p.onProvingWindowExpired(p.ctx, e); err != nil {
log.Error("Handle provingWindow expired event error", "error", err)
}
case <-p.blockProposedCh:
reqProving()
case <-forceProvingTicker.C:
Expand Down Expand Up @@ -764,6 +768,22 @@ func (p *Prover) requestProofByBlockID(blockId *big.Int, l1Height *big.Int) erro
return nil
}

// onProvingWindowExpired tries to submit a proof for an expired block.
func (p *Prover) onProvingWindowExpired(ctx context.Context, e *bindings.TaikoL1ClientBlockProposed) error {
log.Info("Block proving window is expired", "blockID", e.BlockId, "l1Height", e.Raw.BlockNumber)

needNewProof, err := rpc.NeedNewProof(ctx, p.rpc, e.BlockId, p.proverAddress)
if err != nil {
return err
}

if !needNewProof {
return nil
}

return p.requestProofByBlockID(e.BlockId, new(big.Int).SetUint64(e.Raw.BlockNumber))
}

// getProvingWindow returns the provingWindow of the given proposed block.
func (p *Prover) getProvingWindow(e *bindings.TaikoL1ClientBlockProposed) (time.Duration, error) {
for _, t := range p.tiers {
Expand Down

0 comments on commit 994b2e4

Please sign in to comment.