Skip to content

Commit

Permalink
feat: check preconf_router for proposer
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jan 25, 2025
1 parent a92ac5b commit 9c9e47a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/taiko-client/pkg/rpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (c *Client) GetProtocolConfigs(opts *bind.CallOpts) (config.ProtocolConfigs
}

// ResolvePacaya resolves the address from TaikoInbox contract.
func (c *Client) ResolvePacaya(opts *bind.CallOpts, name string) (common.Address, error) {
func (c *Client) ResolvePacaya(opts *bind.CallOpts, name string, allowZero bool) (common.Address, error) {
var cancel context.CancelFunc
if opts == nil {
opts = &bind.CallOpts{Context: context.Background()}
Expand All @@ -74,7 +74,7 @@ func (c *Client) ResolvePacaya(opts *bind.CallOpts, name string) (common.Address
return common.Address{}, fmt.Errorf("failed to create resolver contract: %w", err)
}

return resolver.Resolve(opts, c.L1.ChainID, StringToBytes32(name), false)
return resolver.Resolve(opts, c.L1.ChainID, StringToBytes32(name), allowZero)
}

// ensureGenesisMatched fetches the L2 genesis block from TaikoL1 contract,
Expand Down Expand Up @@ -1134,7 +1134,7 @@ func (c *Client) GetPreconfWhiteListOperator(opts *bind.CallOpts) (common.Addres
opts.Context, cancel = CtxWithTimeoutOrDefault(opts.Context, defaultTimeout)
defer cancel()

whiteListAddress, err := c.ResolvePacaya(opts, "preconf_whitelist")
whiteListAddress, err := c.ResolvePacaya(opts, "preconf_whitelist", true)
if err != nil {
return common.Address{}, err
}
Expand Down
10 changes: 10 additions & 0 deletions packages/taiko-client/proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,16 @@ func (p *Proposer) ProposeTxLists(ctx context.Context, txLists []types.Transacti

// Check if the current L2 chain is after Pacaya fork, propose blocks batch.
if p.chainConfig.IsPacaya(new(big.Int).SetUint64(l2Head + 1)) {
preconfRouter, err := p.rpc.ResolvePacaya(nil, "preconf_router", true)
if err != nil {
return fmt.Errorf("failed to resolve preconfirmation router address: %w", err)
}

if preconfRouter != rpc.ZeroAddress {
log.Info("Preconfirmation router is set, skipping proposing blocks batch")
return nil
}

if err := p.ProposeTxListPacaya(ctx, txLists); err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (a *ProveBlockTxBuilder) BuildProveBatchesPacaya(batchProof *proofProducer.
batchIDs = make([]uint64, len(batchProof.ProofResponses))
)
// NOTE: op_verifier is the only verifier address for now.
opVerifier, err := a.rpc.ResolvePacaya(&bind.CallOpts{Context: txOpts.Context}, "op_verifier")
opVerifier, err := a.rpc.ResolvePacaya(&bind.CallOpts{Context: txOpts.Context}, "op_verifier", false)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 9c9e47a

Please sign in to comment.