Skip to content

Commit

Permalink
Change more elements left derivation on snap sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-orzechowski committed Jan 9, 2025
1 parent 7e0c53c commit 78c8f56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Linq;
using Autofac;
using FluentAssertions;
using Nethermind.Blockchain.Synchronization;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Core.Test.Builders;
Expand Down Expand Up @@ -325,19 +324,19 @@ bool HasMoreChildren(ValueHash256 limitHash)
}

HasMoreChildren(TestItem.Tree.AccountsWithPaths[1].Path).Should().BeFalse();
HasMoreChildren(TestItem.Tree.AccountsWithPaths[2].Path).Should().BeFalse();
HasMoreChildren(TestItem.Tree.AccountsWithPaths[2].Path).Should().BeTrue(); //expect leaves exactly at limit path to be included
HasMoreChildren(TestItem.Tree.AccountsWithPaths[3].Path).Should().BeTrue();
HasMoreChildren(TestItem.Tree.AccountsWithPaths[4].Path).Should().BeTrue();

UInt256 between2and3 = new UInt256(TestItem.Tree.AccountsWithPaths[1].Path.Bytes, true);
between2and3 += 5;
UInt256 between1and2 = new UInt256(TestItem.Tree.AccountsWithPaths[1].Path.Bytes, true);
between1and2 += 5;

HasMoreChildren(new Hash256(between2and3.ToBigEndian())).Should().BeFalse();
HasMoreChildren(new Hash256(between1and2.ToBigEndian())).Should().BeFalse();

between2and3 = new UInt256(TestItem.Tree.AccountsWithPaths[2].Path.Bytes, true);
UInt256 between2and3 = new UInt256(TestItem.Tree.AccountsWithPaths[2].Path.Bytes, true);
between2and3 -= 1;

HasMoreChildren(new Hash256(between2and3.ToBigEndian())).Should().BeFalse();
HasMoreChildren(new Hash256(between2and3.ToBigEndian())).Should().BeTrue();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private static (AddRangeResult result, List<(TrieNode, TreePath)> sortedBoundary
{
bool hasKeccak = node.GetChildHashAsValueKeccak(ci, out ValueHash256 childKeccak);

moreChildrenToRight |= hasKeccak && (ci > right && (ci < limit || noLimit));
moreChildrenToRight |= hasKeccak && (ci > right && (ci <= limit || noLimit));

if (ci >= left && ci <= right)
{
Expand Down

0 comments on commit 78c8f56

Please sign in to comment.