diff --git a/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs b/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs index 3990b33b775..5b23432416d 100644 --- a/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs +++ b/src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs @@ -111,5 +111,10 @@ public static class ErrorCodes /// Invalid RPC simulate call transaction /// public const int InvalidTransaction = -38014; + + /// + /// Too many blocks for simulation + /// + public const int ClientLimitExceededError = -38026; } } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs index 260e06ad804..a67712aeeb3 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs @@ -143,6 +143,11 @@ public override ResultWrapper> Execute( return ResultWrapper>.Fail( $"Block number out of order {givenNumber} is < than given base number of {header.Number}!", ErrorCodes.InvalidInputBlocksOutOfOrder); + // if the no. of filler blocks are greater than maximum simulate blocks cap + if (givenNumber - (ulong)lastBlockNumber > (ulong)_blocksLimit) + return ResultWrapper>.Fail( + $"too many blocks", + ErrorCodes.ClientLimitExceededError); for (ulong fillBlockNumber = (ulong)lastBlockNumber + 1; fillBlockNumber < givenNumber; fillBlockNumber++) {