Skip to content

Commit

Permalink
Fix block number check
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Oct 3, 2024
1 parent ffde4fd commit c0270a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions op-proposer/proposer/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

type L1Client interface {
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
BlockReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
Expand Down
6 changes: 3 additions & 3 deletions op-proposer/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ func (l *L2OutputSubmitter) generateNextProposal(ctx context.Context, lastPropos
}

if shouldPropose {
latestBlockHeader, err := l.L2Client.HeaderByNumber(l.ctx, nil)
latestL1BlockHeader, err := l.L1Client.HeaderByNumber(l.ctx, nil)
if err != nil {
log.Warn("Failed to get latest block header", "err", err)
shouldPropose = false
} else if lastProposal.BlockRef.Number <= latestBlockHeader.Number.Uint64()-256 {
} else if lastProposal.BlockRef.L1Origin.Number <= latestL1BlockHeader.Number.Uint64()-256 {
// only submit onchain if within the blockhash window
log.Warn("Not submitting proposal, block is too old", "block", lastProposal.BlockRef.Number, "latest", latestBlockHeader.Number.Uint64())
log.Warn("Not submitting proposal, block is too old", "l1Origin", lastProposal.BlockRef.L1Origin.Number, "l1Latest", latestL1BlockHeader.Number.Uint64())
shouldPropose = false
}
}
Expand Down

0 comments on commit c0270a1

Please sign in to comment.