diff --git a/pkg/rpc/client.go b/pkg/rpc/client.go index fef3aa98b..87bb01892 100644 --- a/pkg/rpc/client.go +++ b/pkg/rpc/client.go @@ -2,10 +2,11 @@ package rpc import ( "context" - "errors" + "fmt" "math/big" "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient/gethclient" @@ -13,10 +14,6 @@ import ( "github.com/taikoxyz/taiko-client/bindings" ) -var ( - errNotArchiveNode = errors.New("error with rpc: node must be archive node") -) - // Client contains all L1/L2 RPC clients that a driver needs. type Client struct { // Geth ethclient clients @@ -62,15 +59,6 @@ func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error) { return nil, err } - isArchive, err := IsArchiveNode(ctx, l1RPC) - if err != nil { - return nil, err - } - - if !isArchive { - return nil, errNotArchiveNode - } - taikoL1, err := bindings.NewTaikoL1Client(cfg.TaikoL1Address, l1RPC) if err != nil { return nil, err @@ -94,6 +82,20 @@ func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error) { return nil, err } + stateVars, err := taikoL1.GetStateVariables(&bind.CallOpts{Context: ctx}) + if err != nil { + return nil, err + } + + isArchive, err := IsArchiveNode(ctx, l1RPC, stateVars.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) + } + l1RawRPC, err := rpc.Dial(cfg.L1Endpoint) if err != nil { return nil, err diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index 149bc7515..58d2e4a19 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -216,6 +216,7 @@ func (c *Client) GetPoolContent( blockMaxGasLimit uint32, maxBytesPerTxList uint64, locals []common.Address, + maxTransactions uint64, ) ([]types.Transactions, error) { var localsArg []string for _, local := range locals { @@ -232,6 +233,7 @@ func (c *Client) GetPoolContent( maxBytesPerTxList, minTxGasLimit, localsArg, + maxTransactions, ) return result, err diff --git a/pkg/rpc/utils.go b/pkg/rpc/utils.go index 902c384e5..63d01a86e 100644 --- a/pkg/rpc/utils.go +++ b/pkg/rpc/utils.go @@ -175,9 +175,9 @@ func StringToBytes32(str string) [32]byte { return b } -func IsArchiveNode(ctx context.Context, client *ethclient.Client) (bool, error) { - _, err := client.BalanceAt(ctx, zeroAddress, big.NewInt(1)) - if err != nil { +// IsArchiveNode checks if the given node is an archive node. +func IsArchiveNode(ctx context.Context, client *ethclient.Client, l2GenesisHeight uint64) (bool, error) { + if _, err := client.BalanceAt(ctx, zeroAddress, new(big.Int).SetUint64(l2GenesisHeight)); err != nil { if strings.Contains(err.Error(), "missing trie node") { return false, nil } diff --git a/proposer/proposer.go b/proposer/proposer.go index 134eaa50e..0baa80420 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -208,6 +208,7 @@ func (p *Proposer) ProposeOp(ctx context.Context) error { p.protocolConfigs.BlockMaxGasLimit, p.protocolConfigs.BlockMaxTxListBytes, p.locals, + p.maxProposedTxListsPerEpoch, ) if err != nil { return fmt.Errorf("failed to fetch transaction pool content: %w", err)