Skip to content

Commit

Permalink
Allow retrieving memory traces that are unconstrained in size (#6649)
Browse files Browse the repository at this point in the history
  • Loading branch information
guidovranken authored Feb 2, 2024
1 parent 4090798 commit fcc242f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Nethermind/Nethermind.Evm/Tracing/TraceMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public string[] ToHexWordList()
}

private const int MemoryPadLimit = 1024 * 1024;
public ReadOnlySpan<byte> Slice(int start, int length)
public ReadOnlySpan<byte> Slice(int start, int length, bool limit = true)
{
ArgumentOutOfRangeException.ThrowIfNegative(start, nameof(start));
ArgumentOutOfRangeException.ThrowIfNegative(length, nameof(length));
Expand All @@ -55,8 +55,11 @@ public ReadOnlySpan<byte> Slice(int start, int length)

if (start + length > span.Length)
{
int paddingNeeded = start + length - span.Length;
if (paddingNeeded > MemoryPadLimit) throw new InvalidOperationException($"reached limit for padding memory slice: {paddingNeeded}");
if (limit)
{
int paddingNeeded = start + length - span.Length;
if (paddingNeeded > MemoryPadLimit) throw new InvalidOperationException($"reached limit for padding memory slice: {paddingNeeded}");
}
byte[] result = new byte[length];
int overlap = span.Length - start;
if (overlap > 0)
Expand Down

0 comments on commit fcc242f

Please sign in to comment.