Skip to content

Commit

Permalink
Remove in Hash256
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej committed Feb 26, 2025
1 parent 9bc6e87 commit 14e602b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface IRandomContract : IActivatedAtBlock
/// <param name="secretHash">The Keccak-256 hash of the validator's secret.</param>
/// <param name="cipher">The cipher of the validator's secret. Can be used by the node to restore the lost secret after the node is restarted (see the `getCipher` getter).</param>
/// <returns>Transaction to be included in block.</returns>
Transaction CommitHash(in Hash256 secretHash, byte[] cipher);
Transaction CommitHash(Hash256 secretHash, byte[] cipher);

/// <summary>
/// Called by the validator's node to XOR its number with the current random seed.
Expand Down Expand Up @@ -178,7 +178,7 @@ private UInt256 CurrentCollectRound(BlockHeader parentHeader) =>
/// <param name="secretHash">The Keccak-256 hash of the validator's secret.</param>
/// <param name="cipher">The cipher of the validator's secret. Can be used by the node to restore the lost secret after the node is restarted (see the `getCipher` getter).</param>
/// <returns>Transaction to be included in block.</returns>
public Transaction CommitHash(in Hash256 secretHash, byte[] cipher) => GenerateTransaction<GeneratedTransaction>(nameof(CommitHash), SignerAddress, secretHash.BytesToArray(), cipher);
public Transaction CommitHash(Hash256 secretHash, byte[] cipher) => GenerateTransaction<GeneratedTransaction>(nameof(CommitHash), SignerAddress, secretHash.BytesToArray(), cipher);

/// <summary>
/// Called by the validator's node to XOR its number with the current random seed.
Expand Down
7 changes: 3 additions & 4 deletions src/Nethermind/Nethermind.State/SnapServer/ISnapServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ namespace Nethermind.State.SnapServer;

public interface ISnapServer
{
IOwnedReadOnlyList<byte[]>? GetTrieNodes(IReadOnlyList<PathGroup> pathSet, in Hash256 rootHash,
CancellationToken cancellationToken);
IOwnedReadOnlyList<byte[]>? GetTrieNodes(IReadOnlyList<PathGroup> pathSet, Hash256 rootHash, CancellationToken cancellationToken);
IOwnedReadOnlyList<byte[]> GetByteCodes(IReadOnlyList<ValueHash256> requestedHashes, long byteLimit, CancellationToken cancellationToken);

(IOwnedReadOnlyList<PathWithAccount>, IOwnedReadOnlyList<byte[]>) GetAccountRanges(in Hash256 rootHash,
(IOwnedReadOnlyList<PathWithAccount>, IOwnedReadOnlyList<byte[]>) GetAccountRanges(Hash256 rootHash,
in ValueHash256 startingHash,
in ValueHash256? limitHash,
long byteLimit,
CancellationToken cancellationToken);

(IOwnedReadOnlyList<IOwnedReadOnlyList<PathWithStorageSlot>>, IOwnedReadOnlyList<byte[]>?) GetStorageRanges(
in Hash256 rootHash,
Hash256 rootHash,
IReadOnlyList<PathWithAccount> accounts,
in ValueHash256? startingHash,
in ValueHash256? limitHash,
Expand Down
17 changes: 14 additions & 3 deletions src/Nethermind/Nethermind.State/SnapServer/SnapServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private bool IsRootMissing(Hash256 stateRoot)
return !_stateReader.HasStateForRoot(stateRoot) || _lastNStateRootTracker?.HasStateRoot(stateRoot) == false;
}

public IOwnedReadOnlyList<byte[]>? GetTrieNodes(IReadOnlyList<PathGroup> pathSet, in Hash256 rootHash, CancellationToken cancellationToken)
public IOwnedReadOnlyList<byte[]>? GetTrieNodes(IReadOnlyList<PathGroup> pathSet, Hash256 rootHash, CancellationToken cancellationToken)
{
if (IsRootMissing(rootHash)) return ArrayPoolList<byte[]>.Empty();

Expand Down Expand Up @@ -169,7 +169,12 @@ public IOwnedReadOnlyList<byte[]> GetByteCodes(IReadOnlyList<ValueHash256> reque
return response;
}

public (IOwnedReadOnlyList<PathWithAccount>, IOwnedReadOnlyList<byte[]>) GetAccountRanges(in Hash256 rootHash, in ValueHash256 startingHash, in ValueHash256? limitHash, long byteLimit, CancellationToken cancellationToken)
public (IOwnedReadOnlyList<PathWithAccount>, IOwnedReadOnlyList<byte[]>) GetAccountRanges(
Hash256 rootHash,
in ValueHash256 startingHash,
in ValueHash256? limitHash,
long byteLimit,
CancellationToken cancellationToken)
{
if (IsRootMissing(rootHash)) return (ArrayPoolList<PathWithAccount>.Empty(), ArrayPoolList<byte[]>.Empty());
byteLimit = Math.Max(Math.Min(byteLimit, HardResponseByteLimit), 1);
Expand All @@ -189,7 +194,13 @@ public IOwnedReadOnlyList<byte[]> GetByteCodes(IReadOnlyList<ValueHash256> reque
return (nodes, proofs);
}

public (IOwnedReadOnlyList<IOwnedReadOnlyList<PathWithStorageSlot>>, IOwnedReadOnlyList<byte[]>?) GetStorageRanges(in Hash256 rootHash, IReadOnlyList<PathWithAccount> accounts, in ValueHash256? startingHash, in ValueHash256? limitHash, long byteLimit, CancellationToken cancellationToken)
public (IOwnedReadOnlyList<IOwnedReadOnlyList<PathWithStorageSlot>>, IOwnedReadOnlyList<byte[]>?) GetStorageRanges(
Hash256 rootHash,
IReadOnlyList<PathWithAccount> accounts,
in ValueHash256? startingHash,
in ValueHash256? limitHash,
long byteLimit,
CancellationToken cancellationToken)
{
if (IsRootMissing(rootHash)) return (ArrayPoolList<IOwnedReadOnlyList<PathWithStorageSlot>>.Empty(), ArrayPoolList<byte[]>.Empty());
byteLimit = Math.Max(Math.Min(byteLimit, HardResponseByteLimit), 1);
Expand Down

0 comments on commit 14e602b

Please sign in to comment.