Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,16 @@ func (api *BlockChainAPI) SimulateV1(ctx context.Context, opts simOpts, blockNrO
} else if len(opts.BlockStateCalls) > maxSimulateBlocks {
return nil, &clientLimitExceededError{message: "too many blocks"}
}
var totalCalls int
for _, block := range opts.BlockStateCalls {
if len(block.Calls) > maxSimulateCallsPerBlock {
return nil, &clientLimitExceededError{message: fmt.Sprintf("too many calls in block: %d > %d", len(block.Calls), maxSimulateCallsPerBlock)}
}
totalCalls += len(block.Calls)
if totalCalls > maxSimulateTotalCalls {
return nil, &clientLimitExceededError{message: fmt.Sprintf("too many calls: %d > %d", totalCalls, maxSimulateTotalCalls)}
}
}
if blockNrOrHash == nil {
n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
blockNrOrHash = &n
Expand Down
8 changes: 8 additions & 0 deletions internal/ethapi/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ const (
// in a single request.
maxSimulateBlocks = 256

// maxSimulateCallsPerBlock is the maximum number of calls allowed in a
// single simulated block.
maxSimulateCallsPerBlock = 5000

// maxSimulateTotalCalls is the maximum total number of calls allowed
// across all simulated blocks in a single request.
maxSimulateTotalCalls = 10000

// timestampIncrement is the default increment between block timestamps.
timestampIncrement = 12
)
Expand Down
Loading