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

feat(prover): check transition.blockHash before proof generation #415

Merged
merged 2 commits into from
Sep 28, 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
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