Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERA history import/export start #6173

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
301180c
ERA history import/export start
ak88 Sep 26, 2023
5a0b8c4
Rename in unit test
ak88 Oct 9, 2023
04209fb
Fix block index not set
ak88 Oct 9, 2023
4b10a61
Start export
ak88 Oct 10, 2023
bfcbfb5
Era builder
ak88 Oct 13, 2023
e9d91b6
Accumulator calculation
ak88 Oct 17, 2023
7b88e17
ERA history import/export
ak88 Sep 26, 2023
1543a39
Rename in unit test
ak88 Oct 9, 2023
e07cca5
Fix block index not set
ak88 Oct 9, 2023
42131e6
Start export
ak88 Oct 10, 2023
551d974
Era builder
ak88 Oct 13, 2023
aba6cfb
Accumulator calculation
ak88 Oct 17, 2023
65a9225
Builder finalize
ak88 Oct 18, 2023
d0741e5
Merge branch 'feature/era-history' of https://github.com/ak88/netherm…
ak88 Oct 18, 2023
508f1ae
Unit tests
ak88 Oct 23, 2023
c7636c2
Unit tests
ak88 Oct 24, 2023
ee53da7
import geth files
ak88 Nov 1, 2023
8503f08
Reader with netty
ak88 Nov 2, 2023
66eacd1
1mb read buffer
ak88 Nov 2, 2023
8d48264
refactor test and use of netty
ak88 Nov 3, 2023
904ecab
Big blocks test
ak88 Nov 4, 2023
74d14ad
Change to IByteBuffer
ak88 Nov 4, 2023
e1e86ae
buffer allocater injected
ak88 Nov 4, 2023
d8f4ad8
Merge branch 'NettyBuffers' into feature/era-history
ak88 Nov 4, 2023
c27adf6
Squashed commit of the following:
ak88 Nov 5, 2023
27fc5cd
Merge from master
ak88 Nov 5, 2023
756b170
assert files exist
ak88 Nov 5, 2023
e3a6647
reverted
ak88 Nov 6, 2023
f18e742
rollback gitbook
ak88 Nov 6, 2023
7066e64
Merge branch 'master' into feature/era-history
ak88 Nov 6, 2023
d2656d8
revert gitbook
ak88 Nov 6, 2023
5d43047
revert launchsettings
ak88 Nov 6, 2023
dedba82
Delete from this pr
ak88 Nov 6, 2023
f2f03db
format whitespace
ak88 Nov 6, 2023
58f8a06
small fix
ak88 Nov 7, 2023
f089911
accumulator test
ak88 Nov 7, 2023
5c9f698
Squashed commit of the following:
ak88 Nov 9, 2023
ce691f0
ReceiptMessageDecoder cleanup
ak88 Nov 9, 2023
c618d97
Squashed commit of the following:
ak88 Nov 10, 2023
c3e6df8
no seeking to index
ak88 Nov 10, 2023
c0640ed
reuse compression streams
ak88 Nov 10, 2023
85dfb85
format
ak88 Nov 10, 2023
6330162
Performance optimization
ak88 Nov 10, 2023
3fed302
avoid a copy and dispose on ex
ak88 Nov 11, 2023
1900b69
Merge branch 'feature/era-history' of https://github.com/ak88/netherm…
ak88 Nov 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Nethermind/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<PackageVersion Include="SCrypt" Version="2.0.0.2" />
<PackageVersion Include="Seq.Api" Version="2023.3.0" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="Snappier" Version="1.1.1" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it faster or better than then already used Snappy.Standard?

Copy link
Contributor Author

@ak88 ak88 Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that era1 uses framing format which the existing lib does not support

<PackageVersion Include="Snappy.Standard" Version="0.2.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageVersion Include="System.Diagnostics.TextWriterTraceListener" Version="4.3.0" />
Expand Down
4 changes: 4 additions & 0 deletions src/Nethermind/Nethermind.Era.Test/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

global using NUnit.Framework;
68 changes: 68 additions & 0 deletions src/Nethermind/Nethermind.Era.Test/Nethermind.Era1.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Snappier" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Nethermind.Era1\Nethermind.Era1.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="data\checksums.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00000-096013b1.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00001-440820aa.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00002-f324ec16.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00003-627b9dce.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00004-08ecec94.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00005-e2d2b70f.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00006-286c2ca5.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00007-c9075184.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\mainnet-00008-bfd52f39.era1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="data\raw">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
85 changes: 85 additions & 0 deletions src/Nethermind/Nethermind.Era.Test/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System.Diagnostics;
using Nethermind.Core;
using Nethermind.Era1;
using Nethermind.Serialization.Rlp;
using NUnit.Framework.Constraints;
using Snappier;
namespace Nethermind.Era.Test;

public class Tests
{
[SetUp]
public void Setup()
{
}

[Test]
public async Task Test1()
{
var ms = new MemoryStream();
var sut = await E2Store.FromStream(ms);

sut.WriteEntry(E2Store.TypeVersion, Array.Empty<byte>());
}

[Test]
public async Task TestHistoryImport()
{
var eraFiles = E2Store.GetAllEraFiles("data", "mainnet");

foreach (var era in eraFiles)
{
var sut = await EraIterator.Create(era);

await foreach ((Block b, TxReceipt[] r) in sut)
{
Debug.WriteLine($"Reencoding block");

Rlp encodedHeader = new HeaderDecoder().Encode(b.Header);
Debug.WriteLine($"Encoded header {BitConverter.ToString(encodedHeader.Bytes).Replace("-","")}");
Rlp encodedBody = new BlockBodyDecoder().Encode(b.Body);
Debug.WriteLine($"Encoded body {BitConverter.ToString(encodedBody.Bytes).Replace("-", "")}");

NettyRlpStream encodedReceipt = new ReceiptDecoder().EncodeToNewNettyStream(r);
}
}

}

[Test]
public async Task TestE2Store()
{
var sut = await E2Store.FromStream(File.OpenRead("data/mainnet-00000-096013b1.era1"));

var testData = Convert.FromHexString("FF060000734E6150705900B00000FCED3AFBFB0310F901F8A0007A010088A01DCC4DE8DEC75D7AAB85B567B6CCD41AD312451B948A7413F0A142FD40D4934794004A4200F043A09F88BE00EEE1114EDFD9372F52560AAB3980A142EFE8B5B39A09644075084275A056E81F171BCC55A6FF8345E692C0F86E5B48E01B996CADC001622FB5E363B421A0567A210004B9014A7800FE0100FE0100FE0100B601002C83020000808347E7C480808082C90134880000000000000000843B9ACA00");

var compressedHeaders = await sut.FindAll(E2Store.TypeCompressedHeader);

foreach (var cb in compressedHeaders)
{
try
{
void Test()
{
var output = new byte[1000];
var decompressionStream = new SnappyStream(cb.ValueAsStream(), System.IO.Compression.CompressionMode.Decompress);
var x = decompressionStream.Read(output, 0, output.Length);
var s = new Span<byte>(output, 0, x);
var decoded = Rlp.Decode<BlockHeader>(s);

}
Test();

}
catch (InvalidDataException)
{
continue;
}

}
}

}
9 changes: 9 additions & 0 deletions src/Nethermind/Nethermind.Era.Test/data/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0x4c098bf3d1e599a2657ca2856811d885afd2ff3417f073348a0b3ba0989d0a23
0xeb76936ffb61580f077d6c5145575dc1326b1f21aed8ddd04430c9c726ad823f
0x67a1a249dd63ac7fab0292a27c210597cb053afb87d859f70d8470958f50910b
0x2d96d98253775ba8ea505622634a31b44fc7333e564f9c1f40beba44864cb170
0x5f58d700d9374e61283c7f2b463130e11347da23c4682e69972605a2ca637fe0
0x86390cdd139909397b7003aef2ad1863f65cfe2626aeb105ef1cb24e06c37d69
0xe82aec7edfdb310a1259c251af5ae3697194aa30537bd825d97970525a6a4dd0
0x1d20d98da322db6ff5caaa699ffaf1fe5b3ef8e9cd9188d44500633e0814ed9c
0x8fce912ffcdda36a0408cf2bf0777f576624f8b4e1547f2dd59656c0d29dde06
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/Nethermind/Nethermind.Era.Test/data/raw
Binary file not shown.