From c01f18ff306020aa4afa4ee2ee380079d4a085c6 Mon Sep 17 00:00:00 2001 From: Guido Vranken Date: Thu, 1 Feb 2024 22:47:02 +0100 Subject: [PATCH] Allow retrieving memory traces that are unconstrained in size --- src/Nethermind/Nethermind.Evm/Tracing/TraceMemory.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Nethermind/Nethermind.Evm/Tracing/TraceMemory.cs b/src/Nethermind/Nethermind.Evm/Tracing/TraceMemory.cs index cc63b903019..7668c220405 100644 --- a/src/Nethermind/Nethermind.Evm/Tracing/TraceMemory.cs +++ b/src/Nethermind/Nethermind.Evm/Tracing/TraceMemory.cs @@ -46,7 +46,7 @@ public string[] ToHexWordList() } private const int MemoryPadLimit = 1024 * 1024; - public ReadOnlySpan Slice(int start, int length) + public ReadOnlySpan Slice(int start, int length, bool limit = true) { ArgumentOutOfRangeException.ThrowIfNegative(start, nameof(start)); ArgumentOutOfRangeException.ThrowIfNegative(length, nameof(length)); @@ -55,8 +55,11 @@ public ReadOnlySpan 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)