diff --git a/.github/workflows/build-tools.yml b/.github/workflows/build-tools.yml index 4635f0a2ea5a..a2c1b0e6db5e 100644 --- a/.github/workflows/build-tools.yml +++ b/.github/workflows/build-tools.yml @@ -24,13 +24,15 @@ jobs: - Kute/Kute.slnx # - SchemaGenerator/SchemaGenerator.slnx - SendBlobs/SendBlobs.slnx - - TxParser/TxParser.slnx - StatelessExecution/StatelessExecution.slnx + - TxParser/TxParser.slnx steps: - name: Check out repository uses: actions/checkout@v5 + - name: Set up .NET uses: actions/setup-dotnet@v5 + - name: Build ${{ matrix.project }} working-directory: tools run: dotnet build ./${{ matrix.project }} -c ${{ matrix.config }} diff --git a/.github/workflows/nethermind-tests.yml b/.github/workflows/nethermind-tests.yml index 133b3f93b2f8..83ba586c503d 100644 --- a/.github/workflows/nethermind-tests.yml +++ b/.github/workflows/nethermind-tests.yml @@ -33,21 +33,20 @@ jobs: project: - Ethereum.Abi.Test - Ethereum.Basic.Test - - Ethereum.Blockchain.Block.Legacy.Test - Ethereum.Blockchain.Block.Test - - Ethereum.Blockchain.Legacy.Test - Ethereum.Blockchain.Pyspec.Test - - Ethereum.Blockchain.Test - Ethereum.Difficulty.Test - Ethereum.HexPrefix.Test - Ethereum.KeyAddress.Test - Ethereum.KeyStore.Test + - Ethereum.Legacy.Blockchain.Block.Test + - Ethereum.Legacy.Blockchain.Test + - Ethereum.Legacy.Transition.Test + - Ethereum.Legacy.VM.Test - Ethereum.PoW.Test - Ethereum.Rlp.Test - Ethereum.Transaction.Test - - Ethereum.Transition.Test - Ethereum.Trie.Test - - Ethereum.VM.Test - Nethermind.Abi.Test - Nethermind.Api.Test - Nethermind.AuRa.Test diff --git a/.github/workflows/sync-supported-chains.yml b/.github/workflows/sync-supported-chains.yml index 724792f9daff..bfaca5b9ca2d 100644 --- a/.github/workflows/sync-supported-chains.yml +++ b/.github/workflows/sync-supported-chains.yml @@ -178,6 +178,7 @@ jobs: --el-extra-flag "Seq.ServerUrl=https://seq.nethermind.io" \ --el-extra-flag "Seq.ApiKey=${{ secrets.SEQ_API_KEY }}" \ --el-extra-flag Seq.MinLevel=Info \ + --el-extra-flag "Init.LogRules=Synchronization.Peers.SyncPeersReport:Debug" \ --el-extra-flag "Metrics.PushGatewayUrl=${{ secrets.GRAFANA_CONNECTION_STRING }}" ) OP_METRICS_FLAGS=( @@ -186,6 +187,7 @@ jobs: --el-op-extra-flag "Seq.ServerUrl=https://seq.nethermind.io" \ --el-op-extra-flag "Seq.ApiKey=${{ secrets.SEQ_API_KEY }}" \ --el-op-extra-flag Seq.MinLevel=Info \ + --el-op-extra-flag "Init.LogRules=Synchronization.Peers.SyncPeersReport:Debug" \ --el-op-extra-flag "Metrics.PushGatewayUrl=${{ secrets.GRAFANA_CONNECTION_STRING }}" ) L2_METRICS_FLAGS=( @@ -194,6 +196,7 @@ jobs: --el-l2-extra-flag "Seq.ServerUrl=https://seq.nethermind.io" \ --el-l2-extra-flag "Seq.ApiKey=${{ secrets.SEQ_API_KEY }}" \ --el-l2-extra-flag Seq.MinLevel=Info \ + --el-l2-extra-flag "Init.LogRules=Synchronization.Peers.SyncPeersReport:Debug" \ --el-l2-extra-flag "Metrics.PushGatewayUrl=${{ secrets.GRAFANA_CONNECTION_STRING }}" ) diff --git a/scripts/known-failing-hive-tests.txt b/scripts/known-failing-hive-tests.txt index e56c4cdfe1da..d7e55daf2b24 100644 --- a/scripts/known-failing-hive-tests.txt +++ b/scripts/known-failing-hive-tests.txt @@ -2,11 +2,11 @@ eth_getStorageAt/get-storage-invalid-key (nethermind) eth_getStorageAt/get-storage-invalid-key-too-large (nethermind) +eth_createAccessList/create-al-abi-revert (nethermind) eth_sendRawTransaction/send-blob-tx (nethermind) eth_simulateV1/ethSimulate-instrict-gas-38013 (nethermind) eth_simulateV1/ethSimulate-run-gas-spending (nethermind) eth_simulateV1/ethSimulate-run-out-of-gas-in-block-38015 (nethermind) -eth_simulateV1/ethSimulate-simple-more-params-validate (nethermind) eth_simulateV1/ethSimulate-two-blocks-with-complete-eth-sends (nethermind) eth_simulateV1/ethSimulate-use-as-many-features-as-possible (nethermind) diff --git a/src/Nethermind/Chains/swell-mainnet.json.zst b/src/Nethermind/Chains/swell-mainnet.json.zst index 0aecfd71be14..473b4db43440 100644 Binary files a/src/Nethermind/Chains/swell-mainnet.json.zst and b/src/Nethermind/Chains/swell-mainnet.json.zst differ diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Blockhash/blockhash.json b/src/Nethermind/Ethereum.Blockchain.Block.Test/Blockhash/blockhash.json similarity index 100% rename from src/Nethermind/Ethereum.Blockchain.Test/Blockhash/blockhash.json rename to src/Nethermind/Ethereum.Blockchain.Block.Test/Blockhash/blockhash.json diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip3860LimitmeterInitCodeTests.cs b/src/Nethermind/Ethereum.Blockchain.Block.Test/BlockhashTests.cs similarity index 73% rename from src/Nethermind/Ethereum.Blockchain.Test/Eip3860LimitmeterInitCodeTests.cs rename to src/Nethermind/Ethereum.Blockchain.Block.Test/BlockhashTests.cs index bacdc7c7ea57..36b0c76707e9 100644 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip3860LimitmeterInitCodeTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Block.Test/BlockhashTests.cs @@ -1,15 +1,17 @@ // 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; using NUnit.Framework; -namespace Ethereum.Blockchain.Test; +namespace Ethereum.Blockchain.Block.Test; [TestFixture] [Parallelizable(ParallelScope.All)] -public class Eip3860LimitmeterInitCodeTests : GeneralStateTestBase +public class BlockhashTests : GeneralStateTestBase { [TestCaseSource(nameof(LoadTests))] public void Test(GeneralStateTest test) @@ -19,7 +21,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP3860-limitmeterinitcode"); + var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Blockhash")); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Test/Ethereum.Blockchain.Block.Test.csproj b/src/Nethermind/Ethereum.Blockchain.Block.Test/Ethereum.Blockchain.Block.Test.csproj index 1787402212f2..1dff0badfeef 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Test/Ethereum.Blockchain.Block.Test.csproj +++ b/src/Nethermind/Ethereum.Blockchain.Block.Test/Ethereum.Blockchain.Block.Test.csproj @@ -1,5 +1,5 @@ - + @@ -12,7 +12,15 @@ PreserveNewest + + + + PreserveNewest + + + + diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Test/ForgedTests.cs b/src/Nethermind/Ethereum.Blockchain.Block.Test/ForgedTests.cs index a0a2c7957bb6..5950609cb85b 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Test/ForgedTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Block.Test/ForgedTests.cs @@ -16,10 +16,11 @@ public class ForgedTests : BlockchainTestBase [TestCaseSource(nameof(LoadTests))] public async Task Test(BlockchainTest test) { - bool isWindows = System.Runtime.InteropServices.RuntimeInformation - .IsOSPlatform(OSPlatform.Windows); + bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); if (isWindows) + { return; + } await RunTest(test); } diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Test/StateTests.cs b/src/Nethermind/Ethereum.Blockchain.Block.Test/StateTests.cs index 656e042667c7..298b73893beb 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Test/StateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Block.Test/StateTests.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using Ethereum.Test.Base; -using Nethermind.Core.Attributes; using NUnit.Framework; namespace Ethereum.Blockchain.Block.Test @@ -13,7 +12,6 @@ namespace Ethereum.Blockchain.Block.Test [Parallelizable(ParallelScope.All)] public class StateTests : BlockchainTestBase { - [Todo(Improve.TestCoverage, "SuicideStorage tests")] [TestCaseSource(nameof(LoadTests)), Retry(3)] public async Task Test(BlockchainTest test) { diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallCreateCallCodeTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallCreateCallCodeTests.cs deleted file mode 100644 index df2bd0ad6f08..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallCreateCallCodeTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CallCreateCallCodeTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCallCreateCallCodeTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallDelegateCodesCallCodeHomesteadTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallDelegateCodesCallCodeHomesteadTests.cs deleted file mode 100644 index 035a83621966..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallDelegateCodesCallCodeHomesteadTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CallDelegateCodesCallCodeHomesteadTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCallDelegateCodesCallCodeHomestead"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallDelegateCodesHomesteadTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallDelegateCodesHomesteadTests.cs deleted file mode 100644 index 223d7e702ba3..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallDelegateCodesHomesteadTests.cs +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CallDelegateCodesHomesteadTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCallDelegateCodesHomestead"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ChangedEIP150Tests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ChangedEIP150Tests.cs deleted file mode 100644 index e767545f5a44..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ChangedEIP150Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ChangedEIP150Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stChangedEIP150"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CodeCopyTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CodeCopyTests.cs deleted file mode 100644 index 951067aa7b7f..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CodeCopyTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CodeCopyTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCodeCopyTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CodeSizeLimitTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CodeSizeLimitTests.cs deleted file mode 100644 index ec2f3899cca5..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CodeSizeLimitTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CodeSizeLimitTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCodeSizeLimit"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Create2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Create2Tests.cs deleted file mode 100644 index 4ea837b1759f..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Create2Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Create2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCreate2"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CreateTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CreateTests.cs deleted file mode 100644 index c0761e20222b..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CreateTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CreateTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCreateTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/DelegateCallTestHomesteadTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/DelegateCallTestHomesteadTests.cs deleted file mode 100644 index 5604942d4417..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/DelegateCallTestHomesteadTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class DelegateCallTestHomesteadTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stDelegatecallTestHomestead"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/EIP150SingleCodeGasPricesTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/EIP150SingleCodeGasPricesTests.cs deleted file mode 100644 index 85e455636700..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/EIP150SingleCodeGasPricesTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class EIP150SingleCodeGasPricesTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP150singleCodeGasPrices"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Eip150SpecificTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Eip150SpecificTests.cs deleted file mode 100644 index 9602f8be4d4d..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Eip150SpecificTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip150SpecificTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP150Specific"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Eip158SpecificTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Eip158SpecificTests.cs deleted file mode 100644 index e8b16addcdb3..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Eip158SpecificTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip158SpecificTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP158Specific"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Ethereum.Blockchain.Legacy.Test.csproj b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Ethereum.Blockchain.Legacy.Test.csproj deleted file mode 100644 index 82c175be3fc2..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Ethereum.Blockchain.Legacy.Test.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ExampleTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ExampleTests.cs deleted file mode 100644 index 5147949057e9..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ExampleTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ExampleTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stExample"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ExtCodeHashTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ExtCodeHashTests.cs deleted file mode 100644 index 119e3979f486..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ExtCodeHashTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ExtCodeHashTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stExtCodeHash"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/HomesteadSpecificTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/HomesteadSpecificTests.cs deleted file mode 100644 index c23c1052ac42..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/HomesteadSpecificTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class HomesteadSpecificTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stHomesteadSpecific"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/InitCodeTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/InitCodeTests.cs deleted file mode 100644 index e4d3423a1af9..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/InitCodeTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class InitCodeTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stInitCodeTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemExpandingEip150CallsTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemExpandingEip150CallsTests.cs deleted file mode 100644 index eb534eec6286..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemExpandingEip150CallsTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class MemExpandingEip150CallsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stMemExpandingEIP150Calls"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemoryStressTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemoryStressTests.cs deleted file mode 100644 index b8ed97fba088..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemoryStressTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class MemoryStressTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stMemoryStressTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemoryTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemoryTests.cs deleted file mode 100644 index 2a215c22b9ea..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/MemoryTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class MemoryTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stMemoryTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/NonZeroCallTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/NonZeroCallTests.cs deleted file mode 100644 index eb816ae3aad8..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/NonZeroCallTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class NonZeroCallTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stNonZeroCallsTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/PreCompiledContracts2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/PreCompiledContracts2Tests.cs deleted file mode 100644 index 377611884a8b..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/PreCompiledContracts2Tests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class PreCompiledContracts2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stPreCompiledContracts2"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/PreCompiledContractsTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/PreCompiledContractsTests.cs deleted file mode 100644 index 0c55e7fcf251..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/PreCompiledContractsTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class PreCompiledContractsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stPreCompiledContracts"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/QuadraticComplexityTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/QuadraticComplexityTests.cs deleted file mode 100644 index 0f7ae025fddd..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/QuadraticComplexityTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class QuadraticComplexityTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stQuadraticComplexityTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Random2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Random2Tests.cs deleted file mode 100644 index 04a97abdad1a..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/Random2Tests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Random2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRandom2"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RandomTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RandomTests.cs deleted file mode 100644 index e77bf15e90ee..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RandomTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RandomTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRandom"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RecursiveCreateTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RecursiveCreateTests.cs deleted file mode 100644 index cca3d38b529e..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RecursiveCreateTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RecursiveCreateTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRecursiveCreate"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RefundTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RefundTests.cs deleted file mode 100644 index 18c2c316bfd7..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RefundTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RefundTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRefundTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ReturnDataTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ReturnDataTests.cs deleted file mode 100644 index 8e718473a7f0..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ReturnDataTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ReturnDataTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stReturnDataTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RevertTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RevertTests.cs deleted file mode 100644 index 8d62cf44b283..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/RevertTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-FileCopyrightText: 2022 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.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RevertTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRevertTest"); - IEnumerable tests = loader.LoadTests(); - HashSet ignoredTests = new() - { - "RevertPrecompiledTouch", - }; - - return tests.Where(t => !ignoredTests.Any(pattern => t.Name.Contains(pattern))); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SStoreTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SStoreTests.cs deleted file mode 100644 index f5477c916627..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SStoreTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SStoreTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSStoreTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ShiftTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ShiftTests.cs deleted file mode 100644 index 5b614d672fa1..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ShiftTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ShiftTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stShift"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SolidityTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SolidityTests.cs deleted file mode 100644 index a292a97dae65..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SolidityTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SolidityTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSolidityTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SpecialTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SpecialTests.cs deleted file mode 100644 index 6fb70e5ee9c4..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SpecialTests.cs +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SpecialTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - [Retry(3)] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSpecialTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/StackTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/StackTests.cs deleted file mode 100644 index 5921030d5903..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/StackTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class StackTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stStackTests"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/StaticCallTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/StaticCallTests.cs deleted file mode 100644 index 29afd2f8536d..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/StaticCallTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class StaticCallTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stStaticCall"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SystemOperationsTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SystemOperationsTests.cs deleted file mode 100644 index a1f1fefcb3e0..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/SystemOperationsTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SystemOperationsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSystemOperationsTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TimeConsumingTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TimeConsumingTests.cs deleted file mode 100644 index cc4c7372d419..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TimeConsumingTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class TimeConsumingTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stTimeConsuming"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TransactionTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TransactionTests.cs deleted file mode 100644 index 310d1e1b5e7d..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TransactionTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class TransactionTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stTransactionTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TransitionTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TransitionTests.cs deleted file mode 100644 index be1484e6f613..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/TransitionTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class TransitionTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stTransitionTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/WalletTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/WalletTests.cs deleted file mode 100644 index 7aa893f3b264..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/WalletTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class WalletTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stWalletTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroCallsRevertTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroCallsRevertTests.cs deleted file mode 100644 index 7e59be7dbde4..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroCallsRevertTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroCallsRevertTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroCallsRevert"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroCallsTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroCallsTests.cs deleted file mode 100644 index e864de956473..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroCallsTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroCallsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroCallsTest"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroKnowledge2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroKnowledge2Tests.cs deleted file mode 100644 index 2b9051b62304..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroKnowledge2Tests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroKnowledge2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroKnowledge2"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroKnowledgeTests.cs b/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroKnowledgeTests.cs deleted file mode 100644 index af324039128f..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ZeroKnowledgeTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Legacy.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroKnowledgeTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroKnowledge"); - return loader.LoadTests(); - } - } -} - diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinBlockChainTests.cs index 264bc859ca77..5e202049eaf8 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinBlockChainTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinStateTests.cs index cdc20c50d11a..cc32ed244b0f 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/BerlinStateTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumBlockChainTests.cs index b6be913b4c5d..3583300d49c2 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumBlockChainTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumStateTests.cs index a650f3c79666..7579dc2ed9fc 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ByzantiumStateTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunBlockChainTests.cs index 62695ccc71fd..da29277f3419 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunBlockChainTests.cs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LGPL-3.0-only using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Ethereum.Test.Base; using FluentAssertions; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunStateTests.cs index f1f952b6adde..9a7d2402270d 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/CancunStateTests.cs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LGPL-3.0-only using System.Collections.Generic; -using System.Linq; using Ethereum.Test.Base; using FluentAssertions; using NUnit.Framework; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/Constants.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/Constants.cs index 8c80687245d1..50b8bcacbbf7 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/Constants.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/Constants.cs @@ -5,6 +5,6 @@ namespace Ethereum.Blockchain.Pyspec.Test; public class Constants { public const string ARCHIVE_URL_TEMPLATE = "https://github.com/ethereum/execution-spec-tests/releases/download/{0}/{1}"; - public const string DEFAULT_ARCHIVE_VERSION = "v4.4.0"; + public const string DEFAULT_ARCHIVE_VERSION = "v5.0.0"; public const string DEFAULT_ARCHIVE_NAME = "fixtures_develop.tar.gz"; } diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierBlockChainTests.cs index fae15df4b213..0b3c9a4a6417 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierBlockChainTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierStateTests.cs index 6011d779adf7..fbf265a22a8d 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/FrontierStateTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadBlockChainTests.cs index eba45011cbb3..fc6bc1c07b95 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadBlockChainTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadStateTests.cs index 44ec8d4041f5..0fec88659d02 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/HomesteadStateTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulBlockChainTests.cs index af62090dd9e9..4ad81bb85f3a 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulBlockChainTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulStateTests.cs index a4daf560f351..fe0f84a61d36 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/IstanbulStateTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaBlockChainTests.cs index 6e8cafbada58..99231fdd948d 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaBlockChainTests.cs @@ -2,7 +2,6 @@ // 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaEofTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaEofTests.cs index 28326dea3909..874f6a40f6bb 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaEofTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaEofTests.cs @@ -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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaStateTests.cs index 097c9c8f658c..d9c6248b9404 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/OsakaStateTests.cs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LGPL-3.0-only using System.Collections.Generic; -using System.Linq; using Ethereum.Test.Base; using FluentAssertions; using NUnit.Framework; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiBlockChainTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiBlockChainTests.cs index 2d273d715659..2e85ba8918d9 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiBlockChainTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiBlockChainTests.cs @@ -2,7 +2,6 @@ // 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiStateTests.cs b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiStateTests.cs index 5c75a9b80c63..b8e304a15167 100644 --- a/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiStateTests.cs +++ b/src/Nethermind/Ethereum.Blockchain.Pyspec.Test/ShanghaiStateTests.cs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 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; diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ArgsZeroOneBalanceTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ArgsZeroOneBalanceTests.cs deleted file mode 100644 index 70861549a512..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ArgsZeroOneBalanceTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ArgsZeroOneBalanceTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stArgsZeroOneBalance"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/AttackTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/AttackTests.cs deleted file mode 100644 index c63c4027fe1b..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/AttackTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class AttackTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stAttackTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/BadOpcodeTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/BadOpcodeTests.cs deleted file mode 100644 index 826aa7d9bf59..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/BadOpcodeTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class BadOpcodeTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - [Retry(3)] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stBadOpcode"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/BlockhashTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/BlockhashTests.cs deleted file mode 100644 index a929c2829dc1..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/BlockhashTests.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class BlockhashTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Blockhash")); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/BugsTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/BugsTests.cs deleted file mode 100644 index 544b1043d855..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/BugsTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class BugsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stBugs"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/CallCodeTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/CallCodeTests.cs deleted file mode 100644 index 5f153b790c6e..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/CallCodeTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CallCodesTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCallCodes"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/CallCreateCallCodeTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/CallCreateCallCodeTests.cs deleted file mode 100644 index ac4c6254c378..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/CallCreateCallCodeTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CallCreateCallCodeTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCallCreateCallCodeTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/CallDelegateCodesCallCodeHomesteadTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/CallDelegateCodesCallCodeHomesteadTests.cs deleted file mode 100644 index 000b41b60525..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/CallDelegateCodesCallCodeHomesteadTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CallDelegateCodesCallCodeHomesteadTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCallDelegateCodesCallCodeHomestead"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/CallDelegateCodesHomesteadTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/CallDelegateCodesHomesteadTests.cs deleted file mode 100644 index cd13e782b2fe..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/CallDelegateCodesHomesteadTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CallDelegateCodesHomesteadTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCallDelegateCodesHomestead"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ChainIdTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ChainIdTests.cs deleted file mode 100644 index eaba2c3f5216..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ChainIdTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ChainIdTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stChainId"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/CodeCopyTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/CodeCopyTests.cs deleted file mode 100644 index 14fe7570491c..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/CodeCopyTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CodeCopyTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCodeCopyTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/CodeSizeLimitTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/CodeSizeLimitTests.cs deleted file mode 100644 index 211df7ec8172..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/CodeSizeLimitTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CodeSizeLimitTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCodeSizeLimit"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Create2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Create2Tests.cs deleted file mode 100644 index f4fb73889246..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Create2Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Create2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCreate2"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/CreateTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/CreateTests.cs deleted file mode 100644 index fc8e60eee763..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/CreateTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class CreateTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - [Retry(3)] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stCreateTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/DelegateCallTestHomesteadTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/DelegateCallTestHomesteadTests.cs deleted file mode 100644 index 052065f73e28..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/DelegateCallTestHomesteadTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class DelegateCallTestHomesteadTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stDelegatecallTestHomestead"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/EIP150SingleCodeGasPricesTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/EIP150SingleCodeGasPricesTests.cs deleted file mode 100644 index 6b2be886136f..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/EIP150SingleCodeGasPricesTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip150SingleCodeGasPricesTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP150singleCodeGasPrices"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/EIP6110Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/EIP6110Tests.cs deleted file mode 100644 index 9a47a8a81f43..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/EIP6110Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip6110Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP6110"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip150SpecificTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Eip150SpecificTests.cs deleted file mode 100644 index 4776c9a67d41..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip150SpecificTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip150SpecificTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP150Specific"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip1559Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Eip1559Tests.cs deleted file mode 100644 index 7a8131194b5e..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip1559Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip1559Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP1559"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip158SpecificTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Eip158SpecificTests.cs deleted file mode 100644 index 481fe5d12f17..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip158SpecificTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip158SpecificTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP158Specific"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip2537Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Eip2537Tests.cs deleted file mode 100644 index c1d1d2422242..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip2537Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - // [TestFixture] - // [Parallelizable(ParallelScope.All)] - // public class Eip2537Tests : GeneralStateTestBase - // { - // [TestCaseSource(nameof(LoadTests))] - // public void Test(GeneralStateTest test) - // { - // Assert.That(RunTest(test).Pass, Is.True); - // } - // - // public static IEnumerable LoadTests() - // { - // var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP2537"); - // return loader.LoadTests(); - // } - // } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip2930Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Eip2930Tests.cs deleted file mode 100644 index 942d391022b9..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip2930Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip2930Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP2930"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip3540Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Eip3540Tests.cs deleted file mode 100644 index 8ffc83d518d4..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip3540Tests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test; - -[TestFixture] -[Parallelizable(ParallelScope.All)] -public class Eip3540Tests : GeneralStateTestBase -{ - // ToDo: Eip3540 is in development phase on another branch. This will be uncommented after merging that branch. - - // [TestCaseSource(nameof(LoadTests))] - // public void Test(GeneralStateTest test) - // { - // Assert.That(RunTest(test).Pass, Is.True); - // } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP3540"); - return loader.LoadTests(); - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip3607Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Eip3607Tests.cs deleted file mode 100644 index df29efdabbc2..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip3607Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Eip3607Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP3607"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Ethereum.Blockchain.Test.csproj b/src/Nethermind/Ethereum.Blockchain.Test/Ethereum.Blockchain.Test.csproj deleted file mode 100644 index 3c6f02d42f4d..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Ethereum.Blockchain.Test.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - %(RecursiveDir)%(FileName)%(Extension) - PreserveNewest - - - %(RecursiveDir)%(FileName)%(Extension) - PreserveNewest - - - %(RecursiveDir)%(FileName)%(Extension) - PreserveNewest - - - %(RecursiveDir)%(FileName)%(Extension) - PreserveNewest - - - - - - - - - - - PreserveNewest - - - diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ExampleTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ExampleTests.cs deleted file mode 100644 index 46105ac95a38..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ExampleTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ExampleTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stExample"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ExtCodeHashTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ExtCodeHashTests.cs deleted file mode 100644 index 29b1ada04bb5..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ExtCodeHashTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ExtCodeHashTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stExtCodeHash"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/HomesteadSpecificTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/HomesteadSpecificTests.cs deleted file mode 100644 index 6bbe34598eca..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/HomesteadSpecificTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class HomesteadSpecificTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stHomesteadSpecific"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/InitCodeTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/InitCodeTests.cs deleted file mode 100644 index e1ca82e99474..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/InitCodeTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class InitCodeTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stInitCodeTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/LogTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/LogTests.cs deleted file mode 100644 index 725efc21d7b5..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/LogTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class LogTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stLogTests"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/MemExpandingEip150CallsTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/MemExpandingEip150CallsTests.cs deleted file mode 100644 index 482ef80690f6..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/MemExpandingEip150CallsTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class MemExpandingEip150CallsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stMemExpandingEIP150Calls"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/MemoryStressTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/MemoryStressTests.cs deleted file mode 100644 index 317dd72eb377..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/MemoryStressTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class MemoryStressTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stMemoryStressTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/MemoryTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/MemoryTests.cs deleted file mode 100644 index 1888488cc641..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/MemoryTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class MemoryTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - [Retry(3)] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stMemoryTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/MetaTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/MetaTests.cs deleted file mode 100644 index 7636815f1a73..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/MetaTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class MetaTests - { - private List excludesDirectories = new List() - { - "stEWASMTests", - "VMTests", - "Specs", - "runtimes", - "ref", - "TestFiles", - "Blockhash", - "stEIP2537", // ToDo Remove this after updating tests - "Data", - "Log", - "TestResults" - }; - - [Test] - public void All_categories_are_tested() - { - string[] directories = Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory) - .Select(Path.GetFileName) - .ToArray(); - Type[] types = GetType().Assembly.GetTypes(); - List missingCategories = new List(); - foreach (string directory in directories) - { - string expectedTypeName = ExpectedTypeName(directory).Replace("-", ""); - Type type = types.SingleOrDefault(t => string.Equals(t.Name, expectedTypeName, StringComparison.InvariantCultureIgnoreCase)); - if (type is null && !excludesDirectories.Contains(directory)) - { - if (new DirectoryInfo(directory).GetFiles().Any(f => f.Name.Contains(".resources."))) - { - continue; - } - - missingCategories.Add(directory + " - " + expectedTypeName); - } - } - - foreach (string missing in missingCategories) - { - Console.WriteLine($"{missing} category is missing"); - } - - Assert.That(missingCategories.Count, Is.EqualTo(0)); - } - - private static string ExpectedTypeName(string directory) - { - string expectedTypeName = directory.Remove(0, 2); - if (!expectedTypeName.EndsWith("Tests")) - { - if (!expectedTypeName.EndsWith("Test")) - { - expectedTypeName += "Tests"; - } - else - { - expectedTypeName += "s"; - } - } - - if (directory.StartsWith("vm")) - { - return "Vm" + expectedTypeName; - } - - return expectedTypeName; - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/NonZeroCallTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/NonZeroCallTests.cs deleted file mode 100644 index d37ea0fae231..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/NonZeroCallTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class NonZeroCallsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stNonZeroCallsTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/PreCompiledContracts2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/PreCompiledContracts2Tests.cs deleted file mode 100644 index 27682f6c2ef4..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/PreCompiledContracts2Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class PreCompiledContracts2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stPreCompiledContracts2"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/PreCompiledContractsTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/PreCompiledContractsTests.cs deleted file mode 100644 index ada9c2822623..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/PreCompiledContractsTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class PreCompiledContractsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stPreCompiledContracts"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/QuadraticComplexityTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/QuadraticComplexityTests.cs deleted file mode 100644 index 56a7f3c50e78..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/QuadraticComplexityTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class QuadraticComplexityTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stQuadraticComplexityTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Random2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/Random2Tests.cs deleted file mode 100644 index b105f5850a02..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/Random2Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class Random2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stRandom2"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/RandomTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/RandomTests.cs deleted file mode 100644 index 140194260051..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/RandomTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RandomTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stRandom"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/RecursiveCreateTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/RecursiveCreateTests.cs deleted file mode 100644 index 69bc615c7566..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/RecursiveCreateTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RecursiveCreateTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stRecursiveCreate"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/RefundTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/RefundTests.cs deleted file mode 100644 index b5a0bd5a403d..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/RefundTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RefundTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stRefundTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ReturnDataTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ReturnDataTests.cs deleted file mode 100644 index 8be41631af14..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ReturnDataTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ReturnDataTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stReturnDataTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/RevertTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/RevertTests.cs deleted file mode 100644 index 7f1fadb64585..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/RevertTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class RevertTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stRevertTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/SLoadTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/SLoadTests.cs deleted file mode 100644 index 42134fd5e502..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/SLoadTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SLoadTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stSLoadTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/SStoreTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/SStoreTests.cs deleted file mode 100644 index 8723c5ae56c6..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/SStoreTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SStoreTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stSStoreTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/SelfBalanceTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/SelfBalanceTests.cs deleted file mode 100644 index 64b6725d4c79..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/SelfBalanceTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SelfBalanceTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stSelfBalance"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ShiftTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ShiftTests.cs deleted file mode 100644 index df1abbabb21a..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ShiftTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ShiftTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stShift"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/SolidityTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/SolidityTests.cs deleted file mode 100644 index e8caaf346fd9..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/SolidityTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SolidityTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - [Retry(3)] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stSolidityTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/SpecialTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/SpecialTests.cs deleted file mode 100644 index cfeeff65bddb..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/SpecialTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SpecialTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests)), Retry(3)] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stSpecialTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/StackTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/StackTests.cs deleted file mode 100644 index 735c52983f01..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/StackTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class StackTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stStackTests"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/StaticCallTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/StaticCallTests.cs deleted file mode 100644 index 40dc6de1dab0..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/StaticCallTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class StaticCallTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stStaticCall"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/StaticFlagEnabledTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/StaticFlagEnabledTests.cs deleted file mode 100644 index 237b3f2de045..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/StaticFlagEnabledTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class StaticFlagEnabledTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stStaticFlagEnabled"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/SystemOperationsTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/SystemOperationsTests.cs deleted file mode 100644 index 8367c9adb6a4..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/SystemOperationsTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class SystemOperationsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stSystemOperationsTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/TimeConsumingTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/TimeConsumingTests.cs deleted file mode 100644 index 52941d306db6..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/TimeConsumingTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class TimeConsumingTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stTimeConsuming"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/TransactionJsonTest.cs b/src/Nethermind/Ethereum.Blockchain.Test/TransactionJsonTest.cs deleted file mode 100644 index 1467ff8ed394..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/TransactionJsonTest.cs +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using Ethereum.Test.Base; -using FluentAssertions; -using Nethermind.Core; -using Nethermind.Core.Test.Builders; -using Nethermind.Int256; -using Nethermind.Serialization.Json; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class TransactionJsonTest : GeneralStateTestBase - { - [Test] - public void Can_load_access_lists() - { - const string lists = - "{\"accessLists\": [[{\"address\": \"0x0001020304050607080900010203040506070809\", \"storageKeys\": [\"0x00\", \"0x01\"]}]]}"; - - EthereumJsonSerializer serializer = new EthereumJsonSerializer(); - TransactionJson txJson = serializer.Deserialize(lists); - txJson.SecretKey = TestItem.PrivateKeyA.KeyBytes; - txJson.Value = new UInt256[1]; - txJson.GasLimit = new long[1]; - txJson.Data = new byte[1][]; - txJson.AccessLists.Should().NotBeNull(); - txJson.AccessLists[0][0].Address.Should() - .BeEquivalentTo(new Address("0x0001020304050607080900010203040506070809")); - txJson.AccessLists[0][0].StorageKeys[1][0].Should().Be((byte)1); - - Transaction tx = JsonToEthereumTest.Convert(new PostStateJson { Indexes = new IndexesJson() }, txJson); - tx.AccessList.Should().NotBeNull(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/TransactionTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/TransactionTests.cs deleted file mode 100644 index ba200752fc23..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/TransactionTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: 2022 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.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class TransactionTests : GeneralStateTestBase - { - // ToDo: This tests are passing on hive tests, but failing here - private readonly string[] ignored = - { - "HighGasPrice_d0g0v0", - "ValueOverflow" - }; - - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - if (ignored.Any(i => test.Name.Contains(i))) - { - return; - } - - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stTransactionTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/TransitionTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/TransitionTests.cs deleted file mode 100644 index 3ef886b011f3..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/TransitionTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class TransitionTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stTransitionTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/WalletTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/WalletTests.cs deleted file mode 100644 index e6e3fd31ca5f..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/WalletTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class WalletTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stWalletTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ZeroCallsRevertTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ZeroCallsRevertTests.cs deleted file mode 100644 index 68cea5976954..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ZeroCallsRevertTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroCallsRevertTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stZeroCallsRevert"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ZeroCallsTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ZeroCallsTests.cs deleted file mode 100644 index 096086050a54..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ZeroCallsTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroCallsTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stZeroCallsTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ZeroKnowledge2Tests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ZeroKnowledge2Tests.cs deleted file mode 100644 index 1fe846bf06a7..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ZeroKnowledge2Tests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroKnowledge2Tests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stZeroKnowledge2"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/ZeroKnowledgeTests.cs b/src/Nethermind/Ethereum.Blockchain.Test/ZeroKnowledgeTests.cs deleted file mode 100644 index 5f06f881b7fa..000000000000 --- a/src/Nethermind/Ethereum.Blockchain.Test/ZeroKnowledgeTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Blockchain.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class ZeroKnowledgeTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stZeroKnowledge"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/BlockGasLimitTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/BlockGasLimitTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/BlockGasLimitTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/BlockGasLimitTests.cs index 6f853f109e67..0f12857feb34 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/BlockGasLimitTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/BlockGasLimitTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/Ethereum.Blockchain.Block.Legacy.Test.csproj b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/Ethereum.Legacy.Blockchain.Block.Test.csproj similarity index 100% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/Ethereum.Blockchain.Block.Legacy.Test.csproj rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/Ethereum.Legacy.Blockchain.Block.Test.csproj diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ExploitTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ExploitTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ExploitTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ExploitTests.cs index d44297e91a30..d38563a0e824 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ExploitTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ExploitTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ForgedTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ForgedTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ForgedTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ForgedTests.cs index 37d1d92d87fd..6dbf8d1ea0db 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ForgedTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ForgedTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ForkStressTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ForkStressTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ForkStressTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ForkStressTests.cs index cb4f161c835f..2b0988961c60 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ForkStressTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ForkStressTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/GasPricerTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/GasPricerTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/GasPricerTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/GasPricerTests.cs index 98a068c5b0b2..d1a0c141532a 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/GasPricerTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/GasPricerTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/InvalidHeaderTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/InvalidHeaderTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/InvalidHeaderTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/InvalidHeaderTests.cs index 2975ea50acf8..c2eec5fa97e0 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/InvalidHeaderTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/InvalidHeaderTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/MultiChainTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/MultiChainTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/MultiChainTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/MultiChainTests.cs index 2c22bb0caf93..7dd8fcbb24cf 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/MultiChainTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/MultiChainTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/RandomBlockchashTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/RandomBlockchashTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/RandomBlockchashTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/RandomBlockchashTests.cs index cbb00404d352..b66985eb9dc9 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/RandomBlockchashTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/RandomBlockchashTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/StateTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/StateTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/StateTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/StateTests.cs index eaad23627cd4..6612de9c947d 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/StateTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/StateTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/TotalDifficulty.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/TotalDifficulty.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/TotalDifficulty.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/TotalDifficulty.cs index ca207702306c..9f6cb0b02d32 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/TotalDifficulty.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/TotalDifficulty.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleHeaderValidityTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleHeaderValidityTests.cs similarity index 94% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleHeaderValidityTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleHeaderValidityTests.cs index bc6b9f69b6dd..a823bd88472b 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleHeaderValidityTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleHeaderValidityTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleSpecialTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleSpecialTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleSpecialTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleSpecialTests.cs index fb95513cba46..652e78a706ec 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleSpecialTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleSpecialTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleTests.cs index 47bb941b4f99..0ac0f05d0698 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/UncleTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/UncleTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ValidBlockTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ValidBlockTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ValidBlockTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ValidBlockTests.cs index a78284dea94e..1768d20b5b5b 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/ValidBlockTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/ValidBlockTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/WalletTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/WalletTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/WalletTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/WalletTests.cs index f38e13ff1ae0..16140af1cae3 100644 --- a/src/Nethermind/Ethereum.Blockchain.Block.Legacy.Test/WalletTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Block.Test/WalletTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Block.Legacy.Test +namespace Ethereum.Legacy.Blockchain.Block.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ArgsZeroOneBalanceTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ArgsZeroOneBalanceTests.cs similarity index 85% rename from src/Nethermind/Ethereum.Blockchain.Legacy.Test/ArgsZeroOneBalanceTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/ArgsZeroOneBalanceTests.cs index 1dd1c0d509b6..73541bf71673 100644 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/ArgsZeroOneBalanceTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ArgsZeroOneBalanceTests.cs @@ -5,10 +5,10 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Legacy.Test; +namespace Ethereum.Legacy.Blockchain.Test; [Parallelizable(ParallelScope.All)] -public class ArgsZeroOneBalanaceTests : GeneralStateTestBase +public class ArgsZeroOneBalanceTests : GeneralStateTestBase { [TestCaseSource(nameof(LoadTests))] public void Test(GeneralStateTest test) diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/AttackTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/AttackTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Legacy.Test/AttackTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/AttackTests.cs index c3c8450efeb5..4ebc59be7490 100644 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/AttackTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/AttackTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Legacy.Test; +namespace Ethereum.Legacy.Blockchain.Test; [Parallelizable(ParallelScope.All)] public class AttackTests : GeneralStateTestBase diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/BadOpCodeTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/BadOpCodeTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Legacy.Test/BadOpCodeTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/BadOpCodeTests.cs index f63fe28d09c7..e2f46d5ae2fc 100644 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/BadOpCodeTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/BadOpCodeTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Legacy.Test; +namespace Ethereum.Legacy.Blockchain.Test; [Parallelizable(ParallelScope.All)] public class BadOpCodeTests : GeneralStateTestBase diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/BugsTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/BugsTests.cs similarity index 87% rename from src/Nethermind/Ethereum.Blockchain.Legacy.Test/BugsTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/BugsTests.cs index 8504d5b4c5f3..ab7f33f57a0e 100644 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/BugsTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/BugsTests.cs @@ -5,10 +5,10 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Legacy.Test; +namespace Ethereum.Legacy.Blockchain.Test; [Parallelizable(ParallelScope.All)] -public class BugsTets : GeneralStateTestBase +public class BugsTests : GeneralStateTestBase { [TestCaseSource(nameof(LoadTests))] public void Test(GeneralStateTest test) diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallCodesTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallCodesTests.cs similarity index 93% rename from src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallCodesTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallCodesTests.cs index 3ccb9484b531..2092d621f225 100644 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/CallCodesTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallCodesTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Legacy.Test; +namespace Ethereum.Legacy.Blockchain.Test; [Parallelizable(ParallelScope.All)] public class CallCodesTests : GeneralStateTestBase diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip3651WarmCoinbaseTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallCreateCallCodeTests.cs similarity index 70% rename from src/Nethermind/Ethereum.Blockchain.Test/Eip3651WarmCoinbaseTests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallCreateCallCodeTests.cs index f23bedd762d3..b6dc53bdc258 100644 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip3651WarmCoinbaseTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallCreateCallCodeTests.cs @@ -5,11 +5,11 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Test; +namespace Ethereum.Legacy.Blockchain.Test; [TestFixture] [Parallelizable(ParallelScope.All)] -public class Eip3651WarmCoinbaseTests : GeneralStateTestBase +public class CallCreateCallCodeTests : GeneralStateTestBase { [TestCaseSource(nameof(LoadTests))] public void Test(GeneralStateTest test) @@ -19,7 +19,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP3651-warmcoinbase"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCallCreateCallCodeTest"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallDelegateCodesCallCodeHomesteadTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallDelegateCodesCallCodeHomesteadTests.cs new file mode 100644 index 000000000000..25662ec7a4cf --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallDelegateCodesCallCodeHomesteadTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class CallDelegateCodesCallCodeHomesteadTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCallDelegateCodesCallCodeHomestead"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallDelegateCodesHomesteadTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallDelegateCodesHomesteadTests.cs new file mode 100644 index 000000000000..77c197352f62 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CallDelegateCodesHomesteadTests.cs @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class CallDelegateCodesHomesteadTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCallDelegateCodesHomestead"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ChainIdTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ChainIdTests.cs new file mode 100644 index 000000000000..f7a3e6312819 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ChainIdTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ChainIdTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stChainId"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ChangedEIP150Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ChangedEIP150Tests.cs new file mode 100644 index 000000000000..3d00fe7839a6 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ChangedEIP150Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ChangedEIP150Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stChangedEIP150"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CodeCopyTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CodeCopyTests.cs new file mode 100644 index 000000000000..72f63ac92b7c --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CodeCopyTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class CodeCopyTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCodeCopyTest"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CodeSizeLimitTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CodeSizeLimitTests.cs new file mode 100644 index 000000000000..9466e78327bf --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CodeSizeLimitTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class CodeSizeLimitTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCodeSizeLimit"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Create2Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Create2Tests.cs new file mode 100644 index 000000000000..10fe821204c7 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Create2Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class Create2Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCreate2"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CreateTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CreateTests.cs new file mode 100644 index 000000000000..ccf9a43d41c9 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/CreateTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class CreateTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stCreateTest"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/DelegateCallTestHomesteadTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/DelegateCallTestHomesteadTests.cs new file mode 100644 index 000000000000..091f762bf2c1 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/DelegateCallTestHomesteadTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class DelegateCallTestHomesteadTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stDelegatecallTestHomestead"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1153Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1153Tests.cs new file mode 100644 index 000000000000..317726f3ac9a --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1153Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP1153Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP1153"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip1153Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1153transientStorageTests.cs similarity index 78% rename from src/Nethermind/Ethereum.Blockchain.Test/Eip1153Tests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1153transientStorageTests.cs index a0d9ec11c551..a90df15dd407 100644 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip1153Tests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1153transientStorageTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Test; +namespace Ethereum.Legacy.Blockchain.Test; [TestFixture] [Parallelizable(ParallelScope.All)] @@ -19,7 +19,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP1153-transientStorage"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP1153-transientStorage"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP150SingleCodeGasPricesTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP150SingleCodeGasPricesTests.cs new file mode 100644 index 000000000000..bb9f26da51a7 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP150SingleCodeGasPricesTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP150SingleCodeGasPricesTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP150singleCodeGasPrices"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1559Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1559Tests.cs new file mode 100644 index 000000000000..4ed518148d66 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP1559Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP1559Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP1559"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP2930Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP2930Tests.cs new file mode 100644 index 000000000000..3b0aeb5da6a9 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP2930Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP2930Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP2930"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3607Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3607Tests.cs new file mode 100644 index 000000000000..1dff5eccd76b --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3607Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP3607Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP3607"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3651Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3651Tests.cs new file mode 100644 index 000000000000..b3fb35a685af --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3651Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP3651Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP3651"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3651warmcoinbaseTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3651warmcoinbaseTests.cs new file mode 100644 index 000000000000..98f363a2d600 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3651warmcoinbaseTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Blockchain.Legacy.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP3651warmcoinbaseTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP3651-warmcoinbase"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3855Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3855Tests.cs new file mode 100644 index 000000000000..21dc3ab36ea8 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3855Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP3855Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP3855"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3855push0Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3855push0Tests.cs new file mode 100644 index 000000000000..0664789a0407 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3855push0Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Blockchain.Legacy.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP3855push0Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP3855-push0"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3860Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3860Tests.cs new file mode 100644 index 000000000000..e1b713a72159 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3860Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP3860Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP3860"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3860limitmeterinitcodeTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3860limitmeterinitcodeTests.cs new file mode 100644 index 000000000000..b0b53519322b --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP3860limitmeterinitcodeTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Blockchain.Legacy.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP3860limitmeterinitcodeTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP3860-limitmeterinitcode"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP4844Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP4844Tests.cs new file mode 100644 index 000000000000..83a42a8919a1 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP4844Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP4844Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP4844"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip4844Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP4844blobtransactionsTests.cs similarity index 78% rename from src/Nethermind/Ethereum.Blockchain.Test/Eip4844Tests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP4844blobtransactionsTests.cs index 81935e1c6c08..407915ec2b21 100644 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip4844Tests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP4844blobtransactionsTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Test; +namespace Ethereum.Blockchain.Legacy.Test; [TestFixture] [Parallelizable(ParallelScope.All)] @@ -19,7 +19,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP4844-blobtransactions"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP4844-blobtransactions"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip5656Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP5656MCOPYTests.cs similarity index 79% rename from src/Nethermind/Ethereum.Blockchain.Test/Eip5656Tests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP5656MCOPYTests.cs index 5cf5ecd6f7b4..02bb16400ccb 100644 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip5656Tests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP5656MCOPYTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Test; +namespace Ethereum.Blockchain.Legacy.Test; [TestFixture] [Parallelizable(ParallelScope.All)] @@ -19,7 +19,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP5656-MCOPY"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP5656-MCOPY"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP5656Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP5656Tests.cs new file mode 100644 index 000000000000..2fb14f29f097 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/EIP5656Tests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class EIP5656Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP5656"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Eip150SpecificTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Eip150SpecificTests.cs new file mode 100644 index 000000000000..7ec86298dc9a --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Eip150SpecificTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class Eip150SpecificTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP150Specific"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Eip158SpecificTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Eip158SpecificTests.cs new file mode 100644 index 000000000000..d483bd2a50bb --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Eip158SpecificTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class Eip158SpecificTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stEIP158Specific"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Ethereum.Legacy.Blockchain.Test.csproj b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Ethereum.Legacy.Blockchain.Test.csproj new file mode 100644 index 000000000000..11d6c0a0f50d --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Ethereum.Legacy.Blockchain.Test.csproj @@ -0,0 +1,24 @@ + + + + + + + %(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + + + + + + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ExampleTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ExampleTests.cs new file mode 100644 index 000000000000..ec25b97acbb9 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ExampleTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ExampleTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stExample"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ExtCodeHashTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ExtCodeHashTests.cs new file mode 100644 index 000000000000..3957461b26b7 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ExtCodeHashTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ExtCodeHashTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stExtCodeHash"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/HomesteadSpecificTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/HomesteadSpecificTests.cs new file mode 100644 index 000000000000..ee0f3361301a --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/HomesteadSpecificTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class HomesteadSpecificTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stHomesteadSpecific"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/InitCodeTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/InitCodeTests.cs new file mode 100644 index 000000000000..62bb11476db6 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/InitCodeTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class InitCodeTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stInitCodeTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/LogTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/LogTests.cs new file mode 100644 index 000000000000..ba4f228944b6 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/LogTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class LogTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stLogTests"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemExpandingEip150CallsTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemExpandingEip150CallsTests.cs new file mode 100644 index 000000000000..e2532ed67de5 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemExpandingEip150CallsTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class MemExpandingEip150CallsTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stMemExpandingEIP150Calls"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemoryStressTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemoryStressTests.cs new file mode 100644 index 000000000000..21d35dd2d638 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemoryStressTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class MemoryStressTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stMemoryStressTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemoryTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemoryTests.cs new file mode 100644 index 000000000000..3501593becb3 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MemoryTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class MemoryTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stMemoryTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MetaTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MetaTests.cs new file mode 100644 index 000000000000..820025aeca94 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/MetaTests.cs @@ -0,0 +1,79 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class MetaTests +{ + private readonly List excludesDirectories = + [ + "stEWASMTests", + "VMTests", + "Specs", + "runtimes", + "ref", + "TestFiles", + "Blockhash", + "Data", + "Log", + "TestResults" + ]; + + [Test] + public void All_categories_are_tested() + { + string[] directories = Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory) + .Select(Path.GetFileName) + .ToArray(); + Type[] types = GetType().Assembly.GetTypes(); + List missingCategories = new List(); + foreach (string directory in directories) + { + string expectedTypeName = ExpectedTypeName(directory).Replace("-", ""); + Type type = types.SingleOrDefault(t => string.Equals(t.Name, expectedTypeName, StringComparison.InvariantCultureIgnoreCase)); + if (type is null && !excludesDirectories.Contains(directory)) + { + if (new DirectoryInfo(directory).GetFiles().Any(f => f.Name.Contains(".resources."))) + continue; + + missingCategories.Add(directory + " - " + expectedTypeName); + } + } + + foreach (string missing in missingCategories) + { + Console.WriteLine($"{missing} category is missing"); + } + + Assert.That(missingCategories.Count, Is.EqualTo(0)); + } + + private static string ExpectedTypeName(string directory) + { + string expectedTypeName = directory.Remove(0, 2); + if (!expectedTypeName.EndsWith("Tests")) + { + if (!expectedTypeName.EndsWith("Test")) + { + expectedTypeName += "Tests"; + } + else + { + expectedTypeName += "s"; + } + } + + if (directory.StartsWith("vm")) + return "Vm" + expectedTypeName; + + return expectedTypeName; + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/NonZeroCallsTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/NonZeroCallsTests.cs new file mode 100644 index 000000000000..6c2f75d3bf1d --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/NonZeroCallsTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class NonZeroCallsTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stNonZeroCallsTest"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/PreCompiledContracts2Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/PreCompiledContracts2Tests.cs new file mode 100644 index 000000000000..6f8199287cc2 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/PreCompiledContracts2Tests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class PreCompiledContracts2Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stPreCompiledContracts2"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/PreCompiledContractsTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/PreCompiledContractsTests.cs new file mode 100644 index 000000000000..9496c69c86e7 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/PreCompiledContractsTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class PreCompiledContractsTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stPreCompiledContracts"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/QuadraticComplexityTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/QuadraticComplexityTests.cs new file mode 100644 index 000000000000..18d0a424457b --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/QuadraticComplexityTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class QuadraticComplexityTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stQuadraticComplexityTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Random2Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Random2Tests.cs new file mode 100644 index 000000000000..0b9438f55ef2 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/Random2Tests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class Random2Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRandom2"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RandomTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RandomTests.cs new file mode 100644 index 000000000000..87a08b7798c8 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RandomTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class RandomTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRandom"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RecursiveCreateTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RecursiveCreateTests.cs new file mode 100644 index 000000000000..31081732de2b --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RecursiveCreateTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class RecursiveCreateTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRecursiveCreate"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RefundTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RefundTests.cs new file mode 100644 index 000000000000..0deafc7ed83e --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RefundTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class RefundTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRefundTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ReturnDataTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ReturnDataTests.cs new file mode 100644 index 000000000000..835782b50708 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ReturnDataTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ReturnDataTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stReturnDataTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RevertTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RevertTests.cs new file mode 100644 index 000000000000..d2f622115c43 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/RevertTests.cs @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2022 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.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class RevertTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stRevertTest"); + IEnumerable tests = loader.LoadTests(); + HashSet ignoredTests = new() + { + "RevertPrecompiledTouch", + }; + + return tests.Where(t => !ignoredTests.Any(pattern => t.Name.Contains(pattern))); ; + } +} + diff --git a/src/Nethermind/Ethereum.Blockchain.Test/Eip3855Push0Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SLoadTestTests.cs similarity index 70% rename from src/Nethermind/Ethereum.Blockchain.Test/Eip3855Push0Tests.cs rename to src/Nethermind/Ethereum.Legacy.Blockchain.Test/SLoadTestTests.cs index 281c0c6d4fb7..32dc5d064a14 100644 --- a/src/Nethermind/Ethereum.Blockchain.Test/Eip3855Push0Tests.cs +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SLoadTestTests.cs @@ -5,11 +5,10 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Test; +namespace Ethereum.Legacy.Blockchain.Test; -[TestFixture] [Parallelizable(ParallelScope.All)] -public class Eip3855Push0Tests : GeneralStateTestBase +public class SLoadTestTests : GeneralStateTestBase { [TestCaseSource(nameof(LoadTests))] public void Test(GeneralStateTest test) @@ -19,7 +18,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "stEIP3855-push0"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSLoadTest"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SLoadTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SLoadTests.cs new file mode 100644 index 000000000000..f2a986d5a9df --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SLoadTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Blockchain.Legacy.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class SLoadTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSLoadTest"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SStoreTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SStoreTests.cs new file mode 100644 index 000000000000..efca5b0a5427 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SStoreTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class SStoreTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSStoreTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SelfBalanceTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SelfBalanceTests.cs new file mode 100644 index 000000000000..08cc732dcc3e --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SelfBalanceTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class SelfBalanceTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSelfBalance"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ShiftTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ShiftTests.cs new file mode 100644 index 000000000000..556a452dd302 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ShiftTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ShiftTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stShift"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SolidityTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SolidityTests.cs new file mode 100644 index 000000000000..7352761d911e --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SolidityTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class SolidityTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSolidityTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SpecialTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SpecialTests.cs new file mode 100644 index 000000000000..ea9354c0d61a --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SpecialTests.cs @@ -0,0 +1,27 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class SpecialTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + [Retry(3)] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSpecialTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StackTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StackTests.cs new file mode 100644 index 000000000000..2c19e824dec7 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StackTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class StackTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stStackTests"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StaticCallTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StaticCallTests.cs new file mode 100644 index 000000000000..87681c3d153c --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StaticCallTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class StaticCallTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stStaticCall"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StaticFlagEnabledTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StaticFlagEnabledTests.cs new file mode 100644 index 000000000000..c494fcce2fe5 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/StaticFlagEnabledTests.cs @@ -0,0 +1,25 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class StaticFlagEnabledTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stStaticFlagEnabled"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SystemOperationsTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SystemOperationsTests.cs new file mode 100644 index 000000000000..ccaa3d0d4d67 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/SystemOperationsTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class SystemOperationsTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stSystemOperationsTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TimeConsumingTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TimeConsumingTests.cs new file mode 100644 index 000000000000..d5533c02d03c --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TimeConsumingTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class TimeConsumingTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stTimeConsuming"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TransactionTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TransactionTests.cs new file mode 100644 index 000000000000..06351b4d008b --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TransactionTests.cs @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using System.Linq; +using Ethereum.Test.Base; +using Ethereum.Test.Base.Interfaces; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class TransactionTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + try + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stTransactionTest"); + // We don't handle invalid transaction's RLP cases, that are loaded as FailedToLoadTest + return loader.LoadTests().OfType(); + } + catch + { + throw; + } + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TransitionTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TransitionTests.cs new file mode 100644 index 000000000000..cc24e621c1a3 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/TransitionTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class TransitionTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stTransitionTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/WalletTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/WalletTests.cs new file mode 100644 index 000000000000..9e216c9d2bf9 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/WalletTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class WalletTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stWalletTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroCallsRevertTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroCallsRevertTests.cs new file mode 100644 index 000000000000..b74345680f47 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroCallsRevertTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ZeroCallsRevertTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroCallsRevert"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroCallsTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroCallsTests.cs new file mode 100644 index 000000000000..46ffd6c4db2a --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroCallsTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ZeroCallsTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroCallsTest"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroKnowledge2Tests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroKnowledge2Tests.cs new file mode 100644 index 000000000000..e07f237c5a47 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroKnowledge2Tests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ZeroKnowledge2Tests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroKnowledge2"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroKnowledgeTests.cs b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroKnowledgeTests.cs new file mode 100644 index 000000000000..f15cb484eb99 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Blockchain.Test/ZeroKnowledgeTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class ZeroKnowledgeTests : GeneralStateTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public void Test(GeneralStateTest test) + { + Assert.That(RunTest(test).Pass, Is.True); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stZeroKnowledge"); + return loader.LoadTests(); + } +} + diff --git a/src/Nethermind/Ethereum.Legacy.Transition.Test/BerlinToLondonTests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/BerlinToLondonTests.cs new file mode 100644 index 000000000000..835f19a5c038 --- /dev/null +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/BerlinToLondonTests.cs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Collections.Generic; +using System.Threading.Tasks; +using Ethereum.Test.Base; +using NUnit.Framework; + +namespace Ethereum.Legacy.Transition.Test; + +[TestFixture] +[Parallelizable(ParallelScope.None)] +public class BerlinToLondonTests : BlockchainTestBase +{ + [TestCaseSource(nameof(LoadTests))] + public async Task Test(BlockchainTest test) + { + await RunTest(test); + } + + public static IEnumerable LoadTests() + { + var loader = new TestsSourceLoader(new LoadBlockchainTestsStrategy(), "bcBerlinToLondon"); + return loader.LoadTests(); + } +} diff --git a/src/Nethermind/Ethereum.Transition.Test/ByzantiumToConstantinopleFixTests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/ByzantiumToConstantinopleFixTests.cs similarity index 94% rename from src/Nethermind/Ethereum.Transition.Test/ByzantiumToConstantinopleFixTests.cs rename to src/Nethermind/Ethereum.Legacy.Transition.Test/ByzantiumToConstantinopleFixTests.cs index ba743f0ee527..ddad01efea8c 100644 --- a/src/Nethermind/Ethereum.Transition.Test/ByzantiumToConstantinopleFixTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/ByzantiumToConstantinopleFixTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Transition.Test +namespace Ethereum.Legacy.Transition.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Transition.Test/Eip158ToByzantiumTests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/Eip158ToByzantiumTests.cs similarity index 94% rename from src/Nethermind/Ethereum.Transition.Test/Eip158ToByzantiumTests.cs rename to src/Nethermind/Ethereum.Legacy.Transition.Test/Eip158ToByzantiumTests.cs index eb0c0dd46b8f..5566a3bffc7c 100644 --- a/src/Nethermind/Ethereum.Transition.Test/Eip158ToByzantiumTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/Eip158ToByzantiumTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Transition.Test +namespace Ethereum.Legacy.Transition.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Transition.Test/Ethereum.Transition.Test.csproj b/src/Nethermind/Ethereum.Legacy.Transition.Test/Ethereum.Legacy.Transition.Test.csproj similarity index 100% rename from src/Nethermind/Ethereum.Transition.Test/Ethereum.Transition.Test.csproj rename to src/Nethermind/Ethereum.Legacy.Transition.Test/Ethereum.Legacy.Transition.Test.csproj diff --git a/src/Nethermind/Ethereum.Transition.Test/FrontierToHomesteadTests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/FrontierToHomesteadTests.cs similarity index 94% rename from src/Nethermind/Ethereum.Transition.Test/FrontierToHomesteadTests.cs rename to src/Nethermind/Ethereum.Legacy.Transition.Test/FrontierToHomesteadTests.cs index 443fe9e3c27d..62167d3db08e 100644 --- a/src/Nethermind/Ethereum.Transition.Test/FrontierToHomesteadTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/FrontierToHomesteadTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Transition.Test +namespace Ethereum.Legacy.Transition.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Transition.Test/HomesteadToDaoTests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/HomesteadToDaoTests.cs similarity index 94% rename from src/Nethermind/Ethereum.Transition.Test/HomesteadToDaoTests.cs rename to src/Nethermind/Ethereum.Legacy.Transition.Test/HomesteadToDaoTests.cs index 9451f5ff36fc..0a213c05a7e7 100644 --- a/src/Nethermind/Ethereum.Transition.Test/HomesteadToDaoTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/HomesteadToDaoTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Transition.Test +namespace Ethereum.Legacy.Transition.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Transition.Test/HomesteadToEip150Tests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/HomesteadToEip150Tests.cs similarity index 94% rename from src/Nethermind/Ethereum.Transition.Test/HomesteadToEip150Tests.cs rename to src/Nethermind/Ethereum.Legacy.Transition.Test/HomesteadToEip150Tests.cs index f244d82121ca..54295c08cfd5 100644 --- a/src/Nethermind/Ethereum.Transition.Test/HomesteadToEip150Tests.cs +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/HomesteadToEip150Tests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Transition.Test +namespace Ethereum.Legacy.Transition.Test { [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/src/Nethermind/Ethereum.Transition.Test/MergeToShanghaiTests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/MergeToShanghaiTests.cs similarity index 79% rename from src/Nethermind/Ethereum.Transition.Test/MergeToShanghaiTests.cs rename to src/Nethermind/Ethereum.Legacy.Transition.Test/MergeToShanghaiTests.cs index f0fb44ba22eb..2aead08dbb68 100644 --- a/src/Nethermind/Ethereum.Transition.Test/MergeToShanghaiTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/MergeToShanghaiTests.cs @@ -6,7 +6,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Transition.Test; +namespace Ethereum.Legacy.Transition.Test; [TestFixture] [Parallelizable(ParallelScope.All)] @@ -20,7 +20,7 @@ public async Task Test(BlockchainTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadBlockchainTestsStrategy(), "bcMergeToShanghai"); + var loader = new TestsSourceLoader(new LoadLegacyBlockchainTestsStrategy(), "bcMergeToShanghai"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Transition.Test/MetaTests.cs b/src/Nethermind/Ethereum.Legacy.Transition.Test/MetaTests.cs similarity index 96% rename from src/Nethermind/Ethereum.Transition.Test/MetaTests.cs rename to src/Nethermind/Ethereum.Legacy.Transition.Test/MetaTests.cs index 73318524654a..8341e536b6fa 100644 --- a/src/Nethermind/Ethereum.Transition.Test/MetaTests.cs +++ b/src/Nethermind/Ethereum.Legacy.Transition.Test/MetaTests.cs @@ -7,7 +7,7 @@ using System.Linq; using NUnit.Framework; -namespace Ethereum.Transition.Test +namespace Ethereum.Legacy.Transition.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -26,9 +26,7 @@ public void All_categories_are_tested() { string expectedTypeName = ExpectedTypeName(directory); if (types.All(t => !string.Equals(t.Name, expectedTypeName, StringComparison.InvariantCultureIgnoreCase))) - { missingCategories.Add(directory); - } } foreach (string missing in missingCategories) diff --git a/src/Nethermind/Ethereum.VM.Test/AbiTests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/AbiTests.cs similarity index 97% rename from src/Nethermind/Ethereum.VM.Test/AbiTests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/AbiTests.cs index 284e159fe91a..32a1caabc2df 100644 --- a/src/Nethermind/Ethereum.VM.Test/AbiTests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/AbiTests.cs @@ -8,7 +8,7 @@ using Nethermind.Core.Extensions; using NUnit.Framework; -namespace Ethereum.VM.Test; +namespace Ethereum.Legacy.VM.Test; internal class AbiTests { @@ -28,7 +28,7 @@ private static AbiType ToAbiType(string typeName) private static AbiTest Convert(string name, AbiTestJson testJson) { - AbiTest test = new AbiTest(); + AbiTest test = new(); test.Name = name; test.Result = Bytes.FromHexString(testJson.Result); test.Types = testJson.Types.Select(ToAbiType).ToArray(); diff --git a/src/Nethermind/Ethereum.VM.Test/ArithmeticTests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/ArithmeticTests.cs similarity index 80% rename from src/Nethermind/Ethereum.VM.Test/ArithmeticTests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/ArithmeticTests.cs index 692690dba929..6afb75cabdae 100644 --- a/src/Nethermind/Ethereum.VM.Test/ArithmeticTests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/ArithmeticTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.VM.Test +namespace Ethereum.Legacy.VM.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -19,7 +19,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "vmArithmeticTest"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "VMTests", "vmArithmeticTest"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.VM.Test/BitwiseLogicOperationTests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/BitwiseLogicOperationTests.cs similarity index 80% rename from src/Nethermind/Ethereum.VM.Test/BitwiseLogicOperationTests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/BitwiseLogicOperationTests.cs index b128a507861c..ce7605275998 100644 --- a/src/Nethermind/Ethereum.VM.Test/BitwiseLogicOperationTests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/BitwiseLogicOperationTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.VM.Test +namespace Ethereum.Legacy.VM.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -19,7 +19,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "vmBitwiseLogicOperation"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "vmBitwiseLogicOperation"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.VM.Test/Ethereum.VM.Test.csproj b/src/Nethermind/Ethereum.Legacy.VM.Test/Ethereum.Legacy.VM.Test.csproj similarity index 87% rename from src/Nethermind/Ethereum.VM.Test/Ethereum.VM.Test.csproj rename to src/Nethermind/Ethereum.Legacy.VM.Test/Ethereum.Legacy.VM.Test.csproj index 6f57a0eb9757..262db6d8fa6d 100644 --- a/src/Nethermind/Ethereum.VM.Test/Ethereum.VM.Test.csproj +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/Ethereum.Legacy.VM.Test.csproj @@ -10,7 +10,7 @@ %(RecursiveDir)%(FileName)%(Extension) PreserveNewest - + %(RecursiveDir)%(FileName)%(Extension) PreserveNewest diff --git a/src/Nethermind/Ethereum.VM.Test/IOAndFlowOperationsTests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/IOAndFlowOperationsTests.cs similarity index 81% rename from src/Nethermind/Ethereum.VM.Test/IOAndFlowOperationsTests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/IOAndFlowOperationsTests.cs index 1f24fb7077cc..260a281c5ed8 100644 --- a/src/Nethermind/Ethereum.VM.Test/IOAndFlowOperationsTests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/IOAndFlowOperationsTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.VM.Test +namespace Ethereum.Legacy.VM.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -20,7 +20,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "vmIOAndFlowOperations"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "vmIOAndFlowOperations"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/LogTests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/LogTests.cs similarity index 89% rename from src/Nethermind/Ethereum.Blockchain.Legacy.Test/LogTests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/LogTests.cs index 650a03675f21..b7bd487a2c40 100644 --- a/src/Nethermind/Ethereum.Blockchain.Legacy.Test/LogTests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/LogTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.Blockchain.Legacy.Test +namespace Ethereum.Legacy.VM.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -19,9 +19,8 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "stLogTests"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "vmLogTest"); return loader.LoadTests(); } } } - diff --git a/src/Nethermind/Ethereum.VM.Test/MetaTests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/MetaTests.cs similarity index 96% rename from src/Nethermind/Ethereum.VM.Test/MetaTests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/MetaTests.cs index 4181e7f42f0d..de21eef49b49 100644 --- a/src/Nethermind/Ethereum.VM.Test/MetaTests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/MetaTests.cs @@ -7,7 +7,7 @@ using System.Linq; using NUnit.Framework; -namespace Ethereum.VM.Test +namespace Ethereum.Legacy.VM.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -30,9 +30,7 @@ public void All_categories_are_tested() if (types.All(t => !string.Equals(t.Name, expectedTypeName, StringComparison.InvariantCultureIgnoreCase))) { if (new DirectoryInfo(directory).GetFiles().Any(f => f.Name.Contains(".resources."))) - { continue; - } missingCategories.Add(directory + " expected " + expectedTypeName); } diff --git a/src/Nethermind/Ethereum.VM.Test/PerformanceTests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/PerformanceTests.cs similarity index 82% rename from src/Nethermind/Ethereum.VM.Test/PerformanceTests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/PerformanceTests.cs index c9b9dc637a50..84ee86b5a860 100644 --- a/src/Nethermind/Ethereum.VM.Test/PerformanceTests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/PerformanceTests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.VM.Test +namespace Ethereum.Legacy.VM.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -21,7 +21,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "vmPerformance"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "vmPerformance"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.VM.Test/Tests.cs b/src/Nethermind/Ethereum.Legacy.VM.Test/Tests.cs similarity index 82% rename from src/Nethermind/Ethereum.VM.Test/Tests.cs rename to src/Nethermind/Ethereum.Legacy.VM.Test/Tests.cs index 19a1d8f45def..51a22ccbc3aa 100644 --- a/src/Nethermind/Ethereum.VM.Test/Tests.cs +++ b/src/Nethermind/Ethereum.Legacy.VM.Test/Tests.cs @@ -5,7 +5,7 @@ using Ethereum.Test.Base; using NUnit.Framework; -namespace Ethereum.VM.Test +namespace Ethereum.Legacy.VM.Test { [TestFixture] [Parallelizable(ParallelScope.All)] @@ -20,7 +20,7 @@ public void Test(GeneralStateTest test) public static IEnumerable LoadTests() { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "vmTests"); + var loader = new TestsSourceLoader(new LoadLegacyGeneralStateTestsStrategy(), "vmTests"); return loader.LoadTests(); } } diff --git a/src/Nethermind/Ethereum.Test.Base/BlockchainTest.cs b/src/Nethermind/Ethereum.Test.Base/BlockchainTest.cs index 6329281f660f..6916dd59eb53 100644 --- a/src/Nethermind/Ethereum.Test.Base/BlockchainTest.cs +++ b/src/Nethermind/Ethereum.Test.Base/BlockchainTest.cs @@ -20,6 +20,7 @@ public class BlockchainTest : EthereumTest public TestBlockJson[]? Blocks { get; set; } public TestBlockHeaderJson? GenesisBlockHeader { get; set; } + public TestEngineNewPayloadsJson[]? EngineNewPayloads { get; set; } public Dictionary? Pre { get; set; } public Dictionary? PostState { get; set; } diff --git a/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs b/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs index 202c09ade825..374f738ab79d 100644 --- a/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs @@ -31,23 +31,24 @@ using Nethermind.Specs.Test; using Nethermind.Evm.State; using Nethermind.Init.Modules; -using Nethermind.TxPool; using NUnit.Framework; +using Nethermind.Merge.Plugin.Data; +using Nethermind.Merge.Plugin; +using Nethermind.JsonRpc; +using System.Reflection; namespace Ethereum.Test.Base; public abstract class BlockchainTestBase { private static readonly ILogger _logger; - private static readonly ILogManager _logManager = new TestLogManager(); - private static ISealValidator Sealer { get; } + private static readonly ILogManager _logManager = new TestLogManager(LogLevel.Warn); private static DifficultyCalculatorWrapper DifficultyCalculator { get; } + private const int _genesisProcessingTimeoutMs = 5000; static BlockchainTestBase() { DifficultyCalculator = new DifficultyCalculatorWrapper(); - Sealer = new EthashSealValidator(_logManager, DifficultyCalculator, new CryptoRandom(), new Ethash(_logManager), Timestamper.Default); // temporarily keep reusing the same one as otherwise it would recreate cache for each test - _logManager ??= LimboLogs.Instance; _logger = _logManager.GetClassLogger(); } @@ -83,8 +84,13 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? test.Network = ChainUtils.ResolveSpec(test.Network, test.ChainId); test.NetworkAfterTransition = ChainUtils.ResolveSpec(test.NetworkAfterTransition, test.ChainId); + bool isEngineTest = test.Blocks is null && test.EngineNewPayloads is not null; + List<(ForkActivation Activation, IReleaseSpec Spec)> transitions = + isEngineTest ? + [((ForkActivation)0, test.Network)] : [((ForkActivation)0, test.GenesisSpec), ((ForkActivation)1, test.Network)]; // TODO: this thing took a lot of time to find after it was removed!, genesis block is always initialized with Frontier + if (test.NetworkAfterTransition is not null) { transitions.Add((test.TransitionForkActivation!.Value, test.NetworkAfterTransition)); @@ -92,7 +98,7 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? ISpecProvider specProvider = new CustomSpecProvider(test.ChainId, test.ChainId, transitions.ToArray()); - Assert.That(test.ChainId == GnosisSpecProvider.Instance.ChainId || specProvider.GenesisSpec == Frontier.Instance, "Expected genesis spec to be Frontier for blockchain tests"); + Assert.That(isEngineTest || test.ChainId == GnosisSpecProvider.Instance.ChainId || specProvider.GenesisSpec == Frontier.Instance, "Expected genesis spec to be Frontier for blockchain tests"); if (test.Network is Cancun || test.NetworkAfterTransition is Cancun) { @@ -122,18 +128,23 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? IConfigProvider configProvider = new ConfigProvider(); // configProvider.GetConfig().PreWarmStateOnBlockProcessing = false; - await using IContainer container = new ContainerBuilder() + ContainerBuilder containerBuilder = new ContainerBuilder() .AddModule(new TestNethermindModule(configProvider)) .AddSingleton(specProvider) .AddSingleton(_logManager) .AddSingleton(rewardCalculator) - .AddSingleton(DifficultyCalculator) - .AddSingleton(NullTxPool.Instance) - .Build(); + .AddSingleton(DifficultyCalculator); + + if (isEngineTest) + { + containerBuilder.AddModule(new TestMergeModule(configProvider)); + } + + await using IContainer container = containerBuilder.Build(); IMainProcessingContext mainBlockProcessingContext = container.Resolve(); IWorldState stateProvider = mainBlockProcessingContext.WorldState; - IBlockchainProcessor blockchainProcessor = mainBlockProcessingContext.BlockchainProcessor; + BlockchainProcessor blockchainProcessor = (BlockchainProcessor)mainBlockProcessingContext.BlockchainProcessor; IBlockTree blockTree = container.Resolve(); IBlockValidator blockValidator = container.Resolve(); blockchainProcessor.Start(); @@ -165,85 +176,66 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? { if (args.Block.Number == 0) { - Assert.That(stateProvider.HasStateForBlock(genesisBlock.Header), Is.EqualTo(true)); + Assert.That(stateProvider.HasStateForBlock(genesisBlock.Header), Is.True); + genesisProcessed.Set(); + } + }; + + blockchainProcessor.BlockRemoved += (_, args) => + { + if (args.ProcessingResult != ProcessingResult.Success && args.BlockHash == genesisBlock.Header.Hash) + { + Assert.Fail($"Failed to process genesis block: {args.Exception}"); genesisProcessed.Set(); } }; blockTree.SuggestBlock(genesisBlock); - genesisProcessed.WaitOne(); + genesisProcessed.WaitOne(_genesisProcessingTimeoutMs); parentHeader = genesisBlock.Header; // Dispose genesis block's AccountChanges genesisBlock.DisposeAccountChanges(); } - List<(Block Block, string ExpectedException)> correctRlp = DecodeRlps(test, failOnInvalidRlp); - for (int i = 0; i < correctRlp.Count; i++) + if (test.Blocks is not null) { - // Mimic the actual behaviour where block goes through validating sync manager - correctRlp[i].Block.Header.IsPostMerge = correctRlp[i].Block.Difficulty == 0; - - // For tests with reorgs, find the actual parent header from block tree - parentHeader = blockTree.FindHeader(correctRlp[i].Block.ParentHash) ?? parentHeader; - - Assert.That(correctRlp[i].Block.Hash is not null, $"null hash in {test.Name} block {i}"); - - bool expectsException = correctRlp[i].ExpectedException is not null; - // Validate block structure first (mimics SyncServer validation) - if (blockValidator.ValidateSuggestedBlock(correctRlp[i].Block, parentHeader, out string? validationError)) - { - Assert.That(!expectsException, $"Expected block {correctRlp[i].Block.Hash} to fail with '{correctRlp[i].ExpectedException}', but it passed validation"); - try - { - // All validations passed, suggest the block - blockTree.SuggestBlock(correctRlp[i].Block); - - } - catch (InvalidBlockException e) - { - // Exception thrown during block processing - Assert.That(expectsException, $"Unexpected invalid block {correctRlp[i].Block.Hash}: {validationError}, Exception: {e}"); - // else: Expected to fail and did fail via exception → this is correct behavior - } - catch (Exception e) - { - Assert.Fail($"Unexpected exception during processing: {e}"); - } - finally - { - // Dispose AccountChanges to prevent memory leaks in tests - correctRlp[i].Block.DisposeAccountChanges(); - } - } - else - { - // Validation FAILED - Assert.That(expectsException, $"Unexpected invalid block {correctRlp[i].Block.Hash}: {validationError}"); - // else: Expected to fail and did fail → this is correct behavior - } - - parentHeader = correctRlp[i].Block.Header; + // blockchain test + parentHeader = SuggestBlocks(test, failOnInvalidRlp, blockValidator, blockTree, parentHeader); + } + else if (test.EngineNewPayloads is not null) + { + // engine test + IEngineRpcModule engineRpcModule = container.Resolve(); + await RunNewPayloads(test.EngineNewPayloads, engineRpcModule); + } + else + { + Assert.Fail("Invalid blockchain test, did not contain blocks or new payloads."); } // NOTE: Tracer removal must happen AFTER StopAsync to ensure all blocks are traced // Blocks are queued asynchronously, so we need to wait for processing to complete await blockchainProcessor.StopAsync(true); - stopwatch?.Stop(); IBlockCachePreWarmer? preWarmer = container.Resolve().LifetimeScope.ResolveOptional(); - if (preWarmer is not null) + + // Caches are cleared async, which is a problem as read for the MainWorldState with prewarmer is not correct if its not cleared. + preWarmer?.ClearCaches(); + + Block? headBlock = blockTree.RetrieveHeadBlock(); + + Assert.That(headBlock, Is.Not.Null); + if (headBlock is null) { - // Caches are cleared async, which is a problem as read for the MainWorldState with prewarmer is not correct if its not cleared. - preWarmer.ClearCaches(); + return new EthereumTestResult(test.Name, null, false); } - Block? headBlock = blockTree.RetrieveHeadBlock(); List differences; using (stateProvider.BeginScope(headBlock.Header)) { - differences = RunAssertions(test, blockTree.RetrieveHeadBlock(), stateProvider); + differences = RunAssertions(test, headBlock, stateProvider); } bool testPassed = differences.Count == 0; @@ -256,14 +248,8 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? blockchainProcessor.Tracers.Remove(tracer); } - Assert.That(differences.Count, Is.Zero, "differences"); - - return new EthereumTestResult - ( - test.Name, - null, - testPassed - ); + Assert.That(differences, Is.Empty, "differences"); + return new EthereumTestResult(test.Name, null, testPassed); } catch (Exception) { @@ -272,9 +258,93 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? } } - private List<(Block Block, string ExpectedException)> DecodeRlps(BlockchainTest test, bool failOnInvalidRlp) + private static BlockHeader SuggestBlocks(BlockchainTest test, bool failOnInvalidRlp, IBlockValidator blockValidator, IBlockTree blockTree, BlockHeader parentHeader) + { + List<(Block Block, string ExpectedException)> correctRlp = DecodeRlps(test, failOnInvalidRlp); + for (int i = 0; i < correctRlp.Count; i++) + { + // Mimic the actual behaviour where block goes through validating sync manager + correctRlp[i].Block.Header.IsPostMerge = correctRlp[i].Block.Difficulty == 0; + + // For tests with reorgs, find the actual parent header from block tree + parentHeader = blockTree.FindHeader(correctRlp[i].Block.ParentHash) ?? parentHeader; + + Assert.That(correctRlp[i].Block.Hash, Is.Not.Null, $"null hash in {test.Name} block {i}"); + + bool expectsException = correctRlp[i].ExpectedException is not null; + // Validate block structure first (mimics SyncServer validation) + if (blockValidator.ValidateSuggestedBlock(correctRlp[i].Block, parentHeader, out string? validationError)) + { + Assert.That(!expectsException, $"Expected block {correctRlp[i].Block.Hash} to fail with '{correctRlp[i].ExpectedException}', but it passed validation"); + try + { + // All validations passed, suggest the block + blockTree.SuggestBlock(correctRlp[i].Block); + + } + catch (InvalidBlockException e) + { + // Exception thrown during block processing + Assert.That(expectsException, $"Unexpected invalid block {correctRlp[i].Block.Hash}: {validationError}, Exception: {e}"); + // else: Expected to fail and did fail via exception → this is correct behavior + } + catch (Exception e) + { + Assert.Fail($"Unexpected exception during processing: {e}"); + } + finally + { + // Dispose AccountChanges to prevent memory leaks in tests + correctRlp[i].Block.DisposeAccountChanges(); + } + } + else + { + // Validation FAILED + Assert.That(expectsException, $"Unexpected invalid block {correctRlp[i].Block.Hash}: {validationError}"); + // else: Expected to fail and did fail → this is correct behavior + } + + parentHeader = correctRlp[i].Block.Header; + } + return parentHeader; + } + + private async static Task RunNewPayloads(TestEngineNewPayloadsJson[]? newPayloads, IEngineRpcModule engineRpcModule) { - List<(Block Block, string ExpectedException)> correctRlp = new(); + (ExecutionPayloadV3, string[]?, string[]?, int, int)[] payloads = [.. JsonToEthereumTest.Convert(newPayloads)]; + + // blockchain test engine + foreach ((ExecutionPayload executionPayload, string[]? blobVersionedHashes, string[]? validationError, int newPayloadVersion, int fcuVersion) in payloads) + { + ResultWrapper res; + byte[]?[] hashes = blobVersionedHashes is null ? [] : [.. blobVersionedHashes.Select(x => Bytes.FromHexString(x))]; + + MethodInfo newPayloadMethod = engineRpcModule.GetType().GetMethod($"engine_newPayloadV{newPayloadVersion}"); + List newPayloadParams = [executionPayload]; + if (newPayloadVersion >= 3) + { + newPayloadParams.AddRange([hashes, executionPayload.ParentBeaconBlockRoot]); + } + if (newPayloadVersion >= 4) + { + newPayloadParams.Add(executionPayload.ExecutionRequests); + } + + res = await (Task>)newPayloadMethod.Invoke(engineRpcModule, [.. newPayloadParams]); + + if (res.Result.ResultType == ResultType.Success) + { + ForkchoiceStateV1 fcuState = new(executionPayload.BlockHash, executionPayload.BlockHash, executionPayload.BlockHash); + MethodInfo fcuMethod = engineRpcModule.GetType().GetMethod($"engine_forkchoiceUpdatedV{fcuVersion}"); + await (Task>)fcuMethod.Invoke(engineRpcModule, [fcuState, null]); + } + } + } + + private static List<(Block Block, string ExpectedException)> DecodeRlps(BlockchainTest test, bool failOnInvalidRlp) + { + List<(Block Block, string ExpectedException)> correctRlp = []; for (int i = 0; i < test.Blocks!.Length; i++) { TestBlockJson testBlockJson = test.Blocks[i]; @@ -282,6 +352,7 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? { RlpStream rlpContext = Bytes.FromHexString(testBlockJson.Rlp!).AsRlpStream(); Block suggestedBlock = Rlp.Decode(rlpContext); + if (testBlockJson.BlockHeader is not null) { Assert.That(suggestedBlock.Header.Hash, Is.EqualTo(new Hash256(testBlockJson.BlockHeader.Hash))); @@ -313,17 +384,20 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? if (correctRlp.Count == 0) { - Assert.That(test.GenesisBlockHeader, Is.Not.Null); - Assert.That(test.LastBlockHash, Is.EqualTo(new Hash256(test.GenesisBlockHeader.Hash))); + using (Assert.EnterMultipleScope()) + { + Assert.That(test.GenesisBlockHeader, Is.Not.Null); + Assert.That(test.LastBlockHash, Is.EqualTo(new Hash256(test.GenesisBlockHeader.Hash))); + } } return correctRlp; } - private void InitializeTestState(BlockchainTest test, IWorldState stateProvider, ISpecProvider specProvider) + private static void InitializeTestState(BlockchainTest test, IWorldState stateProvider, ISpecProvider specProvider) { foreach (KeyValuePair accountState in - ((IEnumerable>)test.Pre ?? Array.Empty>())) + (IEnumerable>)test.Pre ?? Array.Empty>()) { foreach (KeyValuePair storageItem in accountState.Value.Storage) { @@ -335,24 +409,18 @@ private void InitializeTestState(BlockchainTest test, IWorldState stateProvider, } stateProvider.Commit(specProvider.GenesisSpec); - stateProvider.CommitTree(0); - stateProvider.Reset(); } - private List RunAssertions(BlockchainTest test, Block headBlock, IWorldState stateProvider) + private static List RunAssertions(BlockchainTest test, Block headBlock, IWorldState stateProvider) { if (test.PostStateRoot is not null) { return test.PostStateRoot != stateProvider.StateRoot ? ["state root mismatch"] : Enumerable.Empty().ToList(); } - TestBlockHeaderJson testHeaderJson = (test.Blocks? - .Where(b => b.BlockHeader is not null) - .SingleOrDefault(b => new Hash256(b.BlockHeader.Hash) == headBlock.Hash)?.BlockHeader) ?? test.GenesisBlockHeader; - BlockHeader testHeader = JsonToEthereumTest.Convert(testHeaderJson); - List differences = new(); + List differences = []; IEnumerable> deletedAccounts = test.Pre? .Where(pre => !(test.PostState?.ContainsKey(pre.Key) ?? false)) ?? Array.Empty>(); @@ -365,7 +433,7 @@ private List RunAssertions(BlockchainTest test, Block headBlock, IWorldS } } - foreach ((Address acountAddress, AccountState accountState) in test.PostState!) + foreach ((Address accountAddress, AccountState accountState) in test.PostState!) { int differencesBefore = differences.Count; @@ -375,87 +443,96 @@ private List RunAssertions(BlockchainTest test, Block headBlock, IWorldS break; } - bool accountExists = stateProvider.AccountExists(acountAddress); - UInt256? balance = accountExists ? stateProvider.GetBalance(acountAddress) : null; - UInt256? nonce = accountExists ? stateProvider.GetNonce(acountAddress) : null; + bool accountExists = stateProvider.AccountExists(accountAddress); + UInt256? balance = accountExists ? stateProvider.GetBalance(accountAddress) : null; + UInt256? nonce = accountExists ? stateProvider.GetNonce(accountAddress) : null; if (accountState.Balance != balance) { - differences.Add($"{acountAddress} balance exp: {accountState.Balance}, actual: {balance}, diff: {(balance > accountState.Balance ? balance - accountState.Balance : accountState.Balance - balance)}"); + differences.Add($"{accountAddress} balance exp: {accountState.Balance}, actual: {balance}, diff: {(balance > accountState.Balance ? balance - accountState.Balance : accountState.Balance - balance)}"); } if (accountState.Nonce != nonce) { - differences.Add($"{acountAddress} nonce exp: {accountState.Nonce}, actual: {nonce}"); + differences.Add($"{accountAddress} nonce exp: {accountState.Nonce}, actual: {nonce}"); } - byte[] code = accountExists ? stateProvider.GetCode(acountAddress) : []; + byte[] code = accountExists ? stateProvider.GetCode(accountAddress) : []; if (!Bytes.AreEqual(accountState.Code, code)) { - differences.Add($"{acountAddress} code exp: {accountState.Code?.Length}, actual: {code?.Length}"); + differences.Add($"{accountAddress} code exp: {accountState.Code?.Length}, actual: {code?.Length}"); } if (differences.Count != differencesBefore) { - _logger.Info($"ACCOUNT STATE ({acountAddress}) HAS DIFFERENCES"); + _logger.Info($"ACCOUNT STATE ({accountAddress}) HAS DIFFERENCES"); } differencesBefore = differences.Count; KeyValuePair[] clearedStorages = []; - if (test.Pre.TryGetValue(acountAddress, out AccountState? state)) + if (test.Pre.ContainsKey(accountAddress)) { - clearedStorages = state.Storage.Where(s => !accountState.Storage.ContainsKey(s.Key)).ToArray(); + clearedStorages = [.. test.Pre[accountAddress].Storage.Where(s => !accountState.Storage.ContainsKey(s.Key))]; } foreach (KeyValuePair clearedStorage in clearedStorages) { - ReadOnlySpan value = !stateProvider.AccountExists(acountAddress) ? Bytes.Empty : stateProvider.Get(new StorageCell(acountAddress, clearedStorage.Key)); + ReadOnlySpan value = !stateProvider.AccountExists(accountAddress) ? Bytes.Empty : stateProvider.Get(new StorageCell(accountAddress, clearedStorage.Key)); if (!value.IsZero()) { - differences.Add($"{acountAddress} storage[{clearedStorage.Key}] exp: 0x00, actual: {value.ToHexString(true)}"); + differences.Add($"{accountAddress} storage[{clearedStorage.Key}] exp: 0x00, actual: {value.ToHexString(true)}"); } } foreach (KeyValuePair storageItem in accountState.Storage) { - ReadOnlySpan value = !stateProvider.AccountExists(acountAddress) ? Bytes.Empty : stateProvider.Get(new StorageCell(acountAddress, storageItem.Key)); + ReadOnlySpan value = !stateProvider.AccountExists(accountAddress) ? Bytes.Empty : stateProvider.Get(new StorageCell(accountAddress, storageItem.Key)); if (!Bytes.AreEqual(storageItem.Value, value)) { - differences.Add($"{acountAddress} storage[{storageItem.Key}] exp: {storageItem.Value.ToHexString(true)}, actual: {value.ToHexString(true)}"); + differences.Add($"{accountAddress} storage[{storageItem.Key}] exp: {storageItem.Value.ToHexString(true)}, actual: {value.ToHexString(true)}"); } } if (differences.Count != differencesBefore) { - _logger.Info($"ACCOUNT STORAGE ({acountAddress}) HAS DIFFERENCES"); + _logger.Info($"ACCOUNT STORAGE ({accountAddress}) HAS DIFFERENCES"); } } - BigInteger gasUsed = headBlock.Header.GasUsed; - if ((testHeader?.GasUsed ?? 0) != gasUsed) - { - differences.Add($"GAS USED exp: {testHeader?.GasUsed ?? 0}, actual: {gasUsed}"); - } + TestBlockHeaderJson? testHeaderJson = test.Blocks? + .Where(b => b.BlockHeader is not null) + .SingleOrDefault(b => new Hash256(b.BlockHeader.Hash) == headBlock.Hash)?.BlockHeader; - if (headBlock.Transactions.Any() && testHeader.Bloom.ToString() != headBlock.Header.Bloom.ToString()) + if (testHeaderJson is not null) { - differences.Add($"BLOOM exp: {testHeader.Bloom}, actual: {headBlock.Header.Bloom}"); - } + BlockHeader testHeader = JsonToEthereumTest.Convert(testHeaderJson); - if (testHeader.StateRoot != stateProvider.StateRoot) - { - differences.Add($"STATE ROOT exp: {testHeader.StateRoot}, actual: {stateProvider.StateRoot}"); - } + BigInteger gasUsed = headBlock.Header.GasUsed; + if ((testHeader?.GasUsed ?? 0) != gasUsed) + { + differences.Add($"GAS USED exp: {testHeader?.GasUsed ?? 0}, actual: {gasUsed}"); + } - if (testHeader.TxRoot != headBlock.Header.TxRoot) - { - differences.Add($"TRANSACTIONS ROOT exp: {testHeader.TxRoot}, actual: {headBlock.Header.TxRoot}"); - } + if (headBlock.Transactions.Length != 0 && testHeader.Bloom.ToString() != headBlock.Header.Bloom.ToString()) + { + differences.Add($"BLOOM exp: {testHeader.Bloom}, actual: {headBlock.Header.Bloom}"); + } - if (testHeader.ReceiptsRoot != headBlock.Header.ReceiptsRoot) - { - differences.Add($"RECEIPT ROOT exp: {testHeader.ReceiptsRoot}, actual: {headBlock.Header.ReceiptsRoot}"); + if (testHeader.StateRoot != stateProvider.StateRoot) + { + differences.Add($"STATE ROOT exp: {testHeader.StateRoot}, actual: {stateProvider.StateRoot}"); + } + + if (testHeader.TxRoot != headBlock.Header.TxRoot) + { + differences.Add($"TRANSACTIONS ROOT exp: {testHeader.TxRoot}, actual: {headBlock.Header.TxRoot}"); + } + + if (testHeader.ReceiptsRoot != headBlock.Header.ReceiptsRoot) + { + differences.Add($"RECEIPT ROOT exp: {testHeader.ReceiptsRoot}, actual: {headBlock.Header.ReceiptsRoot}"); + } } if (test.LastBlockHash != headBlock.Hash) diff --git a/src/Nethermind/Ethereum.Test.Base/BlockchainTestJson.cs b/src/Nethermind/Ethereum.Test.Base/BlockchainTestJson.cs index fdd03858fd8c..c344cd773da7 100644 --- a/src/Nethermind/Ethereum.Test.Base/BlockchainTestJson.cs +++ b/src/Nethermind/Ethereum.Test.Base/BlockchainTestJson.cs @@ -24,6 +24,7 @@ public class BlockchainTestJson public TestBlockJson[]? Blocks { get; set; } public TestBlockHeaderJson? GenesisBlockHeader { get; set; } + public TestEngineNewPayloadsJson[]? EngineNewPayloads { get; set; } public Dictionary? Pre { get; set; } public Dictionary? PostState { get; set; } diff --git a/src/Nethermind/Ethereum.Test.Base/FileTestsSource.cs b/src/Nethermind/Ethereum.Test.Base/FileTestsSource.cs index 3e85b70087f4..67b713e570ed 100644 --- a/src/Nethermind/Ethereum.Test.Base/FileTestsSource.cs +++ b/src/Nethermind/Ethereum.Test.Base/FileTestsSource.cs @@ -9,16 +9,10 @@ namespace Ethereum.Test.Base { - public class FileTestsSource + public class FileTestsSource(string fileName, string? wildcard = null) { - private readonly string _fileName; - private readonly string? _wildcard; - - public FileTestsSource(string fileName, string? wildcard = null) - { - _fileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); - _wildcard = wildcard; - } + private readonly string _fileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); + private readonly string? _wildcard = wildcard; public IEnumerable LoadTests(TestType testType) { diff --git a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs index 998319565324..39dbc1517905 100644 --- a/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/GeneralTestBase.cs @@ -1,12 +1,7 @@ // SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using System; -using System.Collections.Generic; -using System.Diagnostics; using Autofac; -using Nethermind.Api; -using NUnit.Framework; using Nethermind.Config; using Nethermind.Consensus.Processing; using Nethermind.Consensus.Validators; @@ -16,17 +11,20 @@ using Nethermind.Core.Specs; using Nethermind.Core.Test.Modules; using Nethermind.Crypto; -using Nethermind.Int256; using Nethermind.Evm; using Nethermind.Evm.EvmObjectFormat; -using Nethermind.Evm.Tracing; using Nethermind.Evm.State; +using Nethermind.Evm.Tracing; using Nethermind.Evm.TransactionProcessing; +using Nethermind.Int256; using Nethermind.Logging; using Nethermind.Specs; using Nethermind.Specs.Forks; using Nethermind.Specs.Test; -using Nethermind.State; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Diagnostics; namespace Ethereum.Test.Base { @@ -88,10 +86,10 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) IMainProcessingContext mainBlockProcessingContext = container.Resolve(); IWorldState stateProvider = mainBlockProcessingContext.WorldState; - using var _ = stateProvider.BeginScope(null); + using IDisposable _ = stateProvider.BeginScope(null); ITransactionProcessor transactionProcessor = mainBlockProcessingContext.TransactionProcessor; - InitializeTestState(test.Pre, stateProvider, specProvider); + InitializeTestState(test.Pre, test.CurrentCoinbase, stateProvider, specProvider); BlockHeader header = new( test.PreviousHash, @@ -101,17 +99,19 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) test.CurrentNumber, test.CurrentGasLimit, test.CurrentTimestamp, - []); - header.BaseFeePerGas = test.Fork.IsEip1559Enabled ? test.CurrentBaseFee ?? _defaultBaseFeeForStateTest : UInt256.Zero; - header.StateRoot = test.PostHash; + []) + { + BaseFeePerGas = test.Fork.IsEip1559Enabled ? test.CurrentBaseFee ?? _defaultBaseFeeForStateTest : UInt256.Zero, + StateRoot = test.PostHash, + IsPostMerge = test.CurrentRandom is not null, + MixHash = test.CurrentRandom, + WithdrawalsRoot = test.CurrentWithdrawalsRoot, + ParentBeaconBlockRoot = test.CurrentBeaconRoot, + ExcessBlobGas = test.CurrentExcessBlobGas ?? (test.Fork is Cancun ? 0ul : null), + BlobGasUsed = BlobGasCalculator.CalculateBlobGas(test.Transaction), + RequestsHash = test.RequestsHash + }; header.Hash = header.CalculateHash(); - header.IsPostMerge = test.CurrentRandom is not null; - header.MixHash = test.CurrentRandom; - header.WithdrawalsRoot = test.CurrentWithdrawalsRoot; - header.ParentBeaconBlockRoot = test.CurrentBeaconRoot; - header.ExcessBlobGas = test.CurrentExcessBlobGas ?? (test.Fork is Cancun ? 0ul : null); - header.BlobGasUsed = BlobGasCalculator.CalculateBlobGas(test.Transaction); - header.RequestsHash = test.RequestsHash; Stopwatch stopwatch = Stopwatch.StartNew(); IReleaseSpec? spec = specProvider.GetSpec((ForkActivation)test.CurrentNumber); @@ -149,19 +149,11 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) } stopwatch.Stop(); + if (txResult is not null && txResult.Value == TransactionResult.Ok) { stateProvider.Commit(specProvider.GetSpec((ForkActivation)1)); stateProvider.CommitTree(1); - - // '@winsvega added a 0-wei reward to the miner , so we had to add that into the state test execution phase. He needed it for retesteth.' - if (!stateProvider.AccountExists(test.CurrentCoinbase)) - { - stateProvider.CreateAccount(test.CurrentCoinbase, 0); - } - - stateProvider.Commit(specProvider.GetSpec((ForkActivation)1)); - stateProvider.RecalculateStateRoot(); } else @@ -170,20 +162,21 @@ protected EthereumTestResult RunTest(GeneralStateTest test, ITxTracer txTracer) } List differences = RunAssertions(test, stateProvider); - EthereumTestResult testResult = new(test.Name, test.ForkName, differences.Count == 0); - testResult.TimeInMs = stopwatch.Elapsed.TotalMilliseconds; - testResult.StateRoot = stateProvider.StateRoot; + EthereumTestResult testResult = new(test.Name, test.ForkName, differences.Count == 0) + { + TimeInMs = stopwatch.Elapsed.TotalMilliseconds, + StateRoot = stateProvider.StateRoot + }; if (differences.Count > 0) { _logger.Info($"\nDifferences from expected\n{string.Join("\n", differences)}"); } - // Assert.Zero(differences.Count, "differences"); return testResult; } - public static void InitializeTestState(Dictionary preState, IWorldState stateProvider, ISpecProvider specProvider) + public static void InitializeTestState(Dictionary preState, Address coinbase, IWorldState stateProvider, ISpecProvider specProvider) { foreach (KeyValuePair accountState in preState) { @@ -201,6 +194,13 @@ public static void InitializeTestState(Dictionary preStat stateProvider.Commit(specProvider.GenesisSpec); stateProvider.CommitTree(0); stateProvider.Reset(); + + if (!stateProvider.AccountExists(coinbase)) + { + stateProvider.CreateAccount(coinbase, 0); + stateProvider.Commit(specProvider.GetSpec((ForkActivation)1)); + stateProvider.RecalculateStateRoot(); + } } private List RunAssertions(GeneralStateTest test, IWorldState stateProvider) diff --git a/src/Nethermind/Ethereum.Test.Base/JsonToEthereumTest.cs b/src/Nethermind/Ethereum.Test.Base/JsonToEthereumTest.cs index 9a09b17017c1..36b05b9fb0ea 100644 --- a/src/Nethermind/Ethereum.Test.Base/JsonToEthereumTest.cs +++ b/src/Nethermind/Ethereum.Test.Base/JsonToEthereumTest.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Json; using Nethermind.Config; using Nethermind.Core; using Nethermind.Core.Crypto; @@ -14,6 +15,7 @@ using Nethermind.Crypto; using Nethermind.Evm.EvmObjectFormat; using Nethermind.Int256; +using Nethermind.Merge.Plugin.Data; using Nethermind.Serialization.Json; using Nethermind.Serialization.Rlp; using Nethermind.Specs; @@ -56,36 +58,89 @@ public static BlockHeader Convert(TestBlockHeaderJson? headerJson) (long)Bytes.FromHexString(headerJson.Number).ToUInt256(), (long)Bytes.FromHexString(headerJson.GasLimit).ToUnsignedBigInteger(), (ulong)Bytes.FromHexString(headerJson.Timestamp).ToUnsignedBigInteger(), - Bytes.FromHexString(headerJson.ExtraData) - ); - - header.Bloom = new Bloom(Bytes.FromHexString(headerJson.Bloom)); - header.GasUsed = (long)Bytes.FromHexString(headerJson.GasUsed).ToUnsignedBigInteger(); - header.Hash = new Hash256(headerJson.Hash); - header.MixHash = new Hash256(headerJson.MixHash); - header.Nonce = (ulong)Bytes.FromHexString(headerJson.Nonce).ToUnsignedBigInteger(); - header.ReceiptsRoot = new Hash256(headerJson.ReceiptTrie); - header.StateRoot = new Hash256(headerJson.StateRoot); - header.TxRoot = new Hash256(headerJson.TransactionsTrie); + Bytes.FromHexString(headerJson.ExtraData), + headerJson.BlobGasUsed is null ? null : (ulong)Bytes.FromHexString(headerJson.BlobGasUsed).ToUnsignedBigInteger(), + headerJson.ExcessBlobGas is null ? null : (ulong)Bytes.FromHexString(headerJson.ExcessBlobGas).ToUnsignedBigInteger(), + headerJson.ParentBeaconBlockRoot is null ? null : new Hash256(headerJson.ParentBeaconBlockRoot), + headerJson.RequestsHash is null ? null : new Hash256(headerJson.RequestsHash) + ) + { + Bloom = new Bloom(Bytes.FromHexString(headerJson.Bloom)), + GasUsed = (long)Bytes.FromHexString(headerJson.GasUsed).ToUnsignedBigInteger(), + Hash = new Hash256(headerJson.Hash), + MixHash = new Hash256(headerJson.MixHash), + Nonce = (ulong)Bytes.FromHexString(headerJson.Nonce).ToUnsignedBigInteger(), + ReceiptsRoot = new Hash256(headerJson.ReceiptTrie), + StateRoot = new Hash256(headerJson.StateRoot), + TxRoot = new Hash256(headerJson.TransactionsTrie), + WithdrawalsRoot = headerJson.WithdrawalsRoot is null ? null : new Hash256(headerJson.WithdrawalsRoot), + // BlockAccessListHash = headerJson.BlockAccessListHash is null ? null : new Hash256(headerJson.BlockAccessListHash), + }; + + if (headerJson.BaseFeePerGas is not null) + { + header.BaseFeePerGas = (ulong)Bytes.FromHexString(headerJson.BaseFeePerGas).ToUnsignedBigInteger(); + } + return header; } + public static IEnumerable<(ExecutionPayloadV3, string[]?, string[]?, int, int)> Convert(TestEngineNewPayloadsJson[]? executionPayloadsJson) + { + if (executionPayloadsJson is null) + { + throw new InvalidDataException("Execution payloads JSON was null when constructing test."); + } + + foreach (TestEngineNewPayloadsJson engineNewPayload in executionPayloadsJson) + { + TestEngineNewPayloadsJson.ParamsExecutionPayload executionPayload = engineNewPayload.Params[0].Deserialize(EthereumJsonSerializer.JsonOptions); + string[]? blobVersionedHashes = engineNewPayload.Params.Length > 1 ? engineNewPayload.Params[1].Deserialize(EthereumJsonSerializer.JsonOptions) : null; + string? parentBeaconBlockRoot = engineNewPayload.Params.Length > 2 ? engineNewPayload.Params[2].Deserialize(EthereumJsonSerializer.JsonOptions) : null; + string[]? validationError = engineNewPayload.Params.Length > 3 ? engineNewPayload.Params[3].Deserialize(EthereumJsonSerializer.JsonOptions) : null; + yield return (new ExecutionPayloadV3() + { + BaseFeePerGas = (ulong)Bytes.FromHexString(executionPayload.BaseFeePerGas).ToUnsignedBigInteger(), + BlockHash = new(executionPayload.BlockHash), + BlockNumber = (long)Bytes.FromHexString(executionPayload.BlockNumber).ToUnsignedBigInteger(), + ExtraData = Bytes.FromHexString(executionPayload.ExtraData), + FeeRecipient = new(executionPayload.FeeRecipient), + GasLimit = (long)Bytes.FromHexString(executionPayload.GasLimit).ToUnsignedBigInteger(), + GasUsed = (long)Bytes.FromHexString(executionPayload.GasUsed).ToUnsignedBigInteger(), + LogsBloom = new(Bytes.FromHexString(executionPayload.LogsBloom)), + ParentHash = new(executionPayload.ParentHash), + PrevRandao = new(executionPayload.PrevRandao), + ReceiptsRoot = new(executionPayload.ReceiptsRoot), + StateRoot = new(executionPayload.StateRoot), + Timestamp = (ulong)Bytes.FromHexString(executionPayload.Timestamp).ToUnsignedBigInteger(), + // BlockAccessList = executionPayload.BlockAccessList is null ? null : Bytes.FromHexString(executionPayload.BlockAccessList), + BlobGasUsed = executionPayload.BlobGasUsed is null ? null : (ulong)Bytes.FromHexString(executionPayload.BlobGasUsed).ToUnsignedBigInteger(), + ExcessBlobGas = executionPayload.ExcessBlobGas is null ? null : (ulong)Bytes.FromHexString(executionPayload.ExcessBlobGas).ToUnsignedBigInteger(), + ParentBeaconBlockRoot = parentBeaconBlockRoot is null ? null : new(parentBeaconBlockRoot), + Withdrawals = executionPayload.Withdrawals is null ? null : [.. executionPayload.Withdrawals.Select(x => Rlp.Decode(Bytes.FromHexString(x)))], + Transactions = [.. executionPayload.Transactions.Select(x => Bytes.FromHexString(x))], + ExecutionRequests = [] + }, blobVersionedHashes, validationError, int.Parse(engineNewPayload.NewPayloadVersion ?? "4"), int.Parse(engineNewPayload.ForkChoiceUpdatedVersion ?? "3")); + } + } + public static Transaction Convert(PostStateJson postStateJson, TransactionJson transactionJson) { - Transaction transaction = new(); - - transaction.Type = transactionJson.Type; - transaction.Value = transactionJson.Value[postStateJson.Indexes.Value]; - transaction.GasLimit = transactionJson.GasLimit[postStateJson.Indexes.Gas]; - transaction.GasPrice = transactionJson.GasPrice ?? transactionJson.MaxPriorityFeePerGas ?? 0; - transaction.DecodedMaxFeePerGas = transactionJson.MaxFeePerGas ?? 0; - transaction.Nonce = transactionJson.Nonce; - transaction.To = transactionJson.To; - transaction.Data = transactionJson.Data[postStateJson.Indexes.Data]; - transaction.SenderAddress = new PrivateKey(transactionJson.SecretKey).Address; - transaction.Signature = new Signature(1, 1, 27); - transaction.BlobVersionedHashes = transactionJson.BlobVersionedHashes; - transaction.MaxFeePerBlobGas = transactionJson.MaxFeePerBlobGas; + Transaction transaction = new() + { + Type = transactionJson.Type, + Value = transactionJson.Value[postStateJson.Indexes.Value], + GasLimit = transactionJson.GasLimit[postStateJson.Indexes.Gas], + GasPrice = transactionJson.GasPrice ?? transactionJson.MaxPriorityFeePerGas ?? 0, + DecodedMaxFeePerGas = transactionJson.MaxFeePerGas ?? 0, + Nonce = transactionJson.Nonce, + To = transactionJson.To, + Data = transactionJson.Data[postStateJson.Indexes.Data], + SenderAddress = new PrivateKey(transactionJson.SecretKey).Address, + Signature = new Signature(1, 1, 27), + BlobVersionedHashes = transactionJson.BlobVersionedHashes, + MaxFeePerBlobGas = transactionJson.MaxFeePerBlobGas + }; transaction.Hash = transaction.CalculateHash(); AccessList.Builder builder = new(); @@ -108,7 +163,7 @@ public static Transaction Convert(PostStateJson postStateJson, TransactionJson t if (transactionJson.AuthorizationList is not null) { transaction.AuthorizationList = - transactionJson.AuthorizationList + [.. transactionJson.AuthorizationList .Select(i => { if (i.Nonce > ulong.MaxValue) @@ -148,7 +203,7 @@ public static Transaction Convert(PostStateJson postStateJson, TransactionJson t (byte)i.V, r, s); - }).ToArray(); + })]; if (transaction.AuthorizationList.Any()) { transaction.Type = TxType.SetCode; @@ -172,14 +227,16 @@ public static void ProcessAccessList(AccessListItemJson[]? accessList, AccessLis public static Transaction Convert(LegacyTransactionJson transactionJson) { - Transaction transaction = new(); - transaction.Value = transactionJson.Value; - transaction.GasLimit = transactionJson.GasLimit; - transaction.GasPrice = transactionJson.GasPrice; - transaction.Nonce = transactionJson.Nonce; - transaction.To = transactionJson.To; - transaction.Data = transactionJson.Data; - transaction.Signature = new Signature(transactionJson.R, transactionJson.S, transactionJson.V); + Transaction transaction = new() + { + Value = transactionJson.Value, + GasLimit = transactionJson.GasLimit, + GasPrice = transactionJson.GasPrice, + Nonce = transactionJson.Nonce, + To = transactionJson.To, + Data = transactionJson.Data, + Signature = new Signature(transactionJson.R, transactionJson.S, transactionJson.V) + }; transaction.Hash = transaction.CalculateHash(); return transaction; } @@ -191,41 +248,42 @@ public static IEnumerable Convert(string name, string category return Enumerable.Repeat(new GeneralStateTest { Name = name, Category = category, LoadFailure = testJson.LoadFailure }, 1); } - List blockchainTests = new(); + List blockchainTests = []; foreach (KeyValuePair postStateBySpec in testJson.Post) { int iterationNumber = 0; foreach (PostStateJson stateJson in postStateBySpec.Value) { - GeneralStateTest test = new(); - test.Name = Path.GetFileName(name) + - $"_d{stateJson.Indexes.Data}g{stateJson.Indexes.Gas}v{stateJson.Indexes.Value}_"; + GeneralStateTest test = new() + { + Name = Path.GetFileName(name) + + $"_d{stateJson.Indexes.Data}g{stateJson.Indexes.Gas}v{stateJson.Indexes.Value}_", + Category = category, + ForkName = postStateBySpec.Key, + Fork = SpecNameParser.Parse(postStateBySpec.Key), + PreviousHash = testJson.Env.PreviousHash, + CurrentCoinbase = testJson.Env.CurrentCoinbase, + CurrentDifficulty = testJson.Env.CurrentDifficulty, + CurrentGasLimit = testJson.Env.CurrentGasLimit, + CurrentNumber = testJson.Env.CurrentNumber, + CurrentTimestamp = testJson.Env.CurrentTimestamp, + CurrentBaseFee = testJson.Env.CurrentBaseFee, + CurrentRandom = testJson.Env.CurrentRandom, + CurrentBeaconRoot = testJson.Env.CurrentBeaconRoot, + CurrentWithdrawalsRoot = testJson.Env.CurrentWithdrawalsRoot, + CurrentExcessBlobGas = testJson.Env.CurrentExcessBlobGas, + ParentBlobGasUsed = testJson.Env.ParentBlobGasUsed, + ParentExcessBlobGas = testJson.Env.ParentExcessBlobGas, + PostReceiptsRoot = stateJson.Logs, + PostHash = stateJson.Hash, + Pre = testJson.Pre.ToDictionary(p => p.Key, p => p.Value), + Transaction = Convert(stateJson, testJson.Transaction) + }; + if (testJson.Info?.Labels?.ContainsKey(iterationNumber.ToString()) ?? false) { test.Name += testJson.Info?.Labels?[iterationNumber.ToString()]?.Replace(":label ", string.Empty); } - test.Category = category; - - test.ForkName = postStateBySpec.Key; - test.Fork = SpecNameParser.Parse(postStateBySpec.Key); - test.PreviousHash = testJson.Env.PreviousHash; - test.CurrentCoinbase = testJson.Env.CurrentCoinbase; - test.CurrentDifficulty = testJson.Env.CurrentDifficulty; - test.CurrentGasLimit = testJson.Env.CurrentGasLimit; - test.CurrentNumber = testJson.Env.CurrentNumber; - test.CurrentTimestamp = testJson.Env.CurrentTimestamp; - test.CurrentBaseFee = testJson.Env.CurrentBaseFee; - test.CurrentRandom = testJson.Env.CurrentRandom; - test.CurrentBeaconRoot = testJson.Env.CurrentBeaconRoot; - test.CurrentWithdrawalsRoot = testJson.Env.CurrentWithdrawalsRoot; - test.CurrentExcessBlobGas = testJson.Env.CurrentExcessBlobGas; - test.ParentBlobGasUsed = testJson.Env.ParentBlobGasUsed; - test.ParentExcessBlobGas = testJson.Env.ParentExcessBlobGas; - test.PostReceiptsRoot = stateJson.Logs; - test.PostHash = stateJson.Hash; - test.Pre = testJson.Pre.ToDictionary(p => p.Key, p => p.Value); - test.Transaction = Convert(stateJson, testJson.Transaction); - blockchainTests.Add(test); ++iterationNumber; } @@ -241,17 +299,20 @@ public static BlockchainTest Convert(string name, string category, BlockchainTes return new BlockchainTest { Name = name, Category = category, LoadFailure = testJson.LoadFailure }; } - BlockchainTest test = new(); - test.Name = name; - test.Category = category; - test.Network = testJson.EthereumNetwork; - test.NetworkAfterTransition = testJson.EthereumNetworkAfterTransition; - test.TransitionForkActivation = testJson.TransitionForkActivation; - test.LastBlockHash = new Hash256(testJson.LastBlockHash); - test.GenesisRlp = testJson.GenesisRlp is null ? null : new Rlp(Bytes.FromHexString(testJson.GenesisRlp)); - test.GenesisBlockHeader = testJson.GenesisBlockHeader; - test.Blocks = testJson.Blocks; - test.Pre = testJson.Pre.ToDictionary(p => p.Key, p => p.Value); + BlockchainTest test = new() + { + Name = name, + Category = category, + Network = testJson.EthereumNetwork, + NetworkAfterTransition = testJson.EthereumNetworkAfterTransition, + TransitionForkActivation = testJson.TransitionForkActivation, + LastBlockHash = new Hash256(testJson.LastBlockHash), + GenesisRlp = testJson.GenesisRlp is null ? null : new Rlp(Bytes.FromHexString(testJson.GenesisRlp)), + GenesisBlockHeader = testJson.GenesisBlockHeader, + Blocks = testJson.Blocks, + EngineNewPayloads = testJson.EngineNewPayloads, + Pre = testJson.Pre.ToDictionary(p => p.Key, p => p.Value) + }; HalfBlockchainTestJson half = testJson as HalfBlockchainTestJson; if (half is not null) @@ -272,7 +333,7 @@ public static BlockchainTest Convert(string name, string category, BlockchainTes public static IEnumerable ConvertToEofTests(string json) { Dictionary testsInFile = _serializer.Deserialize>(json); - List tests = new(); + List tests = []; foreach (KeyValuePair namedTest in testsInFile) { (string name, string category) = GetNameAndCategory(namedTest.Key); @@ -281,11 +342,13 @@ public static IEnumerable ConvertToEofTests(string json) foreach (KeyValuePair pair in namedTest.Value.Vectors) { VectorTestJson vectorJson = pair.Value; - VectorTest vector = new(); - vector.Code = Bytes.FromHexString(vectorJson.Code); - vector.ContainerKind = ParseContainerKind(vectorJson.ContainerKind); + VectorTest vector = new() + { + Code = Bytes.FromHexString(vectorJson.Code), + ContainerKind = ParseContainerKind(vectorJson.ContainerKind) + }; - foreach (var result in vectorJson.Results) + foreach (KeyValuePair result in vectorJson.Results) { EofTest test = new() { @@ -293,10 +356,10 @@ public static IEnumerable ConvertToEofTests(string json) Category = $"{category} [{result.Key}]", Url = url, Description = description, - Spec = spec + Spec = spec, + Vector = vector, + Result = result.ToTestResult() }; - test.Vector = vector; - test.Result = result.ToTestResult(); tests.Add(test); } } @@ -305,7 +368,7 @@ public static IEnumerable ConvertToEofTests(string json) return tests; static ValidationStrategy ParseContainerKind(string containerKind) - => ("INITCODE".Equals(containerKind) ? ValidationStrategy.ValidateInitCodeMode : ValidationStrategy.ValidateRuntimeMode); + => "INITCODE".Equals(containerKind) ? ValidationStrategy.ValidateInitCodeMode : ValidationStrategy.ValidateRuntimeMode; static void GetTestMetaData(KeyValuePair namedTest, out string? description, out string? url, out string? spec) { @@ -332,7 +395,7 @@ public static IEnumerable ConvertStateTest(string json) Dictionary testsInFile = _serializer.Deserialize>(json); - List tests = new(); + List tests = []; foreach (KeyValuePair namedTest in testsInFile) { (string name, string category) = GetNameAndCategory(namedTest.Key); @@ -351,15 +414,16 @@ public static IEnumerable ConvertToBlockchainTests(string json) } catch (Exception) { - var half = _serializer.Deserialize>(json); - testsInFile = new Dictionary(); + Dictionary half = + _serializer.Deserialize>(json); + testsInFile = []; foreach (KeyValuePair pair in half) { testsInFile[pair.Key] = pair.Value; } } - List testsByName = new(); + List testsByName = []; foreach ((string testName, BlockchainTestJson testSpec) in testsInFile) { string[] transitionInfo = testSpec.Network.Split("At"); diff --git a/src/Nethermind/Ethereum.Test.Base/LoadBlockchainTestFileStrategy.cs b/src/Nethermind/Ethereum.Test.Base/LoadBlockchainTestFileStrategy.cs index 6f7aad55a2c3..71c23519184d 100644 --- a/src/Nethermind/Ethereum.Test.Base/LoadBlockchainTestFileStrategy.cs +++ b/src/Nethermind/Ethereum.Test.Base/LoadBlockchainTestFileStrategy.cs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using System; using System.Collections.Generic; using Ethereum.Test.Base.Interfaces; diff --git a/src/Nethermind/Ethereum.Test.Base/LoadEipTestsStrategy.cs b/src/Nethermind/Ethereum.Test.Base/LoadEipTestsStrategy.cs index 1a8e108ded58..9cd12eed7406 100644 --- a/src/Nethermind/Ethereum.Test.Base/LoadEipTestsStrategy.cs +++ b/src/Nethermind/Ethereum.Test.Base/LoadEipTestsStrategy.cs @@ -16,8 +16,6 @@ public IEnumerable Load(string testsDirectoryName, string wildcard if (!Path.IsPathRooted(testsDirectoryName)) { string testsDirectory = GetGeneralStateTestsDirectory(); - - testDirs = Directory.EnumerateDirectories(testsDirectory, testsDirectoryName, new EnumerationOptions { RecurseSubdirectories = true }); } else diff --git a/src/Nethermind/Ethereum.Test.Base/LoadEofTestsStrategy.cs b/src/Nethermind/Ethereum.Test.Base/LoadEofTestsStrategy.cs index 7344f0b354f3..a26ebf22a005 100644 --- a/src/Nethermind/Ethereum.Test.Base/LoadEofTestsStrategy.cs +++ b/src/Nethermind/Ethereum.Test.Base/LoadEofTestsStrategy.cs @@ -16,8 +16,6 @@ public IEnumerable Load(string testsDirectoryName, string wildcard if (!Path.IsPathRooted(testsDirectoryName)) { string testsDirectory = GetGeneralStateTestsDirectory(); - - testDirs = Directory.EnumerateDirectories(testsDirectory, testsDirectoryName, new EnumerationOptions { RecurseSubdirectories = true }); } else diff --git a/src/Nethermind/Ethereum.Test.Base/LoadGeneralStateTestsStrategy.cs b/src/Nethermind/Ethereum.Test.Base/LoadGeneralStateTestsStrategy.cs index b77bea91383c..19334b8606f0 100644 --- a/src/Nethermind/Ethereum.Test.Base/LoadGeneralStateTestsStrategy.cs +++ b/src/Nethermind/Ethereum.Test.Base/LoadGeneralStateTestsStrategy.cs @@ -16,8 +16,6 @@ public IEnumerable Load(string testsDirectoryName, string wildcard if (!Path.IsPathRooted(testsDirectoryName)) { string testsDirectory = GetGeneralStateTestsDirectory(); - - testDirs = Directory.EnumerateDirectories(testsDirectory, testsDirectoryName, new EnumerationOptions { RecurseSubdirectories = true }); } else diff --git a/src/Nethermind/Ethereum.Test.Base/LoadLegacyBlockchainTestsStrategy.cs b/src/Nethermind/Ethereum.Test.Base/LoadLegacyBlockchainTestsStrategy.cs index 537dd221457c..63dd6d9ca0f0 100644 --- a/src/Nethermind/Ethereum.Test.Base/LoadLegacyBlockchainTestsStrategy.cs +++ b/src/Nethermind/Ethereum.Test.Base/LoadLegacyBlockchainTestsStrategy.cs @@ -33,15 +33,15 @@ public IEnumerable Load(string testsDirectoryName, string wildcard return testJsons; } - private string GetLegacyBlockchainTestsDirectory() + private static string GetLegacyBlockchainTestsDirectory() { - char pathSeparator = Path.AltDirectorySeparatorChar; string currentDirectory = AppDomain.CurrentDomain.BaseDirectory; + string rootDirectory = currentDirectory.Remove(currentDirectory.LastIndexOf("src")); - return Path.Combine(currentDirectory.Remove(currentDirectory.LastIndexOf("src")), "src", "tests", "LegacyTests", "Constantinople", "BlockchainTests"); + return Path.Combine(rootDirectory, "src", "tests", "LegacyTests", "Cancun", "BlockchainTests"); } - private IEnumerable LoadTestsFromDirectory(string testDir, string wildcard) + private static IEnumerable LoadTestsFromDirectory(string testDir, string wildcard) { List testsByName = new(); IEnumerable testFiles = Directory.EnumerateFiles(testDir); diff --git a/src/Nethermind/Ethereum.Test.Base/LoadLegacyGeneralStateTestsStrategy.cs b/src/Nethermind/Ethereum.Test.Base/LoadLegacyGeneralStateTestsStrategy.cs index 99a07a29ac66..60f964c0d9be 100644 --- a/src/Nethermind/Ethereum.Test.Base/LoadLegacyGeneralStateTestsStrategy.cs +++ b/src/Nethermind/Ethereum.Test.Base/LoadLegacyGeneralStateTestsStrategy.cs @@ -33,11 +33,12 @@ public IEnumerable Load(string testsDirectoryName, string wildcard return testJsons; } - private string GetLegacyGeneralStateTestsDirectory() + private static string GetLegacyGeneralStateTestsDirectory() { string currentDirectory = AppDomain.CurrentDomain.BaseDirectory; + string rootDirectory = currentDirectory.Remove(currentDirectory.LastIndexOf("src")); - return Path.Combine(currentDirectory.Remove(currentDirectory.LastIndexOf("src")), "src", "tests", "LegacyTests", "Constantinople", "GeneralStateTests"); + return Path.Combine(rootDirectory, "src", "tests", "LegacyTests", "Cancun", "GeneralStateTests"); } private IEnumerable LoadTestsFromDirectory(string testDir, string wildcard) diff --git a/src/Nethermind/Ethereum.Test.Base/TestBlockHeaderJson.cs b/src/Nethermind/Ethereum.Test.Base/TestBlockHeaderJson.cs index 3508dba38c66..c154f53e5743 100644 --- a/src/Nethermind/Ethereum.Test.Base/TestBlockHeaderJson.cs +++ b/src/Nethermind/Ethereum.Test.Base/TestBlockHeaderJson.cs @@ -21,5 +21,12 @@ public class TestBlockHeaderJson public string Timestamp { get; set; } public string TransactionsTrie { get; set; } public string UncleHash { get; set; } + public string? BaseFeePerGas { get; set; } + public string? WithdrawalsRoot { get; set; } + public string? ParentBeaconBlockRoot { get; set; } + public string? RequestsHash { get; set; } + public string? BlockAccessListHash { get; set; } + public string? BlobGasUsed { get; set; } + public string? ExcessBlobGas { get; set; } } } diff --git a/src/Nethermind/Ethereum.Test.Base/TestEngineNewPayloadsJson.cs b/src/Nethermind/Ethereum.Test.Base/TestEngineNewPayloadsJson.cs new file mode 100644 index 000000000000..b89dcd2869b2 --- /dev/null +++ b/src/Nethermind/Ethereum.Test.Base/TestEngineNewPayloadsJson.cs @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Text.Json; + +namespace Ethereum.Test.Base +{ + public class TestEngineNewPayloadsJson + { + public JsonElement[] Params { get; set; } + public string? NewPayloadVersion { get; set; } + public string? ForkChoiceUpdatedVersion { get; set; } + + public class ParamsExecutionPayload + { + public string ParentHash { get; set; } + public string FeeRecipient { get; set; } + public string StateRoot { get; set; } + public string ReceiptsRoot { get; set; } + public string LogsBloom { get; set; } + public string BlockNumber { get; set; } + public string GasLimit { get; set; } + public string GasUsed { get; set; } + public string Timestamp { get; set; } + public string ExtraData { get; set; } + public string PrevRandao { get; set; } + public string BaseFeePerGas { get; set; } + public string BlobGasUsed { get; set; } + public string ExcessBlobGas { get; set; } + public string BlockHash { get; set; } + public string[] Transactions { get; set; } + public string[]? Withdrawals { get; set; } + public string? BlockAccessList { get; set; } + } + } +} diff --git a/src/Nethermind/Ethereum.Transaction.Test/Ethereum.Transaction.Test.csproj b/src/Nethermind/Ethereum.Transaction.Test/Ethereum.Transaction.Test.csproj index 19f745904c0d..8c4d72e50f8f 100644 --- a/src/Nethermind/Ethereum.Transaction.Test/Ethereum.Transaction.Test.csproj +++ b/src/Nethermind/Ethereum.Transaction.Test/Ethereum.Transaction.Test.csproj @@ -1,14 +1,19 @@ - + + - + + + + %(RecursiveDir)%(FileName)%(Extension) PreserveNewest + diff --git a/src/Nethermind/Ethereum.Transaction.Test/TransactionJsonTest.cs b/src/Nethermind/Ethereum.Transaction.Test/TransactionJsonTest.cs new file mode 100644 index 000000000000..7e79ef7c51d1 --- /dev/null +++ b/src/Nethermind/Ethereum.Transaction.Test/TransactionJsonTest.cs @@ -0,0 +1,38 @@ +// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using Ethereum.Test.Base; +using FluentAssertions; +using Nethermind.Core; +using Nethermind.Core.Test.Builders; +using Nethermind.Int256; +using Nethermind.Serialization.Json; +using NUnit.Framework; + +namespace Ethereum.Blockchain.Test; + +[TestFixture] +[Parallelizable(ParallelScope.All)] +public class TransactionJsonTest : GeneralStateTestBase +{ + [Test] + public void Can_load_access_lists() + { + const string lists = + "{\"accessLists\": [[{\"address\": \"0x0001020304050607080900010203040506070809\", \"storageKeys\": [\"0x00\", \"0x01\"]}]]}"; + + EthereumJsonSerializer serializer = new EthereumJsonSerializer(); + TransactionJson txJson = serializer.Deserialize(lists); + txJson.SecretKey = TestItem.PrivateKeyA.KeyBytes; + txJson.Value = new UInt256[1]; + txJson.GasLimit = new long[1]; + txJson.Data = new byte[1][]; + txJson.AccessLists.Should().NotBeNull(); + txJson.AccessLists[0][0].Address.Should() + .BeEquivalentTo(new Address("0x0001020304050607080900010203040506070809")); + txJson.AccessLists[0][0].StorageKeys[1][0].Should().Be((byte)1); + + Nethermind.Core.Transaction tx = JsonToEthereumTest.Convert(new PostStateJson { Indexes = new IndexesJson() }, txJson); + tx.AccessList.Should().NotBeNull(); + } +} diff --git a/src/Nethermind/Ethereum.Transition.Test/BerlinToLondonTests.cs b/src/Nethermind/Ethereum.Transition.Test/BerlinToLondonTests.cs deleted file mode 100644 index 6bdc4a8dce38..000000000000 --- a/src/Nethermind/Ethereum.Transition.Test/BerlinToLondonTests.cs +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using System.Threading.Tasks; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.Transition.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.None)] - public class BerlinToLondonTests : BlockchainTestBase - { - [TestCaseSource(nameof(LoadTests))] - public async Task Test(BlockchainTest test) - { - await RunTest(test); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadBlockchainTestsStrategy(), "bcBerlinToLondon"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/Ethereum.VM.Test/LogTests.cs b/src/Nethermind/Ethereum.VM.Test/LogTests.cs deleted file mode 100644 index 2273f4a7c598..000000000000 --- a/src/Nethermind/Ethereum.VM.Test/LogTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.Collections.Generic; -using Ethereum.Test.Base; -using NUnit.Framework; - -namespace Ethereum.VM.Test -{ - [TestFixture] - [Parallelizable(ParallelScope.All)] - public class LogTests : GeneralStateTestBase - { - [TestCaseSource(nameof(LoadTests))] - public void Test(GeneralStateTest test) - { - Assert.That(RunTest(test).Pass, Is.True); - } - - public static IEnumerable LoadTests() - { - var loader = new TestsSourceLoader(new LoadGeneralStateTestsStrategy(), "vmLogTest"); - return loader.LoadTests(); - } - } -} diff --git a/src/Nethermind/EthereumTests.slnx b/src/Nethermind/EthereumTests.slnx index 3f484f1caf62..b5e21d12b74a 100644 --- a/src/Nethermind/EthereumTests.slnx +++ b/src/Nethermind/EthereumTests.slnx @@ -19,6 +19,7 @@ + @@ -47,22 +48,21 @@ - - - + + + + - - diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs index a82668f7d741..7288c0d85ac1 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs @@ -5,10 +5,8 @@ using Nethermind.Core; using Nethermind.Core.Crypto; using Nethermind.Core.Eip2930; -using Nethermind.Core.Specs; using Nethermind.Core.Test.Builders; using Nethermind.Crypto; -using Nethermind.Evm; using Nethermind.Evm.Tracing; using Nethermind.Evm.TransactionProcessing; using Nethermind.Int256; diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BlockhashProviderTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BlockhashProviderTests.cs index 5020c48f7ef4..bbf93f80b7c8 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/BlockhashProviderTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/BlockhashProviderTests.cs @@ -352,4 +352,71 @@ public void Eip2935_poc_trimmed_hashes() var result = store.GetBlockHashFromState(current.Header, current.Header.Number - 1); Assert.That(result, Is.EqualTo(current.Header.ParentHash)); } + + [Test, MaxTime(Timeout.MaxTestTime)] + public void BlockhashStore_uses_custom_ring_buffer_size() + { + const int customRingBufferSize = 100; + const int chainLength = 150; + + Block genesis = Build.A.Block.Genesis.TestObject; + BlockTree tree = Build.A.BlockTree(genesis).OfHeadersOnly.OfChainLength(chainLength).TestObject; + BlockHeader? head = tree.FindHeader(chainLength - 1, BlockTreeLookupOptions.None); + + (IWorldState worldState, Hash256 stateRoot) = CreateWorldState(); + Block current = Build.A.Block.WithParent(head!).WithStateRoot(stateRoot).TestObject; + tree.SuggestHeader(current.Header); + + // Custom spec with non-standard ring buffer size + ReleaseSpec customSpec = new() + { + IsEip2935Enabled = true, + IsEip7709Enabled = true, + Eip2935RingBufferSize = customRingBufferSize + }; + + var specProvider = new CustomSpecProvider( + (new ForkActivation(0, genesis.Timestamp), customSpec)); + BlockhashStore store = new(specProvider, worldState); + + using IDisposable _ = worldState.BeginScope(current.Header); + + // Insert code (account already created by CreateWorldState) + byte[] code = [1, 2, 3]; + worldState.InsertCode(Eip2935Constants.BlockHashHistoryAddress, ValueKeccak.Compute(code), code, customSpec); + + // Process current block (150) - stores block 149's hash + store.ApplyBlockhashStateChanges(current.Header); + + // Simulate processing blocks 51-149 to fill the ring buffer + // At block 150 with buffer size 100, we need hashes for blocks 50-149 + // Block 150 stores block 149's hash (already done above) + // Now process blocks 51-149 from the tree to store blocks 50-148 + for (long blockNum = chainLength - customRingBufferSize + 1; blockNum < chainLength; blockNum++) + { + BlockHeader? header = tree.FindHeader(blockNum, BlockTreeLookupOptions.None); + Assert.That(header, Is.Not.Null, $"Block {blockNum} should exist in tree"); + + store.ApplyBlockhashStateChanges(header!); + } + + // Now verify all blocks behave correctly with custom ring buffer size + // At block 150 with buffer size 100, only blocks [50, 149] should be retrievable + for (long blockNum = 1; blockNum < chainLength - customRingBufferSize; blockNum++) + { + Hash256? result = store.GetBlockHashFromState(current.Header, blockNum, customSpec); + + Assert.That(result, Is.Null, + $"Block {blockNum} should be outside custom ring buffer of size {customRingBufferSize} (proves custom size is used, not default 8191)"); + } + + for (long blockNum = chainLength - customRingBufferSize; blockNum < chainLength; blockNum++) + { + BlockHeader? expectedHeader = tree.FindHeader(blockNum, BlockTreeLookupOptions.None); + Hash256? result = store.GetBlockHashFromState(current.Header, blockNum, customSpec); + + Assert.That(result, Is.EqualTo(expectedHeader!.Hash), + $"Block {blockNum} should be retrievable within custom ring buffer of size {customRingBufferSize}"); + } + } } diff --git a/src/Nethermind/Nethermind.Blockchain.Test/Filters/FilterStoreTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/Filters/FilterStoreTests.cs index a1e60a9ea8ff..ac95839f0e66 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/Filters/FilterStoreTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/Filters/FilterStoreTests.cs @@ -162,11 +162,10 @@ public async Task CleanUps_filters() store.RefreshFilter(0); await Task.Delay(30); store.RefreshFilter(0); - await Task.Delay(30); - Assert.That(store.FilterExists(0), Is.True, "filter 0 exists"); - Assert.That(store.FilterExists(1), Is.False, "filter 1 doesn't exist"); - Assert.That(store.FilterExists(2), Is.False, "filter 2 doesn't exist"); - Assert.That(store.FilterExists(3), Is.False, "filter 3 doesn't exist"); - Assert.That(removedFilterIds, Is.EquivalentTo([1, 2, 3])); + Assert.That(() => store.FilterExists(0), Is.True.After(30, 5), "filter 0 exists"); + Assert.That(() => store.FilterExists(1), Is.False.After(30, 5), "filter 1 doesn't exist"); + Assert.That(() => store.FilterExists(2), Is.False.After(30, 5), "filter 2 doesn't exist"); + Assert.That(() => store.FilterExists(3), Is.False.After(30, 5), "filter 3 doesn't exist"); + Assert.That(() => removedFilterIds, Is.EquivalentTo([1, 2, 3]).After(30, 5)); } } diff --git a/src/Nethermind/Nethermind.Blockchain.Test/Producers/BuildBlocksOnlyWhenNotProcessingTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/Producers/BuildBlocksOnlyWhenNotProcessingTests.cs index fda6ddbe27a0..0199896bcebb 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/Producers/BuildBlocksOnlyWhenNotProcessingTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/Producers/BuildBlocksOnlyWhenNotProcessingTests.cs @@ -35,8 +35,7 @@ public async Task should_trigger_block_production_when_queue_empties() context.BlockProcessingQueue.IsEmpty.Returns(false); Task buildTask = context.MainBlockProductionTrigger.BuildBlock(); - await Task.Delay(BuildBlocksOnlyWhenNotProcessing.ChainNotYetProcessedMillisecondsDelay * 2); - buildTask.IsCanceled.Should().BeFalse(); + Assert.That(() => buildTask.IsCanceled, Is.False.After(BuildBlocksOnlyWhenNotProcessing.ChainNotYetProcessedMillisecondsDelay * 2, 10)); context.BlockProcessingQueue.IsEmpty.Returns(true); Block? block = await buildTask; @@ -52,8 +51,7 @@ public async Task should_cancel_triggering_block_production() using CancellationTokenSource cancellationTokenSource = new(); Task buildTask = context.MainBlockProductionTrigger.BuildBlock(cancellationToken: cancellationTokenSource.Token); - await Task.Delay(BuildBlocksOnlyWhenNotProcessing.ChainNotYetProcessedMillisecondsDelay * 2); - buildTask.IsCanceled.Should().BeFalse(); + Assert.That(() => buildTask.IsCanceled, Is.False.After(BuildBlocksOnlyWhenNotProcessing.ChainNotYetProcessedMillisecondsDelay * 2, 10)); cancellationTokenSource.Cancel(); diff --git a/src/Nethermind/Nethermind.Blockchain.Test/Receipts/PersistentReceiptStorageTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/Receipts/PersistentReceiptStorageTests.cs index 6f8d35d04b17..fcf32a5ad080 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/Receipts/PersistentReceiptStorageTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/Receipts/PersistentReceiptStorageTests.cs @@ -326,8 +326,7 @@ public void When_TxLookupLimitIs_NegativeOne_DoNotIndexTxHash() CreateStorage(); (Block block, TxReceipt[] receipts) = InsertBlock(isFinalized: true); _blockTree.BlockAddedToMain += Raise.EventWith(new BlockReplacementEventArgs(block)); - Thread.Sleep(100); - _receiptsDb.GetColumnDb(ReceiptsColumns.Transactions)[receipts[0].TxHash!.Bytes].Should().BeNull(); + Assert.That(() => _receiptsDb.GetColumnDb(ReceiptsColumns.Transactions)[receipts[0].TxHash!.Bytes], Is.Null.After(100, 10)); } [TestCase(1L, false)] @@ -339,13 +338,9 @@ public void Should_only_prune_index_tx_hashes_if_blockNumber_is_bigger_than_look CreateStorage(); _blockTree.BlockAddedToMain += Raise.EventWith(new BlockReplacementEventArgs(Build.A.Block.WithNumber(blockNumber).TestObject)); - Thread.Sleep(100); - IEnumerable calls = _blockTree.ReceivedCalls() - .Where(static call => call.GetMethodInfo().Name.EndsWith(nameof(_blockTree.FindBlock))); - if (WillPruneOldIndicies) - calls.Should().NotBeEmpty(); - else - calls.Should().BeEmpty(); + Assert.That(() => _blockTree.ReceivedCalls() + .Where(static call => call.GetMethodInfo().Name.EndsWith(nameof(_blockTree.FindBlock))), + WillPruneOldIndicies ? Is.Not.Empty.After(100, 10) : Is.Empty.After(100, 10)); } [Test] @@ -355,8 +350,7 @@ public void When_HeadBlockIsFarAhead_DoNotIndexTxHash() CreateStorage(); (Block block, TxReceipt[] receipts) = InsertBlock(isFinalized: true, headNumber: 1001); _blockTree.BlockAddedToMain += Raise.EventWith(new BlockReplacementEventArgs(block)); - Thread.Sleep(100); - _receiptsDb.GetColumnDb(ReceiptsColumns.Transactions)[receipts[0].TxHash!.Bytes].Should().BeNull(); + Assert.That(() => _receiptsDb.GetColumnDb(ReceiptsColumns.Transactions)[receipts[0].TxHash!.Bytes], Is.Null.After(100, 10)); } [Test] diff --git a/src/Nethermind/Nethermind.Blockchain.Test/Utils/LastNStateRootTrackerTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/Utils/LastNStateRootTrackerTests.cs index 1af52fc05346..699ef5593bfa 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/Utils/LastNStateRootTrackerTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/Utils/LastNStateRootTrackerTests.cs @@ -106,4 +106,31 @@ public void Test_OnReorg_RebuildSet() tracker.HasStateRoot(Keccak.Compute(100.ToBigEndianByteArray())).Should().BeTrue(); } + + [Test] + public void Test_TrackLastN_WithCustomDepth() + { + System.Collections.Generic.List blocks = new(); + Block currentBlock = Build.A.Block.Genesis.TestObject; + blocks.Add(currentBlock); + for (int i = 0; i < 300; i++) + { + currentBlock = Build.A.Block + .WithParent(currentBlock) + .WithStateRoot(Keccak.Compute(i.ToBigEndianByteArray())) + .TestObject; + blocks.Add(currentBlock); + } + + BlockTree tree = Build.A.BlockTree().WithBlocks(blocks.ToArray()).TestObject; + + // Test with a custom depth of 256 blocks (useful for networks with fast block times like Arbitrum) + LastNStateRootTracker tracker = new LastNStateRootTracker(tree, 256); + + for (int i = 0; i < 320; i++) + { + tracker.HasStateRoot(Keccak.Compute(i.ToBigEndianByteArray())) + .Should().Be(i is >= 44 and < 300); + } + } } diff --git a/src/Nethermind/Nethermind.Blockchain/Blocks/BlockhashStore.cs b/src/Nethermind/Nethermind.Blockchain/Blocks/BlockhashStore.cs index 00d7a44cda82..68c338bda3ce 100644 --- a/src/Nethermind/Nethermind.Blockchain/Blocks/BlockhashStore.cs +++ b/src/Nethermind/Nethermind.Blockchain/Blocks/BlockhashStore.cs @@ -30,7 +30,7 @@ public void ApplyBlockhashStateChanges(BlockHeader blockHeader, IReleaseSpec spe if (!worldState.IsContract(eip2935Account)) return; Hash256 parentBlockHash = blockHeader.ParentHash; - var parentBlockIndex = new UInt256((ulong)((blockHeader.Number - 1) % Eip2935Constants.RingBufferSize)); + UInt256 parentBlockIndex = new UInt256((ulong)((blockHeader.Number - 1) % spec.Eip2935RingBufferSize)); StorageCell blockHashStoreCell = new(eip2935Account, parentBlockIndex); worldState.Set(blockHashStoreCell, parentBlockHash!.Bytes.WithoutLeadingZeros().ToArray()); } @@ -38,14 +38,14 @@ public void ApplyBlockhashStateChanges(BlockHeader blockHeader, IReleaseSpec spe public Hash256? GetBlockHashFromState(BlockHeader currentHeader, long requiredBlockNumber) => GetBlockHashFromState(currentHeader, requiredBlockNumber, specProvider.GetSpec(currentHeader)); - public Hash256? GetBlockHashFromState(BlockHeader currentHeader, long requiredBlockNumber, IReleaseSpec? spec) + public Hash256? GetBlockHashFromState(BlockHeader currentHeader, long requiredBlockNumber, IReleaseSpec spec) { if (requiredBlockNumber >= currentHeader.Number || - requiredBlockNumber + Eip2935Constants.RingBufferSize < currentHeader.Number) + requiredBlockNumber + spec.Eip2935RingBufferSize < currentHeader.Number) { return null; } - var blockIndex = new UInt256((ulong)(requiredBlockNumber % Eip2935Constants.RingBufferSize)); + UInt256 blockIndex = new UInt256((ulong)(requiredBlockNumber % spec.Eip2935RingBufferSize)); Address? eip2935Account = spec.Eip2935ContractAddress ?? Eip2935Constants.BlockHashHistoryAddress; StorageCell blockHashStoreCell = new(eip2935Account, blockIndex); ReadOnlySpan data = worldState.Get(blockHashStoreCell); diff --git a/src/Nethermind/Nethermind.Blockchain/Blocks/IBlockhashStore.cs b/src/Nethermind/Nethermind.Blockchain/Blocks/IBlockhashStore.cs index 77cc6b214f5a..0c19c64986d0 100644 --- a/src/Nethermind/Nethermind.Blockchain/Blocks/IBlockhashStore.cs +++ b/src/Nethermind/Nethermind.Blockchain/Blocks/IBlockhashStore.cs @@ -12,5 +12,5 @@ public interface IBlockhashStore public void ApplyBlockhashStateChanges(BlockHeader blockHeader); public void ApplyBlockhashStateChanges(BlockHeader blockHeader, IReleaseSpec spec); public Hash256? GetBlockHashFromState(BlockHeader currentBlockHeader, long requiredBlockNumber); - public Hash256? GetBlockHashFromState(BlockHeader currentBlockHeader, long requiredBlockNumber, IReleaseSpec? spec); + public Hash256? GetBlockHashFromState(BlockHeader currentBlockHeader, long requiredBlockNumber, IReleaseSpec spec); } diff --git a/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs b/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs index dca9b5979433..45871f73fa1d 100644 --- a/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs +++ b/src/Nethermind/Nethermind.Blockchain/Synchronization/ISyncConfig.cs @@ -138,6 +138,9 @@ public interface ISyncConfig : IConfig [ConfigItem(Description = "_Technical._ Whether to enable snap serving. WARNING: Very slow on hash db layout. Default is to enable on halfpath layout.", DefaultValue = "null", HiddenFromDocs = true)] bool? SnapServingEnabled { get; set; } + [ConfigItem(Description = "The maximum depth (in blocks) for serving snap sync requests. Higher values allow serving requests for older blocks, useful for networks with fast block times like Arbitrum.", DefaultValue = "128")] + int SnapServingMaxDepth { get; set; } + [ConfigItem(Description = "_Technical._ MultiSyncModeSelector sync mode timer loop interval. Used for testing.", DefaultValue = "1000", HiddenFromDocs = true)] int MultiSyncModeSelectorLoopTimerMs { get; set; } diff --git a/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs b/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs index 096d8f57444c..22c592973191 100644 --- a/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs +++ b/src/Nethermind/Nethermind.Blockchain/Synchronization/SyncConfig.cs @@ -65,6 +65,7 @@ public string? PivotHash public int ExitOnSyncedWaitTimeSec { get; set; } = 60; public int MallocTrimIntervalSec { get; set; } = 300; public bool? SnapServingEnabled { get; set; } = null; + public int SnapServingMaxDepth { get; set; } = 128; public int MultiSyncModeSelectorLoopTimerMs { get; set; } = 1000; public int SyncDispatcherEmptyRequestDelayMs { get; set; } = 10; public int SyncDispatcherAllocateTimeoutMs { get; set; } = 1000; diff --git a/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofBlockTracer.cs b/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofBlockTracer.cs index c01b2cf454ad..ab8a6a5a11cb 100644 --- a/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofBlockTracer.cs +++ b/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofBlockTracer.cs @@ -6,16 +6,10 @@ namespace Nethermind.Blockchain.Tracing.Proofs; -public class ProofBlockTracer : BlockTracerBase +public class ProofBlockTracer(Hash256? txHash, bool treatZeroAccountDifferently) + : BlockTracerBase(txHash) { - private readonly bool _treatSystemAccountDifferently; - - public ProofBlockTracer(Hash256? txHash, bool treatSystemAccountDifferently) : base(txHash) - { - _treatSystemAccountDifferently = treatSystemAccountDifferently; - } - - protected override ProofTxTracer OnStart(Transaction? tx) => new(_treatSystemAccountDifferently); + protected override ProofTxTracer OnStart(Transaction? tx) => new(treatZeroAccountDifferently); /// /// Here I decided to return tracer after experimenting with ProofTxTrace class. It encapsulates less but avoid additional type introduction which does not bring much value. diff --git a/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofTxTracer.cs b/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofTxTracer.cs index 1c30f8e6a527..90c79d71e357 100644 --- a/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofTxTracer.cs +++ b/src/Nethermind/Nethermind.Blockchain/Tracing/Proofs/ProofTxTracer.cs @@ -11,7 +11,7 @@ namespace Nethermind.Blockchain.Tracing.Proofs; -public class ProofTxTracer(bool treatSystemAccountDifferently) : TxTracer +public class ProofTxTracer(bool treatZeroAccountDifferently) : TxTracer { public HashSet
Accounts { get; } = new(); @@ -33,7 +33,7 @@ public override void ReportBlockHash(Hash256 blockHash) public override void ReportBalanceChange(Address address, UInt256? before, UInt256? after) { - if (treatSystemAccountDifferently && Address.SystemUser == address && before is null && after?.IsZero != false) + if (treatZeroAccountDifferently && Address.Zero == address && before is null && after?.IsZero != false) { return; } @@ -43,7 +43,7 @@ public override void ReportBalanceChange(Address address, UInt256? before, UInt2 public override void ReportCodeChange(Address address, byte[]? before, byte[]? after) { - if (treatSystemAccountDifferently && Address.SystemUser == address && before is null && + if (treatZeroAccountDifferently && Address.Zero == address && before is null && after == Array.Empty()) { return; @@ -54,7 +54,7 @@ public override void ReportCodeChange(Address address, byte[]? before, byte[]? a public override void ReportNonceChange(Address address, UInt256? before, UInt256? after) { - if (treatSystemAccountDifferently && Address.SystemUser == address && before is null && after?.IsZero != false) + if (treatZeroAccountDifferently && Address.Zero == address && before is null && after?.IsZero != false) { return; } diff --git a/src/Nethermind/Nethermind.Blockchain/Utils/LastNStateRootTracker.cs b/src/Nethermind/Nethermind.Blockchain/Utils/LastNStateRootTracker.cs index c1824d21eaaa..66c4727bfac7 100644 --- a/src/Nethermind/Nethermind.Blockchain/Utils/LastNStateRootTracker.cs +++ b/src/Nethermind/Nethermind.Blockchain/Utils/LastNStateRootTracker.cs @@ -11,8 +11,8 @@ namespace Nethermind.Blockchain.Utils; -// TODO: Move responsibility to IWorldStateManager? Could be, but if IWorldStateManager store more than 128 blocks -// of state, that would be out of spec for snap and it would fail hive test. +// TODO: Move responsibility to IWorldStateManager? Could be, but if IWorldStateManager stores more blocks +// of state than configured, that would require updating the snap serving configuration (ISyncConfig.SnapServingMaxDepth). public class LastNStateRootTracker : ILastNStateRootTracker, IDisposable { private readonly IBlockTree _blockTree; diff --git a/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs b/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs index 9b4f311e1abd..b242c70e9c95 100644 --- a/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs +++ b/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs @@ -865,7 +865,6 @@ public async Task Can_stop() await goerli.StopNode(TestItem.PrivateKeyA, dontDispose: true); goerli.ProcessGenesis(); - await Task.Delay(1000); goerli.AssertHeadBlockIs(TestItem.PrivateKeyA, 0); await goerli.StopNode(TestItem.PrivateKeyA); diff --git a/src/Nethermind/Nethermind.Config/IBlocksConfig.cs b/src/Nethermind/Nethermind.Config/IBlocksConfig.cs index 320bee4879c1..6f7433e7d86f 100644 --- a/src/Nethermind/Nethermind.Config/IBlocksConfig.cs +++ b/src/Nethermind/Nethermind.Config/IBlocksConfig.cs @@ -49,7 +49,7 @@ public interface IBlocksConfig : IConfig [ConfigItem(Description = "The genesis block load timeout, in milliseconds.", DefaultValue = "40000")] int GenesisTimeoutMs { get; set; } - [ConfigItem(Description = "The max transaction bytes to add in block production, in kilobytes.", DefaultValue = "9728")] + [ConfigItem(Description = "The max transaction bytes to add in block production, in kilobytes.", DefaultValue = "7936")] long BlockProductionMaxTxKilobytes { get; set; } [ConfigItem(Description = "The ticker that gas rewards are denominated in for processing logs", DefaultValue = "ETH", HiddenFromDocs = true)] diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Validators/PendingValidatorsDecoder.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Validators/PendingValidatorsDecoder.cs index 7dc6dcc28945..4160d122fc5d 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Validators/PendingValidatorsDecoder.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Validators/PendingValidatorsDecoder.cs @@ -7,9 +7,9 @@ namespace Nethermind.Consensus.AuRa.Validators { - internal class PendingValidatorsDecoder : IRlpObjectDecoder, IRlpStreamDecoder + internal sealed class PendingValidatorsDecoder : RlpStreamDecoder, IRlpObjectDecoder { - public PendingValidators Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override PendingValidators DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -54,7 +54,7 @@ public Rlp Encode(PendingValidators item, RlpBehaviors rlpBehaviors = RlpBehavio return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream rlpStream, PendingValidators item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream rlpStream, PendingValidators item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { (int contentLength, int addressesLength) = GetContentLength(item, rlpBehaviors); rlpStream.StartSequence(contentLength); @@ -68,7 +68,7 @@ public void Encode(RlpStream rlpStream, PendingValidators item, RlpBehaviors rlp rlpStream.Encode(item.AreFinalized); } - public int GetLength(PendingValidators item, RlpBehaviors rlpBehaviors) => + public override int GetLength(PendingValidators item, RlpBehaviors rlpBehaviors) => item is null ? 1 : Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors).Total); private static (int Total, int Addresses) GetContentLength(PendingValidators item, RlpBehaviors rlpBehaviors) diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/Validators/ValidatorInfoDecoder.cs b/src/Nethermind/Nethermind.Consensus.AuRa/Validators/ValidatorInfoDecoder.cs index 71b9c3e5a650..783878be3eec 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/Validators/ValidatorInfoDecoder.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/Validators/ValidatorInfoDecoder.cs @@ -6,9 +6,9 @@ namespace Nethermind.Consensus.AuRa.Validators { - internal class ValidatorInfoDecoder : IRlpStreamDecoder, IRlpObjectDecoder + internal sealed class ValidatorInfoDecoder : RlpStreamDecoder, IRlpObjectDecoder { - public ValidatorInfo? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override ValidatorInfo? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -49,7 +49,7 @@ public Rlp Encode(ValidatorInfo? item, RlpBehaviors rlpBehaviors = RlpBehaviors. return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream stream, ValidatorInfo? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, ValidatorInfo? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -68,7 +68,7 @@ public void Encode(RlpStream stream, ValidatorInfo? item, RlpBehaviors rlpBehavi } } - public int GetLength(ValidatorInfo? item, RlpBehaviors rlpBehaviors) => item is null ? 1 : Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors).Total); + public override int GetLength(ValidatorInfo? item, RlpBehaviors rlpBehaviors) => item is null ? 1 : Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors).Total); private static (int Total, int Validators) GetContentLength(ValidatorInfo item, RlpBehaviors rlpBehaviors) { diff --git a/src/Nethermind/Nethermind.Consensus.Clique/SnapshotDecoder.cs b/src/Nethermind/Nethermind.Consensus.Clique/SnapshotDecoder.cs index 8bf9756d81d5..1d35ce104ffd 100644 --- a/src/Nethermind/Nethermind.Consensus.Clique/SnapshotDecoder.cs +++ b/src/Nethermind/Nethermind.Consensus.Clique/SnapshotDecoder.cs @@ -9,9 +9,9 @@ namespace Nethermind.Consensus.Clique { - internal class SnapshotDecoder : IRlpStreamDecoder + internal sealed class SnapshotDecoder : RlpStreamDecoder { - public Snapshot Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Snapshot DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); @@ -30,7 +30,7 @@ public Snapshot Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehav return snapshot; } - public void Encode(RlpStream stream, Snapshot item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, Snapshot item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { (int contentLength, int signersLength, int votesLength, int tallyLength) = GetContentLength(item, rlpBehaviors); @@ -43,7 +43,7 @@ public void Encode(RlpStream stream, Snapshot item, RlpBehaviors rlpBehaviors = } - public int GetLength(Snapshot item, RlpBehaviors rlpBehaviors) + public override int GetLength(Snapshot item, RlpBehaviors rlpBehaviors) { (int contentLength, int _, int _, int _) = GetContentLength(item, rlpBehaviors); return Rlp.LengthOfSequence(contentLength); diff --git a/src/Nethermind/Nethermind.Consensus.Test/Scheduler/BackgroundTaskSchedulerTests.cs b/src/Nethermind/Nethermind.Consensus.Test/Scheduler/BackgroundTaskSchedulerTests.cs index f6c54aef25e3..94fd09cfe591 100644 --- a/src/Nethermind/Nethermind.Consensus.Test/Scheduler/BackgroundTaskSchedulerTests.cs +++ b/src/Nethermind/Nethermind.Consensus.Test/Scheduler/BackgroundTaskSchedulerTests.cs @@ -54,15 +54,15 @@ public async Task Test_task_will_execute_concurrently_when_configured_so() SemaphoreSlim waitSignal = new SemaphoreSlim(0); scheduler.ScheduleTask(1, async (_, token) => { - counter++; + Interlocked.Increment(ref counter); await waitSignal.WaitAsync(token); - counter--; + Interlocked.Decrement(ref counter); }); scheduler.ScheduleTask(1, async (_, token) => { - counter++; + Interlocked.Increment(ref counter); await waitSignal.WaitAsync(token); - counter--; + Interlocked.Decrement(ref counter); }); Assert.That(() => counter, Is.EqualTo(2).After(5000, 1)); diff --git a/src/Nethermind/Nethermind.Core.Test/Encoding/BlockDecoderTests.cs b/src/Nethermind/Nethermind.Core.Test/Encoding/BlockDecoderTests.cs index c9a16906c344..bd8b19db914f 100644 --- a/src/Nethermind/Nethermind.Core.Test/Encoding/BlockDecoderTests.cs +++ b/src/Nethermind/Nethermind.Core.Test/Encoding/BlockDecoderTests.cs @@ -149,4 +149,23 @@ public void Get_length_null() BlockDecoder decoder = new(); Assert.That(decoder.GetLength(null, RlpBehaviors.None), Is.EqualTo(1)); } + + public static byte[][] MalformedInput = + [ + [0xFF, 0xFF], // Bug #001 original. + [0xF8, 0xFF], // Long list prefix, no length. + [0xB8, 0xFF], // Long string prefix, no length. + "\0\0"u8.ToArray() // Invalid prefix. + ]; + + /// + /// Fuzz-generated edge case: Very short truncated input. + /// + [TestCaseSource(nameof(MalformedInput))] + public void Rejects_malformed_input(byte[] input) + { + BlockDecoder decoder = new(); + RlpStream rlpStream = new(input); + Assert.Throws(() => decoder.Decode(rlpStream)); + } } diff --git a/src/Nethermind/Nethermind.Core.Test/Modules/TestMergeModule.cs b/src/Nethermind/Nethermind.Core.Test/Modules/TestMergeModule.cs index 18347180f0fa..2a930771c265 100644 --- a/src/Nethermind/Nethermind.Core.Test/Modules/TestMergeModule.cs +++ b/src/Nethermind/Nethermind.Core.Test/Modules/TestMergeModule.cs @@ -11,7 +11,6 @@ using Nethermind.Consensus.Rewards; using Nethermind.Merge.Plugin; using Nethermind.Merge.Plugin.BlockProduction; -using Nethermind.Merge.Plugin.InvalidChainTracker; using Nethermind.TxPool; namespace Nethermind.Core.Test.Modules; @@ -43,6 +42,9 @@ protected override void Load(ContainerBuilder builder) .AddDecorator() .AddScoped() .AddDecorator() + + // Engine rpc + .AddSingleton() ; if (txPoolConfig.BlobsSupport.SupportsReorgs()) diff --git a/src/Nethermind/Nethermind.Core.Test/NSubstituteExtensions.cs b/src/Nethermind/Nethermind.Core.Test/NSubstituteExtensions.cs index 8fbecf464e22..d9cb360ea08f 100644 --- a/src/Nethermind/Nethermind.Core.Test/NSubstituteExtensions.cs +++ b/src/Nethermind/Nethermind.Core.Test/NSubstituteExtensions.cs @@ -2,35 +2,71 @@ // SPDX-License-Identifier: LGPL-3.0-only using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; using NSubstitute; +using NSubstitute.Core; +using NUnit.Framework; namespace Nethermind.Core.Test; public static class NSubstituteExtensions { - public static bool ReceivedBool(this T substitute, Action action, int requiredNumberOfCalls = 1) where T : class + /// + /// Checks if a substitute received matching calls without throwing exceptions. + /// Suitable for polling scenarios with Is.True.After(). + /// + public static bool ReceivedCallsMatching( + this T substitute, + Action action, + int requiredNumberOfCalls = 1, + int? maxNumberOfCalls = null, + [CallerArgumentExpression(nameof(action))] string? expression = null) where T : class { - try - { - action(substitute.Received(requiredNumberOfCalls)); - return true; - } - catch - { - return false; - } - } + if (maxNumberOfCalls < requiredNumberOfCalls) throw new ArgumentException($"{nameof(maxNumberOfCalls)} must be greater than or equal to {nameof(requiredNumberOfCalls)}", nameof(maxNumberOfCalls)); + maxNumberOfCalls ??= requiredNumberOfCalls; + ISubstitutionContext context = SubstitutionContext.Current; + ICallRouter callRouter = context.GetCallRouterFor(substitute); - public static bool DidNotReceiveBool(this T substitute, Action action) where T : class - { - try - { - action(substitute.DidNotReceive()); - return true; - } - catch + // Set up the call specification by invoking the action + action(substitute); + + // Get the pending specification that was just set up + IPendingSpecification pendingSpec = context.ThreadContext.PendingSpecification; + if (!pendingSpec.HasPendingCallSpecInfo()) return false; + + // Use a query to check if the call was received + PendingSpecificationInfo? callSpecInfo = context.ThreadContext.PendingSpecification.UseCallSpecInfo(); + int? matchCount = callSpecInfo?.Handle( + // Lambda 1: Handle call specification with Arg matchers + callSpec => callRouter.ReceivedCalls().Where(callSpec.IsSatisfiedBy).Count(), + // Lambda 2: Handle matching with concrete argument values + GetMatchCount); + + return matchCount.HasValue && CheckMatchCount(matchCount.Value); + + bool CheckMatchCount(int count) => count >= requiredNumberOfCalls && count <= maxNumberOfCalls; + + int GetMatchCount(ICall expectedCall) { - return false; + IEnumerable receivedCalls = callRouter.ReceivedCalls(); + MethodInfo expectedMethod = expectedCall.GetMethodInfo(); + object?[] expectedArgs = expectedCall.GetArguments(); + + int matchCount = 0; + foreach (ICall call in receivedCalls) + { + // Match method name and arguments + if (call.GetMethodInfo() == expectedMethod) + { + object?[] callArgs = call.GetArguments(); + matchCount += expectedArgs.SequenceEqual(callArgs) ? 1 : 0; + } + } + + return matchCount; } } } diff --git a/src/Nethermind/Nethermind.Core.Test/RipemdTests.cs b/src/Nethermind/Nethermind.Core.Test/RipemdTests.cs index 88403a11e132..b7c4e8115218 100644 --- a/src/Nethermind/Nethermind.Core.Test/RipemdTests.cs +++ b/src/Nethermind/Nethermind.Core.Test/RipemdTests.cs @@ -9,7 +9,7 @@ namespace Nethermind.Core.Test [TestFixture] public class RipemdTests { - public const string RipemdOfEmptyString = "9c1185a5c5e9fc54612808977ee8f548b2258d31"; + public const string RipemdOfEmptyString = "0000000000000000000000009c1185a5c5e9fc54612808977ee8f548b2258d31"; [Test] public void Empty_byte_array() diff --git a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs index 2960b6443c7f..c2b7221bde4d 100644 --- a/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Core/Specs/IReleaseSpec.cs @@ -306,6 +306,12 @@ public interface IReleaseSpec : IEip1559Spec, IReceiptSpec bool IsEip7709Enabled { get; } Address Eip2935ContractAddress { get; } + /// + /// EIP-2935 ring buffer size for historical block hash storage. + /// Defaults to 8,191 blocks for Ethereum mainnet. + /// + long Eip2935RingBufferSize => Eip2935Constants.RingBufferSize; + /// /// SELFDESTRUCT only in same transaction /// diff --git a/src/Nethermind/Nethermind.Crypto/Ripemd.cs b/src/Nethermind/Nethermind.Crypto/Ripemd.cs index fc02c2e524ef..8fc68db757e3 100644 --- a/src/Nethermind/Nethermind.Crypto/Ripemd.cs +++ b/src/Nethermind/Nethermind.Crypto/Ripemd.cs @@ -1,25 +1,29 @@ // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only +using System; using Nethermind.Core.Extensions; using Org.BouncyCastle.Crypto.Digests; -namespace Nethermind.Crypto +namespace Nethermind.Crypto; + +public static class Ripemd { - public static class Ripemd + const int HashOutputLength = 32; + + public static byte[] Compute(ReadOnlySpan input) { - public static byte[] Compute(byte[] input) - { - var digest = new RipeMD160Digest(); - digest.BlockUpdate(input, 0, input.Length); - var result = new byte[digest.GetDigestSize()]; - digest.DoFinal(result, 0); - return result; - } + RipeMD160Digest digest = new(); + digest.BlockUpdate(input); + byte[] result = new byte[HashOutputLength]; + int length = digest.GetDigestSize(); + Span span = result.AsSpan(HashOutputLength - length, length); + digest.DoFinal(span); + return result; + } - public static string ComputeString(byte[] input) - { - return Compute(input).ToHexString(false); - } + public static string ComputeString(ReadOnlySpan input) + { + return Compute(input).ToHexString(false); } } diff --git a/src/Nethermind/Nethermind.Evm.Precompiles/Ripemd160Precompile.cs b/src/Nethermind/Nethermind.Evm.Precompiles/Ripemd160Precompile.cs index a4977a63c8c4..092a6689de57 100644 --- a/src/Nethermind/Nethermind.Evm.Precompiles/Ripemd160Precompile.cs +++ b/src/Nethermind/Nethermind.Evm.Precompiles/Ripemd160Precompile.cs @@ -38,6 +38,6 @@ public long DataGasCost(ReadOnlyMemory inputData, IReleaseSpec releaseSpec { Metrics.Ripemd160Precompile++; - return (Ripemd.Compute(inputData.ToArray()).PadLeft(32), true); + return (Ripemd.Compute(inputData.Span), true); } } diff --git a/src/Nethermind/Nethermind.Evm.Test/Tracing/CancellationTracerTests.cs b/src/Nethermind/Nethermind.Evm.Test/Tracing/CancellationTracerTests.cs index 0cb2d8461fca..03cc9cd3dc92 100644 --- a/src/Nethermind/Nethermind.Evm.Test/Tracing/CancellationTracerTests.cs +++ b/src/Nethermind/Nethermind.Evm.Test/Tracing/CancellationTracerTests.cs @@ -18,17 +18,14 @@ public class CancellationTracerTests { [Test] [Retry(3)] - public async Task Throw_operation_canceled_after_given_timeout() + public void Throw_operation_canceled_after_given_timeout() { TimeSpan timeout = TimeSpan.FromMilliseconds(10); using CancellationTokenSource cancellationTokenSource = new(timeout); CancellationToken cancellationToken = cancellationTokenSource.Token; CancellationTxTracer tracer = new(Substitute.For(), cancellationToken) { IsTracingActions = true }; - // ReSharper disable once MethodSupportsCancellation - await Task.Delay(100); - - Assert.Throws(() => tracer.ReportActionError(EvmExceptionType.None)); + Assert.That(() => tracer.ReportActionError(EvmExceptionType.None), Throws.TypeOf().After(100, 10)); } [Test] diff --git a/src/Nethermind/Nethermind.Evm/ByteArrayExtensions.cs b/src/Nethermind/Nethermind.Evm/ByteArrayExtensions.cs index 57159706c744..d99b77804dcd 100644 --- a/src/Nethermind/Nethermind.Evm/ByteArrayExtensions.cs +++ b/src/Nethermind/Nethermind.Evm/ByteArrayExtensions.cs @@ -21,15 +21,6 @@ private static ZeroPaddedSpan SliceWithZeroPadding(this ReadOnlySpan span, return new ZeroPaddedSpan(default, length, padDirection); } - if (length == 1) - { - // why do we return zero length here? - // it was passing all the tests like this... - // return bytes.Length == 0 ? new byte[0] : new[] {bytes[startIndex]}; - return span.Length == 0 ? new ZeroPaddedSpan(default, 0, padDirection) : new ZeroPaddedSpan(span.Slice(startIndex, 1), 0, padDirection); - // return bytes.Length == 0 ? new ZeroPaddedSpan(default, 1) : new ZeroPaddedSpan(bytes.Slice(startIndex, 1), 0); - } - int copiedLength = Math.Min(span.Length - startIndex, length); return new ZeroPaddedSpan(span.Slice(startIndex, copiedLength), length - copiedLength, padDirection); } diff --git a/src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Create.cs b/src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Create.cs index 61c55a3e070d..7ff83facf01a 100644 --- a/src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Create.cs +++ b/src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Create.cs @@ -88,12 +88,6 @@ public static EvmExceptionType InstructionCreate( ref readonly ExecutionEnvironment env = ref vm.EvmState.Env; IWorldState state = vm.WorldState; - // Ensure the executing account exists in the world state. If not, create it with a zero balance. - if (!state.AccountExists(env.ExecutingAccount)) - { - state.CreateAccount(env.ExecutingAccount, UInt256.Zero); - } - // Pop parameters off the stack: value to transfer, memory position for the initialization code, // and the length of the initialization code. if (!stack.PopUInt256(out UInt256 value) || diff --git a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs index 438dd62c6cd6..e51c57c39c55 100644 --- a/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs +++ b/src/Nethermind/Nethermind.Evm/TransactionProcessing/TransactionProcessor.cs @@ -734,6 +734,7 @@ private int ExecuteEvmCall( FailContractCreate: if (Logger.IsTrace) Logger.Trace("Restoring state from before transaction"); WorldState.Restore(snapshot); + gasConsumed = RefundOnFailContractCreation(tx, spec, opts, in VirtualMachine.TxExecutionContext.GasPrice); Complete: if (!opts.HasFlag(ExecutionOptions.SkipValidation)) @@ -742,6 +743,11 @@ private int ExecuteEvmCall( return statusCode; } + protected virtual GasConsumed RefundOnFailContractCreation(Transaction tx, IReleaseSpec spec, ExecutionOptions opts, in UInt256 gasPrice) + { + return tx.GasLimit; + } + protected virtual bool DeployLegacyContract(IReleaseSpec spec, Address codeOwner, in TransactionSubstate substate, in StackAccessTracker accessedItems, ref long unspentGas) { long codeDepositGasCost = CodeDepositHandler.CalculateCost(spec, substate.Output.Bytes.Length); diff --git a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs index f9f2d10556f1..7e96065b48c9 100644 --- a/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs +++ b/src/Nethermind/Nethermind.Facade/BlockchainBridge.cs @@ -227,7 +227,7 @@ private TransactionResult CallAndRestore( ITxTracer tracer, BlockProcessingComponents components) { - transaction.SenderAddress ??= Address.SystemUser; + transaction.SenderAddress ??= Address.Zero; //Ignore nonce on all CallAndRestore calls transaction.Nonce = components.StateReader.GetNonce(blockHeader, transaction.SenderAddress); diff --git a/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/BlobTransactionForRpc.cs b/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/BlobTransactionForRpc.cs index f683fcbdadb0..511c638c626c 100644 --- a/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/BlobTransactionForRpc.cs +++ b/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/BlobTransactionForRpc.cs @@ -15,7 +15,6 @@ public class BlobTransactionForRpc : EIP1559TransactionForRpc, IFromTransaction< public override TxType? Type => TxType; [JsonIgnore(Condition = JsonIgnoreCondition.Never)] - [JsonDiscriminator] public UInt256? MaxFeePerBlobGas { get; set; } // TODO: Each item should be a 32 byte array diff --git a/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/LegacyTransactionForRpc.cs b/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/LegacyTransactionForRpc.cs index 058db11d0785..daba9ebcbe32 100644 --- a/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/LegacyTransactionForRpc.cs +++ b/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/LegacyTransactionForRpc.cs @@ -98,7 +98,7 @@ public override Transaction ToTransaction() tx.Data = Input; tx.GasPrice = GasPrice ?? 0; tx.ChainId = ChainId; - tx.SenderAddress = From ?? Address.SystemUser; + tx.SenderAddress = From ?? Address.Zero; if ((R != 0 || S != 0) && (R is not null || S is not null)) { ulong v; @@ -130,7 +130,7 @@ public override void EnsureDefaults(long? gasCap) ? gasCap : Math.Min(gasCap.Value, Gas.Value); - From ??= Address.SystemUser; + From ??= Address.Zero; } public override bool ShouldSetBaseFee() => GasPrice.IsPositive(); diff --git a/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/TransactionForRpc.cs b/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/TransactionForRpc.cs index 327514e932aa..b00781325b4f 100644 --- a/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/TransactionForRpc.cs +++ b/src/Nethermind/Nethermind.Facade/Eth/RpcTransaction/TransactionForRpc.cs @@ -123,27 +123,39 @@ internal static void RegisterTransactionType() where T : TransactionForRpc, I public override TransactionForRpc? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - const string TypeFieldKey = nameof(TransactionForRpc.Type); // Copy the reader so we can do a double parse: // The first parse is used to check for fields, while the second parses the entire Transaction Utf8JsonReader txTypeReader = reader; JsonObject untyped = JsonSerializer.Deserialize(ref txTypeReader, options); - TxType? txType = null; - if (untyped.TryGetPropertyValue(TypeFieldKey, out JsonNode? node)) + Type concreteTxType = DeriveTxType(untyped, options); + + return (TransactionForRpc?)JsonSerializer.Deserialize(ref reader, concreteTxType, options); + } + + private Type DeriveTxType(JsonObject untyped, JsonSerializerOptions options) + { + Type defaultTxType = typeof(EIP1559TransactionForRpc); + const string gasPriceFieldKey = nameof(LegacyTransactionForRpc.GasPrice); + const string typeFieldKey = nameof(TransactionForRpc.Type); + + if (untyped.TryGetPropertyValue(typeFieldKey, out JsonNode? node)) { - txType = node.Deserialize(options); + TxType? setType = node.Deserialize(options); + if (setType is not null) + { + return _txTypes.FirstOrDefault(p => p.TxType == setType)?.Type ?? + throw new JsonException("Unknown transaction type"); + } } - Type concreteTxType = - ( - txType is not null - ? _txTypes.FirstOrDefault(p => p.TxType == txType) - : _txTypes.FirstOrDefault(p => p.DiscriminatorProperties.Any(name => untyped.ContainsKey(name)), _txTypes[^1]) - )?.Type - ?? throw new JsonException("Unknown transaction type"); + if (untyped.ContainsKey(gasPriceFieldKey)) + { + return typeof(LegacyTransactionForRpc); + } - return (TransactionForRpc?)JsonSerializer.Deserialize(ref reader, concreteTxType, options); + return _txTypes + .FirstOrDefault(p => p.DiscriminatorProperties.Any(untyped.ContainsKey))?.Type ?? defaultTxType; } public override void Write(Utf8JsonWriter writer, TransactionForRpc value, JsonSerializerOptions options) diff --git a/src/Nethermind/Nethermind.Init/PruningTrieStateFactory.cs b/src/Nethermind/Nethermind.Init/PruningTrieStateFactory.cs index 55707205ddb5..4153e411934b 100644 --- a/src/Nethermind/Nethermind.Init/PruningTrieStateFactory.cs +++ b/src/Nethermind/Nethermind.Init/PruningTrieStateFactory.cs @@ -87,7 +87,7 @@ ILogManager logManager trieStore, dbProvider, logManager, - new LastNStateRootTracker(blockTree, 128)); + new LastNStateRootTracker(blockTree, syncConfig.SnapServingMaxDepth)); // NOTE: Don't forget this! Very important! TrieStoreBoundaryWatcher trieStoreBoundaryWatcher = new(stateManager, blockTree!, logManager); @@ -190,10 +190,10 @@ ILogManager logManager AdviseConfig(pruningConfig, dbConfig, hardwareInfo); - if (syncConfig.SnapServingEnabled == true && pruningConfig.PruningBoundary < 128) + if (syncConfig.SnapServingEnabled == true && pruningConfig.PruningBoundary < syncConfig.SnapServingMaxDepth) { - if (_logger.IsInfo) _logger.Info($"Snap serving enabled, but {nameof(pruningConfig.PruningBoundary)} is less than 128. Setting to 128."); - pruningConfig.PruningBoundary = 128; + if (_logger.IsInfo) _logger.Info($"Snap serving enabled, but {nameof(pruningConfig.PruningBoundary)} is less than {syncConfig.SnapServingMaxDepth}. Setting to {syncConfig.SnapServingMaxDepth}."); + pruningConfig.PruningBoundary = syncConfig.SnapServingMaxDepth; } if (pruningConfig.PruningBoundary < 64) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Data/Eip2930Tests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Data/Eip2930Tests.cs index dc248851c81e..8559d1621e3e 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Data/Eip2930Tests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Data/Eip2930Tests.cs @@ -98,7 +98,7 @@ public void can_serialize_null_accessList_to_empty_array(TxType txType) [Test] public void can_deserialize_null_accessList() { - string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":null,"accessList":null}"""; + string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gas":"0x0","input":null,"accessList":null}"""; var transactionForRpc = _serializer.Deserialize(json); @@ -138,7 +138,7 @@ public void can_serialize_empty_accessList(TxType txType, string txJson) [Test] public void can_deserialize_empty_accessList() { - string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":null,"accessList":[]}"""; + string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gas":"0x0","input":null,"accessList":[]}"""; TransactionForRpc transactionForRpc = _serializer.Deserialize(json); transactionForRpc.Type.Should().Be(TxType.AccessList); @@ -172,7 +172,7 @@ public void can_serialize_accessList_with_empty_storageKeys(TxType txType, strin [Test] public void can_deserialize_accessList_with_empty_storageKeys() { - string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":null,"accessList":[{"address":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","storageKeys":[]}]}"""; + string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gas":"0x0","input":null,"accessList":[{"address":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099","storageKeys":[]}]}"""; TransactionForRpc transactionForRpc = _serializer.Deserialize(json); transactionForRpc.Type.Should().Be(TxType.AccessList); @@ -185,7 +185,7 @@ public void can_deserialize_accessList_with_empty_storageKeys() [Test] public void can_deserialize_accessList_with_null_storageKeys() { - string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":null,"accessList":[{"address":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099"}]}"""; + string json = """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gas":"0x0","input":null,"accessList":[{"address":"0xb7705ae4c6f81b66cdb323c65f4e8133690fc099"}]}"""; TransactionForRpc transactionForRpc = _serializer.Deserialize(json); transactionForRpc.Type.Should().Be(TxType.AccessList); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Data/TransactionForRpcDeserializationTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Data/TransactionForRpcDeserializationTests.cs index 1b49f26d5e44..6da4e0606c27 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Data/TransactionForRpcDeserializationTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Data/TransactionForRpcDeserializationTests.cs @@ -36,10 +36,13 @@ public static IEnumerable TxJsonTestCases yield return Make(TxType.Legacy, """{"nonce":"0x0","to":null,"value":"0x0","gasPrice":"0x0","gas":"0x0","input":null}"""); yield return Make(TxType.Legacy, """{"nonce":"0x0","to":null,"gasPrice":"0x0","gas":"0x0","input":null}"""); yield return Make(TxType.Legacy, """{"nonce":"0x0","to":null,"gasPrice":"0x0","gas":"0x0","input":null}"""); - yield return Make(TxType.Legacy, """{"nonce":"0x0","input":null}"""); - yield return Make(TxType.Legacy, """{}"""); - yield return Make(TxType.Legacy, """{"type":null}"""); - yield return Make(TxType.Legacy, """{"additionalField":""}"""); + yield return Make(TxType.EIP1559, """{"nonce":"0x0","input":null}"""); + yield return Make(TxType.EIP1559, """{}"""); + yield return Make(TxType.EIP1559, """{"type":null}"""); + yield return Make(TxType.EIP1559, """{"additionalField":""}"""); + yield return Make(TxType.EIP1559, """{"MaxFeePerBlobGas":"0x0"}"""); + yield return Make(TxType.Legacy, + """{"nonce":"0x0","blockHash":null,"blockNumber":null,"transactionIndex":null,"to":null,"value":"0x0","gasPrice":"0x1","gas":"0x0","input":null,"maxPriorityFeePerGas":"0x1"}"""); yield return Make(TxType.AccessList, """{"type":null,"accessList":[]}"""); yield return Make(TxType.AccessList, """{"nonce":"0x0","to":null,"value":"0x0","accessList":[]}"""); @@ -55,11 +58,10 @@ public static IEnumerable TxJsonTestCases yield return Make(TxType.EIP1559, """{"maxFeePerGas":"0x0"}"""); yield return Make(TxType.EIP1559, """{"maxPriorityFeePerGas":"0x0"}"""); yield return Make(TxType.EIP1559, """{"MaxPriorityFeePerGas":"0x0"}"""); + yield return Make(TxType.EIP1559, """{"nonce":"0x0","to":null,"value":"0x0","maxPriorityFeePerGas":"0x0", "maxFeePerGas":"0x0","maxFeePerBlobGas":"0x0"}"""); - yield return Make(TxType.Blob, """{"nonce":"0x0","to":null,"value":"0x0","accessList":[],"maxFeePerBlobGas":"0x0"}"""); - yield return Make(TxType.Blob, """{"nonce":"0x0","to":null,"value":"0x0","maxPriorityFeePerGas":"0x0", "maxFeePerGas":"0x0","maxFeePerBlobGas":"0x0"}"""); + yield return Make(TxType.Blob, """{"nonce":"0x0","to":null,"value":"0x0","accessList":[],"blobVersionedHashes":[]}"""); yield return Make(TxType.Blob, """{"maxFeePerBlobGas":"0x0", "blobVersionedHashes":[]}"""); - yield return Make(TxType.Blob, """{"MaxFeePerBlobGas":"0x0"}"""); yield return Make(TxType.Blob, """{"blobVersionedHashes":[]}"""); yield return Make(TxType.Blob, """{"BlobVersionedHashes":null}"""); yield return Make(TxType.Blob, """{"blobVersionedHashes":["0x01f1872d656b7a820d763e6001728b9b883f829b922089ec6ad7f5f1665470dc"]}"""); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugSimulateTestsBlocksAndTransactions.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugSimulateTestsBlocksAndTransactions.cs index c3e6c11fdcf6..20fb25101bdd 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugSimulateTestsBlocksAndTransactions.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugSimulateTestsBlocksAndTransactions.cs @@ -55,7 +55,7 @@ public async Task Test_debug_simulate_eth_moved() TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain(); UInt256 nonceA = chain.ReadOnlyState.GetNonce(TestItem.AddressA); - Transaction txMainnetAtoB = EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1); + Transaction txMainnetAtoB = EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1, type: TxType.Legacy); SimulatePayload payload = EthSimulateTestsBlocksAndTransactions.CreateEthMovedPayload(chain, nonceA); @@ -93,7 +93,7 @@ public async Task Test_debug_simulate_transactions_forced_fail() UInt256 nonceA = chain.ReadOnlyState.GetNonce(TestItem.AddressA); Transaction txMainnetAtoB = - EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1); + EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1, type: TxType.Legacy); SimulatePayload payload = EthSimulateTestsBlocksAndTransactions.CreateTransactionsForcedFail(chain, nonceA); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EstimateGas.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EstimateGas.cs index 379c644d9e3c..0fe1eec136b7 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EstimateGas.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EstimateGas.cs @@ -125,7 +125,7 @@ public async Task Eth_estimate_gas_with_accessList(bool senderAccessList, long g AccessListTransactionForRpc transaction = test.JsonSerializer.Deserialize( - $"{{\"type\":\"0x1\", \"data\": \"{code.ToHexString(true)}\"}}"); + $"{{\"type\":\"0x1\", \"from\": \"{Address.SystemUser}\", \"data\": \"{code.ToHexString(true)}\"}}"); string serialized = await test.TestEthRpc("eth_estimateGas", transaction, "0x0"); Assert.That( serialized, Is.EqualTo($"{{\"jsonrpc\":\"2.0\",\"result\":\"{gasPriceWithoutAccessList.ToHexString(true)}\",\"id\":67}}")); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EthCall.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EthCall.cs index 409bf3d875b5..e880f58759db 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EthCall.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.EthCall.cs @@ -297,6 +297,51 @@ public async Task Eth_call_with_base_fee_opcode_should_return_0() serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"id\":67}")); } + [Test] + public async Task Eth_call_with_base_fee_opcode_without_from_address_should_return_0() + { + using Context ctx = await Context.CreateWithLondonEnabled(); + + byte[] code = Prepare.EvmCode + .Op(Instruction.BASEFEE) + .PushData(0) + .Op(Instruction.MSTORE) + .PushData("0x20") + .PushData("0x0") + .Op(Instruction.RETURN) + .Done; + + string dataStr = code.ToHexString(); + TransactionForRpc transaction = ctx.Test.JsonSerializer.Deserialize( + $"{{\"type\": \"0x2\", \"data\": \"{dataStr}\"}}"); + string serialized = await ctx.Test.TestEthRpc("eth_call", transaction); + Assert.That( + serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"id\":67}")); + } + + [Test] + public async Task Eth_call_with_value_transfer_without_from_address_should_throw() + { + using Context ctx = await Context.CreateWithLondonEnabled(); + + byte[] code = Prepare.EvmCode + .Op(Instruction.BASEFEE) + .PushData(0) + .Op(Instruction.MSTORE) + .PushData("0x20") + .PushData("0x0") + .Op(Instruction.RETURN) + .Done; + + string dataStr = code.ToHexString(); + TransactionForRpc transaction = ctx.Test.JsonSerializer.Deserialize( + $"{{\"type\": \"0x2\", \"value\":\"{1.Ether()}\", \"data\": \"{dataStr}\"}}"); + string serialized = await ctx.Test.TestEthRpc("eth_call", transaction); + Console.WriteLine(serialized); + Assert.That( + serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32000,\"message\":\"insufficient sender balance\"},\"id\":67}")); + } + [Test] public async Task Eth_call_with_revert() { diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs index 8e2ecb1f265a..0e6b8f73d9ce 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/EthRpcModuleTests.cs @@ -1226,21 +1226,21 @@ public enum AccessListProvided Full } - [TestCase(AccessListProvided.None, false, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] - [TestCase(AccessListProvided.Full, false, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] - [TestCase(AccessListProvided.Partial, false, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] + [TestCase(AccessListProvided.None, false, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] + [TestCase(AccessListProvided.Full, false, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]}],\"gasUsed\":\"0x10f53\"},\"id\":67}")] + [TestCase(AccessListProvided.Partial, false, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] - [TestCase(AccessListProvided.None, true, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] - [TestCase(AccessListProvided.Full, true, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] - [TestCase(AccessListProvided.Partial, true, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] + [TestCase(AccessListProvided.None, true, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] + [TestCase(AccessListProvided.Full, true, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]}],\"gasUsed\":\"0x10f53\"},\"id\":67}")] + [TestCase(AccessListProvided.Partial, true, 2, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]}],\"gasUsed\":\"0xf71b\"},\"id\":67}")] - [TestCase(AccessListProvided.None, true, 12, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0x14739\"},\"id\":67}")] - [TestCase(AccessListProvided.Full, true, 12, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0x14739\"},\"id\":67}")] - [TestCase(AccessListProvided.Partial, true, 12, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\"]}],\"gasUsed\":\"0x14739\"},\"id\":67}")] + [TestCase(AccessListProvided.None, true, 12, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0x14739\"},\"id\":67}")] + [TestCase(AccessListProvided.Full, true, 12, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\"]}],\"gasUsed\":\"0x15f71\"},\"id\":67}")] + [TestCase(AccessListProvided.Partial, true, 12, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\"]}],\"gasUsed\":\"0x14739\"},\"id\":67}")] - [TestCase(AccessListProvided.None, true, 17, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\",\"0x000000000000000000000000000000000000000000000000000000000000000d\",\"0x000000000000000000000000000000000000000000000000000000000000000e\",\"0x000000000000000000000000000000000000000000000000000000000000000f\",\"0x0000000000000000000000000000000000000000000000000000000000000010\",\"0x0000000000000000000000000000000000000000000000000000000000000011\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0x16f48\"},\"id\":67}")] - [TestCase(AccessListProvided.Full, true, 17, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\",\"0x000000000000000000000000000000000000000000000000000000000000000d\",\"0x000000000000000000000000000000000000000000000000000000000000000e\",\"0x000000000000000000000000000000000000000000000000000000000000000f\",\"0x0000000000000000000000000000000000000000000000000000000000000010\",\"0x0000000000000000000000000000000000000000000000000000000000000011\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0x16f48\"},\"id\":67}")] - [TestCase(AccessListProvided.Partial, true, 17, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\",\"0x000000000000000000000000000000000000000000000000000000000000000d\",\"0x000000000000000000000000000000000000000000000000000000000000000e\",\"0x000000000000000000000000000000000000000000000000000000000000000f\",\"0x0000000000000000000000000000000000000000000000000000000000000010\",\"0x0000000000000000000000000000000000000000000000000000000000000011\"]}],\"gasUsed\":\"0x16f48\"},\"id\":67}")] + [TestCase(AccessListProvided.None, true, 17, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\",\"0x000000000000000000000000000000000000000000000000000000000000000d\",\"0x000000000000000000000000000000000000000000000000000000000000000e\",\"0x000000000000000000000000000000000000000000000000000000000000000f\",\"0x0000000000000000000000000000000000000000000000000000000000000010\",\"0x0000000000000000000000000000000000000000000000000000000000000011\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]}],\"gasUsed\":\"0x16f48\"},\"id\":67}")] + [TestCase(AccessListProvided.Full, true, 17, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0xfffffffffffffffffffffffffffffffffffffffe\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\"]},{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\",\"0x000000000000000000000000000000000000000000000000000000000000000d\",\"0x000000000000000000000000000000000000000000000000000000000000000e\",\"0x000000000000000000000000000000000000000000000000000000000000000f\",\"0x0000000000000000000000000000000000000000000000000000000000000010\",\"0x0000000000000000000000000000000000000000000000000000000000000011\"]}],\"gasUsed\":\"0x18780\"},\"id\":67}")] + [TestCase(AccessListProvided.Partial, true, 17, "{\"jsonrpc\":\"2.0\",\"result\":{\"accessList\":[{\"address\":\"0x76e68a8696537e4141926f3e528733af9e237d69\",\"storageKeys\":[]},{\"address\":\"0xbd770416a3345f91e4b34576cb804a576fa48eb1\",\"storageKeys\":[\"0x0000000000000000000000000000000000000000000000000000000000000001\",\"0x0000000000000000000000000000000000000000000000000000000000000002\",\"0x0000000000000000000000000000000000000000000000000000000000000003\",\"0x0000000000000000000000000000000000000000000000000000000000000004\",\"0x0000000000000000000000000000000000000000000000000000000000000005\",\"0x0000000000000000000000000000000000000000000000000000000000000006\",\"0x0000000000000000000000000000000000000000000000000000000000000007\",\"0x0000000000000000000000000000000000000000000000000000000000000008\",\"0x0000000000000000000000000000000000000000000000000000000000000009\",\"0x000000000000000000000000000000000000000000000000000000000000000a\",\"0x000000000000000000000000000000000000000000000000000000000000000b\",\"0x000000000000000000000000000000000000000000000000000000000000000c\",\"0x000000000000000000000000000000000000000000000000000000000000000d\",\"0x000000000000000000000000000000000000000000000000000000000000000e\",\"0x000000000000000000000000000000000000000000000000000000000000000f\",\"0x0000000000000000000000000000000000000000000000000000000000000010\",\"0x0000000000000000000000000000000000000000000000000000000000000011\"]}],\"gasUsed\":\"0x16f48\"},\"id\":67}")] public async Task Eth_create_access_list_sample(AccessListProvided accessListProvided, bool optimize, long loads, string expected) { @@ -1270,6 +1270,16 @@ public static void Should_handle_gasCap_as_max_if_null_or_zero(long? gasCap) Assert.That(rpcTx.Gas, Is.EqualTo(long.MaxValue), "Gas must be set to max if gasCap is null or 0"); } + [Test] + public static void Should_handle_fromAddress_as_zero_if_null() + { + LegacyTransactionForRpc rpcTx = new LegacyTransactionForRpc(); + + rpcTx.EnsureDefaults(0); + + Assert.That(rpcTx.From, Is.EqualTo(Address.Zero), "From address must be set to zero if tx.from is null"); + } + [Ignore(reason: "Shows disparity across 'default' methods")] [TestCase(null)] [TestCase(0)] diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs index 2d245618bd39..4cae9fee60b9 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Eth/Simulate/EthSimulateTestsBlocksAndTransactions.cs @@ -141,10 +141,11 @@ public static SimulatePayload CreateTransactionsForcedFail(Te }; } - public static Transaction GetTransferTxData(UInt256 nonce, IEthereumEcdsa ethereumEcdsa, PrivateKey from, Address to, UInt256 amount) + public static Transaction GetTransferTxData(UInt256 nonce, IEthereumEcdsa ethereumEcdsa, PrivateKey from, Address to, UInt256 amount, TxType type = TxType.EIP1559) { Transaction tx = new() { + Type = type, Value = amount, Nonce = nonce, GasLimit = 50_000, @@ -192,7 +193,7 @@ public async Task Test_eth_simulate_eth_moved() TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain(); UInt256 nonceA = chain.ReadOnlyState.GetNonce(TestItem.AddressA); - Transaction txMainnetAtoB = GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1); + Transaction txMainnetAtoB = GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1, type: TxType.Legacy); SimulatePayload payload = CreateEthMovedPayload(chain, nonceA); @@ -233,7 +234,7 @@ public async Task Test_eth_simulate_transactions_forced_fail() UInt256 nonceA = chain.ReadOnlyState.GetNonce(TestItem.AddressA); Transaction txMainnetAtoB = - GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1); + GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1, type: TxType.Legacy); SimulatePayload payload = CreateTransactionsForcedFail(chain, nonceA); @@ -276,6 +277,7 @@ public static SimulatePayload CreateTransferLogsAddressPayloa }, "calls": [ { + "type": "0x3", "from": "0xc000000000000000000000000000000000000000", "to": "0xc100000000000000000000000000000000000000", "gas": "0x5208", diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Proof/ProofRpcModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Proof/ProofRpcModuleTests.cs index 6a258e603242..a069835132fb 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Proof/ProofRpcModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Proof/ProofRpcModuleTests.cs @@ -46,7 +46,7 @@ namespace Nethermind.JsonRpc.Test.Modules.Proof; [TestFixture(false, false)] public class ProofRpcModuleTests { - private readonly bool _createSystemAccount; + private readonly bool _createZeroAccount; private readonly bool _useNonZeroGasPrice; private IProofRpcModule _proofRpcModule = null!; private IBlockTree _blockTree = null!; @@ -55,9 +55,9 @@ public class ProofRpcModuleTests private WorldStateManager _worldStateManager = null!; private IContainer _container; - public ProofRpcModuleTests(bool createSystemAccount, bool useNonZeroGasPrice) + public ProofRpcModuleTests(bool createZeroAccount, bool useNonZeroGasPrice) { - _createSystemAccount = createSystemAccount; + _createZeroAccount = createZeroAccount; _useNonZeroGasPrice = useNonZeroGasPrice; } @@ -376,7 +376,7 @@ public async Task Can_call_with_storage_load() .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(1 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(2)); } [TestCase] @@ -389,7 +389,7 @@ public async Task Can_call_with_many_storage_loads() .Op(Instruction.SLOAD) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(1 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(2)); } [TestCase] @@ -402,7 +402,7 @@ public async Task Can_call_with_storage_write() .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(1 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(2)); } [TestCase] @@ -416,17 +416,17 @@ public async Task Can_call_with_extcodecopy() .Op(Instruction.EXTCODECOPY) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3)); } [TestCase] - public async Task Can_call_with_extcodecopy_to_system_account() + public async Task Can_call_with_extcodecopy_to_zero_account() { byte[] code = Prepare.EvmCode .PushData("0x20") .PushData("0x00") .PushData("0x00") - .PushData(Address.SystemUser) + .PushData(Address.Zero) .Op(Instruction.EXTCODECOPY) .Done; CallResultWithProof result = await TestCallWithCode(code); @@ -441,14 +441,14 @@ public async Task Can_call_with_extcodesize() .Op(Instruction.EXTCODESIZE) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3)); } [TestCase] - public async Task Can_call_with_extcodesize_to_system_account() + public async Task Can_call_with_extcodesize_to_zero_account() { byte[] code = Prepare.EvmCode - .PushData(Address.SystemUser) + .PushData(Address.Zero) .Op(Instruction.EXTCODESIZE) .Done; CallResultWithProof result = await TestCallWithCode(code); @@ -464,15 +464,15 @@ public async Task Can_call_with_extcodehash() .Op(Instruction.EXTCODEHASH) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3)); } [TestCase] - public async Task Can_call_with_extcodehash_to_system_account() + public async Task Can_call_with_extcodehash_to_zero_account() { _specProvider.NextForkSpec = MuirGlacier.Instance; byte[] code = Prepare.EvmCode - .PushData(Address.SystemUser) + .PushData(Address.Zero) .Op(Instruction.EXTCODEHASH) .Done; CallResultWithProof result = await TestCallWithCode(code); @@ -487,7 +487,7 @@ public async Task Can_call_with_just_basic_addresses() .Op(Instruction.STOP) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(1 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(2)); } [TestCase] @@ -500,7 +500,7 @@ public async Task Can_call_with_balance() .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3 + (_useNonZeroGasPrice ? 1 : 0))); } [TestCase] @@ -512,15 +512,15 @@ public async Task Can_call_with_self_balance() .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(1 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(2)); } [TestCase] - public async Task Can_call_with_balance_of_system_account() + public async Task Can_call_with_balance_of_zero_account() { _specProvider.NextForkSpec = MuirGlacier.Instance; byte[] code = Prepare.EvmCode - .PushData(Address.SystemUser) + .PushData(Address.Zero) .Op(Instruction.BALANCE) .Done; CallResultWithProof result = await TestCallWithCode(code); @@ -528,7 +528,7 @@ public async Task Can_call_with_balance_of_system_account() } [TestCase] - public async Task Can_call_with_call_to_system_account_with_zero_value() + public async Task Can_call_with_call_to_zero_account_with_zero_value() { _specProvider.NextForkSpec = MuirGlacier.Instance; byte[] code = Prepare.EvmCode @@ -537,7 +537,7 @@ public async Task Can_call_with_call_to_system_account_with_zero_value() .PushData(0) .PushData(0) .PushData(0) - .PushData(Address.SystemUser) + .PushData(Address.Zero) .PushData(1000000) .Op(Instruction.CALL) .Done; @@ -546,7 +546,7 @@ public async Task Can_call_with_call_to_system_account_with_zero_value() } [TestCase] - public async Task Can_call_with_static_call_to_system_account() + public async Task Can_call_with_static_call_to_zero_account() { _specProvider.NextForkSpec = MuirGlacier.Instance; byte[] code = Prepare.EvmCode @@ -554,7 +554,7 @@ public async Task Can_call_with_static_call_to_system_account() .PushData(0) .PushData(0) .PushData(0) - .PushData(Address.SystemUser) + .PushData(Address.Zero) .PushData(1000000) .Op(Instruction.STATICCALL) .Done; @@ -563,7 +563,7 @@ public async Task Can_call_with_static_call_to_system_account() } [TestCase] - public async Task Can_call_with_delegate_call_to_system_account() + public async Task Can_call_with_delegate_call_to_zero_account() { _specProvider.NextForkSpec = MuirGlacier.Instance; byte[] code = Prepare.EvmCode @@ -571,7 +571,7 @@ public async Task Can_call_with_delegate_call_to_system_account() .PushData(0) .PushData(0) .PushData(0) - .PushData(Address.SystemUser) + .PushData(Address.Zero) .PushData(1000000) .Op(Instruction.DELEGATECALL) .Done; @@ -580,7 +580,7 @@ public async Task Can_call_with_delegate_call_to_system_account() } [TestCase] - public async Task Can_call_with_call_to_system_account_with_non_zero_value() + public async Task Can_call_with_call_to_zero_account_with_non_zero_value() { _specProvider.NextForkSpec = MuirGlacier.Instance; byte[] code = Prepare.EvmCode @@ -589,7 +589,7 @@ public async Task Can_call_with_call_to_system_account_with_non_zero_value() .PushData(0) .PushData(0) .PushData(1) - .PushData(Address.SystemUser) + .PushData(Address.Zero) .PushData(1000000) .Op(Instruction.CALL) .Done; @@ -612,7 +612,7 @@ public async Task Can_call_with_call_with_zero_value() .Op(Instruction.CALL) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3)); } [TestCase] @@ -629,7 +629,7 @@ public async Task Can_call_with_static_call() .Op(Instruction.STATICCALL) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3)); } [TestCase] @@ -646,7 +646,7 @@ public async Task Can_call_with_delegate_call() .Op(Instruction.DELEGATECALL) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(_createSystemAccount && _useNonZeroGasPrice ? 3 : 2)); + Assert.That(result.Accounts.Length, Is.EqualTo(3)); } [TestCase] @@ -664,7 +664,7 @@ public async Task Can_call_with_call_with_non_zero_value() .Op(Instruction.CALL) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3 + (_useNonZeroGasPrice ? 1 : 0))); } [TestCase] @@ -677,15 +677,15 @@ public async Task Can_call_with_self_destruct() .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(2 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(3 + (_useNonZeroGasPrice ? 1 : 0))); } [TestCase] - public async Task Can_call_with_self_destruct_to_system_account() + public async Task Can_call_with_self_destruct_to_zero_account() { _specProvider.NextForkSpec = MuirGlacier.Instance; byte[] code = Prepare.EvmCode - .PushData(Address.SystemUser) + .PushData(Address.Zero) .Op(Instruction.SELFDESTRUCT) .Done; CallResultWithProof result = await TestCallWithCode(code); @@ -705,7 +705,7 @@ public async Task Can_call_with_many_storage_writes() .Op(Instruction.SSTORE) .Done; CallResultWithProof result = await TestCallWithCode(code); - Assert.That(result.Accounts.Length, Is.EqualTo(1 + (_useNonZeroGasPrice ? 1 : 0))); + Assert.That(result.Accounts.Length, Is.EqualTo(2)); } [TestCase] @@ -846,7 +846,7 @@ private async Task TestCallWithStorageAndCode(byte[] code, UInt256 gasPrice, Add TransactionForRpc tx = new LegacyTransactionForRpc { - // we are testing system transaction here when From is null + // we are testing transaction from zero address here when From is null From = from, To = TestItem.AddressB, GasPrice = gasPrice, @@ -908,9 +908,9 @@ private async Task TestCallWithStorageAndCode(byte[] code, UInt256 gasPrice, Add AddCode(stateProvider, TestItem.AddressB, code); } - if (_createSystemAccount) + if (_createZeroAccount) { - AddAccount(stateProvider, Address.SystemUser, 1.Ether()); + AddAccount(stateProvider, Address.Zero, 1.Ether()); } stateProvider.CommitTree(0); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParitySimulateTestsBlocksAndTransactions.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParitySimulateTestsBlocksAndTransactions.cs index 5bee79033711..fb5fd892d3f0 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParitySimulateTestsBlocksAndTransactions.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParitySimulateTestsBlocksAndTransactions.cs @@ -51,7 +51,7 @@ public async Task Test_trace_simulate_eth_moved() TestRpcBlockchain chain = await EthRpcSimulateTestsBase.CreateChain(); UInt256 nonceA = chain.ReadOnlyState.GetNonce(TestItem.AddressA); - Transaction txMainnetAtoB = EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1); + Transaction txMainnetAtoB = EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1, type: TxType.Legacy); SimulatePayload payload = EthSimulateTestsBlocksAndTransactions.CreateEthMovedPayload(chain, nonceA); @@ -89,7 +89,7 @@ public async Task Test_trace_simulate_transactions_forced_fail() UInt256 nonceA = chain.ReadOnlyState.GetNonce(TestItem.AddressA); Transaction txMainnetAtoB = - EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1); + EthSimulateTestsBlocksAndTransactions.GetTransferTxData(nonceA, chain.EthereumEcdsa, TestItem.PrivateKeyA, TestItem.AddressB, 1, type: TxType.Legacy); SimulatePayload payload = EthSimulateTestsBlocksAndTransactions.CreateTransactionsForcedFail(chain, nonceA); diff --git a/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs b/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs index 82de21c147f5..2398cfda693d 100644 --- a/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs +++ b/src/Nethermind/Nethermind.JsonRpc/JsonRpcService.cs @@ -13,7 +13,6 @@ using System.Threading.Tasks; using Nethermind.Core; using Nethermind.Core.Collections; -using Nethermind.Core.Threading; using Nethermind.JsonRpc.Exceptions; using Nethermind.JsonRpc.Modules; using Nethermind.Logging; @@ -26,6 +25,9 @@ namespace Nethermind.JsonRpc; public class JsonRpcService : IJsonRpcService { + private readonly static Lock _reparseLock = new(); + private static Dictionary _reparseReflectionCache = new(); + private readonly ILogger _logger; private readonly IRpcModuleProvider _rpcModuleProvider; private readonly HashSet _methodsLoggingFiltering; @@ -106,6 +108,75 @@ private Task ExecuteRequestAsync(JsonRpcRequest rpcRequest, Jso private async Task ExecuteAsync(JsonRpcRequest request, string methodName, ResolvedMethodInfo method, JsonRpcContext context) { + const string GetLogsMethodName = "eth_getLogs"; + + JsonRpcErrorResponse? value = PrepareParameters(request, methodName, method, out object[]? parameters, out bool hasMissing); + if (value is not null) + { + return value; + } + + IRpcModule rpcModule = await _rpcModuleProvider.Rent(methodName, method.ReadOnly); + if (rpcModule is IContextAwareRpcModule contextAwareModule) + { + contextAwareModule.Context = context; + } + bool returnImmediately = methodName != GetLogsMethodName; + Action? returnAction = returnImmediately ? null : () => _rpcModuleProvider.Return(methodName, rpcModule); + IResultWrapper? resultWrapper = null; + try + { + // Execute method + object invocationResult = hasMissing ? + method.MethodInfo.Invoke(rpcModule, parameters) : + method.Invoker.Invoke(rpcModule, new Span(parameters)); + + switch (invocationResult) + { + case IResultWrapper wrapper: + resultWrapper = wrapper; + break; + case Task task: + await task; + resultWrapper = GetResultProperty(task)?.GetValue(task) as IResultWrapper; + break; + } + } + catch (Exception ex) + { + return HandleInvocationException(ex, methodName, request, returnAction); + } + finally + { + if (returnImmediately) + { + _rpcModuleProvider.Return(methodName, rpcModule); + } + } + + if (resultWrapper is null) + { + return HandleMissingResultWrapper(request, methodName, returnAction); + } + + Result result = resultWrapper.Result; + return result.ResultType != ResultType.Success + ? GetErrorResponse(methodName, resultWrapper.ErrorCode, result.Error, resultWrapper.Data, request.Id, returnAction, resultWrapper.IsTemporary) + : GetSuccessResponse(methodName, resultWrapper.Data, request.Id, returnAction); + + [MethodImpl(MethodImplOptions.NoInlining)] + JsonRpcResponse HandleMissingResultWrapper(JsonRpcRequest request, string methodName, Action returnAction) + { + string errorMessage = $"Method {methodName} execution result does not implement IResultWrapper"; + if (_logger.IsError) _logger.Error(errorMessage); + return GetErrorResponse(methodName, ErrorCodes.InternalError, errorMessage, null, request.Id, returnAction); + } + } + + private JsonRpcErrorResponse? PrepareParameters(JsonRpcRequest request, string methodName, ResolvedMethodInfo method, out object[]? parameters, out bool hasMissing) + { + parameters = null; + hasMissing = false; JsonElement providedParameters = request.Params; if (_logger.IsTrace) LogRequest(methodName, providedParameters, method.ExpectedParameters); @@ -166,87 +237,48 @@ private async Task ExecuteAsync(JsonRpcRequest request, string missingParamsCount -= explicitNullableParamsCount; - //prepare parameters - object[]? parameters = null; - bool hasMissing = false; + // Prepare parameters if (method.ExpectedParameters.Length > 0) { - (parameters, hasMissing) = DeserializeParameters(method.ExpectedParameters, providedParametersLength, providedParameters, missingParamsCount); - if (parameters is null) + try + { + (parameters, hasMissing) = DeserializeParameters(method.ExpectedParameters, providedParametersLength, providedParameters, missingParamsCount); + } + catch (Exception e) { - if (_logger.IsWarn) _logger.Warn($"Incorrect JSON RPC parameters when calling {methodName} with params [{string.Join(", ", providedParameters)}]"); + if (_logger.IsWarn) _logger.Warn($"Incorrect JSON RPC parameters when calling {methodName} with params [{string.Join(", ", providedParameters)}] {e}"); return GetErrorResponse(methodName, ErrorCodes.InvalidParams, "Invalid params", null, request.Id); } } - //execute method - IResultWrapper resultWrapper = null; - IRpcModule rpcModule = await _rpcModuleProvider.Rent(methodName, method.ReadOnly); - if (rpcModule is IContextAwareRpcModule contextAwareModule) - { - contextAwareModule.Context = context; - } - bool returnImmediately = methodName != "eth_getLogs"; - Action? returnAction = returnImmediately ? null : () => _rpcModuleProvider.Return(methodName, rpcModule); - try - { - object invocationResult = hasMissing ? - method.MethodInfo.Invoke(rpcModule, parameters) : - method.Invoker.Invoke(rpcModule, new Span(parameters)); + return null; + } - switch (invocationResult) - { - case IResultWrapper wrapper: - resultWrapper = wrapper; - break; - case Task task: - await task; - resultWrapper = GetResultProperty(task)?.GetValue(task) as IResultWrapper; - break; - } - } - catch (Exception e) when (e is TargetParameterCountException || e is ArgumentException) - { - return GetErrorResponse(methodName, ErrorCodes.InvalidParams, e.Message, e.ToString(), request.Id, returnAction); - } - catch (TargetInvocationException e) when (e.InnerException is JsonException) - { - return GetErrorResponse(methodName, ErrorCodes.InvalidParams, "Invalid params", e.InnerException?.ToString(), request.Id, returnAction); - } - catch (Exception e) when (e is OperationCanceledException || e.InnerException is OperationCanceledException) - { - string errorMessage = $"{methodName} request was canceled due to enabled timeout."; - return GetErrorResponse(methodName, ErrorCodes.Timeout, errorMessage, null, request.Id, returnAction); - } - catch (Exception e) when (e.InnerException is InsufficientBalanceException) + private JsonRpcErrorResponse HandleInvocationException(Exception ex, string methodName, JsonRpcRequest request, Action? returnAction) + { + return ex switch { - return GetErrorResponse(methodName, ErrorCodes.InvalidInput, e.InnerException.Message, e.ToString(), request.Id, returnAction); - } - catch (Exception ex) + TargetParameterCountException or ArgumentException => + GetErrorResponse(methodName, ErrorCodes.InvalidParams, ex.Message, ex.ToString(), request.Id, returnAction), + + TargetInvocationException and { InnerException: JsonException } => + GetErrorResponse(methodName, ErrorCodes.InvalidParams, "Invalid params", ex.InnerException?.ToString(), request.Id, returnAction), + + OperationCanceledException or { InnerException: OperationCanceledException } => + GetErrorResponse(methodName, ErrorCodes.Timeout, + $"{methodName} request was canceled due to enabled timeout.", null, request.Id, returnAction), + + { InnerException: InsufficientBalanceException } => + GetErrorResponse(methodName, ErrorCodes.InvalidInput, ex.InnerException.Message, ex.ToString(), request.Id, returnAction), + + _ => HandleException(ex, methodName, request, returnAction) + }; + + JsonRpcErrorResponse HandleException(Exception ex, string methodName, JsonRpcRequest request, Action? returnAction) { if (_logger.IsError) _logger.Error($"Error during method execution, request: {request}", ex); return GetErrorResponse(methodName, ErrorCodes.InternalError, "Internal error", ex.ToString(), request.Id, returnAction); } - finally - { - if (returnImmediately) - { - _rpcModuleProvider.Return(methodName, rpcModule); - } - } - - if (resultWrapper is null) - { - string errorMessage = $"Method {methodName} execution result does not implement IResultWrapper"; - if (_logger.IsError) _logger.Error(errorMessage); - return GetErrorResponse(methodName, ErrorCodes.InternalError, errorMessage, null, request.Id, returnAction); - } - - Result? result = resultWrapper.Result; - - return result.ResultType != ResultType.Success - ? GetErrorResponse(methodName, resultWrapper.ErrorCode, result.Error, resultWrapper.Data, request.Id, returnAction, resultWrapper.IsTemporary) - : GetSuccessResponse(methodName, resultWrapper.Data, request.Id, returnAction); } private PropertyInfo? GetResultProperty(Task task) @@ -363,8 +395,12 @@ private void LogRequest(string methodName, JsonElement providedParameters, Expec { if (providedParameter.ValueKind == JsonValueKind.String) { - JsonConverter converter = EthereumJsonSerializer.JsonOptions.GetConverter(paramType); - executionParam = converter.GetType().Namespace.StartsWith("System.", StringComparison.Ordinal) + if (!_reparseReflectionCache.TryGetValue(paramType, out bool reparseString)) + { + reparseString = CreateNewCacheEntry(paramType); + } + + executionParam = reparseString ? JsonSerializer.Deserialize(providedParameter.GetString(), paramType, EthereumJsonSerializer.JsonOptions) : providedParameter.Deserialize(paramType, EthereumJsonSerializer.JsonOptions); } @@ -377,72 +413,61 @@ private void LogRequest(string methodName, JsonElement providedParameters, Expec return executionParam; } - private (object[]? parameters, bool hasMissing) DeserializeParameters( - ExpectedParameter[] expectedParameters, - int providedParametersLength, - JsonElement providedParameters, - int missingParamsCount) + private static bool CreateNewCacheEntry(Type paramType) { - const int parallelThreshold = 4; - try + lock (_reparseLock) { - bool hasMissing = false; - int totalLength = providedParametersLength + missingParamsCount; - - if (totalLength == 0) return (Array.Empty(), false); + // Re-check inside the lock in case another thread already added it + if (_reparseReflectionCache.TryGetValue(paramType, out bool reparseString)) + { + return reparseString; + } - object[] executionParameters = new object[totalLength]; + JsonConverter converter = EthereumJsonSerializer.JsonOptions.GetConverter(paramType); + reparseString = converter.GetType().Namespace.StartsWith("System.", StringComparison.Ordinal); - if (providedParametersLength <= parallelThreshold) + // Copy-on-write: create a new dictionary so we don't mutate + Dictionary reparseReflectionCache = new Dictionary(_reparseReflectionCache) { - for (int i = 0; i < providedParametersLength; i++) - { - JsonElement providedParameter = providedParameters[i]; - ExpectedParameter expectedParameter = expectedParameters[i]; + [paramType] = reparseString + }; - object? parameter = DeserializeParameter(providedParameter, expectedParameter); - executionParameters[i] = parameter; - if (!hasMissing && ReferenceEquals(parameter, Type.Missing)) - { - hasMissing = true; - } - } - } - else if (providedParametersLength > parallelThreshold) - { - ParallelUnbalancedWork.For( - 0, - providedParametersLength, - ParallelUnbalancedWork.DefaultOptions, - (providedParameters, expectedParameters, executionParameters, hasMissing), - static (i, state) => - { - JsonElement providedParameter = state.providedParameters[i]; - ExpectedParameter expectedParameter = state.expectedParameters[i]; + // Publish the new cache instance atomically by swapping the reference. + _reparseReflectionCache = reparseReflectionCache; + return reparseString; + } + } - object? parameter = DeserializeParameter(providedParameter, expectedParameter); - state.executionParameters[i] = parameter; - if (!state.hasMissing && ReferenceEquals(parameter, Type.Missing)) - { - state.hasMissing = true; - } + private static (object[]? parameters, bool hasMissing) DeserializeParameters( + ExpectedParameter[] expectedParameters, + int providedParametersLength, + JsonElement providedParameters, + int missingParamsCount) + { + int totalLength = providedParametersLength + missingParamsCount; + if (totalLength == 0) return (Array.Empty(), false); - return state; - }); - } + object[] executionParameters = new object[totalLength]; - for (int i = providedParametersLength; i < totalLength; i++) - { - executionParameters[i] = Type.Missing; - } - hasMissing |= providedParametersLength < totalLength; - return (executionParameters, hasMissing); + bool hasMissing = missingParamsCount != 0; + int i = 0; + var enumerator = providedParameters.EnumerateArray(); + while (enumerator.MoveNext()) + { + ExpectedParameter expectedParameter = expectedParameters[i]; + + object? parameter = DeserializeParameter(enumerator.Current, expectedParameter); + executionParameters[i] = parameter; + hasMissing |= ReferenceEquals(parameter, Type.Missing); + i++; } - catch (Exception e) + + for (i = providedParametersLength; i < totalLength; i++) { - if (_logger.IsWarn) _logger.Warn("Error while parsing JSON RPC request parameters " + e); - return (null, false); + executionParameters[i] = Type.Missing; } + + return (executionParameters, hasMissing); } private static JsonRpcResponse GetSuccessResponse(string methodName, object result, object id, Action? disposableAction) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs index b6ecef04b02b..5e3cf3443b13 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Eth/SimulateTxExecutor.cs @@ -46,7 +46,6 @@ protected override SimulatePayload Prepare(Simulat StateOverrides = blockStateCall.StateOverrides, Calls = blockStateCall.Calls?.Select(callTransactionModel => { - callTransactionModel = UpdateTxType(callTransactionModel); LegacyTransactionForRpc asLegacy = callTransactionModel as LegacyTransactionForRpc; bool hadGasLimitInRequest = asLegacy?.Gas is not null; bool hadNonceInRequest = asLegacy?.Nonce is not null; @@ -56,8 +55,6 @@ protected override SimulatePayload Prepare(Simulat Transaction tx = callTransactionModel.ToTransaction(); - // The RPC set SystemUser as default, but we want to set it to zero to follow hive test. - if (tx.SenderAddress == Address.SystemUser) tx.SenderAddress = Address.Zero; tx.ChainId = _blockchainBridge.GetChainId(); TransactionWithSourceDetails? result = new() @@ -76,30 +73,6 @@ protected override SimulatePayload Prepare(Simulat return result; } - private static TransactionForRpc UpdateTxType(TransactionForRpc rpcTransaction) - { - // TODO: This is a bit messy since we're changing the transaction type - if (rpcTransaction is LegacyTransactionForRpc legacy && rpcTransaction is not EIP1559TransactionForRpc) - { - rpcTransaction = new EIP1559TransactionForRpc - { - Nonce = legacy.Nonce, - To = legacy.To, - From = legacy.From, - Gas = legacy.Gas, - Value = legacy.Value, - Input = legacy.Input, - GasPrice = legacy.GasPrice, - ChainId = legacy.ChainId, - V = legacy.V, - R = legacy.R, - S = legacy.S, - }; - } - - return rpcTransaction; - } - public override ResultWrapper>> Execute( SimulatePayload call, BlockParameter? blockParameter, diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs index 0e558150ce95..6a8167080165 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/Proof/ProofRpcModule.cs @@ -61,14 +61,14 @@ public ResultWrapper proof_call(TransactionForRpc tx, Block { TxRoot = Keccak.EmptyTreeHash, ReceiptsRoot = Keccak.EmptyTreeHash, - Author = Address.SystemUser + Author = Address.Zero }; callHeader.TotalDifficulty = sourceHeader.TotalDifficulty + callHeader.Difficulty; callHeader.Hash = callHeader.CalculateHash(); Transaction transaction = tx.ToTransaction(); - transaction.SenderAddress ??= Address.SystemUser; + transaction.SenderAddress ??= Address.Zero; if (transaction.GasLimit == 0) { @@ -77,7 +77,7 @@ public ResultWrapper proof_call(TransactionForRpc tx, Block Block block = new(callHeader, new[] { transaction }, []); - ProofBlockTracer proofBlockTracer = new(null, transaction.SenderAddress == Address.SystemUser); + ProofBlockTracer proofBlockTracer = new(null, transaction.SenderAddress == Address.Zero); scope.Component.Trace(block, proofBlockTracer); CallResultWithProof callResultWithProof = new(); diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V2.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V2.cs index 9c2d622c88c0..91bba6a5832a 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V2.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.V2.cs @@ -458,9 +458,9 @@ await rpc.engine_forkchoiceUpdatedV2(new ForkchoiceStateV1(executionPayload1.Blo IEnumerable payloadBodies = rpc.engine_getPayloadBodiesByRangeV1(1, 3).Result.Data; ExecutionPayloadBodyV1Result[] expected = - { + [ new(Array.Empty(), withdrawals), new(txsA, withdrawals) - }; + ]; payloadBodies.Should().BeEquivalentTo(expected, static o => o.WithStrictOrdering()); } diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs index e1d8404c53da..8ad25a2ec4ef 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/ExecutionRequestsProcessorMock.cs @@ -8,7 +8,6 @@ using Nethermind.Core.ExecutionRequest; using Nethermind.Core.Specs; using Nethermind.Core.Test.Builders; -using Nethermind.Evm; using Nethermind.Evm.State; namespace Nethermind.Merge.Plugin.Test; diff --git a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/NewPayloadHandler.cs b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/NewPayloadHandler.cs index 7d32ef7f27ae..0c2d4346c498 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/Handlers/NewPayloadHandler.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/Handlers/NewPayloadHandler.cs @@ -14,6 +14,7 @@ using Nethermind.Core; using Nethermind.Core.Caching; using Nethermind.Core.Crypto; +using Nethermind.Core.Extensions; using Nethermind.Core.Threading; using Nethermind.Crypto; using Nethermind.Int256; @@ -49,7 +50,7 @@ public sealed class NewPayloadHandler : IAsyncHandler? _latestBlocks; + private readonly LruCache? _latestBlocks; private readonly ProcessingOptions _defaultProcessingOptions; private readonly TimeSpan _timeout; @@ -386,6 +387,11 @@ ValidationResult TryCacheResult(ValidationResult result, string? errorMessage) await _processingQueue.Enqueue(block, processingOptions); (result, validationMessage) = await blockProcessed.Task.TimeoutOn(timeoutTask, cts); } + else + { + // Already known block with known processing result, cancel the timeout task + cts.Cancel(); + } } catch (TimeoutException) { diff --git a/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs b/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs index 92d6a2961e0b..5a350188359c 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin/MergePlugin.cs @@ -22,7 +22,6 @@ using Nethermind.Core; using Nethermind.Core.Crypto; using Nethermind.Core.Exceptions; -using Nethermind.Core.Timers; using Nethermind.Db; using Nethermind.Facade.Proxy; using Nethermind.HealthChecks; diff --git a/src/Nethermind/Nethermind.Merge.Plugin/NoEngineRequestTracker.cs b/src/Nethermind/Nethermind.Merge.Plugin/NoEngineRequestTracker.cs new file mode 100644 index 000000000000..e0d1b606bd30 --- /dev/null +++ b/src/Nethermind/Nethermind.Merge.Plugin/NoEngineRequestTracker.cs @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.Threading.Tasks; +using Nethermind.Api; + +namespace Nethermind.Merge.Plugin; + +public class NoEngineRequestsTracker : IEngineRequestsTracker +{ + public void OnForkchoiceUpdatedCalled() { } + + public void OnNewPayloadCalled() { } + + public Task StartAsync() + => Task.CompletedTask; +} diff --git a/src/Nethermind/Nethermind.Network.Discovery.Test/DiscoveryManagerTests.cs b/src/Nethermind/Nethermind.Network.Discovery.Test/DiscoveryManagerTests.cs index 02634ee53c36..d5df1bd8876a 100644 --- a/src/Nethermind/Nethermind.Network.Discovery.Test/DiscoveryManagerTests.cs +++ b/src/Nethermind/Nethermind.Network.Discovery.Test/DiscoveryManagerTests.cs @@ -10,6 +10,7 @@ using FluentAssertions; using Nethermind.Core; using Nethermind.Core.Crypto; +using Nethermind.Core.Test; using Nethermind.Core.Test.Builders; using Nethermind.Core.Timers; using Nethermind.Crypto; @@ -85,10 +86,9 @@ public async Task OnPingMessageTest() //receiving ping IPEndPoint address = new(IPAddress.Parse(Host), Port); _discoveryManager.OnIncomingMsg(new PingMsg(_publicKey, GetExpirationTime(), address, _nodeTable.MasterNode!.Address, new byte[32]) { FarAddress = address }); - await Task.Delay(500); // expecting to send pong - await _msgSender.Received(1).SendMsg(Arg.Is(static m => m.FarAddress!.Address.ToString() == Host && m.FarAddress.Port == Port)); + Assert.That(() => _msgSender.ReceivedCallsMatching(s => s.SendMsg(Arg.Is(static m => m.FarAddress!.Address.ToString() == Host && m.FarAddress.Port == Port))), Is.True.After(500, 10)); // send pings to new node await _msgSender.Received().SendMsg(Arg.Is(static m => m.FarAddress!.Address.ToString() == Host && m.FarAddress.Port == Port)); @@ -179,8 +179,7 @@ public async Task OnNeighborsMessageTest() _discoveryManager.OnIncomingMsg(msg); //expecting to send 3 pings to both nodes - await Task.Delay(600); - await _msgSender.Received(3).SendMsg(Arg.Is(m => m.FarAddress!.Address.ToString() == _nodes[0].Host && m.FarAddress.Port == _nodes[0].Port)); + Assert.That(() => _msgSender.ReceivedCallsMatching(s => s.SendMsg(Arg.Is(m => m.FarAddress!.Address.ToString() == _nodes[0].Host && m.FarAddress.Port == _nodes[0].Port)), 3), Is.True.After(600, 10)); await _msgSender.Received(3).SendMsg(Arg.Is(m => m.FarAddress!.Address.ToString() == _nodes[1].Host && m.FarAddress.Port == _nodes[1].Port)); } diff --git a/src/Nethermind/Nethermind.Network.Test/P2P/Subprotocols/Eth/V62/Eth62ProtocolHandlerTests.cs b/src/Nethermind/Nethermind.Network.Test/P2P/Subprotocols/Eth/V62/Eth62ProtocolHandlerTests.cs index 87bb693219ec..d409db422fd2 100644 --- a/src/Nethermind/Nethermind.Network.Test/P2P/Subprotocols/Eth/V62/Eth62ProtocolHandlerTests.cs +++ b/src/Nethermind/Nethermind.Network.Test/P2P/Subprotocols/Eth/V62/Eth62ProtocolHandlerTests.cs @@ -617,7 +617,8 @@ public void should_send_single_transaction_even_if_exceed_MaxPacketSize(int data _handler.SendNewTransactions(txs); - _session.Received(messagesCount).DeliverMessage(Arg.Is(m => m.Transactions.Count == numberOfTxsInOneMsg || m.Transactions.Count == nonFullMsgTxsCount)); + Assert.That(() => _session.ReceivedCallsMatching(s => s.DeliverMessage(Arg.Is(m => m.Transactions.Count == numberOfTxsInOneMsg || m.Transactions.Count == nonFullMsgTxsCount)), messagesCount), Is.True.After(500, 50)); + } private void HandleZeroMessage(T msg, int messageCode) where T : MessageBase diff --git a/src/Nethermind/Nethermind.Network.Test/PeerManagerTests.cs b/src/Nethermind/Nethermind.Network.Test/PeerManagerTests.cs index 5a15c5b00e11..2330957538e1 100644 --- a/src/Nethermind/Nethermind.Network.Test/PeerManagerTests.cs +++ b/src/Nethermind/Nethermind.Network.Test/PeerManagerTests.cs @@ -78,8 +78,7 @@ public async Task Will_connect_to_a_candidate_node() ctx.SetupPersistedPeers(1); ctx.PeerPool.Start(); ctx.PeerManager.Start(); - await Task.Delay(_travisDelay); - Assert.That(ctx.RlpxPeer.ConnectAsyncCallsCount, Is.EqualTo(1)); + Assert.That(() => ctx.RlpxPeer.ConnectAsyncCallsCount, Is.EqualTo(1).After(_travisDelay, 10)); } [Test, Retry(3)] @@ -305,8 +304,7 @@ public async Task Ok_if_fails_to_connect() ctx.PeerPool.Start(); ctx.PeerManager.Start(); - await Task.Delay(_travisDelay); - Assert.That(ctx.PeerManager.ActivePeers.Count, Is.EqualTo(0)); + Assert.That(() => ctx.PeerManager.ActivePeers.Count, Is.EqualTo(0).After(_travisDelay, 10)); } [Test, Retry(3)] @@ -351,8 +349,7 @@ public async Task Will_fill_up_over_and_over_again_on_newly_discovered() for (int i = 0; i < 10; i++) { ctx.DiscoverNew(25); - await Task.Delay(_travisDelay); - Assert.That(ctx.PeerManager.ActivePeers.Count, Is.EqualTo(25)); + Assert.That(() => ctx.PeerManager.ActivePeers.Count, Is.EqualTo(25).After(_travisDelay, 10)); } } @@ -411,8 +408,7 @@ public async Task IfPeerAdded_with_invalid_chain_then_do_not_connect() ctx.PeerPool.GetOrAdd(networkNode); - await Task.Delay(_travisDelay); - ctx.PeerPool.ActivePeers.Count.Should().Be(0); + Assert.That(() => ctx.PeerPool.ActivePeers.Count, Is.EqualTo(0).After(_travisDelay, 10)); } private readonly int _travisDelay = 500; @@ -432,8 +428,7 @@ public async Task Will_fill_up_with_incoming_over_and_over_again_on_disconnects( for (int i = 0; i < 10; i++) { ctx.CreateNewIncomingSessions(25); - await Task.Delay(_travisDelay); - Assert.That(ctx.PeerManager.ActivePeers.Count, Is.EqualTo(25)); + Assert.That(() => ctx.PeerManager.ActivePeers.Count, Is.EqualTo(25).After(_travisDelay, 10)); } } @@ -550,8 +545,7 @@ public async Task Will_load_static_nodes_and_connect_to_them() ctx.TestNodeSource.AddNode(new Node(TestItem.PublicKeyA, node.Host, node.Port)); } - await Task.Delay(_travisDelay); - ctx.PeerManager.ActivePeers.Count(static p => p.Node.IsStatic).Should().Be(nodesCount); + Assert.That(() => ctx.PeerManager.ActivePeers.Count(static p => p.Node.IsStatic), Is.EqualTo(nodesCount).After(_travisDelay, 10)); } [Test, Retry(5)] @@ -618,8 +612,7 @@ public async Task RemovePeer_should_fail_if_peer_not_added() ctx.PeerPool.Start(); ctx.PeerManager.Start(); var node = new NetworkNode(ctx.GenerateEnode()); - await Task.Delay(_travisDelay); - ctx.PeerPool.TryRemove(node.NodeId, out _).Should().BeFalse(); + Assert.That(() => ctx.PeerPool.TryRemove(node.NodeId, out _), Is.False.After(_travisDelay, 10)); } private class Context : IAsyncDisposable diff --git a/src/Nethermind/Nethermind.Network/NetworkNodeDecoder.cs b/src/Nethermind/Nethermind.Network/NetworkNodeDecoder.cs index c9654dbd9f8b..9b08784346a2 100644 --- a/src/Nethermind/Nethermind.Network/NetworkNodeDecoder.cs +++ b/src/Nethermind/Nethermind.Network/NetworkNodeDecoder.cs @@ -10,7 +10,7 @@ namespace Nethermind.Network { - public class NetworkNodeDecoder : IRlpStreamDecoder, IRlpObjectDecoder + public sealed class NetworkNodeDecoder : RlpStreamDecoder, IRlpObjectDecoder { private static readonly RlpLimit RlpLimit = RlpLimit.For((int)1.KiB(), nameof(NetworkNode.HostIp)); @@ -19,7 +19,7 @@ static NetworkNodeDecoder() Rlp.RegisterDecoder(typeof(NetworkNode), new NetworkNodeDecoder()); } - public NetworkNode Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override NetworkNode DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { rlpStream.ReadSequenceLength(); @@ -41,7 +41,7 @@ public NetworkNode Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBe return networkNode; } - public void Encode(RlpStream stream, NetworkNode item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, NetworkNode item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int contentLength = GetContentLength(item, rlpBehaviors); stream.StartSequence(contentLength); @@ -70,7 +70,7 @@ public void Encode(MemoryStream stream, NetworkNode item, RlpBehaviors rlpBehavi throw new NotImplementedException(); } - public int GetLength(NetworkNode item, RlpBehaviors rlpBehaviors) + public override int GetLength(NetworkNode item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Network/P2P/Subprotocols/Eth/V69/Messages/ReceiptMessageDecoder69.cs b/src/Nethermind/Nethermind.Network/P2P/Subprotocols/Eth/V69/Messages/ReceiptMessageDecoder69.cs index 578cbd42dc97..0920e9499136 100644 --- a/src/Nethermind/Nethermind.Network/P2P/Subprotocols/Eth/V69/Messages/ReceiptMessageDecoder69.cs +++ b/src/Nethermind/Nethermind.Network/P2P/Subprotocols/Eth/V69/Messages/ReceiptMessageDecoder69.cs @@ -10,9 +10,9 @@ namespace Nethermind.Network.P2P.Subprotocols.Eth.V69.Messages; [Rlp.SkipGlobalRegistration] // Created explicitly -public class ReceiptMessageDecoder69(bool skipStateAndStatus = false) : IRlpStreamDecoder, IRlpValueDecoder +public sealed class ReceiptMessageDecoder69(bool skipStateAndStatus = false) : RlpValueDecoder { - public TxReceipt? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TxReceipt? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { Span span = rlpStream.PeekNextItem(); Rlp.ValueDecoderContext ctx = new(span); @@ -22,7 +22,7 @@ public class ReceiptMessageDecoder69(bool skipStateAndStatus = false) : IRlpStre return response; } - public TxReceipt? Decode(ref Rlp.ValueDecoderContext ctx, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TxReceipt? DecodeInternal(ref Rlp.ValueDecoderContext ctx, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (ctx.IsNextItemNull()) { @@ -104,13 +104,13 @@ private static int GetLogsLength(TxReceipt item) return logsLength; } - public int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) + public override int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { (int total, _) = GetContentLength(item, rlpBehaviors); return Rlp.LengthOfSequence(total); } - public void Encode(RlpStream rlpStream, TxReceipt? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream rlpStream, TxReceipt? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { diff --git a/src/Nethermind/Nethermind.Network/Rlpx/Handshake/AckMessageSerializer.cs b/src/Nethermind/Nethermind.Network/Rlpx/Handshake/AckMessageSerializer.cs index 27190620f79d..ea9c54eb8c1f 100644 --- a/src/Nethermind/Nethermind.Network/Rlpx/Handshake/AckMessageSerializer.cs +++ b/src/Nethermind/Nethermind.Network/Rlpx/Handshake/AckMessageSerializer.cs @@ -21,12 +21,9 @@ public class AckMessageSerializer : IZeroMessageSerializer public void Serialize(IByteBuffer byteBuffer, AckMessage msg) { byteBuffer.EnsureWritable(TotalLength); - // TODO: find a way to now allocate this here - byte[] data = new byte[TotalLength]; - Buffer.BlockCopy(msg.EphemeralPublicKey.Bytes, 0, data, EphemeralPublicKeyOffset, EphemeralPublicKeyLength); - Buffer.BlockCopy(msg.Nonce, 0, data, NonceOffset, NonceLength); - data[IsTokenUsedOffset] = msg.IsTokenUsed ? (byte)0x01 : (byte)0x00; - byteBuffer.WriteBytes(data); + byteBuffer.WriteBytes(msg.EphemeralPublicKey.Bytes); + byteBuffer.WriteBytes(msg.Nonce); + byteBuffer.WriteByte(msg.IsTokenUsed ? (byte)0x01 : (byte)0x00); } public AckMessage Deserialize(IByteBuffer msgBytes) diff --git a/src/Nethermind/Nethermind.Optimism.Test/ReceiptDecoderTests.cs b/src/Nethermind/Nethermind.Optimism.Test/ReceiptDecoderTests.cs index 37e1a5e4df79..1ece15c4c294 100644 --- a/src/Nethermind/Nethermind.Optimism.Test/ReceiptDecoderTests.cs +++ b/src/Nethermind/Nethermind.Optimism.Test/ReceiptDecoderTests.cs @@ -16,7 +16,7 @@ public void Test_tx_network_form_receipts_properly_encoded_for_trie(byte[] rlp, static OptimismTxReceipt TestNetworkEncodingRoundTrip(byte[] rlp, bool includesNonce, bool includesVersion) { OptimismReceiptMessageDecoder decoder = new(); - OptimismTxReceipt decodedReceipt = decoder.Decode(new RlpStream(rlp), RlpBehaviors.SkipTypedWrapping); + OptimismTxReceipt decodedReceipt = (OptimismTxReceipt)decoder.Decode(new RlpStream(rlp), RlpBehaviors.SkipTypedWrapping); RlpStream encodedRlp = new(decoder.GetLength(decodedReceipt, RlpBehaviors.SkipTypedWrapping)); decoder.Encode(encodedRlp, decodedReceipt, RlpBehaviors.SkipTypedWrapping); @@ -67,7 +67,7 @@ static void TestTrieEncoding(OptimismTxReceipt decodedReceipt, bool shouldInclud trieDecoder.Encode(encodedTrieRlp, decodedReceipt, RlpBehaviors.SkipTypedWrapping); encodedTrieRlp.Position = 0; - OptimismTxReceipt decodedTrieReceipt = trieDecoder.Decode(encodedTrieRlp, RlpBehaviors.SkipTypedWrapping); + OptimismTxReceipt decodedTrieReceipt = (OptimismTxReceipt)trieDecoder.Decode(encodedTrieRlp, RlpBehaviors.SkipTypedWrapping); Assert.Multiple(() => { diff --git a/src/Nethermind/Nethermind.Optimism/OptimismReceiptMessageDecoder.cs b/src/Nethermind/Nethermind.Optimism/OptimismReceiptMessageDecoder.cs index 89d983442eca..dfb4dbb60df7 100644 --- a/src/Nethermind/Nethermind.Optimism/OptimismReceiptMessageDecoder.cs +++ b/src/Nethermind/Nethermind.Optimism/OptimismReceiptMessageDecoder.cs @@ -11,13 +11,13 @@ namespace Nethermind.Optimism; [Rlp.Decoder(RlpDecoderKey.Trie)] -public class OptimismReceiptTrieDecoder() : OptimismReceiptMessageDecoder(true); +public sealed class OptimismReceiptTrieDecoder() : OptimismReceiptMessageDecoder(true); [Rlp.Decoder] -public class OptimismReceiptMessageDecoder(bool isEncodedForTrie = false, bool skipStateAndStatus = false) : IRlpStreamDecoder +public class OptimismReceiptMessageDecoder(bool isEncodedForTrie = false, bool skipStateAndStatus = false) : RlpStreamDecoder { private readonly bool _skipStateAndStatus = skipStateAndStatus; - public OptimismTxReceipt Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override OptimismTxReceipt DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { OptimismTxReceipt txReceipt = new(); if (!rlpStream.IsSequenceNext()) @@ -126,7 +126,7 @@ public static int GetLogsLength(TxReceipt item) /// /// https://eips.ethereum.org/EIPS/eip-2718 /// - public int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) + public override int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) { (int total, _) = GetContentLength(item, rlpBehaviors); int receiptPayloadLength = Rlp.LengthOfSequence(total); @@ -140,7 +140,7 @@ public int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) return result; } - public void Encode(RlpStream rlpStream, TxReceipt item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream rlpStream, TxReceipt item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -189,11 +189,6 @@ public void Encode(RlpStream rlpStream, TxReceipt item, RlpBehaviors rlpBehavior } } } - - TxReceipt IRlpStreamDecoder.Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors) - { - return Decode(rlpStream, rlpBehaviors); - } } internal static class TxReceiptExt diff --git a/src/Nethermind/Nethermind.Runner/configs/base-mainnet.json b/src/Nethermind/Nethermind.Runner/configs/base-mainnet.json index fd8d2ac609ec..b58a1363b576 100644 --- a/src/Nethermind/Nethermind.Runner/configs/base-mainnet.json +++ b/src/Nethermind/Nethermind.Runner/configs/base-mainnet.json @@ -13,8 +13,8 @@ "FastSync": true, "SnapSync": true, "FastSyncCatchUpHeightDelta": "10000000000", - "PivotNumber": 37310000, - "PivotHash": "0x6914684fefc777f69ee0ff75937ae5aeb0f8713ad9a3401ca65b5da2bc15d268" + "PivotNumber": 37610000, + "PivotHash": "0x2723707e1dc408199fed9010a6d5d70728286503d4d9d0c40139197536d9f26a" }, "Discovery": { "DiscoveryVersion": "V5" diff --git a/src/Nethermind/Nethermind.Runner/configs/base-sepolia.json b/src/Nethermind/Nethermind.Runner/configs/base-sepolia.json index c21fd84419d4..3110dfc1c41e 100644 --- a/src/Nethermind/Nethermind.Runner/configs/base-sepolia.json +++ b/src/Nethermind/Nethermind.Runner/configs/base-sepolia.json @@ -13,8 +13,8 @@ "FastSync": true, "SnapSync": true, "FastSyncCatchUpHeightDelta": "10000000000", - "PivotNumber": 32820000, - "PivotHash": "0xd9097a4f00e38b283e9af34f30c8dd7ff290332f63ec3a40a8f5000b8cab29ab" + "PivotNumber": 33120000, + "PivotHash": "0x0af1a0b85b44d3c90e92c70d6fe3d4ce439049b1140b456047630218dd364947" }, "Discovery": { "DiscoveryVersion": "V5" diff --git a/src/Nethermind/Nethermind.Runner/configs/chiado.json b/src/Nethermind/Nethermind.Runner/configs/chiado.json index 8fcd38ba486e..49d5078ae002 100644 --- a/src/Nethermind/Nethermind.Runner/configs/chiado.json +++ b/src/Nethermind/Nethermind.Runner/configs/chiado.json @@ -18,8 +18,8 @@ "Sync": { "FastSync": true, "SnapSync": true, - "PivotNumber": 18430000, - "PivotHash": "0x1502c72cda0ba5433ee8d5746b949dcab48660b3e1c28ca8dfbf6c7f4cb17a2c", + "PivotNumber": 18540000, + "PivotHash": "0x10d11866e0ccec8048793ed9e2802dfc5778b4de920429e68fd908ba5b870f75", "PivotTotalDifficulty": "231708131825107706987652208063906496124457284", "FastSyncCatchUpHeightDelta": 10000000000, "UseGethLimitsInFastBlocks": false diff --git a/src/Nethermind/Nethermind.Runner/configs/gnosis.json b/src/Nethermind/Nethermind.Runner/configs/gnosis.json index c52465595601..d7f94465007d 100644 --- a/src/Nethermind/Nethermind.Runner/configs/gnosis.json +++ b/src/Nethermind/Nethermind.Runner/configs/gnosis.json @@ -14,8 +14,8 @@ "Sync": { "FastSync": true, "SnapSync": true, - "PivotNumber": 42800000, - "PivotHash": "0xfe4205f86c14a6ac7183460eecbef5d78383019ff6257f7478fe83241e6b5070", + "PivotNumber": 42920000, + "PivotHash": "0x7251da26a4400cbca799c1484e56a51e823a8a8633d1906761f4d8e7b2657ff5", "PivotTotalDifficulty": "8626000110427538733349499292577475819600160930", "UseGethLimitsInFastBlocks": false, "FastSyncCatchUpHeightDelta": 10000000000, diff --git a/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.json b/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.json index d061f18fc6d5..0e154c68305a 100644 --- a/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.json +++ b/src/Nethermind/Nethermind.Runner/configs/joc-mainnet.json @@ -12,9 +12,9 @@ "Sync": { "FastSync": true, "SnapSync": true, - "PivotNumber": 20350000, - "PivotHash": "0x1322f952adf52f780a1f4042b50698ca2cbffe47a6c52c3ee8cfe45325939504", - "PivotTotalDifficulty": "37043030" + "PivotNumber": 20470000, + "PivotHash": "0xfc36a9482cf4f7d61db4ce5aa590ea3be9da33c7deed59b0d65b452793b8c87d", + "PivotTotalDifficulty": "37221457" }, "Metrics": { "NodeName": "JOC-Mainnet" diff --git a/src/Nethermind/Nethermind.Runner/configs/joc-testnet.json b/src/Nethermind/Nethermind.Runner/configs/joc-testnet.json index 5a26d1836576..d4c0dbc4898f 100644 --- a/src/Nethermind/Nethermind.Runner/configs/joc-testnet.json +++ b/src/Nethermind/Nethermind.Runner/configs/joc-testnet.json @@ -12,9 +12,9 @@ "Sync": { "FastSync": true, "SnapSync": true, - "PivotNumber": 13960000, - "PivotHash": "0x49b78a4bc2c1c2b973d928e142cd005fc660af2082d877923aecf373264153fa", - "PivotTotalDifficulty": "23415163" + "PivotNumber": 14080000, + "PivotHash": "0xf6f4974b7c1bdfac2bb0fb4f29c227685c749cd9d5288f113340f50a91ecd4ea", + "PivotTotalDifficulty": "23603193" }, "Metrics": { "NodeName": "JOC-Testnet" diff --git a/src/Nethermind/Nethermind.Runner/configs/linea-mainnet.json b/src/Nethermind/Nethermind.Runner/configs/linea-mainnet.json index b6a1fe0ab7c3..0a90e7a4e690 100644 --- a/src/Nethermind/Nethermind.Runner/configs/linea-mainnet.json +++ b/src/Nethermind/Nethermind.Runner/configs/linea-mainnet.json @@ -17,8 +17,8 @@ }, "Sync": { "SnapSync": true, - "PivotNumber": 24900000, - "PivotHash": "0x41545430031ba1fb54677ac7edaaa09c5718232ec455da9c149f3d63f033c80c", + "PivotNumber": 25160000, + "PivotHash": "0x4e6664f4a677cb6a89c4f22fcea19069bd7869fe636cf81a41f5ad2fec6574af", "PivotTotalDifficulty": "0", "HeaderStateDistance": 6 }, diff --git a/src/Nethermind/Nethermind.Runner/configs/linea-sepolia.json b/src/Nethermind/Nethermind.Runner/configs/linea-sepolia.json index 3c7ccf4ada35..5239b5d253de 100644 --- a/src/Nethermind/Nethermind.Runner/configs/linea-sepolia.json +++ b/src/Nethermind/Nethermind.Runner/configs/linea-sepolia.json @@ -17,8 +17,8 @@ }, "Sync": { "SnapSync": true, - "PivotNumber": 19890000, - "PivotHash": "0x8ccc7427b89aca77749fcb3f1c5777201e8e5950e4bb0a095909ab7d92873d9e", + "PivotNumber": 20190000, + "PivotHash": "0x927b4789e8e6c32a9a50d0666fea16b68830559cc85953c11fc325b221865cc9", "PivotTotalDifficulty": "37331807", "HeaderStateDistance": 6 }, diff --git a/src/Nethermind/Nethermind.Runner/configs/mainnet.json b/src/Nethermind/Nethermind.Runner/configs/mainnet.json index 888e464621a1..d7b4dbea6f44 100644 --- a/src/Nethermind/Nethermind.Runner/configs/mainnet.json +++ b/src/Nethermind/Nethermind.Runner/configs/mainnet.json @@ -10,8 +10,8 @@ "Sync": { "FastSync": true, "SnapSync": true, - "PivotNumber": 23657000, - "PivotHash": "0x9841197759955198a8726749a58082c579c08147f436d8f973c56fe82bb0b931", + "PivotNumber": 23707000, + "PivotHash": "0xc6b161ce092f229bae72d4354e2899aaa539e1b20711c61338071c0fc1a747c2", "PivotTotalDifficulty": "58750003716598352816469", "FastSyncCatchUpHeightDelta": "10000000000", "AncientReceiptsBarrier": 15537394, diff --git a/src/Nethermind/Nethermind.Runner/configs/op-mainnet.json b/src/Nethermind/Nethermind.Runner/configs/op-mainnet.json index 1b9888229448..3c8281dddeb6 100644 --- a/src/Nethermind/Nethermind.Runner/configs/op-mainnet.json +++ b/src/Nethermind/Nethermind.Runner/configs/op-mainnet.json @@ -15,8 +15,8 @@ "FastSyncCatchUpHeightDelta": "10000000000", "AncientBodiesBarrier": 105235063, "AncientReceiptsBarrier": 105235063, - "PivotNumber": 142910000, - "PivotHash": "0x0bb18551efe5c041345ae90cd3e86f3f9a1ff8d1022b9faf617010867c84994b" + "PivotNumber": 143210000, + "PivotHash": "0x69235193f94a0938beb6529cba251d7d23a91902e6a40dab69603cc431695288" }, "Discovery": { "DiscoveryVersion": "V5" diff --git a/src/Nethermind/Nethermind.Runner/configs/op-sepolia.json b/src/Nethermind/Nethermind.Runner/configs/op-sepolia.json index ac81375ccf85..a910f49efd59 100644 --- a/src/Nethermind/Nethermind.Runner/configs/op-sepolia.json +++ b/src/Nethermind/Nethermind.Runner/configs/op-sepolia.json @@ -13,8 +13,8 @@ "FastSync": true, "SnapSync": true, "FastSyncCatchUpHeightDelta": "10000000000", - "PivotNumber": 34800000, - "PivotHash": "0xe1682ee31297d2d1c8431a3ba2e9fba56ad95e2b9533f8d327095fd3d080a926" + "PivotNumber": 35110000, + "PivotHash": "0x0b0b729947d683e7bc6384ff18f16cfc501bc0b6ee863bfefd99c85dd7e32e6a" }, "Discovery": { "DiscoveryVersion": "V5" diff --git a/src/Nethermind/Nethermind.Runner/configs/sepolia.json b/src/Nethermind/Nethermind.Runner/configs/sepolia.json index ba158eff855e..60dfc50382c6 100644 --- a/src/Nethermind/Nethermind.Runner/configs/sepolia.json +++ b/src/Nethermind/Nethermind.Runner/configs/sepolia.json @@ -17,8 +17,8 @@ "FastSync": true, "SnapSync": true, "UseGethLimitsInFastBlocks": true, - "PivotNumber": 9489000, - "PivotHash": "0x0701715fe2509f8a91b39b64ec85eec8aeba14dce5dfca1a04a492962bc32198", + "PivotNumber": 9539000, + "PivotHash": "0xd3ec641ed35ac55726db6cf1a28a4ff57daf4cee21767505b48fc68204dfb5c1", "PivotTotalDifficulty": "17000018015853232", "FastSyncCatchUpHeightDelta": 10000000000, "AncientReceiptsBarrier": 1450409, diff --git a/src/Nethermind/Nethermind.Runner/configs/worldchain-mainnet.json b/src/Nethermind/Nethermind.Runner/configs/worldchain-mainnet.json index 6884eb77e242..b0758650b0c0 100644 --- a/src/Nethermind/Nethermind.Runner/configs/worldchain-mainnet.json +++ b/src/Nethermind/Nethermind.Runner/configs/worldchain-mainnet.json @@ -13,8 +13,8 @@ "FastSync": true, "SnapSync": true, "FastSyncCatchUpHeightDelta": "10000000000", - "PivotNumber": 21040000, - "PivotHash": "0x14d35cdb573e4481eb718d15c1467d63118bfe9d30b83566a676d8c0247fc342" + "PivotNumber": 21340000, + "PivotHash": "0x443b64c4dd2871f7a98b2c803fc64fc093b853ce10bd07c6e1252408c55e34b0" }, "Discovery": { "DiscoveryVersion": "V5" diff --git a/src/Nethermind/Nethermind.Runner/configs/worldchain-sepolia.json b/src/Nethermind/Nethermind.Runner/configs/worldchain-sepolia.json index a938a000d049..fa5255ce8611 100644 --- a/src/Nethermind/Nethermind.Runner/configs/worldchain-sepolia.json +++ b/src/Nethermind/Nethermind.Runner/configs/worldchain-sepolia.json @@ -13,8 +13,8 @@ "FastSync": true, "SnapSync": true, "FastSyncCatchUpHeightDelta": "10000000000", - "PivotNumber": 20430000, - "PivotHash": "0xf74c53163dd35e1332ad5f4ad92240d0284b5802846684043b2296e3a11b42b0" + "PivotNumber": 20730000, + "PivotHash": "0x94651bad64b3c54df48057b1854658661ee2f982a23093f953300d0e63cfe5a9" }, "Discovery": { "DiscoveryVersion": "V5" diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/AccountDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/AccountDecoder.cs index 2e992b2443d2..ab7651dda751 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/AccountDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/AccountDecoder.cs @@ -7,7 +7,7 @@ namespace Nethermind.Serialization.Rlp { - public class AccountDecoder : IRlpObjectDecoder, IRlpStreamDecoder, IRlpValueDecoder + public sealed class AccountDecoder : RlpValueDecoder, IRlpObjectDecoder { private readonly bool _slimFormat; @@ -54,7 +54,7 @@ public Hash256 DecodeStorageRootOnly(ref Rlp.ValueDecoderContext context) return storageRoot; } - public Account? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Account? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int length = rlpStream.ReadSequenceLength(); if (length == 1) @@ -74,7 +74,7 @@ public Hash256 DecodeStorageRootOnly(ref Rlp.ValueDecoderContext context) return new(nonce, balance, storageRoot, codeHash); } - public void Encode(RlpStream stream, Account? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, Account? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -144,7 +144,7 @@ public int GetLength(Account[] accounts) return length; } - public int GetLength(Account? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override int GetLength(Account? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -234,7 +234,7 @@ private Hash256 DecodeCodeHash(RlpStream rlpStream) return codeHash; } - public Account? Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Account? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int length = decoderContext.ReadSequenceLength(); if (length == 1) diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/BasicStreamDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/BasicStreamDecoder.cs index 106413dbc446..c3cf4d93f67c 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/BasicStreamDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/BasicStreamDecoder.cs @@ -6,109 +6,109 @@ namespace Nethermind.Serialization.Rlp; // If any of these is triggered in prod, then something went wrong, coz these are fairly slow path. These are only // useful for easy tests. -public class ByteStreamDecoder : IRlpStreamDecoder +public sealed class ByteStreamDecoder : RlpStreamDecoder { - public int GetLength(byte item, RlpBehaviors rlpBehaviors) + public override int GetLength(byte item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOf(item); } - public byte Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override byte DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return rlpStream.DecodeByte(); } - public void Encode(RlpStream stream, byte item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, byte item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.Encode(item); } } -public class ShortStreamDecoder : IRlpStreamDecoder +public sealed class ShortStreamDecoder : RlpStreamDecoder { - public int GetLength(short item, RlpBehaviors rlpBehaviors) + public override int GetLength(short item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOf(item); } - public short Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override short DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return (short)rlpStream.DecodeLong(); } - public void Encode(RlpStream stream, short item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, short item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.Encode(item); } } -public class UShortStreamDecoder : IRlpStreamDecoder +public sealed class UShortStreamDecoder : RlpStreamDecoder { - public int GetLength(ushort item, RlpBehaviors rlpBehaviors) + public override int GetLength(ushort item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOf((long)item); } - public ushort Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override ushort DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return (ushort)rlpStream.DecodeLong(); } - public void Encode(RlpStream stream, ushort item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, ushort item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.Encode(item); } } -public class IntStreamDecoder : IRlpStreamDecoder +public sealed class IntStreamDecoder : RlpStreamDecoder { - public int GetLength(int item, RlpBehaviors rlpBehaviors) + public override int GetLength(int item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOf(item); } - public int Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override int DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return rlpStream.DecodeInt(); } - public void Encode(RlpStream stream, int item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, int item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.Encode(item); } } -public class UIntStreamDecoder : IRlpStreamDecoder +public sealed class UIntStreamDecoder : RlpStreamDecoder { - public int GetLength(uint item, RlpBehaviors rlpBehaviors) + public override int GetLength(uint item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOf((long)item); } - public uint Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override uint DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return rlpStream.DecodeUInt(); } - public void Encode(RlpStream stream, uint item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, uint item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.Encode(item); } } -public class ULongStreamDecoder : IRlpStreamDecoder +public sealed class ULongStreamDecoder : RlpStreamDecoder { - public int GetLength(ulong item, RlpBehaviors rlpBehaviors) + public override int GetLength(ulong item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOf(item); } - public ulong Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override ulong DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return rlpStream.DecodeUInt(); } - public void Encode(RlpStream stream, ulong item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, ulong item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.Encode(item); } diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/BlockBodyDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/BlockBodyDecoder.cs index 4bf4179fce24..b2287601a824 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/BlockBodyDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/BlockBodyDecoder.cs @@ -6,7 +6,7 @@ namespace Nethermind.Serialization.Rlp; -public class BlockBodyDecoder : IRlpValueDecoder, IRlpStreamDecoder +public sealed class BlockBodyDecoder : RlpValueDecoder { private readonly TxDecoder _txDecoder = TxDecoder.Instance; private readonly IHeaderDecoder _headerDecoder; @@ -21,7 +21,7 @@ public BlockBodyDecoder(IHeaderDecoder headerDecoder = null) _headerDecoder = headerDecoder ?? new HeaderDecoder(); } - public int GetLength(BlockBody item, RlpBehaviors rlpBehaviors) + public override int GetLength(BlockBody item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOfSequence(GetBodyLength(item)); } @@ -80,7 +80,7 @@ private int GetWithdrawalsLength(Withdrawal[] withdrawals) return sum; } - public BlockBody? Decode(ref Rlp.ValueDecoderContext ctx, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override BlockBody? DecodeInternal(ref Rlp.ValueDecoderContext ctx, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int sequenceLength = ctx.ReadSequenceLength(); int startingPosition = ctx.Position; @@ -106,7 +106,7 @@ private int GetWithdrawalsLength(Withdrawal[] withdrawals) return new BlockBody(transactions, uncles, withdrawals); } - public BlockBody Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override BlockBody DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { Span span = rlpStream.PeekNextItem(); Rlp.ValueDecoderContext ctx = new Rlp.ValueDecoderContext(span); @@ -116,7 +116,7 @@ public BlockBody Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBeha return response; } - public void Encode(RlpStream stream, BlockBody body, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, BlockBody body, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.StartSequence(GetBodyLength(body)); stream.StartSequence(GetTxLength(body.Transactions)); diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/BlockDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/BlockDecoder.cs index 55d42c6854a7..136035521590 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/BlockDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/BlockDecoder.cs @@ -7,14 +7,14 @@ namespace Nethermind.Serialization.Rlp { - public class BlockDecoder(IHeaderDecoder headerDecoder) : IRlpValueDecoder, IRlpStreamDecoder + public sealed class BlockDecoder(IHeaderDecoder headerDecoder) : RlpValueDecoder { private readonly IHeaderDecoder _headerDecoder = headerDecoder ?? throw new ArgumentNullException(nameof(headerDecoder)); private readonly BlockBodyDecoder _blockBodyDecoder = new BlockBodyDecoder(headerDecoder); public BlockDecoder() : this(new HeaderDecoder()) { } - public Block? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Block? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.Length == 0) { @@ -48,7 +48,7 @@ public BlockDecoder() : this(new HeaderDecoder()) { } return (contentLength, txs, uncles, withdrawals); } - public int GetLength(Block? item, RlpBehaviors rlpBehaviors) + public override int GetLength(Block? item, RlpBehaviors rlpBehaviors) { if (item is null) { @@ -58,7 +58,7 @@ public int GetLength(Block? item, RlpBehaviors rlpBehaviors) return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors).Total); } - public Block? Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Block? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) { @@ -92,7 +92,7 @@ public Rlp Encode(Block? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new(rlpStream.Data.ToArray()); } - public void Encode(RlpStream stream, Block? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, Block? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/BlockInfoDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/BlockInfoDecoder.cs index 69ee52db06c1..92cbb67ba098 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/BlockInfoDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/BlockInfoDecoder.cs @@ -7,11 +7,11 @@ namespace Nethermind.Serialization.Rlp { - public class BlockInfoDecoder : IRlpStreamDecoder, IRlpValueDecoder + public sealed class BlockInfoDecoder : RlpValueDecoder { public static BlockInfoDecoder Instance { get; } = new(); - public BlockInfo? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override BlockInfo? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -52,7 +52,7 @@ public class BlockInfoDecoder : IRlpStreamDecoder, IRlpValueDecoder, IRlpValueDecoder + public sealed class ChainLevelDecoder : RlpValueDecoder { - public ChainLevelInfo? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override ChainLevelInfo? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.Length == 0) { @@ -50,7 +50,7 @@ public class ChainLevelDecoder : IRlpStreamDecoder, IRlpValueDec return info; } - public void Encode(RlpStream stream, ChainLevelInfo? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, ChainLevelInfo? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -78,7 +78,7 @@ static void ThrowHasNull() => throw new InvalidOperationException($"{nameof(BlockInfo)} is null when encoding {nameof(ChainLevelInfo)}"); } - public ChainLevelInfo? Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override ChainLevelInfo? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) { @@ -127,7 +127,7 @@ private static int GetContentLength(ChainLevelInfo item, RlpBehaviors rlpBehavio return contentLength; } - public int GetLength(ChainLevelInfo? item, RlpBehaviors rlpBehaviors) + public override int GetLength(ChainLevelInfo? item, RlpBehaviors rlpBehaviors) { if (item is null) { diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/CompactReceiptStorageDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/CompactReceiptStorageDecoder.cs index b6dea59d6ecc..9deecdaf1e72 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/CompactReceiptStorageDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/CompactReceiptStorageDecoder.cs @@ -13,7 +13,7 @@ namespace Nethermind.Serialization.Rlp { [Decoder(RlpDecoderKey.Storage)] - public class CompactReceiptStorageDecoder : IRlpStreamDecoder, IRlpValueDecoder, IRlpObjectDecoder, IReceiptRefDecoder + public sealed class CompactReceiptStorageDecoder : RlpValueDecoder, IRlpObjectDecoder, IReceiptRefDecoder { public static readonly CompactReceiptStorageDecoder Instance = new(); @@ -21,7 +21,7 @@ public CompactReceiptStorageDecoder() { } - public TxReceipt? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TxReceipt? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -67,7 +67,7 @@ public CompactReceiptStorageDecoder() return txReceipt; } - public TxReceipt? Decode(ref Rlp.ValueDecoderContext decoderContext, + protected override TxReceipt? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) @@ -171,7 +171,7 @@ public Rlp Encode(TxReceipt item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream rlpStream, TxReceipt? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream rlpStream, TxReceipt? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -245,7 +245,7 @@ private static int GetLogsLength(TxReceipt item) return logsLength; } - public int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) + public override int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) { (int Total, _) = GetContentLength(item, rlpBehaviors); return Rlp.LengthOfSequence(Total); diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/Eip2930/AccessListDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/Eip2930/AccessListDecoder.cs index e61b35690cca..2556b482e275 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/Eip2930/AccessListDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/Eip2930/AccessListDecoder.cs @@ -7,7 +7,7 @@ namespace Nethermind.Serialization.Rlp.Eip2930 { - public class AccessListDecoder : IRlpStreamDecoder, IRlpValueDecoder + public sealed class AccessListDecoder : RlpValueDecoder { private const int IndexLength = 32; @@ -20,7 +20,7 @@ public class AccessListDecoder : IRlpStreamDecoder, IRlpValueDecode /// RLP serializable item and keep it as a compiled call available at runtime. /// It would be slightly slower but still much faster than what we would get from using dynamic serializers. /// - public AccessList? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override AccessList? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -78,7 +78,7 @@ public class AccessListDecoder : IRlpStreamDecoder, IRlpValueDecode /// Question to Lukasz here -> would it be fine to always use ValueDecoderContext only? /// I believe it cannot be done for the network items decoding and is only relevant for the DB loads. /// - public AccessList? Decode( + protected override AccessList? DecodeInternal( ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { @@ -132,7 +132,7 @@ public class AccessListDecoder : IRlpStreamDecoder, IRlpValueDecode return accessListBuilder.Build(); } - public void Encode(RlpStream stream, AccessList? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, AccessList? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -166,7 +166,7 @@ public void Encode(RlpStream stream, AccessList? item, RlpBehaviors rlpBehaviors } } - public int GetLength(AccessList? accessList, RlpBehaviors rlpBehaviors) + public override int GetLength(AccessList? accessList, RlpBehaviors rlpBehaviors) { if (accessList is null) { diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/Eip7702/AuthorizationTupleDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/Eip7702/AuthorizationTupleDecoder.cs index 9557c6f29354..9ab45209ba1c 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/Eip7702/AuthorizationTupleDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/Eip7702/AuthorizationTupleDecoder.cs @@ -9,11 +9,11 @@ namespace Nethermind.Serialization.Rlp; -public class AuthorizationTupleDecoder : IRlpStreamDecoder, IRlpValueDecoder +public sealed class AuthorizationTupleDecoder : RlpValueDecoder { public static readonly AuthorizationTupleDecoder Instance = new(); - public AuthorizationTuple Decode(RlpStream stream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override AuthorizationTuple DecodeInternal(RlpStream stream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int length = stream.ReadSequenceLength(); int check = length + stream.Position; @@ -37,7 +37,7 @@ public AuthorizationTuple Decode(RlpStream stream, RlpBehaviors rlpBehaviors = R return new AuthorizationTuple(chainId, codeAddress, nonce, yParity, r, s); } - public AuthorizationTuple Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override AuthorizationTuple DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int length = decoderContext.ReadSequenceLength(); int check = length + decoderContext.Position; @@ -68,7 +68,7 @@ public RlpStream Encode(AuthorizationTuple item, RlpBehaviors rlpBehaviors = Rlp return stream; } - public void Encode(RlpStream stream, AuthorizationTuple item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, AuthorizationTuple item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { int contentLength = GetContentLength(item); stream.StartSequence(contentLength); @@ -89,7 +89,7 @@ public static void EncodeWithoutSignature(RlpStream stream, UInt256 chainId, Add stream.Encode(nonce); } - public int GetLength(AuthorizationTuple item, RlpBehaviors rlpBehaviors) => Rlp.LengthOfSequence(GetContentLength(item)); + public override int GetLength(AuthorizationTuple item, RlpBehaviors rlpBehaviors) => Rlp.LengthOfSequence(GetContentLength(item)); private static int GetContentLength(AuthorizationTuple tuple) => GetContentLengthWithoutSig(tuple.ChainId, tuple.CodeAddress, tuple.Nonce) diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs index e4e824bfddf7..6a7164d46b92 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/HeaderDecoder.cs @@ -11,11 +11,11 @@ namespace Nethermind.Serialization.Rlp public interface IHeaderDecoder : IBlockHeaderDecoder { } public interface IBlockHeaderDecoder : IRlpValueDecoder, IRlpStreamDecoder where T : BlockHeader { } - public class HeaderDecoder : IHeaderDecoder + public sealed class HeaderDecoder : RlpValueDecoder, IHeaderDecoder { public const int NonceLength = 8; - public BlockHeader? Decode(ref Rlp.ValueDecoderContext decoderContext, + protected override BlockHeader? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) @@ -85,7 +85,7 @@ public class HeaderDecoder : IHeaderDecoder return blockHeader; } - public BlockHeader? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override BlockHeader? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -155,7 +155,7 @@ public class HeaderDecoder : IHeaderDecoder return blockHeader; } - public void Encode(RlpStream rlpStream, BlockHeader? header, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream rlpStream, BlockHeader? header, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (header is null) { @@ -289,7 +289,7 @@ private static int GetContentLength(BlockHeader? item, RlpBehaviors rlpBehaviors return contentLength; } - public int GetLength(BlockHeader? item, RlpBehaviors rlpBehaviors) + public override int GetLength(BlockHeader? item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/IRlpDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/IRlpDecoder.cs index 4895b9e46d27..d8c508e93769 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/IRlpDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/IRlpDecoder.cs @@ -2,6 +2,8 @@ // SPDX-License-Identifier: LGPL-3.0-only using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace Nethermind.Serialization.Rlp { @@ -11,7 +13,7 @@ public interface IRlpDecoder public interface IRlpDecoder : IRlpDecoder { - int GetLength(T item, RlpBehaviors rlpBehaviors); + int GetLength(T item, RlpBehaviors rlpBehaviors = RlpBehaviors.None); } public interface IRlpStreamDecoder : IRlpDecoder @@ -38,4 +40,51 @@ public static T Decode(this IRlpValueDecoder decoder, ReadOnlySpan b return decoder.Decode(ref context, rlpBehaviors); } } + + public abstract class RlpStreamDecoder : IRlpStreamDecoder + { + public abstract int GetLength(T item, RlpBehaviors rlpBehaviors = RlpBehaviors.None); + + public T Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + { + try + { + return DecodeInternal(rlpStream, rlpBehaviors); + } + catch (Exception e) when (e is IndexOutOfRangeException or ArgumentOutOfRangeException) + { + ThrowRlpException(e); + return default; + } + } + + [DoesNotReturn] + [StackTraceHidden] + protected static void ThrowRlpException(Exception exception) + { + throw new RlpException($"Cannot decode stream of {nameof(T)}", exception); + } + + protected abstract T DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None); + + public abstract void Encode(RlpStream stream, T item, RlpBehaviors rlpBehaviors = RlpBehaviors.None); + } + + public abstract class RlpValueDecoder : RlpStreamDecoder, IRlpValueDecoder + { + public T Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + { + try + { + return DecodeInternal(ref decoderContext, rlpBehaviors); + } + catch (Exception e) when (e is IndexOutOfRangeException or ArgumentOutOfRangeException) + { + ThrowRlpException(e); + return default; + } + } + + protected abstract T DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None); + } } diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/KeccakDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/KeccakDecoder.cs index 89dd7e564860..90d78edc2f3b 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/KeccakDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/KeccakDecoder.cs @@ -5,14 +5,19 @@ namespace Nethermind.Serialization.Rlp { - public class KeccakDecoder : IRlpValueDecoder + public sealed class KeccakDecoder : RlpValueDecoder { public static readonly KeccakDecoder Instance = new(); - public Hash256? Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) => decoderContext.DecodeKeccak(); + protected override Hash256? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) => decoderContext.DecodeKeccak(); - public static Rlp Encode(Hash256 item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) => Rlp.Encode(item); + protected override Hash256? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) => rlpStream.DecodeKeccak(); - public int GetLength(Hash256 item, RlpBehaviors rlpBehaviors) => Rlp.LengthOf(item); + public override int GetLength(Hash256 item, RlpBehaviors rlpBehaviors) => Rlp.LengthOf(item); + + public override void Encode(RlpStream stream, Hash256 item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + { + stream.Encode(item); + } } } diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/LogEntryDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/LogEntryDecoder.cs index 7fc7be2d202b..966b5f9efdb1 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/LogEntryDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/LogEntryDecoder.cs @@ -7,11 +7,11 @@ namespace Nethermind.Serialization.Rlp { - public class LogEntryDecoder : IRlpStreamDecoder, IRlpValueDecoder + public sealed class LogEntryDecoder : RlpValueDecoder { public static LogEntryDecoder Instance { get; } = new(); - public LogEntry? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override LogEntry? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -33,7 +33,7 @@ public class LogEntryDecoder : IRlpStreamDecoder, IRlpValueDecoder +public sealed class ReceiptArrayStorageDecoder(bool compactEncoding = true) : RlpStreamDecoder { public static readonly ReceiptArrayStorageDecoder Instance = new(); @@ -20,7 +20,7 @@ public class ReceiptArrayStorageDecoder(bool compactEncoding = true) : IRlpStrea public const int CompactEncoding = 127; - public int GetLength(TxReceipt[] items, RlpBehaviors rlpBehaviors) + public override int GetLength(TxReceipt[] items, RlpBehaviors rlpBehaviors) { if (items is null || items.Length == 0) { @@ -59,7 +59,7 @@ private int GetContentLength(TxReceipt[] items, RlpBehaviors rlpBehaviors) } } - public TxReceipt[] Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TxReceipt[] DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.PeekByte() == CompactEncoding) { @@ -72,7 +72,7 @@ public TxReceipt[] Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBe } } - public void Encode(RlpStream stream, TxReceipt[] items, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, TxReceipt[] items, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (items is null || items.Length == 0) { diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptMessageDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptMessageDecoder.cs index c6330d11746e..dc25bc96d35e 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptMessageDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptMessageDecoder.cs @@ -10,7 +10,7 @@ namespace Nethermind.Serialization.Rlp { [Rlp.Decoder(RlpDecoderKey.Default)] [Rlp.Decoder(RlpDecoderKey.Trie)] - public class ReceiptMessageDecoder : IRlpStreamDecoder, IRlpValueDecoder + public sealed class ReceiptMessageDecoder : RlpValueDecoder { private readonly bool _skipStateAndStatus; @@ -18,7 +18,7 @@ public ReceiptMessageDecoder(bool skipStateAndStatus = false) { _skipStateAndStatus = skipStateAndStatus; } - public TxReceipt Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TxReceipt DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { Span span = rlpStream.PeekNextItem(); Rlp.ValueDecoderContext ctx = new Rlp.ValueDecoderContext(span); @@ -28,7 +28,7 @@ public TxReceipt Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBeha return response; } - public TxReceipt Decode(ref Rlp.ValueDecoderContext ctx, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TxReceipt DecodeInternal(ref Rlp.ValueDecoderContext ctx, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (ctx.IsNextItemNull()) { @@ -115,7 +115,7 @@ private static int GetLogsLength(TxReceipt item) /// /// https://eips.ethereum.org/EIPS/eip-2718 /// - public int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) + public override int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) { (int Total, _) = GetContentLength(item, rlpBehaviors); int receiptPayloadLength = Rlp.LengthOfSequence(Total); @@ -142,7 +142,7 @@ public byte[] EncodeNew(TxReceipt? item, RlpBehaviors rlpBehaviors = RlpBehavior return stream.Data.ToArray(); } - public void Encode(RlpStream rlpStream, TxReceipt item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream rlpStream, TxReceipt item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptStorageDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptStorageDecoder.cs index 655dadabfcf8..d6673d1a089b 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptStorageDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/ReceiptStorageDecoder.cs @@ -11,7 +11,7 @@ namespace Nethermind.Serialization.Rlp { [Rlp.Decoder(RlpDecoderKey.LegacyStorage)] - public class ReceiptStorageDecoder : IRlpStreamDecoder, IRlpValueDecoder, IRlpObjectDecoder, IReceiptRefDecoder + public sealed class ReceiptStorageDecoder : RlpValueDecoder, IRlpObjectDecoder, IReceiptRefDecoder { private readonly bool _supportTxHash; private const byte MarkTxHashByte = 255; @@ -26,7 +26,7 @@ public ReceiptStorageDecoder() : this(true) { } - public TxReceipt? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TxReceipt? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -100,7 +100,7 @@ public ReceiptStorageDecoder() : this(true) return txReceipt; } - public TxReceipt? Decode(ref Rlp.ValueDecoderContext decoderContext, + protected override TxReceipt? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) @@ -182,7 +182,7 @@ public Rlp Encode(TxReceipt item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream rlpStream, TxReceipt? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream rlpStream, TxReceipt? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -319,7 +319,7 @@ private static int GetLogsLength(TxReceipt item) /// /// https://eips.ethereum.org/EIPS/eip-2718 /// - public int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) + public override int GetLength(TxReceipt item, RlpBehaviors rlpBehaviors) { (int Total, _) = GetContentLength(item, rlpBehaviors); int receiptPayloadLength = Rlp.LengthOfSequence(Total); diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/TxDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/TxDecoder.cs index 082cbcc3bd92..bf3174dd9a74 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/TxDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/TxDecoder.cs @@ -29,7 +29,7 @@ static TxDecoder() public sealed class SystemTxDecoder : TxDecoder; public sealed class GeneratedTxDecoder : TxDecoder; -public class TxDecoder : IRlpStreamDecoder, IRlpValueDecoder where T : Transaction, new() +public class TxDecoder : RlpValueDecoder where T : Transaction, new() { private readonly ITxDecoder?[] _decoders = new ITxDecoder?[Transaction.MaxTxType + 1]; @@ -45,7 +45,7 @@ protected TxDecoder(Func? transactionFactory = null) public void RegisterDecoder(ITxDecoder decoder) => _decoders[(int)decoder.Type] = decoder; - public T? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override T? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { static void ThrowIfLegacy(TxType txType1) { @@ -88,7 +88,7 @@ private ITxDecoder GetDecoder(TxType txType) => ? decoder : throw new RlpException($"Unknown transaction type {txType}") { Data = { { "txType", txType } } }; - public T? Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override T? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { T transaction = null; Decode(ref decoderContext, ref transaction, rlpBehaviors); @@ -131,6 +131,11 @@ public void Decode(ref Rlp.ValueDecoderContext decoderContext, ref T? transactio GetDecoder(txType).Decode(ref Unsafe.As(ref transaction), txSequenceStart, transactionSequence, ref decoderContext, rlpBehaviors); } + public override void Encode(RlpStream stream, T? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + { + EncodeTx(stream, item, rlpBehaviors, forSigning: false, isEip155Enabled: false, chainId: 0); + } + public Rlp Encode(T item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { RlpStream rlpStream = new(GetLength(item, rlpBehaviors)); @@ -138,11 +143,6 @@ public Rlp Encode(T item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new Rlp(rlpStream.Data.ToArray() ?? []); } - public void Encode(RlpStream stream, T? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) - { - EncodeTx(stream, item, rlpBehaviors, forSigning: false, isEip155Enabled: false, chainId: 0); - } - public Rlp EncodeTx(T? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None, bool forSigning = false, bool isEip155Enabled = false, ulong chainId = 0) { RlpStream rlpStream = new(GetLength(item, rlpBehaviors, forSigning, isEip155Enabled, chainId)); @@ -153,7 +153,7 @@ public Rlp EncodeTx(T? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None, bool /// /// https://eips.ethereum.org/EIPS/eip-2718 /// - public int GetLength(T tx, RlpBehaviors rlpBehaviors) => GetLength(tx, rlpBehaviors, forSigning: false, isEip155Enabled: false, chainId: 0); + public override int GetLength(T tx, RlpBehaviors rlpBehaviors) => GetLength(tx, rlpBehaviors, forSigning: false, isEip155Enabled: false, chainId: 0); public void EncodeTx(RlpStream stream, T? item, RlpBehaviors rlpBehaviors, bool forSigning, bool isEip155Enabled, ulong chainId) { diff --git a/src/Nethermind/Nethermind.Serialization.Rlp/WithdrawalDecoder.cs b/src/Nethermind/Nethermind.Serialization.Rlp/WithdrawalDecoder.cs index 6ddd0e6a6009..d70984bb7e71 100644 --- a/src/Nethermind/Nethermind.Serialization.Rlp/WithdrawalDecoder.cs +++ b/src/Nethermind/Nethermind.Serialization.Rlp/WithdrawalDecoder.cs @@ -5,9 +5,9 @@ namespace Nethermind.Serialization.Rlp; -public class WithdrawalDecoder : IRlpStreamDecoder, IRlpValueDecoder +public sealed class WithdrawalDecoder : RlpValueDecoder { - public Withdrawal? Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Withdrawal? DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) { @@ -27,7 +27,7 @@ public class WithdrawalDecoder : IRlpStreamDecoder, IRlpValueDecoder }; } - public Withdrawal? Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Withdrawal? DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) { @@ -47,7 +47,7 @@ public class WithdrawalDecoder : IRlpStreamDecoder, IRlpValueDecoder }; } - public void Encode(RlpStream stream, Withdrawal? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, Withdrawal? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -79,5 +79,5 @@ private static int GetContentLength(Withdrawal item) => Rlp.LengthOfAddressRlp + Rlp.LengthOf(item.AmountInGwei); - public int GetLength(Withdrawal item, RlpBehaviors _) => Rlp.LengthOfSequence(GetContentLength(item)); + public override int GetLength(Withdrawal item, RlpBehaviors _) => Rlp.LengthOfSequence(GetContentLength(item)); } diff --git a/src/Nethermind/Nethermind.Shutter.Test/ShutterIntegrationTests.cs b/src/Nethermind/Nethermind.Shutter.Test/ShutterIntegrationTests.cs index fede30d6d11a..81c18d20d89a 100644 --- a/src/Nethermind/Nethermind.Shutter.Test/ShutterIntegrationTests.cs +++ b/src/Nethermind/Nethermind.Shutter.Test/ShutterIntegrationTests.cs @@ -38,7 +38,7 @@ public async Task Can_load_when_previous_block_arrives_late() // keys arrive 5 seconds before slot start // waits for previous block to timeout then loads txs - chain.Api!.AdvanceSlot(20); + chain.Api.AdvanceSlot(20); // no events loaded initially var txs = chain.Api.TxSource.GetTransactions(chain.BlockTree!.Head!.Header, 0, payloadAttributes).ToList(); @@ -46,8 +46,8 @@ public async Task Can_load_when_previous_block_arrives_late() // after timeout they should be loaded using CancellationTokenSource cts = new(); - await chain.Api.TxSource.WaitForTransactions((ulong)BuildingSlot, cts.Token); - txs = chain.Api.TxSource.GetTransactions(chain.BlockTree!.Head!.Header, 0, payloadAttributes).ToList(); + await chain.Api.TxSource.WaitForTransactions(BuildingSlot, cts.Token); + txs = chain.Api.TxSource.GetTransactions(chain.BlockTree.Head!.Header, 0, payloadAttributes).ToList(); Assert.That(txs, Has.Count.EqualTo(20)); // late block arrives, then next block should contain loaded transactions @@ -71,10 +71,10 @@ public async Task Can_load_when_block_arrives_before_keys() using var chain = (ShutterTestBlockchain)await new ShutterTestBlockchain(rnd, timestamper).Build(ShutterTestsCommon.SpecProvider); IEngineRpcModule rpc = chain.EngineRpcModule; IReadOnlyList executionPayloads = await ProduceBranchV1(rpc, chain, BuildingSlot - 2, CreateParentBlockRequestOnHead(chain.BlockTree), true, null, 5); - ExecutionPayload lastPayload = executionPayloads[executionPayloads.Count - 1]; + ExecutionPayload lastPayload = executionPayloads[^1]; // no events loaded initially - var txs = chain.Api!.TxSource.GetTransactions(chain.BlockTree!.Head!.Header, 0, payloadAttributes).ToList(); + var txs = chain.Api.TxSource.GetTransactions(chain.BlockTree.Head!.Header, 0, payloadAttributes).ToList(); Assert.That(txs, Has.Count.EqualTo(0)); chain.Api.AdvanceSlot(20); @@ -82,7 +82,7 @@ public async Task Can_load_when_block_arrives_before_keys() IReadOnlyList payloads = await ProduceBranchV1(rpc, chain, 1, lastPayload, true, null, 5); lastPayload = payloads[0]; - txs = chain.Api.TxSource.GetTransactions(chain.BlockTree!.Head!.Header, 0, payloadAttributes).ToList(); + txs = chain.Api.TxSource.GetTransactions(chain.BlockTree.Head!.Header, 0, payloadAttributes).ToList(); Assert.That(txs, Has.Count.EqualTo(20)); payloads = await ProduceBranchV1(rpc, chain, 1, lastPayload, true, null, 5); diff --git a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainParameters.cs b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainParameters.cs index ff14862f117f..a1a02a58ea9a 100644 --- a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainParameters.cs +++ b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainParameters.cs @@ -129,6 +129,7 @@ public class ChainParameters public Address Eip7251ContractAddress { get; set; } public ulong? Eip2935TransitionTimestamp { get; set; } public Address Eip2935ContractAddress { get; set; } + public long Eip2935RingBufferSize { get; set; } = Eip2935Constants.RingBufferSize; public ulong? Eip7951TransitionTimestamp { get; set; } public ulong? Rip7212TransitionTimestamp { get; set; } public ulong? Eip7692TransitionTimestamp { get; set; } diff --git a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecBasedSpecProvider.cs b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecBasedSpecProvider.cs index 0b4fdc3c8fa4..9ab4f76e4081 100644 --- a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecBasedSpecProvider.cs +++ b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecBasedSpecProvider.cs @@ -257,6 +257,7 @@ protected virtual ReleaseSpec CreateReleaseSpec(ChainSpec chainSpec, long releas releaseSpec.IsEip2935Enabled = (chainSpec.Parameters.Eip2935TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; releaseSpec.IsEofEnabled = (chainSpec.Parameters.Eip7692TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; releaseSpec.Eip2935ContractAddress = chainSpec.Parameters.Eip2935ContractAddress; + releaseSpec.Eip2935RingBufferSize = chainSpec.Parameters.Eip2935RingBufferSize; releaseSpec.IsEip7702Enabled = (chainSpec.Parameters.Eip7702TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; releaseSpec.IsEip7823Enabled = (chainSpec.Parameters.Eip7823TransitionTimestamp ?? ulong.MaxValue) <= releaseStartTimestamp; diff --git a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs index 7374ae2341d4..13a2f5994e38 100644 --- a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs +++ b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/ChainSpecLoader.cs @@ -159,6 +159,7 @@ bool GetForInnerPathExistence(KeyValuePair o) => Eip4788ContractAddress = chainSpecJson.Params.Eip4788ContractAddress ?? Eip4788Constants.BeaconRootsAddress, Eip2935TransitionTimestamp = chainSpecJson.Params.Eip2935TransitionTimestamp, Eip2935ContractAddress = chainSpecJson.Params.Eip2935ContractAddress ?? Eip2935Constants.BlockHashHistoryAddress, + Eip2935RingBufferSize = chainSpecJson.Params.Eip2935RingBufferSize ?? Eip2935Constants.RingBufferSize, TransactionPermissionContract = chainSpecJson.Params.TransactionPermissionContract, TransactionPermissionContractTransition = chainSpecJson.Params.TransactionPermissionContractTransition, ValidateChainIdTransition = chainSpecJson.Params.ValidateChainIdTransition, diff --git a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/Json/ChainSpecParamsJson.cs b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/Json/ChainSpecParamsJson.cs index 6a80e4a902e1..4611a4f6f7eb 100644 --- a/src/Nethermind/Nethermind.Specs/ChainSpecStyle/Json/ChainSpecParamsJson.cs +++ b/src/Nethermind/Nethermind.Specs/ChainSpecStyle/Json/ChainSpecParamsJson.cs @@ -148,6 +148,7 @@ public class ChainSpecParamsJson public Address Eip4788ContractAddress { get; set; } public ulong? Eip2935TransitionTimestamp { get; set; } public Address Eip2935ContractAddress { get; set; } + public long? Eip2935RingBufferSize { get; set; } public UInt256? Eip4844BlobGasPriceUpdateFraction { get; set; } public UInt256? Eip4844MinBlobGasPrice { get; set; } public ulong? Eip4844FeeCollectorTransitionTimestamp { get; set; } diff --git a/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs b/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs index ea60eb262bf4..9eb2c4d5f7ba 100644 --- a/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs +++ b/src/Nethermind/Nethermind.Specs/ReleaseSpec.cs @@ -166,6 +166,7 @@ public Address Eip2935ContractAddress private FrozenSet? _precompiles; FrozenSet IReleaseSpec.Precompiles => _precompiles ??= BuildPrecompilesCache(); + public long Eip2935RingBufferSize { get; set; } = Eip2935Constants.RingBufferSize; public virtual FrozenSet BuildPrecompilesCache() { diff --git a/src/Nethermind/Nethermind.State.Test/StateProviderTests.cs b/src/Nethermind/Nethermind.State.Test/StateProviderTests.cs index 243bb99cd4c6..27f361829033 100644 --- a/src/Nethermind/Nethermind.State.Test/StateProviderTests.cs +++ b/src/Nethermind/Nethermind.State.Test/StateProviderTests.cs @@ -10,13 +10,11 @@ using Nethermind.Specs; using Nethermind.Specs.Forks; using Nethermind.Core.Test.Builders; -using Nethermind.Db; using Nethermind.Int256; using Nethermind.Blockchain.Tracing.ParityStyle; using Nethermind.Logging; using Nethermind.Evm.State; using Nethermind.State; -using Nethermind.Trie; using NUnit.Framework; namespace Nethermind.Store.Test; diff --git a/src/Nethermind/Nethermind.State.Test/WorldStateManagerTests.cs b/src/Nethermind/Nethermind.State.Test/WorldStateManagerTests.cs index 63ba31d6fedd..805bf20237ab 100644 --- a/src/Nethermind/Nethermind.State.Test/WorldStateManagerTests.cs +++ b/src/Nethermind/Nethermind.State.Test/WorldStateManagerTests.cs @@ -5,6 +5,7 @@ using Autofac; using FluentAssertions; using Nethermind.Blockchain; +using Nethermind.Blockchain.Synchronization; using Nethermind.Config; using Nethermind.Core; using Nethermind.Core.Crypto; @@ -76,10 +77,10 @@ public void ShouldNotSupportHashLookupOnHalfpath(INodeStorage.KeyScheme keySchem public void ShouldAnnounceReorgOnDispose() { int lastBlock = 256; - int reorgDepth = 128; // Default reorg depth with snap serving IBlockTree blockTree = Substitute.For(); IConfigProvider configProvider = new ConfigProvider(); + int reorgDepth = configProvider.GetConfig().SnapServingMaxDepth; { using IContainer ctx = new ContainerBuilder() diff --git a/src/Nethermind/Nethermind.State/Snap/Constants.cs b/src/Nethermind/Nethermind.State/Snap/Constants.cs index 394923319b95..ef2ab6cf3850 100644 --- a/src/Nethermind/Nethermind.State/Snap/Constants.cs +++ b/src/Nethermind/Nethermind.State/Snap/Constants.cs @@ -5,6 +5,10 @@ namespace Nethermind.State.Snap { public class Constants { + /// + /// Maximum distance from head for pivot block validation in merge/beacon chain sync. + /// Note: For snap serving depth configuration, use ISyncConfig.SnapServingMaxDepth instead. + /// public const int MaxDistanceFromHead = 128; } } diff --git a/src/Nethermind/Nethermind.Synchronization.Test/FastSync/StateSyncFeedTests.cs b/src/Nethermind/Nethermind.Synchronization.Test/FastSync/StateSyncFeedTests.cs index 8c2ce8306f21..362ecd23c3e8 100644 --- a/src/Nethermind/Nethermind.Synchronization.Test/FastSync/StateSyncFeedTests.cs +++ b/src/Nethermind/Nethermind.Synchronization.Test/FastSync/StateSyncFeedTests.cs @@ -39,6 +39,7 @@ public class StateSyncFeedTests(int peerCount, int maxNodeLatency) [Test] [TestCaseSource(nameof(Scenarios))] [Repeat(TestRepeatCount)] + [Explicit("This test is not stable, especially on slow Github Actions machines")] public async Task Big_test((string Name, Action SetupTree) testCase) { DbContext dbContext = new(_logger, _logManager) diff --git a/src/Nethermind/Nethermind.Synchronization.Test/ForwardHeaderProviderTests.cs b/src/Nethermind/Nethermind.Synchronization.Test/ForwardHeaderProviderTests.cs index 8fdee4f9018a..78df4b4c558d 100644 --- a/src/Nethermind/Nethermind.Synchronization.Test/ForwardHeaderProviderTests.cs +++ b/src/Nethermind/Nethermind.Synchronization.Test/ForwardHeaderProviderTests.cs @@ -248,6 +248,31 @@ public async Task Cache_block_headers_unless_peer_changed() await newSyncPeer.Received(1).GetBlockHeaders(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()); } + [Test] + public async Task Cache_block_headers_with_disposal() + { + await using IContainer node = CreateNode(); + Context ctx = node.Resolve(); + + ISyncPeer syncPeer = Substitute.For(); + syncPeer.TotalDifficulty.Returns(UInt256.MaxValue); + syncPeer.GetBlockHeaders(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) + .Returns(ci => ctx.ResponseBuilder.BuildHeaderResponse(ci.ArgAt(0), ci.ArgAt(1), Response.AllCorrect)); + + PeerInfo peerInfo = new(syncPeer); + syncPeer.HeadNumber.Returns(1000); + ctx.ConfigureBestPeer(peerInfo); + + IForwardHeaderProvider forwardHeader = ctx.ForwardHeaderProvider; + + using IOwnedReadOnlyList? headers1 = await forwardHeader.GetBlockHeaders(0, 128, CancellationToken.None); + headers1.Should().NotBeNull(); + using IOwnedReadOnlyList? headers2 = await forwardHeader.GetBlockHeaders(0, 128, CancellationToken.None); + headers2.Should().NotBeNull(); + + await syncPeer.Received(1).GetBlockHeaders(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()); + } + private class SlowSealValidator : ISealValidator { public bool ValidateParams(BlockHeader parent, BlockHeader header, bool isUncle = false) diff --git a/src/Nethermind/Nethermind.Synchronization/Blocks/PowForwardHeaderProvider.cs b/src/Nethermind/Nethermind.Synchronization/Blocks/PowForwardHeaderProvider.cs index 640252a7f686..b2905f365de2 100644 --- a/src/Nethermind/Nethermind.Synchronization/Blocks/PowForwardHeaderProvider.cs +++ b/src/Nethermind/Nethermind.Synchronization/Blocks/PowForwardHeaderProvider.cs @@ -116,7 +116,7 @@ private IOwnedReadOnlyList? LastResponseBatch } LastResponseBatch = newResponse; - return LastResponseBatch; + return newResponse.ToPooledList(newResponse.Count); } private void OnNewBestPeer(PeerInfo newBestPeer) diff --git a/src/Nethermind/Nethermind.Synchronization/ParallelSync/MultiSyncModeSelector.cs b/src/Nethermind/Nethermind.Synchronization/ParallelSync/MultiSyncModeSelector.cs index dd9a6d3ee210..71a99f54b449 100644 --- a/src/Nethermind/Nethermind.Synchronization/ParallelSync/MultiSyncModeSelector.cs +++ b/src/Nethermind/Nethermind.Synchronization/ParallelSync/MultiSyncModeSelector.cs @@ -201,6 +201,7 @@ public void Update() best.IsInFullSync = ShouldBeInFullSyncMode(best); best.IsInDisconnected = ShouldBeInDisconnectedMode(best); best.IsInWaitingForBlock = ShouldBeInWaitingForBlockMode(best); + if (_logger.IsTrace) _logger.Trace($"Snapshot: {BuildStateStringDebug(best)}"); newModes = SyncMode.None; CheckAddFlag(best.IsInUpdatingPivot, SyncMode.UpdatingPivot, ref newModes); @@ -392,7 +393,7 @@ private bool ShouldBeInFastSyncMode(Snapshot best) // We stop `FastSyncLag` block before the highest known block in case the highest known block is non-canon // and we need to sync away from it. - // Note: its ok if target block height is not accurate as long as long full sync downloader does not stop + // Note: its ok if target block height is not accurate as long as full sync downloader does not stop // earlier than this condition below which would cause a hang. bool notReachedFullSyncTransition = best.Header < best.TargetBlock - TotalSyncLag; @@ -420,7 +421,7 @@ private bool ShouldBeInFastSyncMode(Snapshot best) (nameof(postPivotPeerAvailable), postPivotPeerAvailable), (nameof(notReachedFullSyncTransition), notReachedFullSyncTransition), (nameof(notInAStickyFullSync), notInAStickyFullSync), - ($"{nameof(stateNotDownloadedYet)}||${longRangeCatchUp}", stateNotDownloadedYet || longRangeCatchUp), + ($"{nameof(stateNotDownloadedYet)} || ${longRangeCatchUp}", stateNotDownloadedYet || longRangeCatchUp), (nameof(notNeedToWaitForHeaders), notNeedToWaitForHeaders)); } @@ -606,8 +607,8 @@ private bool ShouldBeInStateSyncMode(Snapshot best) (nameof(notInUpdatingPivot), notInUpdatingPivot), (nameof(hasFastSyncBeenActive), hasFastSyncBeenActive), (nameof(hasAnyPostPivotPeer), hasAnyPostPivotPeer), - ($"{nameof(notInFastSync)}||{nameof(stickyStateNodes)}", notInFastSync || stickyStateNodes), - ($"{nameof(stateNotDownloadedYet)}||{nameof(longRangeCatchUp)}", stateNotDownloadedYet || longRangeCatchUp), + ($"{nameof(notInFastSync)} || {nameof(stickyStateNodes)}", notInFastSync || stickyStateNodes), + ($"{nameof(stateNotDownloadedYet)} || {nameof(longRangeCatchUp)}", stateNotDownloadedYet || longRangeCatchUp), (nameof(notInAStickyFullSync), notInAStickyFullSync), (nameof(notNeedToWaitForHeaders), notNeedToWaitForHeaders)); } @@ -627,7 +628,7 @@ private bool ShouldBeInStateNodesMode(Snapshot best) { LogDetailedSyncModeChecks("STATE_NODES", (nameof(isInStateSync), isInStateSync), - ($"{nameof(snapSyncDisabled)}||{nameof(snapRangesFinished)}", snapSyncDisabled || snapRangesFinished)); + ($"{nameof(snapSyncDisabled)} || {nameof(snapRangesFinished)}", snapSyncDisabled || snapRangesFinished)); } return result; @@ -760,15 +761,15 @@ private void LogDetailedSyncModeChecks(string syncType, params (string Name, boo List matched = new(); List failed = new(); - foreach ((string Name, bool IsSatisfied) in checks) + foreach ((string name, bool isSatisfied) in checks) { - if (IsSatisfied) + if (isSatisfied) { - matched.Add(Name); + matched.Add(name); } else { - failed.Add(Name); + failed.Add(name); } } diff --git a/src/Nethermind/Nethermind.Synchronization/Reporting/SyncReport.cs b/src/Nethermind/Nethermind.Synchronization/Reporting/SyncReport.cs index 17c71464dc03..48cddfc837f6 100644 --- a/src/Nethermind/Nethermind.Synchronization/Reporting/SyncReport.cs +++ b/src/Nethermind/Nethermind.Synchronization/Reporting/SyncReport.cs @@ -28,7 +28,7 @@ public class SyncReport : ISyncReport private const int NoProgressStateSyncReportFrequency = 30; private const int SyncAllocatedPeersReportFrequency = 30; private const int SyncFullPeersReportFrequency = 120; - private static readonly TimeSpan _defaultReportingIntervals = TimeSpan.FromSeconds(1); + private readonly TimeSpan _defaultReportingIntervals; public SyncReport(ISyncPeerPool syncPeerPool, INodeStatsManager nodeStatsManager, ISyncConfig syncConfig, IPivot pivot, ILogManager logManager, ITimerFactory? timerFactory = null, double tickTime = 1000) { @@ -37,6 +37,7 @@ public SyncReport(ISyncPeerPool syncPeerPool, INodeStatsManager nodeStatsManager _syncConfig = syncConfig ?? throw new ArgumentNullException(nameof(syncConfig)); _pivot = pivot ?? throw new ArgumentNullException(nameof(pivot)); _syncPeersReport = new SyncPeersReport(syncPeerPool, nodeStatsManager, logManager); + _defaultReportingIntervals = TimeSpan.FromSeconds(_logger.IsDebug ? 1 : 10); _timer = (timerFactory ?? TimerFactory.Default).CreateTimer(_defaultReportingIntervals); FastBlocksHeaders = new("Old Headers", logManager); diff --git a/src/Nethermind/Nethermind.Taiko/L1OriginDecoder.cs b/src/Nethermind/Nethermind.Taiko/L1OriginDecoder.cs index 4429af90bb95..4d5fb87948a8 100644 --- a/src/Nethermind/Nethermind.Taiko/L1OriginDecoder.cs +++ b/src/Nethermind/Nethermind.Taiko/L1OriginDecoder.cs @@ -8,11 +8,11 @@ namespace Nethermind.Taiko; -public class L1OriginDecoder : IRlpStreamDecoder +public sealed class L1OriginDecoder : RlpStreamDecoder { const int BuildPayloadArgsIdLength = 8; - public L1Origin Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override L1Origin DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { (int _, int contentLength) = rlpStream.ReadPrefixAndContentLength(); int itemsCount = rlpStream.PeekNumberOfItemsRemaining(maxSearch: contentLength); @@ -36,7 +36,7 @@ public Rlp Encode(L1Origin? item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new(rlpStream.Data.ToArray()!); } - public void Encode(RlpStream stream, L1Origin item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, L1Origin item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { stream.StartSequence(GetLength(item, rlpBehaviors)); @@ -55,7 +55,7 @@ public void Encode(RlpStream stream, L1Origin item, RlpBehaviors rlpBehaviors = } } - public int GetLength(L1Origin item, RlpBehaviors rlpBehaviors) + public override int GetLength(L1Origin item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOfSequence( Rlp.LengthOf(item.BlockId) diff --git a/src/Nethermind/Nethermind.Test.Runner/BlockchainTestsRunner.cs b/src/Nethermind/Nethermind.Test.Runner/BlockchainTestsRunner.cs index 51da785e1a6b..a596548ec393 100644 --- a/src/Nethermind/Nethermind.Test.Runner/BlockchainTestsRunner.cs +++ b/src/Nethermind/Nethermind.Test.Runner/BlockchainTestsRunner.cs @@ -7,8 +7,6 @@ using System.Threading.Tasks; using Ethereum.Test.Base; using Ethereum.Test.Base.Interfaces; -using Nethermind.Blockchain.Tracing.GethStyle; -using Nethermind.Evm.Tracing; namespace Nethermind.Test.Runner; @@ -21,21 +19,29 @@ public class BlockchainTestsRunner( bool traceNoStack = false) : BlockchainTestBase, IBlockchainTestRunner { - private readonly ConsoleColor _defaultColour = Console.ForegroundColor; + private readonly ConsoleColor _defaultColor = Console.ForegroundColor; private readonly ITestSourceLoader _testsSource = testsSource ?? throw new ArgumentNullException(nameof(testsSource)); public async Task> RunTestsAsync() { - List testResults = new(); - IEnumerable tests = _testsSource.LoadTests(); + List testResults = []; + IEnumerable tests = _testsSource.LoadTests(); + foreach (EthereumTest loadedTest in tests) + { + if (loadedTest as FailedToLoadTest is not null) + { + WriteRed(loadedTest.LoadFailure); + testResults.Add(new EthereumTestResult(loadedTest.Name, loadedTest.LoadFailure)); + continue; + } - // Create a streaming tracer once for all tests if tracing is enabled - using BlockchainTestStreamingTracer? tracer = trace - ? new BlockchainTestStreamingTracer(new() { EnableMemory = traceMemory, DisableStack = traceNoStack }) - : null; + // Create a streaming tracer once for all tests if tracing is enabled + using BlockchainTestStreamingTracer? tracer = trace + ? new BlockchainTestStreamingTracer(new() { EnableMemory = traceMemory, DisableStack = traceNoStack }) + : null; + + BlockchainTest test = loadedTest as BlockchainTest; - foreach (BlockchainTest test in tests) - { if (filter is not null && test.Name is not null && !Regex.Match(test.Name, $"^({filter})").Success) continue; Setup(); @@ -66,13 +72,13 @@ private void WriteRed(string text) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(text); - Console.ForegroundColor = _defaultColour; + Console.ForegroundColor = _defaultColor; } private void WriteGreen(string text) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(text); - Console.ForegroundColor = _defaultColour; + Console.ForegroundColor = _defaultColor; } } diff --git a/src/Nethermind/Nethermind.TxPool.Test/RetryCacheTests.cs b/src/Nethermind/Nethermind.TxPool.Test/RetryCacheTests.cs index e05cbc535837..87990c5ac310 100644 --- a/src/Nethermind/Nethermind.TxPool.Test/RetryCacheTests.cs +++ b/src/Nethermind/Nethermind.TxPool.Test/RetryCacheTests.cs @@ -24,15 +24,15 @@ public class RetryCacheTests public interface ITestHandler : IMessageHandler; private CancellationTokenSource _cancellationTokenSource; - private RetryCache cache; + private RetryCache _cache; - private readonly int Timeout = 1000; + private readonly int Timeout = 5000; [SetUp] public void Setup() { _cancellationTokenSource = new CancellationTokenSource(); - cache = new(TestLogManager.Instance, timeoutMs: Timeout / 2, token: _cancellationTokenSource.Token); + _cache = new(TestLogManager.Instance, timeoutMs: Timeout / 2, token: _cancellationTokenSource.Token); } [TearDown] @@ -45,8 +45,8 @@ public void TearDown() [Test] public void Announced_SameResourceDifferentNode_ReturnsEnqueued() { - AnnounceResult result1 = cache.Announced(1, Substitute.For()); - AnnounceResult result2 = cache.Announced(1, Substitute.For()); + AnnounceResult result1 = _cache.Announced(1, Substitute.For()); + AnnounceResult result2 = _cache.Announced(1, Substitute.For()); Assert.That(result1, Is.EqualTo(AnnounceResult.New)); Assert.That(result2, Is.EqualTo(AnnounceResult.Enqueued)); @@ -58,11 +58,11 @@ public void Announced_AfterTimeout_ExecutesRetryRequests() ITestHandler request1 = Substitute.For(); ITestHandler request2 = Substitute.For(); - cache.Announced(1, request1); - cache.Announced(1, request2); + _cache.Announced(1, request1); + _cache.Announced(1, request2); - Assert.That(() => request1.DidNotReceiveBool(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); - Assert.That(() => request2.ReceivedBool(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); + Assert.That(() => request2.ReceivedCallsMatching(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); + request1.DidNotReceive().HandleMessage(Arg.Any()); } [Test] @@ -73,37 +73,40 @@ public void Announced_MultipleResources_ExecutesAllRetryRequestsExceptInititalOn ITestHandler request3 = Substitute.For(); ITestHandler request4 = Substitute.For(); - cache.Announced(1, request1); - cache.Announced(1, request2); - cache.Announced(2, request3); - cache.Announced(2, request4); + _cache.Announced(1, request1); + _cache.Announced(1, request2); + _cache.Announced(2, request3); + _cache.Announced(2, request4); - Assert.That(() => request1.DidNotReceiveBool(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); - Assert.That(() => request2.ReceivedBool(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); - Assert.That(() => request3.DidNotReceiveBool(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); - Assert.That(() => request4.ReceivedBool(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); + Assert.That(() => request2.ReceivedCallsMatching(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); + Assert.That(() => request4.ReceivedCallsMatching(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); + request1.DidNotReceive().HandleMessage(Arg.Any()); + request3.DidNotReceive().HandleMessage(Arg.Any()); } [Test] public void Received_RemovesResourceFromRetryQueue() { - cache.Announced(1, Substitute.For()); - cache.Received(1); + _cache.Announced(1, Substitute.For()); + _cache.Received(1); - AnnounceResult result = cache.Announced(1, Substitute.For()); + AnnounceResult result = _cache.Announced(1, Substitute.For()); Assert.That(result, Is.EqualTo(AnnounceResult.New)); } [Test] - public void Received_BeforeTimeout_PreventsRetryExecution() + public async Task Received_BeforeTimeout_PreventsRetryExecution() { ITestHandler request = Substitute.For(); - cache.Announced(1, request); - cache.Announced(1, request); - cache.Received(1); + _cache.Announced(1, request); + _cache.Announced(1, request); + _cache.Received(1); - Assert.That(() => request.DidNotReceiveBool(r => r.HandleMessage(ResourceRequestMessage.New(1))), Is.True.After(Timeout, 100)); + + await Task.Delay(Timeout, _cancellationTokenSource.Token); + + request.DidNotReceive().HandleMessage(ResourceRequestMessage.New(1)); } [Test] @@ -114,36 +117,38 @@ public void RetryExecution_HandlesExceptions() faultyRequest.When(x => x.HandleMessage(Arg.Any())).Do(x => throw new InvalidOperationException("Test exception")); - cache.Announced(1, Substitute.For()); - cache.Announced(1, faultyRequest); - cache.Announced(1, normalRequest); + _cache.Announced(1, Substitute.For()); + _cache.Announced(1, faultyRequest); + _cache.Announced(1, normalRequest); - Assert.That(() => normalRequest.ReceivedBool(r => r.HandleMessage(ResourceRequestMessage.New(1))), Is.True.After(Timeout, 100)); + Assert.That(() => normalRequest.ReceivedCallsMatching(r => r.HandleMessage(ResourceRequestMessage.New(1))), Is.True.After(Timeout, 100)); } [Test] - public void CancellationToken_StopsProcessing() + public async Task CancellationToken_StopsProcessing() { ITestHandler request = Substitute.For(); - cache.Announced(1, request); - _cancellationTokenSource.Cancel(); - Assert.That(() => request.DidNotReceiveBool(r => r.HandleMessage(Arg.Any())), Is.True.After(Timeout, 100)); + _cache.Announced(1, request); + await _cancellationTokenSource.CancelAsync(); + await Task.Delay(Timeout); + + request.DidNotReceive().HandleMessage(Arg.Any()); } [Test] public async Task Announced_AfterRetryInProgress_ReturnsNew() { - cache.Announced(1, Substitute.For()); + _cache.Announced(1, Substitute.For()); await Task.Delay(Timeout, _cancellationTokenSource.Token); - Assert.That(() => cache.Announced(1, Substitute.For()), Is.EqualTo(AnnounceResult.New).After(Timeout, 100)); + Assert.That(() => _cache.Announced(1, Substitute.For()), Is.EqualTo(AnnounceResult.New).After(Timeout, 100)); } [Test] public void Received_NonExistentResource_DoesNotThrow() { - Assert.That(() => cache.Received(999), Throws.Nothing); + Assert.That(() => _cache.Received(999), Throws.Nothing); } } diff --git a/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs b/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs index 823d402adea2..c432bce991fa 100644 --- a/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs +++ b/src/Nethermind/Nethermind.TxPool.Test/TxPoolTests.cs @@ -1130,15 +1130,14 @@ public void should_notify_added_peer_of_own_tx_when_we_are_synced([Values(0, 1)] } [Test] - public async Task should_notify_peer_only_once() + public void should_notify_peer_only_once() { _txPool = CreatePool(); ITxPoolPeer txPoolPeer = Substitute.For(); txPoolPeer.Id.Returns(TestItem.PublicKeyA); _txPool.AddPeer(txPoolPeer); _ = AddTransactionToPool(); - await Task.Delay(500); - txPoolPeer.Received(1).SendNewTransaction(Arg.Any()); + Assert.That(() => txPoolPeer.ReceivedCallsMatching(p => p.SendNewTransaction(Arg.Any())), Is.True.After(500, 10)); txPoolPeer.DidNotReceive().SendNewTransactions(Arg.Any>(), false); } @@ -1489,7 +1488,7 @@ public void should_increase_nonce_when_transaction_not_included_in_txPool_but_br } [Test] - public async Task should_include_transaction_after_removal() + public void should_include_transaction_after_removal() { ISpecProvider specProvider = GetLondonSpecProvider(); _txPool = CreatePool(new TxPoolConfig { Size = 2 }, specProvider); @@ -1528,11 +1527,8 @@ public async Task should_include_transaction_after_removal() Raise.Event>(this, new BlockReplacementEventArgs(Build.A.Block.WithTransactions(expensiveTx1).TestObject)); - // Wait four event processing - await Task.Delay(100); - - // Send txA again => should be Accepted - _txPool.SubmitTx(txA, TxHandlingOptions.None).Should().Be(AcceptTxResult.Accepted); + // Wait for event processing and send txA again => should be Accepted + Assert.That(() => _txPool.SubmitTx(txA, TxHandlingOptions.None), Is.EqualTo(AcceptTxResult.Accepted).After(100, 10)); } [TestCase(true, 1, 1, true)] diff --git a/src/Nethermind/Nethermind.Xdc/RLP/ExtraConsensusDataDecoder.cs b/src/Nethermind/Nethermind.Xdc/RLP/ExtraConsensusDataDecoder.cs index a31ae50e3087..0869fec40552 100644 --- a/src/Nethermind/Nethermind.Xdc/RLP/ExtraConsensusDataDecoder.cs +++ b/src/Nethermind/Nethermind.Xdc/RLP/ExtraConsensusDataDecoder.cs @@ -10,10 +10,10 @@ using System.Threading.Tasks; namespace Nethermind.Xdc.RLP; -internal class ExtraConsensusDataDecoder : IRlpValueDecoder, IRlpStreamDecoder +internal sealed class ExtraConsensusDataDecoder : RlpValueDecoder { private QuorumCertificateDecoder _quorumCertificateDecoder = new(); - public ExtraFieldsV2 Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override ExtraFieldsV2 DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) return null; @@ -28,7 +28,7 @@ public ExtraFieldsV2 Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehav return new ExtraFieldsV2(round, quorumCert); } - public ExtraFieldsV2 Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override ExtraFieldsV2 DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) return null; @@ -52,7 +52,7 @@ public Rlp Encode(ExtraFieldsV2 item, RlpBehaviors rlpBehaviors = RlpBehaviors.N return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream stream, ExtraFieldsV2 item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, ExtraFieldsV2 item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -65,7 +65,7 @@ public void Encode(RlpStream stream, ExtraFieldsV2 item, RlpBehaviors rlpBehavio _quorumCertificateDecoder.Encode(stream, item.QuorumCert, rlpBehaviors); } - public int GetLength(ExtraFieldsV2 item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override int GetLength(ExtraFieldsV2 item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Xdc/RLP/QuorumCertificateDecoder.cs b/src/Nethermind/Nethermind.Xdc/RLP/QuorumCertificateDecoder.cs index c3d25f156986..7d5e22762065 100644 --- a/src/Nethermind/Nethermind.Xdc/RLP/QuorumCertificateDecoder.cs +++ b/src/Nethermind/Nethermind.Xdc/RLP/QuorumCertificateDecoder.cs @@ -17,10 +17,10 @@ using BlockRoundInfo = Nethermind.Xdc.Types.BlockRoundInfo; namespace Nethermind.Xdc; -internal class QuorumCertificateDecoder : IRlpValueDecoder, IRlpStreamDecoder +internal sealed class QuorumCertificateDecoder : RlpValueDecoder { private XdcBlockInfoDecoder _blockInfoDecoder = new XdcBlockInfoDecoder(); - public QuorumCertificate Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override QuorumCertificate DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) return null; @@ -46,7 +46,7 @@ public QuorumCertificate Decode(ref Rlp.ValueDecoderContext decoderContext, RlpB return new QuorumCertificate(blockInfo, signatures, gap); } - public QuorumCertificate Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override QuorumCertificate DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) return null; @@ -83,7 +83,7 @@ public Rlp Encode(QuorumCertificate item, RlpBehaviors rlpBehaviors = RlpBehavio return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream stream, QuorumCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, QuorumCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -113,7 +113,7 @@ public void Encode(RlpStream stream, QuorumCertificate item, RlpBehaviors rlpBeh stream.Encode(item.GapNumber); } - public int GetLength(QuorumCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override int GetLength(QuorumCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Xdc/RLP/SnapshotDecoder.cs b/src/Nethermind/Nethermind.Xdc/RLP/SnapshotDecoder.cs index e46d339dea09..743a298c9ac8 100644 --- a/src/Nethermind/Nethermind.Xdc/RLP/SnapshotDecoder.cs +++ b/src/Nethermind/Nethermind.Xdc/RLP/SnapshotDecoder.cs @@ -12,9 +12,9 @@ using System.Threading.Tasks; namespace Nethermind.Xdc.RLP; -internal class SnapshotDecoder : IRlpStreamDecoder, IRlpValueDecoder +internal sealed class SnapshotDecoder : RlpValueDecoder { - public Snapshot Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Snapshot DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) return null; @@ -59,7 +59,7 @@ public Rlp Encode(Snapshot item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new Rlp(rlpStream.Data.ToArray()); } - public Snapshot Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Snapshot DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) return null; @@ -73,7 +73,7 @@ public Snapshot Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehav return new Snapshot(number, hash256, candidate); } - public void Encode(RlpStream stream, Snapshot item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, Snapshot item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -103,7 +103,7 @@ private void EncodeAddressSequence(RlpStream stream, Address[] nextEpochCandidat } } - public int GetLength(Snapshot item, RlpBehaviors rlpBehaviors) + public override int GetLength(Snapshot item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Xdc/RLP/TimeoutCertificateDecoder.cs b/src/Nethermind/Nethermind.Xdc/RLP/TimeoutCertificateDecoder.cs index 20e4a5d24926..942e38e1060e 100644 --- a/src/Nethermind/Nethermind.Xdc/RLP/TimeoutCertificateDecoder.cs +++ b/src/Nethermind/Nethermind.Xdc/RLP/TimeoutCertificateDecoder.cs @@ -9,9 +9,9 @@ namespace Nethermind.Xdc.RLP; -public class TimeoutCertificateDecoder : IRlpValueDecoder, IRlpStreamDecoder +public sealed class TimeoutCertificateDecoder : RlpValueDecoder { - public TimeoutCertificate Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TimeoutCertificate DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) return null; @@ -43,7 +43,7 @@ public TimeoutCertificate Decode(ref Rlp.ValueDecoderContext decoderContext, Rlp return new TimeoutCertificate(round, signatures, gapNumber); } - public TimeoutCertificate Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override TimeoutCertificate DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) return null; @@ -86,7 +86,7 @@ public Rlp Encode(TimeoutCertificate item, RlpBehaviors rlpBehaviors = RlpBehavi return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream stream, TimeoutCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, TimeoutCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -110,7 +110,7 @@ public void Encode(RlpStream stream, TimeoutCertificate item, RlpBehaviors rlpBe stream.Encode(item.GapNumber); } - public int GetLength(TimeoutCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override int GetLength(TimeoutCertificate item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Xdc/RLP/TimeoutDecoder.cs b/src/Nethermind/Nethermind.Xdc/RLP/TimeoutDecoder.cs index 74e87d5d2e69..980acefbe9f4 100644 --- a/src/Nethermind/Nethermind.Xdc/RLP/TimeoutDecoder.cs +++ b/src/Nethermind/Nethermind.Xdc/RLP/TimeoutDecoder.cs @@ -9,9 +9,9 @@ namespace Nethermind.Xdc.RLP; -public class TimeoutDecoder : IRlpValueDecoder, IRlpStreamDecoder +public sealed class TimeoutDecoder : RlpValueDecoder { - public Timeout Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Timeout DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) return null; @@ -38,7 +38,7 @@ public Timeout Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors r return new Timeout(round, signature, gapNumber); } - public Timeout Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Timeout DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) return null; @@ -76,7 +76,7 @@ public Rlp Encode(Timeout item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new Rlp(rlpStream.Data.ToArray()); } - public void Encode(RlpStream stream, Timeout item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, Timeout item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -100,7 +100,7 @@ public void Encode(RlpStream stream, Timeout item, RlpBehaviors rlpBehaviors = R stream.Encode(item.GapNumber); } - public int GetLength(Timeout item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override int GetLength(Timeout item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Xdc/RLP/VoteDecoder.cs b/src/Nethermind/Nethermind.Xdc/RLP/VoteDecoder.cs index e424126dc8df..3240f7ad6db4 100644 --- a/src/Nethermind/Nethermind.Xdc/RLP/VoteDecoder.cs +++ b/src/Nethermind/Nethermind.Xdc/RLP/VoteDecoder.cs @@ -12,11 +12,11 @@ using System.Threading.Tasks; namespace Nethermind.Xdc; -public class VoteDecoder : IRlpValueDecoder, IRlpStreamDecoder +public sealed class VoteDecoder : RlpValueDecoder { private static readonly XdcBlockInfoDecoder _xdcBlockInfoDecoder = new(); - public Vote Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Vote DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) return null; @@ -40,7 +40,7 @@ public Vote Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpB return new Vote(proposedBlockInfo, gapNumber, signature); } - public Vote Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override Vote DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) return null; @@ -64,7 +64,7 @@ public Vote Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors return new Vote(proposedBlockInfo, gapNumber, signature); } - public void Encode(RlpStream stream, Vote item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, Vote item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -89,7 +89,7 @@ public Rlp Encode(Vote item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) return new Rlp(rlpStream.Data.ToArray()); } - public int GetLength(Vote item, RlpBehaviors rlpBehaviors) + public override int GetLength(Vote item, RlpBehaviors rlpBehaviors) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/Nethermind/Nethermind.Xdc/RLP/XdcBlockInfoDecoder.cs b/src/Nethermind/Nethermind.Xdc/RLP/XdcBlockInfoDecoder.cs index c634fd4a2b11..aa8c2eee13fc 100644 --- a/src/Nethermind/Nethermind.Xdc/RLP/XdcBlockInfoDecoder.cs +++ b/src/Nethermind/Nethermind.Xdc/RLP/XdcBlockInfoDecoder.cs @@ -6,9 +6,9 @@ using Nethermind.Xdc.Types; namespace Nethermind.Xdc.RLP; -internal class XdcBlockInfoDecoder : IRlpValueDecoder, IRlpStreamDecoder +internal sealed class XdcBlockInfoDecoder : RlpValueDecoder { - public BlockRoundInfo Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override BlockRoundInfo DecodeInternal(ref Rlp.ValueDecoderContext decoderContext, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (decoderContext.IsNextItemNull()) return null; @@ -25,7 +25,7 @@ public BlockRoundInfo Decode(ref Rlp.ValueDecoderContext decoderContext, RlpBeha } - public BlockRoundInfo Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + protected override BlockRoundInfo DecodeInternal(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (rlpStream.IsNextItemNull()) return null; @@ -41,7 +41,7 @@ public BlockRoundInfo Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = Rl return new BlockRoundInfo(new Hash256(hashBytes), round, number); } - public void Encode(RlpStream stream, BlockRoundInfo item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override void Encode(RlpStream stream, BlockRoundInfo item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { if (item is null) { @@ -54,7 +54,7 @@ public void Encode(RlpStream stream, BlockRoundInfo item, RlpBehaviors rlpBehavi stream.Encode(item.BlockNumber); } - public int GetLength(BlockRoundInfo item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) + public override int GetLength(BlockRoundInfo item, RlpBehaviors rlpBehaviors = RlpBehaviors.None) { return Rlp.LengthOfSequence(GetContentLength(item, rlpBehaviors)); } diff --git a/src/tests b/src/tests index 08b5fe38c23c..c67e485ff8b5 160000 --- a/src/tests +++ b/src/tests @@ -1 +1 @@ -Subproject commit 08b5fe38c23c3ea4f88af93e10fbf03b715414f7 +Subproject commit c67e485ff8b5be9abc8ad15345ec21aa22e290d9 diff --git a/tools/Evm/Evm.slnx b/tools/Evm/Evm.slnx index 957bc390ccc4..46e72a9b9238 100644 --- a/tools/Evm/Evm.slnx +++ b/tools/Evm/Evm.slnx @@ -1,3 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/Evm/T8n/T8nExecutor.cs b/tools/Evm/T8n/T8nExecutor.cs index 72935f0e7674..dec1b583c8a6 100644 --- a/tools/Evm/T8n/T8nExecutor.cs +++ b/tools/Evm/T8n/T8nExecutor.cs @@ -14,23 +14,20 @@ using Nethermind.Core.Specs; using Nethermind.Core.Test; using Nethermind.Crypto; -using Nethermind.Db; using Nethermind.Evm; using Nethermind.Evm.State; -using Nethermind.Evm.Tracing; using Nethermind.Blockchain.Tracing.GethStyle; using Nethermind.Blockchain.Tracing; using Nethermind.Evm.TransactionProcessing; using Nethermind.Logging; using Nethermind.State; -using Nethermind.Trie.Pruning; using Nethermind.Blockchain; namespace Evm.T8n; public static class T8nExecutor { - private static ILogManager _logManager = LimboLogs.Instance; + private static readonly ILogManager _logManager = LimboLogs.Instance; public static T8nExecutionResult Execute(T8nCommandArguments arguments) { @@ -55,7 +52,7 @@ public static T8nExecutionResult Execute(T8nCommandArguments arguments) _logManager); stateProvider.CreateAccount(test.CurrentCoinbase, 0); - GeneralStateTestBase.InitializeTestState(test.Alloc, stateProvider, test.SpecProvider); + GeneralStateTestBase.InitializeTestState(test.Alloc, test.CurrentCoinbase, stateProvider, test.SpecProvider); Block block = test.ConstructBlock(); var withdrawalProcessor = new WithdrawalProcessor(stateProvider, _logManager); diff --git a/tools/StatelessExecution/StatelessExecution.csproj b/tools/StatelessExecution/StatelessExecution.csproj index 58ff2bc0aaba..8131de9abf90 100644 --- a/tools/StatelessExecution/StatelessExecution.csproj +++ b/tools/StatelessExecution/StatelessExecution.csproj @@ -2,9 +2,6 @@ Exe - net9.0 - enable - enable