diff --git a/src/Nethermind/Nethermind.Evm/Precompiles/IdentityPrecompile.cs b/src/Nethermind/Nethermind.Evm/Precompiles/IdentityPrecompile.cs index e26dc714acc..4b9273a7c1d 100644 --- a/src/Nethermind/Nethermind.Evm/Precompiles/IdentityPrecompile.cs +++ b/src/Nethermind/Nethermind.Evm/Precompiles/IdentityPrecompile.cs @@ -29,7 +29,7 @@ public long DataGasCost(in ReadOnlyMemory inputData, IReleaseSpec releaseS public (ReadOnlyMemory, bool) Run(in ReadOnlyMemory inputData, IReleaseSpec releaseSpec) { - return (inputData, true); + return (inputData.ToArray(), true); } } } diff --git a/src/Nethermind/Nethermind.Evm/VirtualMachine.cs b/src/Nethermind/Nethermind.Evm/VirtualMachine.cs index 14e6a432ff4..a058b6a4ac3 100644 --- a/src/Nethermind/Nethermind.Evm/VirtualMachine.cs +++ b/src/Nethermind/Nethermind.Evm/VirtualMachine.cs @@ -34,6 +34,7 @@ namespace Nethermind.Evm; using System.Collections.Frozen; using System.Linq; +using System.Runtime.InteropServices; using System.Threading; using Int256; @@ -139,7 +140,7 @@ internal readonly ref struct CallResult public static CallResult StackOverflowException => new(EvmExceptionType.StackOverflow); // TODO: use these to avoid CALL POP attacks public static CallResult StackUnderflowException => new(EvmExceptionType.StackUnderflow); // TODO: use these to avoid CALL POP attacks public static CallResult InvalidCodeException => new(EvmExceptionType.InvalidCode); - public static CallResult Empty => new(Array.Empty(), null); + public static CallResult Empty => new(default, null); public CallResult(EvmState stateToExecute) { @@ -159,7 +160,7 @@ private CallResult(EvmExceptionType exceptionType) ExceptionType = exceptionType; } - public CallResult(byte[] output, bool? precompileSuccess, bool shouldRevert = false, EvmExceptionType exceptionType = EvmExceptionType.None) + public CallResult(ReadOnlyMemory output, bool? precompileSuccess, bool shouldRevert = false, EvmExceptionType exceptionType = EvmExceptionType.None) { StateToExecute = null; Output = output; @@ -690,7 +691,7 @@ private CallResult ExecutePrecompile(EvmState state, IReleaseSpec spec) try { (ReadOnlyMemory output, bool success) = precompile.Run(callData, spec); - CallResult callResult = new(output.ToArray(), success, !success); + CallResult callResult = new(output, success, !success); return callResult; } catch (DllNotFoundException exception) @@ -701,7 +702,7 @@ private CallResult ExecutePrecompile(EvmState state, IReleaseSpec spec) catch (Exception exception) { if (_logger.IsError) _logger.Error($"Precompiled contract ({precompile.GetType()}) execution exception", exception); - CallResult callResult = new(Array.Empty(), false, true); + CallResult callResult = new(default, false, true); return callResult; } }