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

Add Eof Execution context #6896

Draft
wants to merge 206 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
ed3f6f5
update release spec
Demuirgos Jan 16, 2024
9e16b0b
added new transaction type for eof initcode
Demuirgos Jan 16, 2024
20f3003
Added new opcodes
Demuirgos Jan 17, 2024
fb96c12
migrate validation code from old PR
Demuirgos Jan 17, 2024
94f5672
added legacy call* opcode changes
Demuirgos Jan 17, 2024
f93ed8c
added EofInitcode tx validation
Demuirgos Jan 18, 2024
8a45800
added static relative jumps
Demuirgos Jan 18, 2024
420505d
added prototype implementation for : dupn, swapn, exchange
Demuirgos Jan 18, 2024
8d8c8ea
added function section codes
Demuirgos Jan 18, 2024
62b3154
added call* opcodes to EVM
Demuirgos Jan 18, 2024
a3ff60d
use ICreateInfo + CodeInfoFactory
Demuirgos Jan 18, 2024
f5edf56
initial eof contract creation implementation
Demuirgos Jan 22, 2024
9b89484
fix Create substate handling
Demuirgos Jan 22, 2024
ecb86a6
merge master, resolved conflicts
Demuirgos Jan 23, 2024
845c86b
- Added non-returnning check to CALLF
Demuirgos Jan 23, 2024
7c645e5
applied suggested refactors
Demuirgos Jan 24, 2024
70d66a4
Added Data* opcodes
Demuirgos Jan 24, 2024
d8edb9e
name fix
Demuirgos Jan 24, 2024
a37a8d5
applied simple refactor
Demuirgos Jan 24, 2024
ba97f7a
jump jumpv validation
Demuirgos Jan 24, 2024
d80806b
update opcode values, and added metadata for *CALL2 opcodes
Demuirgos Jan 24, 2024
defadfd
fix instruction metadata
Demuirgos Jan 26, 2024
f9fc118
Merge master
Demuirgos Jan 30, 2024
0632fce
fix build issues
Demuirgos Jan 30, 2024
49ec29b
Merge remote-tracking branch 'origin/master' into Feature/EVM/EOF
Demuirgos Jan 31, 2024
f7be1ef
change reachable code check
Demuirgos Jan 31, 2024
da924b6
remove old check and use new one
Demuirgos Jan 31, 2024
4929e1a
changing RJUMP check and considring it Terminating opcode
Demuirgos Jan 31, 2024
3f507a9
minor refactors
Demuirgos Feb 1, 2024
e2c8db9
Merge remote-tracking branch 'origin/master' into Feature/EVM/EOF
Demuirgos Feb 1, 2024
5e8b528
add pragueActivation and fix releaseSpec
Demuirgos Feb 1, 2024
6ce44ca
fixes to header parsing and validation
Demuirgos Feb 2, 2024
aed51de
more fixes
Demuirgos Feb 4, 2024
ea1075b
added some tests for eof Opcodes
Demuirgos Feb 4, 2024
0c030db
added deploy_code validation (maybe redundant)
Demuirgos Feb 5, 2024
230931b
- extend EOF validation rules
Demuirgos Feb 5, 2024
469bfb2
minor fix
Demuirgos Feb 6, 2024
c8501df
fixed eof code deployment code
Demuirgos Feb 6, 2024
9c49a48
fix build failure
Demuirgos Feb 7, 2024
95bb439
rename opcodes
Demuirgos Mar 5, 2024
07a4c9e
merge master
Demuirgos Mar 5, 2024
f385efb
fix building issues
Demuirgos Mar 5, 2024
4ed08e2
minor refactor
Demuirgos Mar 8, 2024
e7ea075
reorder and fix EXTDELEGATECALL
Demuirgos Mar 20, 2024
db3e816
another fix for EXTDELEGATECALL
Demuirgos Mar 20, 2024
092eac6
add error txErrors
Demuirgos Mar 20, 2024
79edebb
fix build
Demuirgos Mar 20, 2024
3a6e541
update EOFCREATE implementation, CREATECONTRACT
Demuirgos Apr 2, 2024
58e924c
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Apr 3, 2024
ad8a2a5
match spec changes
Demuirgos Apr 3, 2024
9592bc6
minor refactor
Demuirgos Apr 3, 2024
3464617
fix build issue
Demuirgos Apr 3, 2024
c946f48
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Apr 14, 2024
c7ab88f
added EOF eip tests loader (wip)
Demuirgos Apr 14, 2024
2496016
merge master
Demuirgos Apr 26, 2024
b122907
fix build issue
Demuirgos Apr 26, 2024
6bdb124
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Apr 30, 2024
dd8d6db
minor refactors
Demuirgos Apr 30, 2024
7e8b5ae
fix build issue
Demuirgos Apr 30, 2024
34799e4
merged master
Demuirgos Jun 11, 2024
d07df5f
minor refactors
Demuirgos Jun 12, 2024
1b1fafc
* reimplemented Eip5450
Demuirgos Jun 17, 2024
62caacb
fixed build issues
Demuirgos Jun 17, 2024
8342e33
merged master
Demuirgos Jun 17, 2024
dfbd13d
fix build issues
Demuirgos Jun 19, 2024
be7fc22
fix build issue
Demuirgos Jun 20, 2024
f4da9ec
added version to EOF logs
Demuirgos Jun 21, 2024
cc5961a
* (temporary) added prague pyspec tests suite
Demuirgos Jun 25, 2024
765aed3
fix some failing tests :
Demuirgos Jun 25, 2024
0112f8b
reimplement *CALL opcodes
Demuirgos Jun 26, 2024
5aa20d4
Merged master
Demuirgos Jun 26, 2024
7bb0958
Minor code changes
Demuirgos Jun 30, 2024
6b28af5
added status error codes
Demuirgos Jul 1, 2024
71f7de1
fix some failing tests
Demuirgos Jul 2, 2024
4d336ce
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 2, 2024
522bff7
removing unused code
Demuirgos Jul 2, 2024
529ea09
some refactor
Demuirgos Jul 2, 2024
e5e88e1
Formatting
benaadams Jul 2, 2024
10ce03b
Fix enablement bracketing logic
benaadams Jul 2, 2024
b628386
Clean up, fix if bracketing
benaadams Jul 2, 2024
b26fb9a
Return 1 for non-eof contract don't charge call gas
benaadams Jul 2, 2024
961609a
Only available in EOF
benaadams Jul 3, 2024
1d57470
Return statuscode should continue
benaadams Jul 3, 2024
a815169
Check stack returns
benaadams Jul 3, 2024
486e619
Handle ArrayPool arrays more safely
benaadams Jul 3, 2024
b4f1475
Fix out of bounds vector access
benaadams Jul 3, 2024
b037ba8
Added comments, and fixed bugs
Demuirgos Jul 3, 2024
2765ac0
fix unreachable code check
Demuirgos Jul 3, 2024
68cfba3
Add more validation rules for EOFCREATE and RETURNCONTRACT
Demuirgos Jul 4, 2024
bdbb912
Formatting
benaadams Jul 4, 2024
259711b
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 4, 2024
151398f
- some EofCreate/ReturnContract fixes
Demuirgos Jul 5, 2024
e684eff
some refactors to CodeInfo and EofCodeInfo
Demuirgos Jul 8, 2024
3aba7de
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 8, 2024
103f834
formatting
benaadams Jul 9, 2024
8c81d45
Merge branch 'master' into feature/evm/eof
benaadams Jul 9, 2024
e4b2ca6
Increment Nonce before snapshot
benaadams Jul 9, 2024
c6ff84f
Comment out new tests
benaadams Jul 9, 2024
1864710
Revert "Comment out new tests"
benaadams Jul 9, 2024
051c786
fix exchange failing tests in pyspec
Demuirgos Jul 9, 2024
5ad754a
* fix Create2 in Eof
Demuirgos Jul 10, 2024
d97d653
Fomratting
benaadams Jul 10, 2024
4737cdd
Fix All_tx_should_pass_before_3541
benaadams Jul 10, 2024
e676f62
Output differences
benaadams Jul 10, 2024
37fc94f
extcodehash is Keccak not Sha256
benaadams Jul 10, 2024
d690c27
Fix extcodecopy_out_of_bounds
benaadams Jul 10, 2024
4c3f815
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 10, 2024
e73a606
Merge branch 'master' into feature/evm/eof
benaadams Jul 10, 2024
0c2250d
Lookup code once
benaadams Jul 11, 2024
07beadb
Use correct static flag
benaadams Jul 11, 2024
f0667bd
Invert failure for EOF
benaadams Jul 11, 2024
3c203f3
Tidy up
benaadams Jul 11, 2024
0d99150
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 11, 2024
207a05b
fix EXTDELEGATECALL
benaadams Jul 11, 2024
adf2c78
* minor refactor
Demuirgos Jul 12, 2024
617c30e
* fix index out of range in EOFCREATE
Demuirgos Jul 12, 2024
58c2168
formatting
benaadams Jul 12, 2024
af36d4e
Fix address extension checks
benaadams Jul 13, 2024
a539c17
Fix returndatacopy
benaadams Jul 13, 2024
f3b32ed
Update tests versions
benaadams Jul 15, 2024
71891af
Include code for tx creates
benaadams Jul 15, 2024
becbade
Use bytecode
benaadams Jul 15, 2024
6b8926d
* fix RETURNCONTRACT data section handling
Demuirgos Jul 15, 2024
34cf80a
formatting
benaadams Jul 15, 2024
4104ebe
* Fix to RETURNCONTRACT targeting wrong container
Demuirgos Jul 15, 2024
9aedcbc
Merge branch 'feature/evm/eof' of https://github.com/NethermindEth/ne…
Demuirgos Jul 15, 2024
d49a80c
* Fix overflow and underflow check in RETURNCONTRACT
Demuirgos Jul 15, 2024
a81e2b6
* Aligned TxCreate with EOFCREATE
Demuirgos Jul 16, 2024
ebf4a82
* fix failing build test
Demuirgos Jul 16, 2024
241f095
* fix CREATETX deploy gas value
Demuirgos Jul 16, 2024
ead0ebc
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 16, 2024
bbf305e
* Add EofBlockChainTests
Demuirgos Jul 17, 2024
744bf19
Include more detail in logs
benaadams Jul 17, 2024
cbdbea7
Fix DATACOPY gas
benaadams Jul 17, 2024
f9aa9c5
better fix
benaadams Jul 17, 2024
0f43515
* remove unnecessary validation
Demuirgos Jul 17, 2024
91063aa
* perform datasize overflow and underflow in ReturnContract regardles…
Demuirgos Jul 17, 2024
a3b2292
Max container size is MAX_INITCODE_SIZE
benaadams Jul 17, 2024
d9ed010
* fix maxCodeSize check
Demuirgos Jul 17, 2024
ed7eddd
Merge branch 'feature/evm/eof' of https://github.com/NethermindEth/ne…
Demuirgos Jul 17, 2024
794b1dc
Use section max size
benaadams Jul 17, 2024
5f3d9c3
* Added Eip3860 check and cost
Demuirgos Jul 17, 2024
2817f1e
Merge branch 'feature/evm/eof' of https://github.com/NethermindEth/ne…
Demuirgos Jul 17, 2024
a9985d0
* remove Eip3860 check
Demuirgos Jul 17, 2024
7547caa
Tidy up
benaadams Jul 17, 2024
38f378f
Add new tests
benaadams Jul 18, 2024
e19be65
Fix initcode failure states
benaadams Jul 18, 2024
584cc43
Fix Evm tests
benaadams Jul 18, 2024
49f3b8e
Update current state for RETURNCONTRACT
benaadams Jul 18, 2024
72a8919
Merge branch 'master' into feature/evm/eof
benaadams Jul 18, 2024
ad5edf7
Mark test as incorrect
benaadams Jul 18, 2024
ece6ba8
Tidy up usings
benaadams Jul 18, 2024
dd347e0
Update tests to v1.0.7
benaadams Jul 20, 2024
5745549
Merge branch 'master' into feature/evm/eof
benaadams Jul 20, 2024
c31667b
Spelling
benaadams Jul 20, 2024
a501030
Simpler if
benaadams Jul 20, 2024
99e934d
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 22, 2024
f63a833
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Jul 26, 2024
b3aec67
Merge branch 'master' into feature/evm/eof
benaadams Aug 14, 2024
333daed
Merge branch 'master' into feature/evm/eof
benaadams Aug 15, 2024
b5d5dd6
Update tests
benaadams Aug 15, 2024
b48ed47
add missing opcodes from metadata dictionary
Demuirgos Aug 20, 2024
871be2f
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Aug 20, 2024
b65bab4
* refactor nested containers validations
Demuirgos Aug 26, 2024
95ee042
Merge remote-tracking branch 'origin/master' into feature/evm/eof
Demuirgos Aug 26, 2024
d9c16c4
* index out of range fix
Demuirgos Aug 26, 2024
e098dcb
* remove unnecessary double check
Demuirgos Aug 26, 2024
c5080f7
* fix wrong boundary check
Demuirgos Aug 26, 2024
0f115b4
* Added EOFCREATE / RETURNCONTRACT null checks
Demuirgos Aug 26, 2024
43559a9
Add new EOF tests format for Pyspec tests (#7344)
Demuirgos Sep 3, 2024
b8f160b
Merge branch 'master' into feature/evm/eof
benaadams Sep 3, 2024
6f762b8
Add EOFTest CLI Support (#7383)
benaadams Sep 3, 2024
19d35ec
Merge branch 'master' into feature/evm/eof
benaadams Sep 3, 2024
ae9201a
Merge branch 'master' into feature/evm/eof
benaadams Sep 5, 2024
56377ea
Fix stackoverflow in tests
benaadams Sep 5, 2024
39c6c7e
Fix subsection init
benaadams Sep 5, 2024
970a4f3
Update tests
benaadams Sep 9, 2024
35d724e
ssert tests
shemnon Sep 9, 2024
42f502a
Eof/valdiation fixes (#7405)
shemnon Sep 10, 2024
ba5f05e
Merge branch 'master' into feature/evm/eof
benaadams Sep 16, 2024
8ee4221
Merge branch 'master' into feature/evm/eof
benaadams Sep 16, 2024
d4980f4
Break tests up
benaadams Sep 17, 2024
b02e797
Formatting
benaadams Sep 17, 2024
4d8ac02
Clarify tests
benaadams Sep 18, 2024
1b7df28
Fix bitmaps
benaadams Sep 18, 2024
d8f954e
Merge branch 'master' into feature/evm/eof
benaadams Sep 18, 2024
3d24a08
Containers start at 1
benaadams Sep 18, 2024
42199a2
Handle push0 properly
benaadams Sep 18, 2024
150855e
Update tests
benaadams Sep 23, 2024
74925fe
Merge branch 'master' into feature/evm/eof
benaadams Sep 23, 2024
09de61c
Merge conflict
benaadams Sep 23, 2024
86645b9
Output more info for failing tests
benaadams Sep 24, 2024
74a21df
Merge branch 'master' into feature/evm/eof
benaadams Sep 26, 2024
8627577
Merge conflict
benaadams Sep 26, 2024
f8ee255
Update tests
benaadams Sep 26, 2024
370c2c3
Fix remaining EOF validation issues (#7556)
shemnon Oct 5, 2024
6cc5616
Merge branch 'master' into eof-merge
benaadams Oct 9, 2024
7940272
Merge conflicts
benaadams Oct 9, 2024
e8a39ea
Merge branch 'master' into feature/evm/eof
benaadams Oct 10, 2024
84237e6
Merge branch 'master' into feature/evm/eof
benaadams Oct 10, 2024
7076d32
Merge branch 'master' into feature/evm/eof
benaadams Oct 14, 2024
d5b7fb1
Merge conflict
benaadams Oct 15, 2024
a747bd4
Merge branch 'master' into feature/evm/eof
benaadams Oct 15, 2024
4fc4b70
Merge branch 'master' into feature/evm/eof
benaadams Oct 23, 2024
6a477c2
Merge branch 'master' into feature/evm/eof
benaadams Oct 24, 2024
d9dd09e
Adaot to EEST Osaka Activation (#7657)
shemnon Oct 26, 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
1 change: 0 additions & 1 deletion src/Nethermind/Ethereum.Basic.Test/TransactionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text.Json.Serialization;

using Ethereum.Test.Base;
using Nethermind.Core;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

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)
Expand All @@ -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);
Expand All @@ -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()
};

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()
};

failedTest.Name = testDir;
failedTest.LoadFailure = $"Failed to load: {e}";
testsByName.Add(failedTest);
Expand Down
29 changes: 29 additions & 0 deletions src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaEofTests.cs
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-osaka.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));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System.Collections.Generic;
using System.Linq;
using Ethereum.Test.Base;
Expand All @@ -9,14 +12,18 @@ namespace Ethereum.Blockchain.Pyspec.Test;
[TestFixture]
[Parallelizable(ParallelScope.All)]
[Explicit("These tests are not ready yet")]
public class PragueStateTests : GeneralStateTestBase
public class OsakaStateTests : GeneralStateTestBase
{
[TestCaseSource(nameof(LoadTests))]
public void Test(GeneralStateTest test) => RunTest(test).Pass.Should().BeTrue();

private static IEnumerable<GeneralStateTest> LoadTests()
{
TestsSourceLoader loader = new(new LoadPyspecTestsStrategy(), $"fixtures/state_tests/prague");
TestsSourceLoader loader = new(new LoadPyspecTestsStrategy()
{
ArchiveName = "fixtures_eip7692-osaka.tar.gz",
ArchiveVersion = "[email protected]"
}, $"fixtures/state_tests/osaka");
return loader.LoadTests().Cast<GeneralStateTest>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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 ready yet")]
public class PragueBlockChainTests : BlockchainTestBase
{
[TestCaseSource(nameof(LoadTests))]
public async Task Test(BlockchainTest test) => await RunTest(test);

private static IEnumerable<BlockchainTest> LoadTests()
{
TestsSourceLoader loader = new(new LoadPyspecTestsStrategy(), $"fixtures/blockchain_tests/prague");
return loader.LoadTests().OfType<BlockchainTest>();
}
}
1 change: 0 additions & 1 deletion src/Nethermind/Ethereum.Blockchain.Test/BadOpcodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: LGPL-3.0-only

using System.Collections.Generic;
using System.Linq;
using Ethereum.Test.Base;
using NUnit.Framework;

Expand Down
24 changes: 15 additions & 9 deletions src/Nethermind/Ethereum.Blockchain.Test/EofTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// 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;

Expand All @@ -11,17 +13,21 @@ namespace Ethereum.Blockchain.Test;
[Parallelizable(ParallelScope.All)]
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();
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);
}
}
31 changes: 31 additions & 0 deletions src/Nethermind/Ethereum.Test.Base/EofTest.cs
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; }
}
77 changes: 77 additions & 0 deletions src/Nethermind/Ethereum.Test.Base/EofTestBase.cs
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;
}
}
}
17 changes: 17 additions & 0 deletions src/Nethermind/Ethereum.Test.Base/EofTestJson.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

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

namespace Ethereum.Test.Base
{
public class EofTestJson
{
[JsonPropertyName("_info")]
public GeneralStateTestInfoJson? Info { get; set; }

public Dictionary<string, VectorTestJson> Vectors { get; set; }

}
}
2 changes: 0 additions & 2 deletions src/Nethermind/Ethereum.Test.Base/EthereumTestResult.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System.Text.Json.Serialization;

using Nethermind.Core.Crypto;

namespace Ethereum.Test.Base
Expand Down
25 changes: 24 additions & 1 deletion src/Nethermind/Ethereum.Test.Base/FileTestsSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ public FileTestsSource(string fileName, string? wildcard = null)
_wildcard = wildcard;
}

public IEnumerable<EofTest> LoadEofTests()
{
try
{
if (Path.GetFileName(_fileName).StartsWith("."))
{
return Enumerable.Empty<EofTest>();
}

if (_wildcard is not null && !_fileName.Contains(_wildcard))
{
return Enumerable.Empty<EofTest>();
}

string json = File.ReadAllText(_fileName);
return JsonToEthereumTest.ConvertToEofTests(json);
}
catch (Exception e)
{
return Enumerable.Repeat(new EofTest { Name = _fileName, LoadFailure = $"Failed to load: {e}" }, 1);
}
}

public IEnumerable<GeneralStateTest> LoadGeneralStateTests()
{
try
Expand All @@ -35,7 +58,7 @@ public IEnumerable<GeneralStateTest> LoadGeneralStateTests()
}

string json = File.ReadAllText(_fileName);
return JsonToEthereumTest.Convert(json);
return JsonToEthereumTest.ConvertStateTest(json);
}
catch (Exception e)
{
Expand Down
Loading