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

Commit

Permalink
we should remove current blocks waiting for proof window no matter wh…
Browse files Browse the repository at this point in the history
…at, and check blockHash on profo window expired
  • Loading branch information
cyberhorsey committed Jul 11, 2023
1 parent fe16d35 commit 2b127dd
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,24 +824,27 @@ func (p *Prover) checkProofWindowExpired(ctx context.Context, i int, blockId uin
return encoding.TryParsingCustomError(err)
}

// we should remove this block from being watched regardless of whether the block
// has a valid proof
p.currentBlocksWaitingForProofWindow = append(
p.currentBlocksWaitingForProofWindow[:i],
p.currentBlocksWaitingForProofWindow[i+1:]...,
)

if forkChoice.Prover == zeroAddress {
// we can generate the proof
// we can generate the proof, no proof came in by proof window expiring
p.proveNotify <- big.NewInt(int64(blockId))
} else {
// we need to check the block hash vs the proof's blockHash to see
// if the proof is valid or not
block, err := p.rpc.L2.BlockByNumber(ctx, new(big.Int).SetUint64(blockId))
if err != nil {
return err
}

if block.Hash() == forkChoice.BlockHash {
// we should remove this block from being watched, a proof has already come in that agrees with
// our expected fork choice.
// cancel will remove this from the map.
p.currentBlocksWaitingForProofWindow = append(
p.currentBlocksWaitingForProofWindow[:i],
p.currentBlocksWaitingForProofWindow[i+1:]...,
)
} else {
// if the hashes dont match, we can generate proof even though
// a proof came in before proofwindow expired.
if block.Hash() != forkChoice.BlockHash {
// we can generate the proof, the proof is incorrect since blockHash does not match
// the correct one but parentHash/gasUsed are correct.
p.proveNotify <- big.NewInt(int64(blockId))
Expand Down

0 comments on commit 2b127dd

Please sign in to comment.