diff --git a/.github/workflows/build-tools.yml b/.github/workflows/build-tools.yml index 1f25cb17a86..8ce05c32f74 100644 --- a/.github/workflows/build-tools.yml +++ b/.github/workflows/build-tools.yml @@ -18,6 +18,7 @@ jobs: config: [release] project: - DocGen/DocGen.sln + - Evm/Evm.sln - HiveCompare/HiveCompare.sln - HiveConsensusWorkflowGenerator/HiveConsensusWorkflowGenerator.csproj - Nethermind.Tools.Kute/Nethermind.Tools.Kute.csproj diff --git a/tools/Evm/Evm.csproj b/tools/Evm/Evm.csproj new file mode 100644 index 00000000000..03357b7bed7 --- /dev/null +++ b/tools/Evm/Evm.csproj @@ -0,0 +1,22 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + + + + + diff --git a/tools/Evm/Evm.sln b/tools/Evm/Evm.sln index 74ba8e12abf..87bfcbb7007 100644 --- a/tools/Evm/Evm.sln +++ b/tools/Evm/Evm.sln @@ -1,6 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Evm", "Evm\Evm.csproj", "{9D450C5A-C4B3-457A-8398-4690DFF4C47C}" +# 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Evm", "Evm.csproj", "{8CF2FE31-3082-4EE8-9880-DC1D6E50BDF9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -8,9 +11,12 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9D450C5A-C4B3-457A-8398-4690DFF4C47C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9D450C5A-C4B3-457A-8398-4690DFF4C47C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9D450C5A-C4B3-457A-8398-4690DFF4C47C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9D450C5A-C4B3-457A-8398-4690DFF4C47C}.Release|Any CPU.Build.0 = Release|Any CPU + {8CF2FE31-3082-4EE8-9880-DC1D6E50BDF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8CF2FE31-3082-4EE8-9880-DC1D6E50BDF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8CF2FE31-3082-4EE8-9880-DC1D6E50BDF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8CF2FE31-3082-4EE8-9880-DC1D6E50BDF9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/tools/Evm/Evm/Evm.csproj b/tools/Evm/Evm/Evm.csproj deleted file mode 100644 index 73617641c01..00000000000 --- a/tools/Evm/Evm/Evm.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - - - - - - - - - - - - - diff --git a/tools/Evm/Evm/Program.cs b/tools/Evm/Evm/Program.cs deleted file mode 100644 index ea9c991fabf..00000000000 --- a/tools/Evm/Evm/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.CommandLine; -using Evm.t8n; - -namespace Evm; - -public static class Program -{ - public static async Task Main(string[] args) - { - var rootCmd = new RootCommand { Name = "Evm" }; - - T8NCommand.Configure(ref rootCmd); - - await rootCmd.InvokeAsync(args); - } -} diff --git a/tools/Evm/Evm/t8n/T8NCommand.cs b/tools/Evm/Evm/t8n/T8NCommand.cs deleted file mode 100644 index 75cf7f2f558..00000000000 --- a/tools/Evm/Evm/t8n/T8NCommand.cs +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using System.CommandLine; - -namespace Evm.t8n; - -public static class T8NCommand -{ - public static void Configure(ref RootCommand rootCmd) - { - Command cmd = T8NCommandOptions.CreateCommand(); - rootCmd.Add(cmd); - - cmd.SetHandler( - context => - { - var arguments = T8NCommandArguments.FromParseResult(context.ParseResult); - T8NExecutor.Execute(arguments); - }); - } -} diff --git a/tools/Evm/Evm/t8n/T8NCommandOptions.cs b/tools/Evm/Evm/t8n/T8NCommandOptions.cs deleted file mode 100644 index e29d2b8247f..00000000000 --- a/tools/Evm/Evm/t8n/T8NCommandOptions.cs +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -namespace Evm.t8n; - -using System.CommandLine; - -public static class T8NCommandOptions -{ - public static Option InputAllocOpt { get; } = new("--input.alloc", description: "Input allocations"); - public static Option InputEnvOpt { get; } = new("--input.env", description: "Input environment"); - public static Option InputTxsOpt { get; } = new("--input.txs", description: "Input transactions"); - - public static Option OutputAllocOpt { get; } = new("--output.alloc", description: "Output allocations"); - public static Option OutputResultOpt { get; } = new("--output.result", description: "Output result"); - public static Option OutputBodyOpt { get; } = new("--output.body", description: "Output body"); - public static Option OutputBaseDirOpt { get; } = new("--output.basedir", description: "Output base directory"); - - public static Option StateChainIdOpt { get; } = new("--state.chainid", description: "State chain id"); - public static Option StateForkOpt { get; } = new("--state.fork", description: "State fork"); - public static Option StateRewardOpt { get; } = new("--state.reward", description: "State reward"); - - public static Option TraceOpt { get; } = new("--trace", description: "Configures the use of the JSON opcode tracer. This tracer emits traces to files as trace--.json"); - public static Option TraceMemoryOpt { get; } = new("--trace.memory", description: "Trace memory"); - public static Option TraceNoStackOpt { get; } = new("--trace.nostack", description: "Trace no stack"); - public static Option TraceReturnDataOpt { get; } = new("--trace.returndata", description: "Trace return data"); - - public static Command CreateCommand() - { - var cmd = new Command("t8n", "EVM State Transition command") - { - InputAllocOpt, - InputEnvOpt, - InputTxsOpt, - OutputAllocOpt, - OutputBaseDirOpt, - OutputBodyOpt, - OutputResultOpt, - StateChainIdOpt, - StateForkOpt, - StateRewardOpt, - TraceOpt, - TraceMemoryOpt, - TraceNoStackOpt, - TraceReturnDataOpt, - }; - cmd.AddAlias("transition"); - return cmd; - } -} diff --git a/tools/Evm/Evm/t8n/T8NExecutor.cs b/tools/Evm/Evm/t8n/T8NExecutor.cs deleted file mode 100644 index 570f3c0f0ea..00000000000 --- a/tools/Evm/Evm/t8n/T8NExecutor.cs +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited -// SPDX-License-Identifier: LGPL-3.0-only - -using Evm.t8n.JsonTypes; - -namespace Evm.t8n; - -public static class T8NExecutor -{ - public static void Execute(T8NCommandArguments arguments) - { - T8NTest t8nTest = T8NInputProcessor.ProcessInputAndConvertToT8NTest(arguments); - } -} diff --git a/tools/Evm/Program.cs b/tools/Evm/Program.cs new file mode 100644 index 00000000000..20c57e71887 --- /dev/null +++ b/tools/Evm/Program.cs @@ -0,0 +1,13 @@ +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using Evm.T8n; +using System.CommandLine; + +CliRootCommand rootCmd = []; + +T8nCommand.Configure(ref rootCmd); + +CliConfiguration cli = new(rootCmd); + +return cli.Invoke(args); diff --git a/tools/Evm/Evm/t8n/Errors/T8NErrorCodes.cs b/tools/Evm/T8n/Errors/T8nErrorCodes.cs similarity index 86% rename from tools/Evm/Evm/t8n/Errors/T8NErrorCodes.cs rename to tools/Evm/T8n/Errors/T8nErrorCodes.cs index cfd9e5750e1..e8c6d5ab296 100644 --- a/tools/Evm/Evm/t8n/Errors/T8NErrorCodes.cs +++ b/tools/Evm/T8n/Errors/T8nErrorCodes.cs @@ -1,11 +1,11 @@ // SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -namespace Evm.t8n.Errors; +namespace Evm.T8n.Errors; -public class T8NErrorCodes +public class T8nErrorCodes { - public const int ErrorEVM = 2; // Other EVM error + public const int ErrorEvm = 2; // Other EVM error public const int ErrorConfig = 3; // Failed configuration: when a non-supported or invalid fork was specified. public const int ErrorMissingBlockhash = 4; // Block history is not supplied, but needed for a BLOCKHASH operation. If BLOCKHASH is invoked targeting a block which history has not been provided for, the program will exit with code 4. diff --git a/tools/Evm/Evm/t8n/Errors/T8NException.cs b/tools/Evm/T8n/Errors/T8nException.cs similarity index 54% rename from tools/Evm/Evm/t8n/Errors/T8NException.cs rename to tools/Evm/T8n/Errors/T8nException.cs index c37211d2c5c..a44f6c46a5b 100644 --- a/tools/Evm/Evm/t8n/Errors/T8NException.cs +++ b/tools/Evm/T8n/Errors/T8nException.cs @@ -3,21 +3,21 @@ using Nethermind.Core.Exceptions; -namespace Evm.t8n.Errors; +namespace Evm.T8n.Errors; -public class T8NException : Exception, IExceptionWithExitCode +public class T8nException : Exception, IExceptionWithExitCode { - public T8NException(Exception e, int exitCode) : base(e.Message, e) + public T8nException(Exception e, int exitCode) : base(e.Message, e) { ExitCode = exitCode; } - public T8NException(Exception e, string message, int exitCode) : base(message, e) + public T8nException(Exception e, string message, int exitCode) : base(message, e) { ExitCode = exitCode; } - public T8NException(string message, int exitCode) : base(message) + public T8nException(string message, int exitCode) : base(message) { ExitCode = exitCode; } diff --git a/tools/Evm/Evm/t8n/JsonTypes/EnvJson.cs b/tools/Evm/T8n/JsonTypes/EnvJson.cs similarity index 98% rename from tools/Evm/Evm/t8n/JsonTypes/EnvJson.cs rename to tools/Evm/T8n/JsonTypes/EnvJson.cs index f79636d645f..4c5973265dc 100644 --- a/tools/Evm/Evm/t8n/JsonTypes/EnvJson.cs +++ b/tools/Evm/T8n/JsonTypes/EnvJson.cs @@ -5,7 +5,7 @@ using Nethermind.Core.Crypto; using Nethermind.Int256; -namespace Evm.t8n.JsonTypes; +namespace Evm.T8n.JsonTypes; public class EnvJson { diff --git a/tools/Evm/Evm/t8n/JsonTypes/InputData.cs b/tools/Evm/T8n/JsonTypes/InputData.cs similarity index 98% rename from tools/Evm/Evm/t8n/JsonTypes/InputData.cs rename to tools/Evm/T8n/JsonTypes/InputData.cs index 6cf58a894f0..2cfbf99cbb9 100644 --- a/tools/Evm/Evm/t8n/JsonTypes/InputData.cs +++ b/tools/Evm/T8n/JsonTypes/InputData.cs @@ -9,7 +9,7 @@ using Nethermind.Facade.Eth.RpcTransaction; using Nethermind.Serialization.Rlp; -namespace Evm.t8n.JsonTypes; +namespace Evm.T8n.JsonTypes; public class InputData { diff --git a/tools/Evm/Evm/t8n/JsonTypes/Ommer.cs b/tools/Evm/T8n/JsonTypes/Ommer.cs similarity index 90% rename from tools/Evm/Evm/t8n/JsonTypes/Ommer.cs rename to tools/Evm/T8n/JsonTypes/Ommer.cs index 1f89ca61ac3..96e3928547d 100644 --- a/tools/Evm/Evm/t8n/JsonTypes/Ommer.cs +++ b/tools/Evm/T8n/JsonTypes/Ommer.cs @@ -3,7 +3,7 @@ using Nethermind.Core; -namespace Evm.t8n.JsonTypes; +namespace Evm.T8n.JsonTypes; public class Ommer(int delta, Address address) { diff --git a/tools/Evm/Evm/t8n/JsonTypes/T8NTest.cs b/tools/Evm/T8n/JsonTypes/T8nTest.cs similarity index 95% rename from tools/Evm/Evm/t8n/JsonTypes/T8NTest.cs rename to tools/Evm/T8n/JsonTypes/T8nTest.cs index f50703d26c5..462dd26440f 100644 --- a/tools/Evm/Evm/t8n/JsonTypes/T8NTest.cs +++ b/tools/Evm/T8n/JsonTypes/T8nTest.cs @@ -9,9 +9,9 @@ using Nethermind.Int256; using Nethermind.Specs; -namespace Evm.t8n.JsonTypes; +namespace Evm.T8n.JsonTypes; -public class T8NTest(IReleaseSpec spec, ISpecProvider specProvider) +public class T8nTest(IReleaseSpec spec, ISpecProvider specProvider) { public IReleaseSpec Spec { get; set; } = spec; public ISpecProvider SpecProvider { get; set; } = specProvider; diff --git a/tools/Evm/Evm/t8n/JsonTypes/TransactionMetaData.cs b/tools/Evm/T8n/JsonTypes/TransactionMetaData.cs similarity index 88% rename from tools/Evm/Evm/t8n/JsonTypes/TransactionMetaData.cs rename to tools/Evm/T8n/JsonTypes/TransactionMetaData.cs index d4b66eae1fe..737a052e715 100644 --- a/tools/Evm/Evm/t8n/JsonTypes/TransactionMetaData.cs +++ b/tools/Evm/T8n/JsonTypes/TransactionMetaData.cs @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -namespace Evm.t8n.JsonTypes; +namespace Evm.T8n.JsonTypes; public class TransactionMetaData { diff --git a/tools/Evm/T8n/T8nCommand.cs b/tools/Evm/T8n/T8nCommand.cs new file mode 100644 index 00000000000..606c8b4ed43 --- /dev/null +++ b/tools/Evm/T8n/T8nCommand.cs @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.CommandLine; + +namespace Evm.T8n; + +public static class T8nCommand +{ + public static void Configure(ref CliRootCommand rootCmd) + { + CliCommand cmd = T8nCommandOptions.CreateCommand(); + + cmd.SetAction(parseResult => + { + var arguments = T8nCommandArguments.FromParseResult(parseResult); + + T8nExecutor.Execute(arguments); + }); + + rootCmd.Add(cmd); + } +} diff --git a/tools/Evm/Evm/t8n/T8NCommandArguments.cs b/tools/Evm/T8n/T8nCommandArguments.cs similarity index 55% rename from tools/Evm/Evm/t8n/T8NCommandArguments.cs rename to tools/Evm/T8n/T8nCommandArguments.cs index 32194860cd6..e80dcaaca80 100644 --- a/tools/Evm/Evm/t8n/T8NCommandArguments.cs +++ b/tools/Evm/T8n/T8nCommandArguments.cs @@ -1,12 +1,12 @@ // SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using System.CommandLine.Parsing; +using System.CommandLine; using Nethermind.Specs; -namespace Evm.t8n; +namespace Evm.T8n; -public class T8NCommandArguments +public class T8nCommandArguments { public string InputAlloc { get; set; } = "alloc.json"; public string InputEnv { get; set; } = "env.json"; @@ -26,61 +26,61 @@ public class T8NCommandArguments public bool TraceNoStack { get; set; } public bool TraceReturnData { get; set; } - public static T8NCommandArguments FromParseResult(ParseResult parseResult) + public static T8nCommandArguments FromParseResult(ParseResult parseResult) { - var arguments = new T8NCommandArguments + var arguments = new T8nCommandArguments { - OutputBody = parseResult.GetValueForOption(T8NCommandOptions.OutputBodyOpt), - OutputBaseDir = parseResult.GetValueForOption(T8NCommandOptions.OutputBaseDirOpt), - Trace = parseResult.GetValueForOption(T8NCommandOptions.TraceOpt), - TraceMemory = parseResult.GetValueForOption(T8NCommandOptions.TraceMemoryOpt), - TraceNoStack = parseResult.GetValueForOption(T8NCommandOptions.TraceNoStackOpt), - TraceReturnData = parseResult.GetValueForOption(T8NCommandOptions.TraceReturnDataOpt) + OutputBody = parseResult.GetValue(T8nCommandOptions.OutputBodyOpt), + OutputBaseDir = parseResult.GetValue(T8nCommandOptions.OutputBaseDirOpt), + Trace = parseResult.GetValue(T8nCommandOptions.TraceOpt), + TraceMemory = parseResult.GetValue(T8nCommandOptions.TraceMemoryOpt), + TraceNoStack = parseResult.GetValue(T8nCommandOptions.TraceNoStackOpt), + TraceReturnData = parseResult.GetValue(T8nCommandOptions.TraceReturnDataOpt) }; - var inputAlloc = parseResult.GetValueForOption(T8NCommandOptions.InputAllocOpt); + var inputAlloc = parseResult.GetValue(T8nCommandOptions.InputAllocOpt); if (inputAlloc is not null) { arguments.InputAlloc = inputAlloc; } - var inputEnv = parseResult.GetValueForOption(T8NCommandOptions.InputEnvOpt); + var inputEnv = parseResult.GetValue(T8nCommandOptions.InputEnvOpt); if (inputEnv is not null) { arguments.InputEnv = inputEnv; } - var inputTxs = parseResult.GetValueForOption(T8NCommandOptions.InputTxsOpt); + var inputTxs = parseResult.GetValue(T8nCommandOptions.InputTxsOpt); if (inputTxs is not null) { arguments.InputTxs = inputTxs; } - var outputAlloc = parseResult.GetValueForOption(T8NCommandOptions.OutputAllocOpt); + var outputAlloc = parseResult.GetValue(T8nCommandOptions.OutputAllocOpt); if (outputAlloc is not null) { arguments.OutputAlloc = outputAlloc; } - var outputResult = parseResult.GetValueForOption(T8NCommandOptions.OutputResultOpt); + var outputResult = parseResult.GetValue(T8nCommandOptions.OutputResultOpt); if (outputResult is not null) { arguments.OutputResult = outputResult; } - var stateFork = parseResult.GetValueForOption(T8NCommandOptions.StateForkOpt); + var stateFork = parseResult.GetValue(T8nCommandOptions.StateForkOpt); if (stateFork is not null) { arguments.StateFork = stateFork; } - var stateReward = parseResult.GetValueForOption(T8NCommandOptions.StateRewardOpt); + var stateReward = parseResult.GetValue(T8nCommandOptions.StateRewardOpt); if (stateReward is not null) { arguments.StateReward = stateReward; } - var stateChainId = parseResult.GetValueForOption(T8NCommandOptions.StateChainIdOpt); + var stateChainId = parseResult.GetValue(T8nCommandOptions.StateChainIdOpt); if (stateChainId.HasValue) { arguments.StateChainId = stateChainId.Value; diff --git a/tools/Evm/T8n/T8nCommandOptions.cs b/tools/Evm/T8n/T8nCommandOptions.cs new file mode 100644 index 00000000000..33b8b2ea89d --- /dev/null +++ b/tools/Evm/T8n/T8nCommandOptions.cs @@ -0,0 +1,92 @@ +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using System.CommandLine; + +namespace Evm.T8n; + +public static class T8nCommandOptions +{ + public static CliOption InputAllocOpt { get; } = new("--input-alloc") + { + Description = "Input allocations" + }; + public static CliOption InputEnvOpt { get; } = new("--input-env") + { + Description = "Input environment" + }; + public static CliOption InputTxsOpt { get; } = new("--input-txs") + { + Description = "Input transactions" + }; + + public static CliOption OutputAllocOpt { get; } = new("--output-alloc") + { + Description = "Output allocations" + }; + public static CliOption OutputResultOpt { get; } = new("--output-result") + { + Description = "Output result" + }; + public static CliOption OutputBodyOpt { get; } = new("--output-body") + { + Description = "Output body" + }; + public static CliOption OutputBaseDirOpt { get; } = new("--output-basedir") + { + Description = "Output base directory" + }; + + public static CliOption StateChainIdOpt { get; } = new("--state-chainid") + { + Description = "State chain id" + }; + public static CliOption StateForkOpt { get; } = new("--state-fork") + { + Description = "State fork" + }; + public static CliOption StateRewardOpt { get; } = new("--state-reward") + { + Description = "State reward" + }; + public static CliOption TraceOpt { get; } = new("--trace") + { + Description = "Configures the use of the JSON opcode tracer. This tracer emits traces to files as trace--.json" + }; + public static CliOption TraceMemoryOpt { get; } = new("--trace-memory") + { + Description = "Trace memory" + }; + public static CliOption TraceNoStackOpt { get; } = new("--trace-nostack") + { + Description = "Trace no stack" + }; + public static CliOption TraceReturnDataOpt { get; } = new("--trace-returndata") + { + Description = "Trace return data" + }; + + public static CliCommand CreateCommand() + { + CliCommand cmd = new("t8n", "EVM state transition") + { + InputAllocOpt, + InputEnvOpt, + InputTxsOpt, + OutputAllocOpt, + OutputBaseDirOpt, + OutputBodyOpt, + OutputResultOpt, + StateChainIdOpt, + StateForkOpt, + StateRewardOpt, + TraceOpt, + TraceMemoryOpt, + TraceNoStackOpt, + TraceReturnDataOpt, + }; + cmd.Aliases.Add("transition"); + + return cmd; + } +} diff --git a/tools/Evm/T8n/T8nExecutor.cs b/tools/Evm/T8n/T8nExecutor.cs new file mode 100644 index 00000000000..307f1c83afa --- /dev/null +++ b/tools/Evm/T8n/T8nExecutor.cs @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using Evm.T8n.JsonTypes; + +namespace Evm.T8n; + +public static class T8nExecutor +{ + public static void Execute(T8nCommandArguments arguments) + { + T8nTest t8nTest = T8nInputProcessor.ProcessInputAndConvertToT8nTest(arguments); + } +} diff --git a/tools/Evm/Evm/t8n/T8NInputProcessor.cs b/tools/Evm/T8n/T8nInputProcessor.cs similarity index 85% rename from tools/Evm/Evm/t8n/T8NInputProcessor.cs rename to tools/Evm/T8n/T8nInputProcessor.cs index cb7e44db382..45abf4c104c 100644 --- a/tools/Evm/Evm/t8n/T8NInputProcessor.cs +++ b/tools/Evm/T8n/T8nInputProcessor.cs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: LGPL-3.0-only using Ethereum.Test.Base; -using Evm.t8n.Errors; -using Evm.t8n.JsonTypes; +using Evm.T8n.Errors; +using Evm.T8n.JsonTypes; using Nethermind.Core.Specs; using Nethermind.Evm.Tracing.GethStyle; using Nethermind.Int256; @@ -12,24 +12,24 @@ using Nethermind.Specs.Forks; using Nethermind.Specs.Test; -namespace Evm.t8n; +namespace Evm.T8n; -public static class T8NInputProcessor +public static class T8nInputProcessor { private static readonly TxDecoder TxDecoder = TxDecoder.Instance; - public static T8NTest ProcessInputAndConvertToT8NTest(T8NCommandArguments arguments) + public static T8nTest ProcessInputAndConvertToT8nTest(T8nCommandArguments arguments) { - InputData inputData = T8NInputReader.ReadInputData(arguments); + InputData inputData = T8nInputReader.ReadInputData(arguments); if (inputData.Env is null) { - throw new T8NException("Env is not provided", T8NErrorCodes.ErrorIO); + throw new T8nException("Env is not provided", T8nErrorCodes.ErrorIO); } (ISpecProvider specProvider, IReleaseSpec spec) = GetSpec(arguments, inputData.Env); - T8NValidator.ApplyChecks(inputData.Env, specProvider, spec); + T8nValidator.ApplyChecks(inputData.Env, specProvider, spec); var gethTraceOptions = new GethTraceOptions { @@ -37,7 +37,7 @@ public static T8NTest ProcessInputAndConvertToT8NTest(T8NCommandArguments argume DisableStack = arguments.TraceNoStack }; - T8NTest test = new(spec, specProvider) + T8nTest test = new(spec, specProvider) { Alloc = inputData.Alloc ?? [], Transactions = inputData.GetTransactions(TxDecoder), @@ -69,7 +69,7 @@ public static T8NTest ProcessInputAndConvertToT8NTest(T8NCommandArguments argume return test; } - private static (ISpecProvider, IReleaseSpec) GetSpec(T8NCommandArguments arguments, EnvJson env) + private static (ISpecProvider, IReleaseSpec) GetSpec(T8nCommandArguments arguments, EnvJson env) { IReleaseSpec spec; try @@ -78,7 +78,7 @@ private static (ISpecProvider, IReleaseSpec) GetSpec(T8NCommandArguments argumen } catch (NotSupportedException e) { - throw new T8NException(e, $"unsupported fork {arguments.StateFork}", T8NErrorCodes.ErrorConfig); + throw new T8nException(e, $"unsupported fork {arguments.StateFork}", T8nErrorCodes.ErrorConfig); } OverridableReleaseSpec overridableReleaseSpec = new(spec); diff --git a/tools/Evm/Evm/t8n/T8NInputReader.cs b/tools/Evm/T8n/T8nInputReader.cs similarity index 79% rename from tools/Evm/Evm/t8n/T8NInputReader.cs rename to tools/Evm/T8n/T8nInputReader.cs index 4cf86c29d2e..bf89abf1963 100644 --- a/tools/Evm/Evm/t8n/T8NInputReader.cs +++ b/tools/Evm/T8n/T8nInputReader.cs @@ -3,20 +3,20 @@ using System.Text.Json; using Ethereum.Test.Base; -using Evm.t8n.Errors; -using Evm.t8n.JsonTypes; +using Evm.T8n.Errors; +using Evm.T8n.JsonTypes; using Nethermind.Core; using Nethermind.Facade.Eth.RpcTransaction; using Nethermind.Serialization.Json; -namespace Evm.t8n; +namespace Evm.T8n; -public static class T8NInputReader +public static class T8nInputReader { private static readonly EthereumJsonSerializer EthereumJsonSerializer = new(); private const string Stdin = "stdin"; - public static InputData ReadInputData(T8NCommandArguments arguments) + public static InputData ReadInputData(T8nCommandArguments arguments) { InputData inputData = new(); @@ -47,7 +47,7 @@ public static InputData ReadInputData(T8NCommandArguments arguments) inputData.TxRlp = File.ReadAllText(arguments.InputTxs).Replace("\"", "").Replace("\n", ""); break; default: - throw new T8NException("Transactions file support only rlp, json formats", T8NErrorCodes.ErrorIO); + throw new T8nException("Transactions file support only rlp, json formats", T8nErrorCodes.ErrorIO); } } @@ -63,11 +63,11 @@ private static T LoadDataFromFile(string filePath, string description) } catch (FileNotFoundException e) { - throw new T8NException(e, "failed reading {filePath} file: {description}", T8NErrorCodes.ErrorIO); + throw new T8nException(e, "failed reading {filePath} file: {description}", T8nErrorCodes.ErrorIO); } catch (JsonException e) { - throw new T8NException(e, $"failed unmarshalling {filePath} file: {description}", T8NErrorCodes.ErrorJson); + throw new T8nException(e, $"failed unmarshalling {filePath} file: {description}", T8nErrorCodes.ErrorJson); } } @@ -80,7 +80,7 @@ private static InputData ReadStdInput() } catch (Exception e) { - throw new T8NException(e, T8NErrorCodes.ErrorJson); + throw new T8nException(e, T8nErrorCodes.ErrorJson); } } } diff --git a/tools/Evm/Evm/t8n/T8NValidator.cs b/tools/Evm/T8n/T8nValidator.cs similarity index 75% rename from tools/Evm/Evm/t8n/T8NValidator.cs rename to tools/Evm/T8n/T8nValidator.cs index 00ae49b80d6..f302bff3c5b 100644 --- a/tools/Evm/Evm/t8n/T8NValidator.cs +++ b/tools/Evm/T8n/T8nValidator.cs @@ -1,17 +1,17 @@ // SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using Evm.t8n.Errors; -using Evm.t8n.JsonTypes; +using Evm.T8n.Errors; +using Evm.T8n.JsonTypes; using Nethermind.Consensus.Ethash; using Nethermind.Core; using Nethermind.Core.Specs; using Nethermind.Core.Test.Builders; using Nethermind.Specs.Forks; -namespace Evm.t8n; +namespace Evm.T8n; -public static class T8NValidator +public static class T8nValidator { public static void ApplyChecks(EnvJson env, ISpecProvider specProvider, IReleaseSpec spec) { @@ -28,8 +28,8 @@ private static void ApplyLondonChecks(EnvJson env, IReleaseSpec spec) if (!env.ParentBaseFee.HasValue || env.CurrentNumber == 0) { - throw new T8NException("EIP-1559 config but missing 'parentBaseFee' in env section", - T8NErrorCodes.ErrorConfig); + throw new T8nException("EIP-1559 config but missing 'parentBaseFee' in env section", + T8nErrorCodes.ErrorConfig); } var parent = Build.A.BlockHeader.WithNumber(env.CurrentNumber - 1).WithBaseFee(env.ParentBaseFee.Value) @@ -42,8 +42,8 @@ private static void ApplyShanghaiChecks(EnvJson env, IReleaseSpec spec) if (spec is not Shanghai) return; if (env.Withdrawals is null) { - throw new T8NException("Shanghai config but missing 'withdrawals' in env section", - T8NErrorCodes.ErrorConfig); + throw new T8nException("Shanghai config but missing 'withdrawals' in env section", + T8nErrorCodes.ErrorConfig); } } @@ -57,8 +57,8 @@ private static void ApplyCancunChecks(EnvJson env, IReleaseSpec spec) if (env.ParentBeaconBlockRoot is null) { - throw new T8NException("post-cancun env requires parentBeaconBlockRoot to be set", - T8NErrorCodes.ErrorConfig); + throw new T8nException("post-cancun env requires parentBeaconBlockRoot to be set", + T8nErrorCodes.ErrorConfig); } } @@ -67,33 +67,33 @@ private static void ApplyMergeChecks(EnvJson env, ISpecProvider specProvider) if (specProvider.TerminalTotalDifficulty?.IsZero ?? false) { if (env.CurrentRandom is null) - throw new T8NException("post-merge requires currentRandom to be defined in env", - T8NErrorCodes.ErrorConfig); + throw new T8nException("post-merge requires currentRandom to be defined in env", + T8nErrorCodes.ErrorConfig); if (env.CurrentDifficulty?.IsZero ?? false) - throw new T8NException("post-merge difficulty must be zero (or omitted) in env", - T8NErrorCodes.ErrorConfig); + throw new T8nException("post-merge difficulty must be zero (or omitted) in env", + T8nErrorCodes.ErrorConfig); return; } if (env.CurrentDifficulty is not null) return; if (!env.ParentDifficulty.HasValue) { - throw new T8NException( + throw new T8nException( "currentDifficulty was not provided, and cannot be calculated due to missing parentDifficulty", - T8NErrorCodes.ErrorConfig); + T8nErrorCodes.ErrorConfig); } if (env.CurrentNumber == 0) { - throw new T8NException("currentDifficulty needs to be provided for block number 0", - T8NErrorCodes.ErrorConfig); + throw new T8nException("currentDifficulty needs to be provided for block number 0", + T8nErrorCodes.ErrorConfig); } if (env.CurrentTimestamp <= env.ParentTimestamp) { - throw new T8NException( + throw new T8nException( $"currentDifficulty cannot be calculated -- currentTime ({env.CurrentTimestamp}) needs to be after parent time ({env.ParentTimestamp})", - T8NErrorCodes.ErrorConfig); + T8nErrorCodes.ErrorConfig); } EthashDifficultyCalculator difficultyCalculator = new(specProvider);