NethermindEth / Paprika

A custom storage engine of Nethermind, benefiting from the alignment of the underlying data structure with the layout of State & Storage trees of Ethereum.
GNU Lesser General Public License v3.0
91 stars 13 forks source link

Keccak should compute over non-contiuous memory regions #127

Closed Scooletz closed 3 hours ago

Scooletz commented 1 year ago

Paprika has a copy of Keccak from Nethermind Keccak. Currently, Keccak implementation does not implement HashAlgorithm. The mentioned class provides two methods

  1. HashCore(ReadOnlySpan))) and
  2. HashFinal() that can be used to construct a hash over a non-continuous memory. It'd be great if Keccak, even without implementing the actual HashAlgorithm allowed for handling the upgradability and consumption of sequences of memory.

Once provided, RLP encoding could benefit from it greatly.

Be minded, that it does not have to use ReadOnlySequence<byte> per se, but might provide some other, streaming API that could for example accept up to N spans by providing a span-like sequence or multiple overloads.

Scooletz commented 1 year ago

https://github.com/NethermindEth/nethermind/blob/bb5c5d5834ce631f4c611592fcb0832c6636025b/src/Nethermind/Nethermind.Core/Crypto/KeccakHash.cs#L444 Should be used.

Scooletz commented 3 hours ago

Not worth to pursue. We copy so little atm.