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

Commit

Permalink
fix(prover): fix a fork choice checking issue (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jul 7, 2023
1 parent e190146 commit a393ed8
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math"
"math/big"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -732,23 +733,28 @@ func (p *Prover) checkProofWindowExpired(ctx context.Context, i int, blockId uin
p.currentBlocksWaitingForProofWindowMutex.Lock()
defer p.currentBlocksWaitingForProofWindowMutex.Unlock()

block, err := p.rpc.TaikoL1.GetBlock(nil, big.NewInt(int64(blockId)))
block, err := p.rpc.TaikoL1.GetBlock(nil, new(big.Int).SetUint64(blockId))
if err != nil {
return err
return encoding.TryParsingCustomError(err)
}

if time.Now().Unix() > int64(block.ProposedAt)+int64(block.ProofWindow) {
// we can see if a fork choice with correct parentHash/gasUsed has come in.
// if it hasnt, we can start to generate a proof for this.

parent, err := p.rpc.L2ParentByBlockId(ctx, big.NewInt(int64(blockId)))
parent, err := p.rpc.L2ParentByBlockId(ctx, new(big.Int).SetUint64(blockId))
if err != nil {
return err
}

forkChoice, err := p.rpc.TaikoL1.GetForkChoice(nil, big.NewInt(int64(blockId)), parent.Hash(), uint32(parent.GasUsed))
if err != nil {
return err
forkChoice, err := p.rpc.TaikoL1.GetForkChoice(
nil,
new(big.Int).SetUint64(blockId),
parent.Hash(),
uint32(parent.GasUsed),
)

if err != nil && !strings.Contains(encoding.TryParsingCustomError(err).Error(), "L1_FORK_CHOICE_NOT_FOUND") {
return encoding.TryParsingCustomError(err)
}

if forkChoice.Prover == zeroAddress {
Expand Down

0 comments on commit a393ed8

Please sign in to comment.