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

Commit

Permalink
feat(prover): optimize skipProofWindowExpiredCheck check && update …
Browse files Browse the repository at this point in the history
…`NeedNewProof` check
  • Loading branch information
davidtaikocha committed Jul 12, 2023
1 parent 003a86b commit f01004f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
5 changes: 0 additions & 5 deletions pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ func NeedNewProof(
return true, nil
}

if fc.Prover == encoding.OracleProverAddress {
log.Info("Only oracle proof submitted, try generating a normal proof", "blockID", id)
return true, nil
}

if proverAddress == fc.Prover {
log.Info("📬 Block's proof has already been submitted by current prover", "blockID", id)
return false, nil
Expand Down
24 changes: 14 additions & 10 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,30 +461,29 @@ func (p *Prover) onBlockProposed(
"proofWindow", block.ProofWindow,
)

var skipProofWindowExpiredCheck bool = false

var skipProofWindowExpiredCheck bool
if p.cfg.OracleProver {
for {
shouldSkipProofWindowExpiredCheck := func() (bool, error) {
parent, err := p.rpc.L2ParentByBlockId(ctx, event.BlockId)
if err != nil {
return err
return false, err
}

// check if an invalid proof has been submitted, if so, we can skip proofWindowExpired check below
// and always submit proof. otherwise, oracleProver follows same proof logic as regular.
forkChoice, err := p.rpc.TaikoL1.GetForkChoice(nil, event.BlockId, parent.Hash(), uint32(parent.GasUsed))
if err != nil {
if strings.Contains(encoding.TryParsingCustomError(err).Error(), "L1_FORK_CHOICE_NOT_FOUND") {
// proof hasnt been submitted, just break and continue as normal
break
// proof hasnt been submitted
return false, nil
} else {
return err
return false, err
}
}

block, err := p.rpc.L2.BlockByNumber(ctx, event.BlockId)
if err != nil {
return err
return false, err
}

// proof is invalid but has correct parents, oracle prover should skip
Expand All @@ -497,9 +496,14 @@ func (p *Prover) onBlockProposed(
"expectedBlockHash", block.Hash().Hex(),
)

skipProofWindowExpiredCheck = true
break
return true, nil
}

return false, nil
}

if skipProofWindowExpiredCheck, err = shouldSkipProofWindowExpiredCheck(); err != nil {
return err
}
}

Expand Down

0 comments on commit f01004f

Please sign in to comment.