Skip to content

Commit

Permalink
Update hive tests for gray glacier (#4203)
Browse files Browse the repository at this point in the history
* Update hive tests for gray glacier

* Fix/merge instance (#4204)

* London instance as a placeholder for the merge

* fix access list tests

* fix access list check

* Print general tests results

* Revert "Print general tests results"

This reverts commit cf94a8b.

* Add support for post-merge tests

* small refactors

* fix some warnings to run pipeline

Co-authored-by: Tanishq Jasoria <jasoriatanishq@gmail.com>
  • Loading branch information
LukaszRozmej and tanishqjasoria committed Jun 28, 2022
1 parent f519cb1 commit bb7402e
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/Nethermind/Ethereum.Test.Base/GeneralStateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class GeneralStateTest : IEthereumTest
public Keccak? PostReceiptsRoot { get; set; }
public string? LoadFailure { get; set; }
public Transaction? Transaction { get; set; }

public Keccak? CurrentRandom { get; set; }

public override string ToString()
{
return $"{Path.GetFileName(Category)}.{Name}_{ForkName}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class GeneralStateTestEnvJson
public UInt256 CurrentTimestamp { get; set; }
public UInt256? CurrentBaseFee { get; set; }
public Keccak PreviousHash { get; set; }
public Keccak? CurrentRandom { get; set; }
}
}
4 changes: 3 additions & 1 deletion src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer)
InitializeTestState(test, stateProvider, storageProvider, specProvider);

BlockHeader header = new(test.PreviousHash, Keccak.OfAnEmptySequenceRlp, test.CurrentCoinbase,
test.CurrentDifficulty, test.CurrentNumber, test.CurrentGasLimit, test.CurrentTimestamp, new byte[0]);
test.CurrentDifficulty, test.CurrentNumber, test.CurrentGasLimit, test.CurrentTimestamp, Array.Empty<byte>());
header.BaseFeePerGas = test.Fork.IsEip1559Enabled ? test.CurrentBaseFee ?? _defaultBaseFeeForStateTest : UInt256.Zero;
header.StateRoot = test.PostHash;
header.Hash = header.CalculateHash();
header.IsPostMerge = test.CurrentRandom is not null;
header.MixHash = test.CurrentRandom;

Stopwatch stopwatch = Stopwatch.StartNew();
var txValidator = new TxValidator((MainnetSpecProvider.Instance.ChainId));
Expand Down
22 changes: 12 additions & 10 deletions src/Nethermind/Ethereum.Test.Base/JsonToEthereumTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private static IReleaseSpec ParseSpec(string network)
"Istanbul" => Istanbul.Instance,
"Berlin" => Berlin.Instance,
"London" => London.Instance,
"Merge" => London.Instance,
_ => throw new NotSupportedException()
};
}
Expand Down Expand Up @@ -103,11 +104,7 @@ public static Block Convert(PostStateJson postStateJson, TestBlockJson testBlock
public static Transaction Convert(PostStateJson postStateJson, TransactionJson transactionJson)
{
Transaction transaction = new();
if (transaction.AccessList != null)
transaction.Type = TxType.AccessList;
if (transactionJson.MaxFeePerGas != null)
transaction.Type = TxType.EIP1559;


transaction.Value = transactionJson.Value[postStateJson.Indexes.Value];
transaction.GasLimit = transactionJson.GasLimit[postStateJson.Indexes.Gas];
transaction.GasPrice = transactionJson.GasPrice ?? transactionJson.MaxPriorityFeePerGas ?? 0;
Expand All @@ -124,6 +121,14 @@ public static Transaction Convert(PostStateJson postStateJson, TransactionJson t
? transactionJson.AccessLists[postStateJson.Indexes.Data]
: transactionJson.AccessList, builder);
transaction.AccessList = builder.ToAccessList();

if (transaction.AccessList.Data.Count != 0)
transaction.Type = TxType.AccessList;
else
transaction.AccessList = null;

if (transactionJson.MaxFeePerGas != null)
transaction.Type = TxType.EIP1559;

return transaction;
}
Expand Down Expand Up @@ -201,14 +206,11 @@ public static IEnumerable<GeneralStateTest> Convert(string name, GeneralStateTes
test.CurrentNumber = testJson.Env.CurrentNumber;
test.CurrentTimestamp = testJson.Env.CurrentTimestamp;
test.CurrentBaseFee = testJson.Env.CurrentBaseFee;
test.CurrentRandom = testJson.Env.CurrentRandom;
test.PostReceiptsRoot = stateJson.Logs;
test.PostHash = stateJson.Hash;
test.Pre = testJson.Pre.ToDictionary(p => new Address(p.Key), p => Convert(p.Value));
test.Transaction = Convert(stateJson, testJson.Transaction);
if (!test.Fork.UseTxAccessLists)
{
test.Transaction.AccessList = null;
}

blockchainTests.Add(test);
++iterationNumber;
Expand Down Expand Up @@ -250,7 +252,7 @@ public static BlockchainTest Convert(string name, BlockchainTestJson testJson)
return test;
}

private static EthereumJsonSerializer _serializer = new();
private static readonly EthereumJsonSerializer _serializer = new();

public static IEnumerable<GeneralStateTest> Convert(string json)
{
Expand Down
1 change: 1 addition & 0 deletions src/Nethermind/Ethereum.Transition.Test/MetaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void All_categories_are_tested()
{
string[] directories = Directory.GetDirectories(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tests"))
.Select(Path.GetFileName)
.Except(new[] { "bcArrowGlacierToMerge" }) // this one is missing
.ToArray();
Type[] types = GetType().Assembly.GetTypes();
List<string> missingCategories = new List<string>();
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Core/BlockHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public enum Format
public BlockHeader Clone()
{
BlockHeader header = (BlockHeader)MemberwiseClone();
header.Bloom = Bloom.Clone();
header.Bloom = Bloom?.Clone() ?? new Bloom();
return header;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Core/Timers/TimerWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void Dispose()
_timer.Dispose();
}

private void OnElapsed(object sender, ElapsedEventArgs e)
private void OnElapsed(object? sender, ElapsedEventArgs e)
{
Elapsed?.Invoke(sender, e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Network.Dns/EnrLeaf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Nethermind.Network.Dns;
/// </summary>
public class EnrLeaf : EnrTreeNode
{
public string NodeRecord { get; set; }
public string NodeRecord { get; set; } = string.Empty;

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Network.Dns/EnrLinkedTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Nethermind.Network.Dns;
/// </summary>
public class EnrLinkedTree : EnrTreeNode
{
public string Link { get; set; }
public string Link { get; set; } = string.Empty;

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Network.Dns/EnrTreeBranch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Nethermind.Network.Dns;
/// </summary>
public class EnrTreeBranch : EnrTreeNode
{
public string[] Hashes { get; set; }
public string[] Hashes { get; set; } = Array.Empty<string>();

public override string ToString()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Nethermind/Nethermind.Network.Dns/EnrTreeRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class EnrTreeRoot : EnrTreeNode
/// <summary>
/// the root hashes of subtrees containing nodes and links subtrees
/// </summary>
public string EnrRoot { get; set; }
public string EnrRoot { get; set; } = string.Empty;

/// <summary>
/// the root hashes of subtrees containing nodes and links subtrees
/// </summary>
public string LinkRoot { get; set; }
public string LinkRoot { get; set; } = string.Empty;

/// <summary>
/// Updated each time the tree gets updated.
Expand All @@ -41,7 +41,7 @@ public class EnrTreeRoot : EnrTreeNode
/// <summary>
/// Signature but need to learn where to take the public key from
/// </summary>
public string Signature { get; set; }
public string Signature { get; set; } = string.Empty;

public override string ToString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public enum WhenTrace

public class StateTestsRunner : GeneralStateTestBase, IStateTestRunner
{
private ITestSourceLoader _testsSource;
private readonly ITestSourceLoader _testsSource;
private readonly WhenTrace _whenTrace;
private readonly bool _traceMemory;
private readonly bool _traceStack;
private IJsonSerializer _serializer = new EthereumJsonSerializer();
private static readonly IJsonSerializer _serializer = new EthereumJsonSerializer();

public StateTestsRunner(ITestSourceLoader testsSource, WhenTrace whenTrace, bool traceMemory, bool traceStack)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.State/IStateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface IStateProvider : IReadOnlyStateProvider, IJournal<int>
{
void RecalculateStateRoot();

Keccak StateRoot { get; set; }
new Keccak StateRoot { get; set; }

void DeleteAccount(Address address);

Expand Down
2 changes: 1 addition & 1 deletion src/tests
Submodule tests updated 91 files
+2 −0 .gitignore
+2,150 −0 BlockchainTests/GeneralStateTests/stCreateTest/createLargeResult.json
+1,810 −98 BlockchainTests/GeneralStateTests/stExample/accessListExample.json
+967 −4 BlockchainTests/GeneralStateTests/stExample/basefeeExample.json
+967 −4 BlockchainTests/GeneralStateTests/stExample/eip1559.json
+131 −0 BlockchainTests/GeneralStateTests/stExample/mergeTest.json
+957 −0 BlockchainTests/GeneralStateTests/stPreCompiledContracts2/CallEcrecover_Overflow.json
+429 −0 BlockchainTests/TransitionTests/bcArrowGlacierToMerge/powToPosBlockRejection.json
+336 −0 BlockchainTests/TransitionTests/bcArrowGlacierToMerge/powToPosTest.json
+85 −85 BlockchainTests/ValidBlocks/bcEIP1559/burnVerify.json
+709 −0 BlockchainTests/ValidBlocks/bcEIP1559/burnVerifyLondon.json
+133 −126 BlockchainTests/ValidBlocks/bcEIP1559/tips.json
+1,295 −0 BlockchainTests/ValidBlocks/bcEIP1559/tipsLondon.json
+124 −3 BlockchainTests/ValidBlocks/bcExample/basefeeExample.json
+244 −0 BlockchainTests/ValidBlocks/bcExample/mergeExample.json
+7,056 −0 DifficultyTests/dfGrayGlacier/difficultyGrayGlacier.json
+4,016 −0 DifficultyTests/dfGrayGlacier/difficultyGrayGlacierForkBlock.json
+7,056 −0 DifficultyTests/dfGrayGlacier/difficultyGrayGlacierMinus1.json
+1,632 −0 DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff1.json
+1,632 −0 DifficultyTests/dfGrayGlacier/difficultyGrayGlacierTimeDiff2.json
+262 −0 GeneralStateTests/stCreateTest/createLargeResult.json
+197 −5 GeneralStateTests/stExample/accessListExample.json
+122 −5 GeneralStateTests/stExample/basefeeExample.json
+122 −5 GeneralStateTests/stExample/eip1559.json
+81 −0 GeneralStateTests/stExample/mergeTest.json
+156 −0 GeneralStateTests/stPreCompiledContracts2/CallEcrecover_Overflow.json
+61 −0 TransactionTests/ttEIP1559/GasLimitPriceProductOverflow.json
+63 −0 TransactionTests/ttEIP1559/GasLimitPriceProductOverflowtMinusOne.json
+61 −0 TransactionTests/ttEIP1559/GasLimitPriceProductPlusOneOverflow.json
+61 −0 TransactionTests/ttEIP1559/maxFeePerGas00prefix.json
+61 −0 TransactionTests/ttEIP1559/maxFeePerGas32BytesValue.json
+61 −0 TransactionTests/ttEIP1559/maxFeePerGasOverflow.json
+61 −0 TransactionTests/ttEIP1559/maxPriorityFeePerGas00prefix.json
+61 −0 TransactionTests/ttEIP1559/maxPriorityFeePerGasOverflow.json
+61 −0 TransactionTests/ttEIP1559/maxPriorityFeePerGass32BytesValue.json
+61 −0 TransactionTests/ttEIP2930/accessListAddressGreaterThan20.json
+61 −0 TransactionTests/ttEIP2930/accessListAddressLessThan20.json
+61 −0 TransactionTests/ttEIP2930/accessListAddressPrefix00.json
+61 −0 TransactionTests/ttEIP2930/accessListStorage0x0001.json
+64 −0 TransactionTests/ttEIP2930/accessListStorage32Bytes.json
+61 −0 TransactionTests/ttEIP2930/accessListStorageOver32Bytes.json
+61 −0 TransactionTests/ttEIP2930/accessListStoragePrefix00.json
+57 −0 TransactionTests/ttWrongRLP/RLP_04_maxFeePerGas32BytesValue.json
+57 −0 TransactionTests/ttWrongRLP/RLP_09_maxFeePerGas32BytesValue.json
+13 −3 docs/blockchain-tutorial.rst
+12 −2 docs/retesteth-tutorial.rst
+20 −91 docs/t8ntool-ref.rst
+5 −3 docs/test_filler/test_blockheader.rst
+6 −6 docs/tutorial_samples/08_eip2315_invalid_jumpFiller.yml
+113 −0 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_MergeEnvConvertionFiller.json
+113 −0 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_eip1559EnvConvertionFiller.json
+112 −0 src/BlockchainTestsFiller/InvalidBlocks/bcExpectSection/result_legacyEnvConvertionFiller.json
+208 −0 src/BlockchainTestsFiller/TransitionTests/bcArrowGlacierToMerge/powToPosBlockRejectionFiller.json
+172 −0 src/BlockchainTestsFiller/TransitionTests/bcArrowGlacierToMerge/powToPosTestFiller.json
+22 −15 src/BlockchainTestsFiller/ValidBlocks/bcEIP1559/burnVerifyFiller.yml
+465 −0 src/BlockchainTestsFiller/ValidBlocks/bcEIP1559/burnVerifyLondonFiller.yml
+9 −3 src/BlockchainTestsFiller/ValidBlocks/bcEIP1559/tipsFiller.yml
+637 −0 src/BlockchainTestsFiller/ValidBlocks/bcEIP1559/tipsLondonFiller.yml
+86 −0 src/BlockchainTestsFiller/ValidBlocks/bcExample/mergeExampleFiller.json
+13 −0 src/DifficultyTestsFiller/dfGrayGlacier/difficultyGrayGlacierFiller.json
+13 −0 src/DifficultyTestsFiller/dfGrayGlacier/difficultyGrayGlacierForkBlockFiller.json
+13 −0 src/DifficultyTestsFiller/dfGrayGlacier/difficultyGrayGlacierMinus1Filler.json
+13 −0 src/DifficultyTestsFiller/dfGrayGlacier/difficultyGrayGlacierTimeDiff1Filler.json
+13 −0 src/DifficultyTestsFiller/dfGrayGlacier/difficultyGrayGlacierTimeDiff2Filler.json
+431 −0 src/GeneralStateTestsFiller/stCreateTest/createLargeResultFiller.yml
+14 −1 src/GeneralStateTestsFiller/stExample/accessListExampleFiller.yml
+12 −0 src/GeneralStateTestsFiller/stExample/basefeeExampleFiller.yml
+14 −0 src/GeneralStateTestsFiller/stExample/eip1559Filler.yml
+69 −0 src/GeneralStateTestsFiller/stExample/mergeTestFiller.yml
+130 −0 src/GeneralStateTestsFiller/stExpectSection/result_eip1559EnvConvertionFiller.json
+129 −0 src/GeneralStateTestsFiller/stExpectSection/result_legacyEnvConvertionFiller.json
+130 −0 src/GeneralStateTestsFiller/stExpectSection/result_mergeEnvConvertionFiller.json
+124 −0 src/GeneralStateTestsFiller/stPreCompiledContracts2/CallEcrecover_OverflowFiller.yml
+24 −0 src/TransactionTestsFiller/ttEIP1559/GasLimitPriceProductOverflowFiller.json
+23 −0 src/TransactionTestsFiller/ttEIP1559/GasLimitPriceProductOverflowtMinusOneFiller.json
+24 −0 src/TransactionTestsFiller/ttEIP1559/GasLimitPriceProductPlusOneOverflowFiller.json
+23 −0 src/TransactionTestsFiller/ttEIP1559/maxFeePerGas00prefixFiller.json
+24 −0 src/TransactionTestsFiller/ttEIP1559/maxFeePerGas32BytesValueFiller.json
+24 −0 src/TransactionTestsFiller/ttEIP1559/maxFeePerGasOverflowFiller.json
+23 −0 src/TransactionTestsFiller/ttEIP1559/maxPriorityFeePerGas00prefixFiller.json
+24 −0 src/TransactionTestsFiller/ttEIP1559/maxPriorityFeePerGasOverflowFiller.json
+24 −0 src/TransactionTestsFiller/ttEIP1559/maxPriorityFeePerGass32BytesValueFiller.json
+31 −0 src/TransactionTestsFiller/ttEIP2930/accessListAddressGreaterThan20Filler.json
+31 −0 src/TransactionTestsFiller/ttEIP2930/accessListAddressLessThan20Filler.json
+31 −0 src/TransactionTestsFiller/ttEIP2930/accessListAddressPrefix00Filler.json
+30 −0 src/TransactionTestsFiller/ttEIP2930/accessListStorage0x0001Filler.json
+30 −0 src/TransactionTestsFiller/ttEIP2930/accessListStorage32BytesFiller.json
+31 −0 src/TransactionTestsFiller/ttEIP2930/accessListStorageOver32BytesFiller.json
+30 −0 src/TransactionTestsFiller/ttEIP2930/accessListStoragePrefix00Filler.json
+47 −0 src/TransactionTestsFiller/ttWrongRLP/RLP_04_maxFeePerGas32BytesValueCopier.json
+47 −0 src/TransactionTestsFiller/ttWrongRLP/RLP_09_maxFeePerGas32BytesValueCopier.json

0 comments on commit bb7402e

Please sign in to comment.