Skip to content

Commit

Permalink
Merge branch 'main' into importer
Browse files Browse the repository at this point in the history
  • Loading branch information
Scooletz committed Sep 24, 2024
2 parents 0eb21cc + f39981b commit bae2328
Show file tree
Hide file tree
Showing 12 changed files with 538 additions and 149 deletions.
141 changes: 124 additions & 17 deletions src/Paprika.Tests/Data/SlottedArrayTests.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Paprika.Tests/Merkle/AdditionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task Account_destruction_same_block()
const int seed = 17;
const int storageCount = 32 * 1024;

using var db = PagedDb.NativeMemoryDb(32 * 1024 * 1024, 2);
using var db = PagedDb.NativeMemoryDb(16 * 1024 * 1024, 2);
using var merkle = new ComputeMerkleBehavior();

await using var blockchain = new Blockchain(db, merkle);
Expand Down
10 changes: 5 additions & 5 deletions src/Paprika.Tests/Merkle/RootHashFuzzyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task CalculateStateRootHash(
{
var generator = Build(test);

using var db = PagedDb.NativeMemoryDb(16 * 1024 * 1024, 2);
using var db = PagedDb.NativeMemoryDb(32 * 1024 * 1024, 2);
var parallelism = parallel ? ComputeMerkleBehavior.ParallelismUnlimited : ComputeMerkleBehavior.ParallelismNone;
var merkle = new ComputeMerkleBehavior(parallelism);

Expand Down Expand Up @@ -116,13 +116,13 @@ public async Task CalculateStateRootHash(
//AnsiConsole.Write(visitor.Tree);
}

[TestCase(nameof(Accounts_10_000), 64 * 1024 * 1024UL)]
[TestCase(nameof(Accounts_1_000_000), 1024 * 1024 * 1024UL, Category = Categories.LongRunning)]
public async Task CalculateThenDelete(string test, ulong size)
[TestCase(nameof(Accounts_10_000), 256 * 1024 * 1024L)]
[TestCase(nameof(Accounts_1_000_000), 2 * 1024 * 1024 * 1024L, Category = Categories.LongRunning)]
public async Task CalculateThenDelete(string test, long size)
{
var generator = Build(test);

using var db = PagedDb.NativeMemoryDb(1024 * 1024 * 1024, 2);
using var db = PagedDb.NativeMemoryDb(size, 2);
using var merkle = new ComputeMerkleBehavior(ComputeMerkleBehavior.ParallelismNone);
await using var blockchain = new Blockchain(db, merkle, null, new CacheBudget.Options(2000, 4),
new CacheBudget.Options(2000, 4));
Expand Down
4 changes: 2 additions & 2 deletions src/Paprika.Tests/Store/AbandonedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void Properly_handles_page_addresses_that_are_packed_2()

[TestCase(20, 1, 10_000, false, TestName = "Accounts - 1")]
[TestCase(428, 100, 10_000, false, TestName = "Accounts - 100")]
[TestCase(19285, 4000, 200, false,
[TestCase(19278, 4000, 200, false,
TestName = "Accounts - 4000 to get a bit reuse",
Category = Categories.LongRunning)]
[TestCase(48240, 10_000, 50, false,
[TestCase(48228, 10_000, 50, false,
TestName = "Accounts - 10000 to breach the AbandonedPage",
Category = Categories.LongRunning)]
[TestCase(88262, 20_000, 50, true,
Expand Down
19 changes: 14 additions & 5 deletions src/Paprika.Tests/Store/PageStructurePrintingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,22 @@ Keccak GetStorageAddress(int i)
}
}

[Test]
public async Task Merkle_storage_account()
[TestCase(400_000)]
[TestCase(300_000)]
[TestCase(200_000)]
public async Task Merkle_one_big_storage_account(int storageSlots)
{
var account = Keccak.EmptyTreeHash;

using var db = PagedDb.NativeMemoryDb(MB256);

await using var blockchain = new Blockchain(db, new ComputeMerkleBehavior());

const int storageSlots = 400_000;

var value = new byte[32];

var random = new Random(13);
const int seed = 13;

var random = new Random(seed);
random.NextBytes(value);

using var block = blockchain.StartNew(Keccak.EmptyTreeHash);
Expand All @@ -91,6 +93,13 @@ public async Task Merkle_storage_account()
blockchain.Finalize(commit);
await blockchain.WaitTillFlush(1);

// Assert
using var read = db.BeginReadOnlyBatch();
for (var slot = 0; slot < storageSlots; slot++)
{
read.AssertStorageValue(account, GetStorageAddress(slot), value);
}

var view = new TreeView(db);
db.VisitRoot(view);

Expand Down
4 changes: 2 additions & 2 deletions src/Paprika.Tests/Store/PagedDbTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Paprika.Tests.Store;

public class PagedDbTests
{
private const int Mb = 1024 * 1024;
private const long Mb = 1024 * 1024;
private const int Seed = 17;

[Test]
Expand Down Expand Up @@ -183,7 +183,7 @@ public async Task Multiple_storages_per_commit()
const int accounts = 512 * 1024;
const int size = 10_000;

using var db = PagedDb.NativeMemoryDb(1024 * Mb, 2);
using var db = PagedDb.NativeMemoryDb(2 * 1024 * Mb, 2);

var value = new byte[1] { 13 };

Expand Down
2 changes: 2 additions & 0 deletions src/Paprika.Tests/TestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public static Keccak NextKeccak(this Random random)
return keccak;
}

public static byte NextByte(this Random random) => (byte)random.Next(0, byte.MaxValue);

public static Task WaitTillFlush(this Blockchain chain, uint blockNumber)
{
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
Expand Down
Loading

0 comments on commit bae2328

Please sign in to comment.