Skip to content

Commit 7ae3d74

Browse files
committed
add block limit error
1 parent b2b143a commit 7ae3d74

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Nethermind/Nethermind.JsonRpc/ErrorCodes.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,10 @@ public static class ErrorCodes
111111
/// Invalid RPC simulate call transaction
112112
/// </summary>
113113
public const int InvalidTransaction = -38014;
114+
115+
/// <summary>
116+
/// Too many blocks for simulation
117+
/// </summary>
118+
public const int ClientLimitExceededError = -38026;
114119
}
115120
}

src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ public override ResultWrapper<IReadOnlyList<SimulateBlockResult>> Execute(
143143
return ResultWrapper<IReadOnlyList<SimulateBlockResult>>.Fail(
144144
$"Block number out of order {givenNumber} is < than given base number of {header.Number}!", ErrorCodes.InvalidInputBlocksOutOfOrder);
145145

146+
// if the no. of filler blocks are greater than maximum simulate blocks cap
147+
if (givenNumber - (ulong)lastBlockNumber > (ulong)_blocksLimit)
148+
return ResultWrapper<IReadOnlyList<SimulateBlockResult>>.Fail(
149+
$"too many blocks",
150+
ErrorCodes.ClientLimitExceededError);
146151

147152
for (ulong fillBlockNumber = (ulong)lastBlockNumber + 1; fillBlockNumber < givenNumber; fillBlockNumber++)
148153
{

0 commit comments

Comments
 (0)