Skip to content

Commit

Permalink
Optimize GMP data import (NethermindEth#6551)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo authored Jan 16, 2024
1 parent 47a67a5 commit 3e1ff45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Evm/Precompiles/ModExpPrecompile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ private static mpz_t ImportDataToGmp(byte[] data)
{
mpz_t result = new();
gmp_lib.mpz_init(result);
ulong memorySize = ulong.Parse(data.Length.ToString());
ulong memorySize = (ulong)data.Length;
using void_ptr memoryChunk = gmp_lib.allocate(memorySize);

Marshal.Copy(data, 0, memoryChunk.ToIntPtr(), data.Length);
gmp_lib.mpz_import(result, ulong.Parse(data.Length.ToString()), 1, 1, 1, 0, memoryChunk);
gmp_lib.mpz_import(result, memorySize, 1, 1, 1, 0, memoryChunk);

return result;
}
Expand Down

0 comments on commit 3e1ff45

Please sign in to comment.