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

Commit

Permalink
feat(pkg): remove IsArchiveNode check for L1 endpoint (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Mar 21, 2024
1 parent d6d82cc commit fed3a27
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
14 changes: 0 additions & 14 deletions pkg/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package rpc

import (
"context"
"fmt"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/taikoxyz/taiko-client/bindings"
)
Expand Down Expand Up @@ -88,18 +86,6 @@ func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error) {
}
}

stateVars, err := taikoL1.GetStateVariables(&bind.CallOpts{Context: ctxWithTimeout})
if err != nil {
return nil, err
}
isArchive, err := IsArchiveNode(ctxWithTimeout, l1Client, stateVars.A.GenesisHeight)
if err != nil {
return nil, err
}
if !isArchive {
return nil, fmt.Errorf("error with RPC endpoint: node (%s) must be archive node", cfg.L1Endpoint)
}

// If not providing L2EngineEndpoint or JwtSecret, then the L2Engine client
// won't be initialized.
var l2AuthClient *EngineClient
Expand Down
16 changes: 0 additions & 16 deletions pkg/rpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,22 +381,6 @@ func StringToBytes32(str string) [32]byte {
return b
}

// IsArchiveNode checks if the given node is an archive node.
func IsArchiveNode(ctx context.Context, client *EthClient, l2GenesisHeight uint64) (bool, error) {
ctxWithTimeout, cancel := ctxWithTimeoutOrDefault(ctx, defaultTimeout)
defer cancel()

if _, err := client.BalanceAt(ctxWithTimeout, ZeroAddress, new(big.Int).SetUint64(l2GenesisHeight)); err != nil {
if strings.Contains(err.Error(), "missing trie node") {
return false, nil
}

return false, err
}

return true, nil
}

// ctxWithTimeoutOrDefault sets a context timeout if the deadline has not passed or is not set,
// and otherwise returns the context as passed in. cancel func is always set to an empty function
// so is safe to defer the cancel.
Expand Down

0 comments on commit fed3a27

Please sign in to comment.