diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 3a91dde4de..9238fd0086 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1229,6 +1229,13 @@ func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrO // Note, this function doesn't make any changes in the state/blockchain and is // useful to execute and retrieve values. func (s *BlockChainAPI) MulticallV1(ctx context.Context, opts multicallOpts, blockNrOrHash *rpc.BlockNumberOrHash) ([]blockResult, error) { + if len(opts.BlockStateCalls) == 0 { + // TODO return error code. + return nil, errors.New("invalid params") + } else if len(opts.BlockStateCalls) > maxMulticallBlocks { + // TODO return error code. + return nil, errors.New("invalid params") + } if blockNrOrHash == nil { n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) blockNrOrHash = &n diff --git a/internal/ethapi/multicall.go b/internal/ethapi/multicall.go index f6151f09fb..c3e20da04d 100644 --- a/internal/ethapi/multicall.go +++ b/internal/ethapi/multicall.go @@ -37,6 +37,12 @@ import ( "github.com/ethereum/go-ethereum/trie" ) +const ( + // maxMulticallBlocks is the maximum number of blocks that can be simulated + // in a single request. + maxMulticallBlocks = 256 +) + // CallBatch is a batch of calls to be simulated sequentially. type CallBatch struct { BlockOverrides *BlockOverrides