From fed3a27c17260e81726f946170b3f02e5af5197e Mon Sep 17 00:00:00 2001 From: David Date: Thu, 21 Mar 2024 11:37:59 +0800 Subject: [PATCH] feat(pkg): remove `IsArchiveNode` check for L1 endpoint (#652) --- pkg/rpc/client.go | 14 -------------- pkg/rpc/utils.go | 16 ---------------- 2 files changed, 30 deletions(-) diff --git a/pkg/rpc/client.go b/pkg/rpc/client.go index 11eff024f..3aa2b0a51 100644 --- a/pkg/rpc/client.go +++ b/pkg/rpc/client.go @@ -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" ) @@ -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 diff --git a/pkg/rpc/utils.go b/pkg/rpc/utils.go index 0730ff4dd..20fa554ea 100644 --- a/pkg/rpc/utils.go +++ b/pkg/rpc/utils.go @@ -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.