-
Notifications
You must be signed in to change notification settings - Fork 380
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
Closed
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 5a0b8c4
Rename in unit test
ak88 04209fb
Fix block index not set
ak88 4b10a61
Start export
ak88 bfcbfb5
Era builder
ak88 e9d91b6
Accumulator calculation
ak88 7b88e17
ERA history import/export
ak88 1543a39
Rename in unit test
ak88 e07cca5
Fix block index not set
ak88 42131e6
Start export
ak88 551d974
Era builder
ak88 aba6cfb
Accumulator calculation
ak88 65a9225
Builder finalize
ak88 d0741e5
Merge branch 'feature/era-history' of https://github.com/ak88/netherm…
ak88 508f1ae
Unit tests
ak88 c7636c2
Unit tests
ak88 ee53da7
import geth files
ak88 8503f08
Reader with netty
ak88 66eacd1
1mb read buffer
ak88 8d48264
refactor test and use of netty
ak88 904ecab
Big blocks test
ak88 74d14ad
Change to IByteBuffer
ak88 e1e86ae
buffer allocater injected
ak88 d8f4ad8
Merge branch 'NettyBuffers' into feature/era-history
ak88 c27adf6
Squashed commit of the following:
ak88 27fc5cd
Merge from master
ak88 756b170
assert files exist
ak88 e3a6647
reverted
ak88 f18e742
rollback gitbook
ak88 7066e64
Merge branch 'master' into feature/era-history
ak88 d2656d8
revert gitbook
ak88 5d43047
revert launchsettings
ak88 dedba82
Delete from this pr
ak88 f2f03db
format whitespace
ak88 58f8a06
small fix
ak88 f089911
accumulator test
ak88 5c9f698
Squashed commit of the following:
ak88 ce691f0
ReceiptMessageDecoder cleanup
ak88 c618d97
Squashed commit of the following:
ak88 c3e6df8
no seeking to index
ak88 c0640ed
reuse compression streams
ak88 85dfb85
format
ak88 6330162
Performance optimization
ak88 3fed302
avoid a copy and dispose on ex
ak88 1900b69
Merge branch 'feature/era-history' of https://github.com/ak88/netherm…
ak88 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
68
src/Nethermind/Nethermind.Era.Test/Nethermind.Era1.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+577 Bytes
src/Nethermind/Nethermind.Era.Test/data/mainnet-00008-bfd52f39.era1
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
?There was a problem hiding this comment.
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