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

feat(prover): optimize skipProofWindowExpiredCheck check && update NeedNewProof check #313

Merged
merged 3 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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