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

Feature/t8n #6833

Closed
wants to merge 142 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
b1bfcab
Initial structure for t8n
jmjac Jan 25, 2024
f4d7d60
Add block header
jmjac Jan 25, 2024
59afebe
Convert alloc to worldstate
jmjac Jan 26, 2024
599a494
Set proper account nonce from alloc
jmjac Jan 26, 2024
395f414
Logic for executing transaction(not working correctly yet)
jmjac Jan 27, 2024
b861f0b
Clean up and correctly set which args are null
jmjac Jan 31, 2024
1d20a71
Add missing fields to tx conversion
jmjac Jan 31, 2024
340d0ad
fixed transaction execution
yeerke Mar 4, 2024
66742af
fixed transaction execution
yeerke Mar 5, 2024
9a043d2
added baseFee for header
yeerke Mar 5, 2024
2e7c3b1
fix tests
yerke26 Mar 13, 2024
7a37879
Merge branch 'master' into feature/t8n
yerke26 Mar 13, 2024
a76beb9
resolve merge conflicts
yerke26 Mar 13, 2024
c85fbf2
Updated TestBlockhashProvider
yerke26 Mar 14, 2024
9e9b62c
refactoring
yerke26 Mar 14, 2024
1734d0f
refactoring
yerke26 Mar 14, 2024
25cf5d1
Env refactoring
yerke26 Mar 14, 2024
776f787
Env refactoring
yerke26 Mar 15, 2024
5e3ba28
refactoring
yerke26 Mar 15, 2024
97e00c1
refactoring
yerke26 Mar 15, 2024
24acdb2
refactoring
yerke26 Mar 15, 2024
a3daa7d
added more test data
yerke26 Mar 15, 2024
0d7f0c1
fix formatting
yerke26 Mar 17, 2024
99d01da
Add T8NBlockHashProvider
yerke26 Mar 17, 2024
8be2f94
output in files
yerke26 Mar 18, 2024
037b3f8
added Env checks
yerke26 Mar 18, 2024
ab7e34a
added exception handling with exit codes
yerke26 Mar 18, 2024
a0417ee
exit codes
yerke26 Mar 18, 2024
af6494d
add withdrawals, fix tests
yerke26 Mar 19, 2024
754ff4a
Add reward calculation
yerke26 Mar 20, 2024
892bd05
refactoring
yerke26 Mar 20, 2024
cf8b481
refactoring
yerke26 Mar 21, 2024
1a96a65
refactoring
yerke26 Mar 21, 2024
aba5364
fix code formatting
yerke26 Mar 22, 2024
faca266
add unit test
yerke26 Mar 25, 2024
05bc8e8
add unit test
yerke26 Mar 25, 2024
f9455a2
Update T8NTool.cs
Demuirgos Mar 27, 2024
48f4e59
added more unit tests
yerke26 Mar 27, 2024
b6e259e
fix ReceiptJsonConverter
yerke26 Mar 28, 2024
4a6dae4
Merge branch 'feature/t8n' of https://github.com/NethermindEth/nether…
yerke26 Mar 28, 2024
b24757a
fix tests
yerke26 Mar 28, 2024
91345a9
fix
yerke26 Mar 28, 2024
e3ad744
add storage cells to output alloc
yerke26 Apr 1, 2024
caca101
fixed storage output
yerke26 Apr 1, 2024
b83e2e2
Implement native prestate tracer
natebeauregard Apr 1, 2024
256addf
Use prestate values for balance/storage
natebeauregard Apr 1, 2024
afd7b74
Derive executing account in tracer and respond to CR comments
natebeauregard Apr 2, 2024
658ca70
Fix runtime errors and coinbase address bug
natebeauregard Apr 2, 2024
b49c889
Fix error with null transaction To entry
natebeauregard Apr 2, 2024
e757b28
Allow UInt256 values to be serialized in dictionaries
natebeauregard Apr 3, 2024
9e14eba
Fix bugs from testing
natebeauregard Apr 8, 2024
39aef06
Add UInt256 read as property name functionality
natebeauregard Apr 8, 2024
3c18376
Add tests
natebeauregard Apr 8, 2024
f4c2338
Fix whitespace issues
natebeauregard Apr 8, 2024
20ab3dc
Pass through execution environment as a tracer param
natebeauregard Apr 9, 2024
0b96c83
Fix call depth bug
natebeauregard Apr 9, 2024
7539103
Update JS prestate tracer filename in test
natebeauregard Apr 9, 2024
34eb7a7
Address CR comments
natebeauregard Apr 11, 2024
350f88b
deleted testdata folder
yerke26 Apr 15, 2024
a30d65f
resolving PR comments
yerke26 Apr 15, 2024
19fced1
fixing tests
yerke26 Apr 15, 2024
2382297
revert TransactionInfo
yerke26 Apr 16, 2024
e320b54
revert TransactionForRpc
yerke26 Apr 16, 2024
9ef7dc9
Merge remote-tracking branch 'origin/master' into feature/t8n
yerke26 Apr 16, 2024
9503a8e
Merge remote-tracking branch 'origin/feat/native-prestate-tracer' int…
yerke26 Apr 16, 2024
76219f3
Merge remote-tracking branch 'origin/master' into feature/t8n
yerke26 Apr 16, 2024
ad33f18
resolve comments
yerke26 Apr 16, 2024
a2f5865
removed DictionaryUInt256KeyConverter
yerke26 Apr 17, 2024
83a1f76
refactoring
yerke26 Apr 17, 2024
32597c9
update tests submodule
yerke26 Apr 29, 2024
44a427d
merge, resolve conflicts
yerke26 Jul 4, 2024
45a18d2
Merge T8NTool into GeneralTestBase
yerke26 Jul 7, 2024
fb30b0a
Merge branch 'master' into feature/t8n
yerke26 Jul 7, 2024
42198e3
fix compilation error
yerke26 Jul 7, 2024
a13d7e5
fix white spaces, fix tracer in GeneralTestBase
yerke26 Jul 7, 2024
1bf7e3c
Fix Ethereum Tests
yerke26 Jul 7, 2024
6a22202
fix GeneralTestBase
yerke26 Jul 7, 2024
82a2e4f
refactoring
yerke26 Jul 7, 2024
061c277
fix Ethereum Tests
yerke26 Jul 7, 2024
40bcb07
fix Ethereum Tests
yerke26 Jul 7, 2024
e9f3628
test Ethereum tests
yerke26 Jul 8, 2024
a0a6b59
test Ethereum tests
yerke26 Jul 8, 2024
c0e8996
fix Ethereum tests
yerke26 Jul 8, 2024
45b6aa2
clean up
yerke26 Jul 8, 2024
a0e9cab
refactoring
yerke26 Jul 8, 2024
99b9c75
add StateReward to EhtereumBaseTest
yerke26 Jul 8, 2024
ff74397
refactoring
yerke26 Jul 8, 2024
192c5aa
Add ArrowGlacier
yerke26 Jul 8, 2024
a271268
fixing t8n tests
yerke26 Jul 9, 2024
706c5c6
refactoring
yerke26 Jul 9, 2024
021a2ac
refactoring
yerke26 Jul 9, 2024
38c263c
fix whitespaces
yerke26 Jul 9, 2024
3a30e0b
refactoring
yerke26 Jul 9, 2024
90e79c6
Merge branch 'master' into feature/t8n
yerke26 Jul 9, 2024
860fa41
fix missing imports
yerke26 Jul 9, 2024
96cf1c5
refactoring of Tracers
yerke26 Jul 9, 2024
37a96b9
Add GethLikeTrace
yerke26 Jul 10, 2024
c9debf1
add testdata
yerke26 Jul 10, 2024
dc06f1d
whitespaces
yerke26 Jul 10, 2024
8e6f825
fix GeneralTestBase
yerke26 Jul 10, 2024
264bcb3
fix
yerke26 Jul 10, 2024
fca9a2c
whitespaces
yerke26 Jul 10, 2024
a6ad2f8
fix GeneralTestBase
yerke26 Jul 10, 2024
7fa1e93
fix
yerke26 Jul 10, 2024
5d6e0df
fix
yerke26 Jul 10, 2024
798ced4
refactoring
yerke26 Jul 10, 2024
adc25b8
fix t8n test case
yerke26 Jul 10, 2024
48a7ef0
fix T8NTests
yerke26 Jul 17, 2024
ed935cd
add IsStateTest flag
yerke26 Jul 17, 2024
a71e4b2
fix compilation error
yerke26 Jul 17, 2024
5a281bb
Revert
yerke26 Jul 17, 2024
f96fd74
Revert "add IsStateTest flag"
yerke26 Jul 17, 2024
a7e1268
Reapply "add IsStateTest flag"
yerke26 Jul 17, 2024
c2ffd4f
Revert "fix t8n test case"
yerke26 Jul 17, 2024
b3a8616
refactoring
yerke26 Jul 18, 2024
323d546
fix IsNullOrEmpty
yerke26 Jul 18, 2024
6f205c3
fix IsNullOrEmpty
yerke26 Jul 18, 2024
f0bdf25
fix whitespaces, test case
yerke26 Jul 18, 2024
ad5a462
Merge branch 'master' into feature/t8n
stdevMac Aug 5, 2024
c1ee07e
fix test case
yerke26 Aug 12, 2024
c543cd1
Merge remote-tracking branch 'origin/feature/t8n' into feature/t8n
yerke26 Aug 12, 2024
c80fee4
Merge branch 'master' into feature/t8n
yerke26 Aug 16, 2024
e280140
fix
yerke26 Aug 18, 2024
21cdad9
fix evm tests
yerke26 Aug 18, 2024
d2945c6
Merge branch 'master' into feature/t8n
yerke26 Aug 18, 2024
aeed2fd
Feature t8n gnosis (#7319)
stdevMac Oct 16, 2024
709d3ab
Merge branch 'master' into feature/t8n
yerke26 Oct 16, 2024
9248d16
resolve merge conflicts
yerke26 Oct 16, 2024
6484d73
Merge remote-tracking branch 'origin/feature/t8n' into feature/t8n
yerke26 Oct 16, 2024
dd35a9b
fix compilation error
yerke26 Oct 16, 2024
1b81ff1
Merge branch 'master' into feature/t8n
yerke26 Oct 20, 2024
465e39b
fix GeneralTestBase
yerke26 Oct 20, 2024
f6ea323
fix test case
yerke26 Oct 21, 2024
21db0ab
Merge branch 'master' into feature/t8n
yerke26 Oct 21, 2024
be06d3b
Merge branch 'master' into feature/t8n
yerke26 Oct 24, 2024
1437238
revert GeneralTestBase
yerke26 Oct 27, 2024
62338cc
add account storage from BeaconBlockRootHandler
yerke26 Oct 27, 2024
84bab83
fix Gnosis Genesis spec
yerke26 Oct 28, 2024
68e5ab2
Update t8n arguments to lowercase
yerke26 Oct 28, 2024
a4422b9
fix BeaconBlockRootHandlerTests
yerke26 Oct 28, 2024
3001398
set output alloc, result default values
yerke26 Oct 28, 2024
2d7386f
fix write to file
yerke26 Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/Nethermind/Ethereum.Test.Base/AccountState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using System.Collections.Generic;
using Nethermind.Int256;

namespace Ethereum.Test.Base
namespace Ethereum.Test.Base;

public class AccountState
{
public class AccountState
public byte[]? Code { get; set; }
public UInt256 Balance { get; set; }
public UInt256 Nonce { get; set; }
public Dictionary<UInt256, byte[]>? Storage { get; set; }

public bool IsEmptyAccount()
{
public byte[] Code { get; set; }
public UInt256 Balance { get; set; }
public UInt256 Nonce { get; set; }
public Dictionary<UInt256, byte[]> Storage { get; set; }
return Balance.IsZero && Nonce.IsZero && (Code == null || Code.Length == 0) && (Storage == null || Storage.Count == 0);
}
}
65 changes: 65 additions & 0 deletions src/Nethermind/Ethereum.Test.Base/AccountStateConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.Collections.Generic;
using System.Linq;
using Nethermind.Core.Extensions;

namespace Ethereum.Test.Base;

using Nethermind.Int256;
using Nethermind.Serialization.Json;
using System;
using System.Text.Json;
using System.Text.Json.Serialization;

public class AccountStateConverter : JsonConverter<AccountState>
{
private EthereumJsonSerializer _ethereumJsonSerializer = new();

public override AccountState? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return _ethereumJsonSerializer.Deserialize<AccountState>(ref reader);
}

public override void Write(Utf8JsonWriter writer, AccountState value, JsonSerializerOptions options)
{
NumberConversion? previousValue = ForcedNumberConversion.ForcedConversion.Value;
try
{
writer.WriteStartObject();

ForcedNumberConversion.ForcedConversion.Value = NumberConversion.Hex;
if (value.Balance != UInt256.Zero)
{
writer.WritePropertyName("balance"u8);
JsonSerializer.Serialize(writer, value.Balance, options);
}

ForcedNumberConversion.ForcedConversion.Value = NumberConversion.Hex;
if (value.Nonce != UInt256.Zero)
{
writer.WritePropertyName("nonce"u8);
JsonSerializer.Serialize(writer, value.Nonce, options);
}

if (value.Code is not null)
{
writer.WritePropertyName("code"u8);
JsonSerializer.Serialize(writer, value.Code, options);
}

ForcedNumberConversion.ForcedConversion.Value = NumberConversion.ZeroPaddedHex;
if (value.Storage?.Count > 0)
{
Dictionary<UInt256, UInt256> storage =
value.Storage.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.ToUInt256());
writer.WritePropertyName("storage"u8);
JsonSerializer.Serialize(writer, storage, options);
}

writer.WriteEndObject();
}
finally
{
ForcedNumberConversion.ForcedConversion.Value = previousValue;
}
}
}
15 changes: 0 additions & 15 deletions src/Nethermind/Ethereum.Test.Base/AccountStateJson.cs

This file was deleted.

7 changes: 5 additions & 2 deletions src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,12 @@ private void InitializeTestState(BlockchainTest test, IWorldState stateProvider,
foreach (KeyValuePair<Address, AccountState> accountState in
((IEnumerable<KeyValuePair<Address, AccountState>>)test.Pre ?? Array.Empty<KeyValuePair<Address, AccountState>>()))
{
foreach (KeyValuePair<UInt256, byte[]> storageItem in accountState.Value.Storage)
if (accountState.Value.Storage is not null)
{
stateProvider.Set(new StorageCell(accountState.Key, storageItem.Key), storageItem.Value);
foreach (KeyValuePair<UInt256, byte[]> storageItem in accountState.Value.Storage)
{
stateProvider.Set(new StorageCell(accountState.Key, storageItem.Key), storageItem.Value);
}
}

stateProvider.CreateAccount(accountState.Key, accountState.Value.Balance, accountState.Value.Nonce);
Expand Down
5 changes: 3 additions & 2 deletions src/Nethermind/Ethereum.Test.Base/BlockchainTestJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System.Collections.Generic;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Core.Specs;

Expand All @@ -24,8 +25,8 @@ public class BlockchainTestJson
public TestBlockJson[]? Blocks { get; set; }
public TestBlockHeaderJson? GenesisBlockHeader { get; set; }

public Dictionary<string, AccountStateJson>? Pre { get; set; }
public Dictionary<string, AccountStateJson>? PostState { get; set; }
public Dictionary<Address, AccountState>? Pre { get; set; }
public Dictionary<Address, AccountState>? PostState { get; set; }

public Hash256? PostStateHash { get; set; }

Expand Down
21 changes: 20 additions & 1 deletion src/Nethermind/Ethereum.Test.Base/EthereumTestResult.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System.Collections.Generic;
using System.Text.Json.Serialization;

using Ethereum.Test.Base.T8NUtils;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Evm.Tracing.GethStyle.Custom.Native.Prestate;
using Nethermind.Int256;

namespace Ethereum.Test.Base
{
Expand Down Expand Up @@ -37,5 +41,20 @@ public EthereumTestResult(string? name, string? loadFailure)
public double TimeInMs { get; set; }

public Hash256 StateRoot { get; set; } = Keccak.EmptyTreeHash;

public T8NResult T8NResult { get; set; }
}
}

public class RejectedTx
{
public RejectedTx(int index, string error)
{
Index = index;
Error = error;
}

public int Index { get; set; }
public string? Error { get; set; }
}

80 changes: 78 additions & 2 deletions src/Nethermind/Ethereum.Test.Base/GeneralStateTest.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Collections.Generic;
using System.IO;
using Ethereum.Test.Base.Interfaces;
using Nethermind.Consensus.Ethash;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Core.Specs;
using Nethermind.Core.Test.Builders;
using Nethermind.Crypto;
using Nethermind.Evm;
using Nethermind.Evm.Tracing.GethStyle;
using Nethermind.Int256;
using Nethermind.Specs;
using Nethermind.Specs.Forks;

namespace Ethereum.Test.Base
{
public class GeneralStateTest : IEthereumTest
{
public bool IsT8NTest { get; set; } = false;
public string? Category { get; set; }
public string? Name { get; set; }
public IReleaseSpec? Fork { get; set; }
public string? ForkName { get; set; }
public Address? CurrentCoinbase { get; set; }
public UInt256 CurrentDifficulty { get; set; }
public UInt256? CurrentDifficulty { get; set; }

public UInt256? CurrentBaseFee { get; set; }
public long CurrentGasLimit { get; set; }
Expand All @@ -29,7 +38,7 @@ public class GeneralStateTest : IEthereumTest
public Hash256? PostHash { get; set; }
public Hash256? PostReceiptsRoot { get; set; }
public string? LoadFailure { get; set; }
public Transaction? Transaction { get; set; }
public Transaction[] Transactions { get; set; } = [];
public Hash256? CurrentRandom { get; set; }
public Hash256? CurrentBeaconRoot { get; set; }
public Hash256? CurrentWithdrawalsRoot { get; set; }
Expand All @@ -39,9 +48,76 @@ public class GeneralStateTest : IEthereumTest

public Hash256? RequestsRoot { get; set; }

public Withdrawal[] Withdrawals { get; set; } = [];
public ulong ParentTimestamp { get; set; } // optional?
public UInt256? ParentDifficulty { get; set; }
public Hash256? ParentUncleHash { get; set; }
public Hash256? ParentBeaconBlockRoot { get; set; }
public UInt256? ParentBaseFee { get; set; }
public long ParentGasUsed { get; set; }
public long ParentGasLimit { get; set; }
public Dictionary<string, Hash256> BlockHashes { get; set; } = [];
public Ommer[] Ommers { get; set; } = [];
public string? StateReward { get; set; }
public ulong StateChainId { get; set; } = MainnetSpecProvider.Instance.ChainId;
public GethTraceOptions GethTraceOptions { get; set; } = GethTraceOptions.Default;
public bool IsTraceEnabled { get; set; } = false;
public bool IsStateTest { get; set; }

public override string ToString()
{
return $"{Path.GetFileName(Category)}.{Name}_{ForkName}";
}

public BlockHeader GetBlockHeader()
{
BlockHeader header = new(
PreviousHash,
Keccak.OfAnEmptySequenceRlp,
CurrentCoinbase ?? throw new Exception("CurrentCoinbase is missing"),
CurrentDifficulty ?? UInt256.Zero,
CurrentNumber,
CurrentGasLimit,
CurrentTimestamp,
[]);
header.StateRoot = PostHash;
header.Hash = header.CalculateHash();
header.IsPostMerge = Fork is Paris;
header.MixHash = CurrentRandom;
header.WithdrawalsRoot = CurrentWithdrawalsRoot;
header.ParentBeaconBlockRoot = CurrentBeaconRoot;
header.ExcessBlobGas = CurrentExcessBlobGas ?? (Fork is Cancun ? 0ul : null);
header.BlobGasUsed = BlobGasCalculator.CalculateBlobGas(Transactions);
header.ParentBeaconBlockRoot = ParentBeaconBlockRoot;

return header;
}

public BlockHeader? GetParentBlockHeader()
{
if (ParentBlobGasUsed is not null && ParentExcessBlobGas is not null)
{
BlockHeader parent = new(
parentHash: Keccak.Zero,
unclesHash: Keccak.OfAnEmptySequenceRlp,
beneficiary: CurrentCoinbase,
difficulty: ParentDifficulty ?? CurrentDifficulty ?? UInt256.Zero,
number: CurrentNumber - 1,
gasLimit: ParentGasLimit,
timestamp: ParentTimestamp,
extraData: []
)
{
BlobGasUsed = (ulong)ParentBlobGasUsed,
ExcessBlobGas = (ulong)ParentExcessBlobGas,
};
if (ParentBaseFee.HasValue) parent.BaseFeePerGas = ParentBaseFee.Value;
parent.GasUsed = ParentGasUsed;
if (ParentUncleHash != null) parent.UnclesHash = ParentUncleHash;
return parent;
}

return null;
}
}
}
3 changes: 2 additions & 1 deletion src/Nethermind/Ethereum.Test.Base/GeneralStateTestJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Text.Json.Serialization;
using Nethermind.Core;

namespace Ethereum.Test.Base
{
Expand All @@ -12,7 +13,7 @@ public class GeneralStateTestJson
public GeneralStateTestInfoJson? Info { get; set; }
public GeneralStateTestEnvJson? Env { get; set; }
public Dictionary<string, PostStateJson[]>? Post { get; set; }
public Dictionary<string, AccountStateJson>? Pre { get; set; }
public Dictionary<Address, AccountState>? Pre { get; set; }
public string? SealEngine { get; set; }
public string? LoadFailure { get; set; }
public TransactionJson? Transaction { get; set; }
Expand Down
Loading