-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
- Loading branch information
1 parent
cedb007
commit 9e12334
Showing
15 changed files
with
210 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Evm", "Evm\Evm.csproj", "{9D450C5A-C4B3-457A-8398-4690DFF4C47C}" | ||
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 | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<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.22272.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System.CommandLine.Parsing; | ||
|
||
namespace Evm.t8n; | ||
|
||
public class T8NCommandArguments | ||
{ | ||
public string? InputAlloc { get; set; } | ||
public string? InputEnv { get; set; } | ||
public string? InputTxs { get; set; } | ||
|
||
public string? OutputAlloc { get; set; } | ||
public string? OutputResult { get; set; } | ||
public string? OutputBody { get; set; } | ||
public string? OutputBaseDir { get; set; } | ||
|
||
public ulong? StateChainId { get; set; } | ||
public string? StateFork { get; set; } | ||
public string? StateReward { get; set; } | ||
|
||
public bool? Trace { get; set; } | ||
public bool? TraceMemory { get; set; } | ||
public bool? TraceNoStack { get; set; } | ||
public bool? TraceReturnData { get; set; } | ||
|
||
public static T8NCommandArguments FromParseResult(ParseResult parseResult) | ||
{ | ||
return new T8NCommandArguments | ||
{ | ||
InputAlloc = parseResult.GetValueForOption(T8NCommandOptions.InputAllocOpt), | ||
InputEnv = parseResult.GetValueForOption(T8NCommandOptions.InputEnvOpt), | ||
InputTxs = parseResult.GetValueForOption(T8NCommandOptions.InputTxsOpt), | ||
|
||
OutputAlloc = parseResult.GetValueForOption(T8NCommandOptions.OutputAllocOpt), | ||
OutputResult = parseResult.GetValueForOption(T8NCommandOptions.OutputResultOpt), | ||
OutputBody = parseResult.GetValueForOption(T8NCommandOptions.OutputBodyOpt), | ||
OutputBaseDir = parseResult.GetValueForOption(T8NCommandOptions.OutputBaseDirOpt), | ||
|
||
StateChainId = parseResult.GetValueForOption(T8NCommandOptions.StateChainIdOpt), | ||
StateFork = parseResult.GetValueForOption(T8NCommandOptions.StateForkOpt), | ||
StateReward = parseResult.GetValueForOption(T8NCommandOptions.StateRewardOpt), | ||
|
||
Trace = parseResult.GetValueForOption(T8NCommandOptions.TraceOpt), | ||
TraceMemory = parseResult.GetValueForOption(T8NCommandOptions.TraceMemoryOpt), | ||
TraceNoStack = parseResult.GetValueForOption(T8NCommandOptions.TraceNoStackOpt), | ||
TraceReturnData = parseResult.GetValueForOption(T8NCommandOptions.TraceReturnDataOpt) | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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<string> InputAllocOpt { get; } = new Option<string>("--input.alloc", description: "Input allocations", getDefaultValue: () => "alloc.json"); | ||
public static Option<string> InputEnvOpt { get; } = new Option<string>("--input.env", description: "Input environment", getDefaultValue: () => "env.json"); | ||
public static Option<string> InputTxsOpt { get; } = new Option<string>("--input.txs", description: "Input transactions", getDefaultValue: () => "txs.json"); | ||
|
||
public static Option<string> OutputAllocOpt { get; } = new Option<string>("--output.alloc", description: "Output allocations", getDefaultValue: () => "alloc.json"); | ||
public static Option<string> OutputResultOpt { get; } = new Option<string>("--output.result", description: "Output result", getDefaultValue: () => "result.json"); | ||
public static Option<string> OutputBodyOpt { get; } = new Option<string>("--output.body", description: "Output body"); | ||
public static Option<string> OutputBaseDirOpt { get; } = new Option<string>("--output.basedir", description: "Output base directory"); | ||
|
||
public static Option<ulong> StateChainIdOpt { get; } = new Option<ulong>("--state.chainid", description: "State chain id", getDefaultValue: () => 1); | ||
public static Option<string> StateForkOpt { get; } = new Option<string>("--state.fork", description: "State fork", getDefaultValue: () => "GrayGlacier"); | ||
public static Option<string> StateRewardOpt { get; } = new Option<string>("--state.reward", description: "State reward"); | ||
|
||
public static Option<bool> TraceOpt { get; } = new Option<bool>("--trace", description: "Configures the use of the JSON opcode tracer. This tracer emits traces to files as trace-<txIndex>-<txHash>.json", getDefaultValue: () => false); | ||
public static Option<bool> TraceMemoryOpt { get; } = new Option<bool>("--trace.memory", description: "Trace memory", getDefaultValue: () => false); | ||
public static Option<bool> TraceNoStackOpt { get; } = new Option<bool>("--trace.nostack", description: "Trace no stack", getDefaultValue: () => false); | ||
public static Option<bool> TraceReturnDataOpt { get; } = new Option<bool>("--trace.returndata", description: "Trace return data", getDefaultValue: () => false); | ||
|
||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
namespace Evm.t8n; | ||
|
||
public static class T8NExecutor | ||
{ | ||
public static void Execute(T8NCommandArguments arguments) | ||
{ | ||
|
||
} | ||
} |