Skip to content

Commit

Permalink
pushbytes fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Scooletz committed Jan 10, 2025
1 parent 11baa10 commit e728269
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Nethermind/Nethermind.Evm/EvmStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,25 @@ public ref Word PushRef()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref UInt256 PushRefAsUInt256() => ref Unsafe.As<Word, UInt256>(ref PushRef());


public void PushBytes(scoped ReadOnlySpan<byte> value)
{
if (typeof(TTracing) == typeof(IsTracing)) _tracer.ReportStackPush(value);

ref Word top = ref PushRef();
top = Unsafe.As<byte, Word>(ref MemoryMarshal.GetReference(value));
if (value.Length != WordSize)
{
// Not full entry, clear first.
top = default;
var offset = WordSize - value.Length;
value.CopyTo(MemoryMarshal.CreateSpan(ref Unsafe.Add(ref Unsafe.As<Word, byte>(ref top), offset),
value.Length));
}
else
{
top = Unsafe.As<byte, Word>(ref MemoryMarshal.GetReference(value));
}

Reshuffle(ref top);
}

Expand Down

0 comments on commit e728269

Please sign in to comment.