-
Notifications
You must be signed in to change notification settings - Fork 487
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
Add Eof Execution EIP-7692 (EIP-663, EIP-3540, EIP-3670, EIP-4200, EIP-4750, EIP-5450, EIP-6206, EIP-7069, EIP-7480, EIP-7620, EIP-7698, EIP-7756) #8176
base: master
Are you sure you want to change the base?
Changes from all commits
529ea09
e5e88e1
10ce03b
b628386
b26fb9a
961609a
1d57470
a815169
486e619
b4f1475
b037ba8
2765ac0
68cfba3
bdbb912
259711b
151398f
e684eff
3aba7de
103f834
8c81d45
e4b2ca6
c6ff84f
1864710
051c786
5ad754a
d97d653
4737cdd
e676f62
37fc94f
d690c27
4c3f815
e73a606
0c2250d
07beadb
f0667bd
3c203f3
0d99150
207a05b
adf2c78
617c30e
58c2168
af36d4e
a539c17
f3b32ed
71891af
becbade
6b8926d
34cf80a
4104ebe
9aedcbc
d49a80c
a81e2b6
ebf4a82
241f095
ead0ebc
bbf305e
744bf19
cbdbea7
f9aa9c5
0f43515
91063aa
a3b2292
d9ed010
ed7eddd
794b1dc
5f3d9c3
2817f1e
a9985d0
7547caa
38f378f
e19be65
584cc43
49f3b8e
72a8919
ad5edf7
ece6ba8
dd347e0
5745549
c31667b
a501030
99e934d
f63a833
b3aec67
333daed
b5d5dd6
b48ed47
871be2f
b65bab4
95ee042
d9c16c4
e098dcb
c5080f7
0f115b4
43559a9
b8f160b
6f762b8
19d35ec
ae9201a
56377ea
39c6c7e
970a4f3
35d724e
42f502a
ba5f05e
8ee4221
d4980f4
b02e797
4d8ac02
1b7df28
d8f954e
3d24a08
42199a2
150855e
74925fe
09de61c
86645b9
74a21df
8627577
f8ee255
370c2c3
6cc5616
7940272
e8a39ea
84237e6
7076d32
d5b7fb1
a747bd4
4fc4b70
6a477c2
d9dd09e
39733d2
c850168
17dd735
c33fa89
022f9ab
2b19f4c
cff2a83
3910982
50955b8
e60f58b
7415eea
4a22a1c
0e61f6e
50e1220
4dca7a4
d578bb3
b8f4e44
920f66c
57d0c28
d0617c8
b36cdb5
616505e
4d3ba97
d316e73
a9949bf
5c795bd
dd36155
5cda52b
6d1617f
cbd8358
a7267a5
665c79d
df9ffff
fac0832
60ebed1
d986b2f
7f6e239
e563274
c1fcddf
9846294
3a512c7
a5dde38
84c16ed
f77e996
a0cf43a
00410ee
f5853be
740d515
f7617ba
fac8a61
524fe8c
9cef3ef
6f4987a
6846c13
d14ea29
4ee95fd
20cfe69
5fbc8cc
ac05b5a
b206a45
575b899
67153f3
5edcbed
c4f211f
05c0851
dbcc231
8315efd
b17f392
e1a46cf
a934244
f4a6372
d1eacde
9bc1317
8e7c6ad
4a1ff05
0011aed
bd9a5b9
47638b5
a050765
624b098
e7aeb84
990f049
222cb44
19dd6f2
dfae489
2136999
f2dd20a
8e6edad
e013ad1
5283990
3b264bf
e9a5b4e
edfa1c0
9c277fb
d693d90
b24e37c
2a956fd
0910445
b14808e
9cd3b37
758d101
e9fcdb1
aef435b
025506f
36fb787
a0fac5a
df45003
97b4d08
20da4b1
6d2415b
f987ef9
daa6a76
cd7a4ea
e1e375c
86f39c5
d931e5b
2772f42
bb96661
6350b85
0258716
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,12 @@ namespace Ethereum.Blockchain.Pyspec.Test; | |
|
||
public class LoadPyspecTestsStrategy : ITestLoadStrategy | ||
{ | ||
private enum TestType | ||
{ | ||
Blockchain, | ||
GeneralState, | ||
Eof | ||
} | ||
public string ArchiveVersion { get; init; } = Constants.DEFAULT_ARCHIVE_VERSION; | ||
public string ArchiveName { get; init; } = Constants.DEFAULT_ARCHIVE_NAME; | ||
|
||
|
@@ -23,11 +29,16 @@ public IEnumerable<IEthereumTest> Load(string testsDir, string wildcard = null) | |
string testsDirectoryName = Path.Combine(AppContext.BaseDirectory, "PyTests", ArchiveVersion, ArchiveName.Split('.')[0]); | ||
if (!Directory.Exists(testsDirectoryName)) // Prevent redownloading the fixtures if they already exists with this version and archive name | ||
DownloadAndExtract(ArchiveVersion, ArchiveName, testsDirectoryName); | ||
bool isStateTest = testsDir.Contains("state_tests", StringComparison.InvariantCultureIgnoreCase); | ||
TestType testType = testsDir.Contains("state_tests", StringComparison.InvariantCultureIgnoreCase) | ||
? TestType.GeneralState | ||
: testsDir.Contains("eof_tests", StringComparison.InvariantCultureIgnoreCase) | ||
? TestType.Eof | ||
: TestType.Blockchain; | ||
Comment on lines
+32
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change TestType to { State, EoF, Blockchain } and base the test type detenction on a loop with condition |
||
|
||
IEnumerable<string> testDirs = !string.IsNullOrEmpty(testsDir) | ||
? Directory.EnumerateDirectories(Path.Combine(testsDirectoryName, testsDir), "*", new EnumerationOptions { RecurseSubdirectories = true }) | ||
: Directory.EnumerateDirectories(testsDirectoryName, "*", new EnumerationOptions { RecurseSubdirectories = true }); | ||
return testDirs.SelectMany(td => LoadTestsFromDirectory(td, wildcard, isStateTest)); | ||
return testDirs.SelectMany(td => LoadTestsFromDirectory(td, wildcard, testType)); | ||
} | ||
|
||
private void DownloadAndExtract(string archiveVersion, string archiveName, string testsDirectoryName) | ||
|
@@ -44,7 +55,7 @@ private void DownloadAndExtract(string archiveVersion, string archiveName, strin | |
TarFile.ExtractToDirectory(gzStream, testsDirectoryName, true); | ||
} | ||
|
||
private IEnumerable<IEthereumTest> LoadTestsFromDirectory(string testDir, string wildcard, bool isStateTest) | ||
private IEnumerable<IEthereumTest> LoadTestsFromDirectory(string testDir, string wildcard, TestType testType) | ||
{ | ||
List<IEthereumTest> testsByName = new(); | ||
IEnumerable<string> testFiles = Directory.EnumerateFiles(testDir); | ||
|
@@ -54,20 +65,28 @@ private IEnumerable<IEthereumTest> LoadTestsFromDirectory(string testDir, string | |
FileTestsSource fileTestsSource = new(testFile, wildcard); | ||
try | ||
{ | ||
IEnumerable<IEthereumTest> tests = isStateTest | ||
? fileTestsSource.LoadGeneralStateTests() | ||
: fileTestsSource.LoadBlockchainTests(); | ||
IEnumerable<IEthereumTest> tests = testType switch | ||
{ | ||
TestType.Eof => fileTestsSource.LoadEofTests(), | ||
TestType.GeneralState => fileTestsSource.LoadGeneralStateTests(), | ||
_ => fileTestsSource.LoadBlockchainTests() | ||
}; | ||
Comment on lines
+68
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do it in OO way? |
||
|
||
foreach (IEthereumTest test in tests) | ||
{ | ||
test.Category = testDir; | ||
test.Category ??= testDir; | ||
} | ||
testsByName.AddRange(tests); | ||
} | ||
catch (Exception e) | ||
{ | ||
IEthereumTest failedTest = isStateTest | ||
? new GeneralStateTest() | ||
: new BlockchainTest(); | ||
IEthereumTest failedTest = testType switch | ||
{ | ||
TestType.Eof => new EofTest(), | ||
TestType.GeneralState => new GeneralStateTest(), | ||
_ => new BlockchainTest() | ||
}; | ||
|
||
Comment on lines
+83
to
+89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
failedTest.Name = testDir; | ||
failedTest.LoadFailure = $"Failed to load: {e}"; | ||
testsByName.Add(failedTest); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Ethereum.Test.Base; | ||
using NUnit.Framework; | ||
|
||
namespace Ethereum.Blockchain.Pyspec.Test; | ||
|
||
[TestFixture] | ||
[Parallelizable(ParallelScope.All)] | ||
[Explicit("These tests are not yet updated to devnet-6")] | ||
public class OsakaBlockChainTests : BlockchainTestBase | ||
{ | ||
[TestCaseSource(nameof(LoadTests))] | ||
public async Task Test(BlockchainTest test) => await RunTest(test); | ||
|
||
private static IEnumerable<TestCaseData> LoadTests() | ||
{ | ||
TestsSourceLoader loader = new(new LoadPyspecTestsStrategy() | ||
{ | ||
ArchiveName = "fixtures_eip7692.tar.gz", | ||
ArchiveVersion = "[email protected]" | ||
}, $"fixtures/blockchain_tests/osaka"); | ||
return loader.LoadTests().OfType<BlockchainTest>().Select(t => new TestCaseData(t) | ||
.SetName(t.Name) | ||
.SetCategory(t.Category)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Ethereum.Test.Base; | ||
using NUnit.Framework; | ||
|
||
namespace Ethereum.Blockchain.Pyspec.Test; | ||
|
||
[TestFixture] | ||
[Parallelizable(ParallelScope.All)] | ||
public class OsakaEofTests : EofTestBase | ||
{ | ||
[TestCaseSource(nameof(LoadTests))] | ||
public void Test(EofTest test) => RunCITest(test); | ||
|
||
private static IEnumerable<TestCaseData> LoadTests() | ||
{ | ||
TestsSourceLoader loader = new(new LoadPyspecTestsStrategy() | ||
{ | ||
ArchiveName = "fixtures_eip7692.tar.gz", | ||
ArchiveVersion = "[email protected]" | ||
}, $"fixtures/eof_tests/osaka"); | ||
return loader.LoadTests().Cast<EofTest>().Select(t => new TestCaseData(t) | ||
.SetName(t.Name) | ||
.SetCategory(t.Category)); | ||
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this part is very similar in all types with only the difference of the generic type, maybe we can abstract that to base types and or generics on type? |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Ethereum.Test.Base; | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
|
||
namespace Ethereum.Blockchain.Pyspec.Test; | ||
|
||
[TestFixture] | ||
[Parallelizable(ParallelScope.All)] | ||
public class OsakaStateTests : GeneralStateTestBase | ||
{ | ||
[TestCaseSource(nameof(LoadTests))] | ||
public void Test(GeneralStateTest test) => RunTest(test).Pass.Should().BeTrue(); | ||
|
||
private static IEnumerable<TestCaseData> LoadTests() | ||
{ | ||
TestsSourceLoader loader = new(new LoadPyspecTestsStrategy() | ||
{ | ||
ArchiveName = "fixtures_eip7692.tar.gz", | ||
ArchiveVersion = "[email protected]" | ||
}, $"fixtures/state_tests/osaka"); | ||
return loader.LoadTests().Cast<GeneralStateTest>().Select(t => new TestCaseData(t) | ||
.SetName(t.Name) | ||
.SetCategory(t.Category)); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Ethereum.Test.Base; | ||
using NUnit.Framework; | ||
|
||
namespace Ethereum.Blockchain.Test; | ||
|
||
[TestFixture] | ||
[Parallelizable(ParallelScope.All)] | ||
[Explicit("Legacy ethereum/tests EOF tests currently are based on a Prague spec, which lacks EOF.")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is temporary? Maybe add TODO |
||
public class EOFTests : GeneralStateTestBase | ||
{ | ||
// Uncomment when EOF tests are merged | ||
|
||
// [TestCaseSource(nameof(LoadTests))] | ||
// public void Test(GeneralStateTest test) | ||
// { | ||
// Assert.That(RunTest(test).Pass, Is.True); | ||
// } | ||
[TestCaseSource(nameof(LoadTests))] | ||
public void Test(GeneralStateTest test) | ||
{ | ||
// Legacy ethereum/tests EOF tests currently are based on a Prague spec, which lacks EOF. | ||
// All EOF tests are now a part of EEST | ||
//Assert.That(RunTest(test).Pass, Is.True); | ||
} | ||
|
||
public static IEnumerable<GeneralStateTest> LoadTests() | ||
{ | ||
var loader = new TestsSourceLoader(new LoadEipTestsStrategy(), "stEOF"); | ||
return (IEnumerable<GeneralStateTest>)loader.LoadTests(); | ||
return []; | ||
|
||
//var eip3540Loader = (IEnumerable<GeneralStateTest>)(new TestsSourceLoader(new LoadEofTestsStrategy(), "stEIP3540").LoadTests()); | ||
//var eip3670Loader = (IEnumerable<GeneralStateTest>)(new TestsSourceLoader(new LoadEofTestsStrategy(), "stEIP3670").LoadTests()); | ||
//var eip4200Loader = (IEnumerable<GeneralStateTest>)(new TestsSourceLoader(new LoadEofTestsStrategy(), "stEIP4200").LoadTests()); | ||
//var eip4750Loader = (IEnumerable<GeneralStateTest>)(new TestsSourceLoader(new LoadEofTestsStrategy(), "stEIP4750").LoadTests()); | ||
//var eip5450Loader = (IEnumerable<GeneralStateTest>)(new TestsSourceLoader(new LoadEofTestsStrategy(), "stEIP5450").LoadTests()); | ||
//return eip3540Loader.Concat(eip3670Loader).Concat(eip4200Loader).Concat(eip4750Loader).Concat(eip5450Loader); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using Ethereum.Test.Base.Interfaces; | ||
using Nethermind.Evm.EvmObjectFormat; | ||
|
||
namespace Ethereum.Test.Base; | ||
public class Result | ||
{ | ||
public string Fork { get; set; } | ||
public bool Success { get; set; } | ||
public string? Error { get; set; } | ||
} | ||
|
||
public class VectorTest | ||
{ | ||
public byte[] Code { get; set; } | ||
public ValidationStrategy ContainerKind { get; set; } | ||
} | ||
|
||
public class EofTest : IEthereumTest | ||
{ | ||
public string Name { get; set; } | ||
public VectorTest Vector { get; set; } | ||
public string? Category { get; set; } | ||
public string? LoadFailure { get; set; } | ||
public Result Result { get; internal set; } | ||
public string? Description { get; set; } | ||
public string? Url { get; set; } | ||
public string? Spec { get; set; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using Nethermind.Evm; | ||
using Nethermind.Evm.Tracing; | ||
using Nethermind.Logging; | ||
using NUnit.Framework; | ||
using Nethermind.Evm.EvmObjectFormat; | ||
|
||
namespace Ethereum.Test.Base | ||
{ | ||
public abstract class EofTestBase | ||
{ | ||
private static ILogger _logger = new(TextContextLogger.Instance); | ||
private static ILogManager _logManager = new TestLogManager(LogLevel.Warn); | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
EofValidator.Logger = _logger; | ||
} | ||
|
||
protected static void Setup(ILogManager logManager) | ||
{ | ||
_logManager = logManager ?? LimboLogs.Instance; | ||
_logger = _logManager.GetClassLogger(); | ||
} | ||
|
||
protected void RunCITest(EofTest test) | ||
{ | ||
var result = RunTest(test, NullTxTracer.Instance); | ||
|
||
if (result != test.Result.Success) | ||
{ | ||
_logger.Info($"Spec: {test.Spec}"); | ||
_logger.Info(test.Description); | ||
_logger.Info($"Url: {test.Url}"); | ||
} | ||
|
||
Assert.That(result, Is.EqualTo(test.Result.Success)); | ||
} | ||
|
||
protected bool RunTest(EofTest test) | ||
{ | ||
return RunTest(test, NullTxTracer.Instance) == test.Result.Success; | ||
} | ||
|
||
protected bool RunTest(EofTest test, ITxTracer txTracer) | ||
{ | ||
TestContext.Out.WriteLine($"Running {test.Name} at {DateTime.UtcNow:HH:mm:ss.ffffff}"); | ||
Assert.That(test.LoadFailure, Is.Null, "test data loading failure"); | ||
|
||
var vector = test.Vector; | ||
var code = vector.Code; | ||
var strategy = vector.ContainerKind; | ||
var fork = test.Result.Fork switch | ||
{ | ||
"Osaka" => Nethermind.Specs.Forks.Osaka.Instance, | ||
"Prague" => Nethermind.Specs.Forks.Prague.Instance, | ||
"Berlin" => Nethermind.Specs.Forks.Berlin.Instance, | ||
"London" => Nethermind.Specs.Forks.London.Instance, | ||
"Shanghai" => Nethermind.Specs.Forks.Shanghai.Instance, | ||
"Constantinople" => Nethermind.Specs.Forks.Constantinople.Instance, | ||
"Byzantium" => Nethermind.Specs.Forks.Byzantium.Instance, | ||
"SpuriousDragon" => Nethermind.Specs.Forks.SpuriousDragon.Instance, | ||
"TangerineWhistle" => Nethermind.Specs.Forks.TangerineWhistle.Instance, | ||
"Homestead" => Nethermind.Specs.Forks.Homestead.Instance, | ||
"Frontier" => Nethermind.Specs.Forks.Frontier.Instance, | ||
_ => throw new NotSupportedException($"Fork {test.Result.Fork} is not supported") | ||
}; | ||
|
||
bool result = CodeDepositHandler.IsValidWithEofRules(fork, code, 1, strategy); | ||
return result; | ||
} | ||
} | ||
} |
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.
This is redundant. We already use the same CLI parser for everything else.