Skip to content

Commit

Permalink
feat: update client.go
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Jan 23, 2025
1 parent b53f40e commit b9f2f43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/taiko-client/bindings/pacaya/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d1346e7ff43f8e1676bc3ad52518dbf024562a74
b53f40ec44a60f18c5039efe720fad56fa7627b1
24 changes: 12 additions & 12 deletions packages/taiko-client/pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
defaultTimeout = 1 * time.Minute
pacayaForkHeightDevnet = 0
pacayaForkHeightDevnet = 10
pacayaForkHeightHekla = 0
pacayaForkHeklaMainnet = 0
)
Expand Down Expand Up @@ -146,22 +146,22 @@ func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error) {

// Initialize all smart contract clients.
if err := c.initOntakeClients(cfg); err != nil {
return nil, err
return nil, fmt.Errorf("failed to initialize Ontake clients: %w", err)
}
if err := c.initPacayaClients(cfg); err != nil {
return nil, err
return nil, fmt.Errorf("failed to initialize Pacaya clients: %w", err)
}

// Ensure that the genesis block hash of L1 and L2 match.
ctxWithTimeout, cancel := CtxWithTimeoutOrDefault(ctx, defaultTimeout)
defer cancel()
if err := c.ensureGenesisMatched(ctxWithTimeout); err != nil {
return nil, err
}

// Initialize the fork height numbers.
if err := c.initForkHeightConfigs(ctxWithTimeout); err != nil {
return nil, err
return nil, fmt.Errorf("failed to initialize fork height configs: %w", err)
}

// Ensure that the genesis block hash of L1 and L2 match.
if err := c.ensureGenesisMatched(ctxWithTimeout); err != nil {
return nil, fmt.Errorf("failed to ensure genesis block matched: %w", err)
}

return c, nil
Expand Down Expand Up @@ -290,21 +290,21 @@ func (c *Client) initForkHeightConfigs(ctx context.Context) error {
"error", err,
)
switch c.L2.ChainID.Uint64() {
case params.TaikoInternalL2ANetworkID.Uint64():
c.PacayaClients.ForkHeight = pacayaForkHeightDevnet
case params.HeklaNetworkID.Uint64():
c.PacayaClients.ForkHeight = pacayaForkHeightHekla
case params.TaikoMainnetNetworkID.Uint64():
c.PacayaClients.ForkHeight = pacayaForkHeklaMainnet
default:
return fmt.Errorf("unknown L2 chain ID: %d", c.L2.ChainID.Uint64())
log.Debug("Using devnet Pacaya fork height", "height", pacayaForkHeightDevnet)
c.PacayaClients.ForkHeight = pacayaForkHeightDevnet
}

ontakeProtocolConfigs, err := c.OntakeClients.TaikoL1.GetConfig(&bind.CallOpts{Context: ctx})
if err != nil {
return fmt.Errorf("failed to get Ontake protocol configs: %w", err)
}
c.OntakeClients.ForkHeight = ontakeProtocolConfigs.OntakeForkHeight
return nil
}

// Otherwise, chain is after the Pacaya fork, just use the fork height numbers from the protocol configs.
Expand Down

0 comments on commit b9f2f43

Please sign in to comment.