Skip to content

Commit

Permalink
Refactor Evm tool (#7701)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubo authored Nov 2, 2024
1 parent 5af8f17 commit 4950b6f
Show file tree
Hide file tree
Showing 23 changed files with 249 additions and 202 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions tools/Evm/Evm.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.24517.1" />
<ProjectReference Include="..\..\src\Nethermind\Ethereum.Test.Base\Ethereum.Test.Base.csproj" />
<ProjectReference Include="..\..\src\Nethermind\Nethermind.Core\Nethermind.Core.csproj" />
<ProjectReference Include="..\..\src\Nethermind\Nethermind.Evm\Nethermind.Evm.csproj" />
<ProjectReference Include="..\..\src\Nethermind\Nethermind.Db\Nethermind.Db.csproj" />
<ProjectReference Include="..\..\src\Nethermind\Nethermind.Specs\Nethermind.Specs.csproj" />
<ProjectReference Include="..\..\src\Nethermind\Nethermind.Trie\Nethermind.Trie.csproj" />
<ProjectReference Include="..\..\src\Nethermind\Nethermind.Consensus\Nethermind.Consensus.csproj" />
<ProjectReference Include="..\..\src\Nethermind\Nethermind.Consensus.AuRa\Nethermind.Consensus.AuRa.csproj" />
</ItemGroup>

</Project>
16 changes: 11 additions & 5 deletions tools/Evm/Evm.sln
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@

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
Debug|Any CPU = Debug|Any CPU
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
22 changes: 0 additions & 22 deletions tools/Evm/Evm/Evm.csproj

This file was deleted.

16 changes: 0 additions & 16 deletions tools/Evm/Evm/Program.cs

This file was deleted.

22 changes: 0 additions & 22 deletions tools/Evm/Evm/t8n/T8NCommand.cs

This file was deleted.

50 changes: 0 additions & 50 deletions tools/Evm/Evm/t8n/T8NCommandOptions.cs

This file was deleted.

14 changes: 0 additions & 14 deletions tools/Evm/Evm/t8n/T8NExecutor.cs

This file was deleted.

13 changes: 13 additions & 0 deletions tools/Evm/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Nethermind.Core.Crypto;
using Nethermind.Int256;

namespace Evm.t8n.JsonTypes;
namespace Evm.T8n.JsonTypes;

public class EnvJson
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Nethermind.Facade.Eth.RpcTransaction;
using Nethermind.Serialization.Rlp;

namespace Evm.t8n.JsonTypes;
namespace Evm.T8n.JsonTypes;

public class InputData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using Nethermind.Core;

namespace Evm.t8n.JsonTypes;
namespace Evm.T8n.JsonTypes;

public class Ommer(int delta, Address address)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
23 changes: 23 additions & 0 deletions tools/Evm/T8n/T8nCommand.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading

0 comments on commit 4950b6f

Please sign in to comment.