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

Commit

Permalink
feat(prover): check transition.blockHash before proof generation (#415
Browse files Browse the repository at this point in the history
)
  • Loading branch information
davidtaikocha authored Sep 28, 2023
1 parent 84eedae commit dd77f7a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
14 changes: 14 additions & 0 deletions pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ func NeedNewProof(
return true, nil
}

l1Origin, err := cli.WaitL1Origin(ctxWithTimeout, id)
if err != nil {
return false, err
}

if l1Origin.L2BlockHash != transition.BlockHash {
log.Info(
"Different blockhash detected, try submitting a proof",
"local", common.BytesToHash(l1Origin.L2BlockHash[:]),
"protocol", common.BytesToHash(transition.BlockHash[:]),
)
return true, nil
}

if proverAddress == transition.Prover {
log.Info("📬 Block's proof has already been submitted by current prover", "blockID", id)
return false, nil
Expand Down
24 changes: 11 additions & 13 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,20 +460,18 @@ func (p *Prover) onBlockProposed(
}

// Check whether the block's proof is still needed.
if !p.cfg.OracleProver {
needNewProof, err := rpc.NeedNewProof(
p.ctx,
p.rpc,
event.BlockId,
p.proverAddress,
)
if err != nil {
return fmt.Errorf("failed to check whether the L2 block needs a new proof: %w", err)
}
needNewProof, err := rpc.NeedNewProof(
p.ctx,
p.rpc,
event.BlockId,
p.proverAddress,
)
if err != nil {
return fmt.Errorf("failed to check whether the L2 block needs a new proof: %w", err)
}

if !needNewProof {
return nil
}
if !needNewProof {
return nil
}

// Check if the current prover has seen this block ID before, there was probably
Expand Down

0 comments on commit dd77f7a

Please sign in to comment.