From deb31715f436108a010eefa1f1e5d7aeaeec5649 Mon Sep 17 00:00:00 2001 From: Dimitry Kh Date: Wed, 5 Jul 2023 00:11:54 +0200 Subject: [PATCH 1/2] attempt to fix -v --version and t8n args for different t8ns --- src/evm_transition_tool/__init__.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/evm_transition_tool/__init__.py b/src/evm_transition_tool/__init__.py index 0fd9cf5bec..bf5c4e6116 100644 --- a/src/evm_transition_tool/__init__.py +++ b/src/evm_transition_tool/__init__.py @@ -149,6 +149,7 @@ class EvmTransitionTool(TransitionTool): binary: Path cached_version: Optional[str] = None trace: bool + require_t8n: bool = True def __init__( self, @@ -174,6 +175,10 @@ def __init__( raise Exception("evm process unexpectedly returned a non-zero status code: " f"{e}.") except Exception as e: raise Exception(f"Unexpected exception calling evm tool: {e}.") + if not result.stdout.strip(): + args = [str(self.binary), "--help"] + result = subprocess.run(args, capture_output=True, text=True) + self.require_t8n = False self.help_string = result.stdout def evaluate( @@ -199,7 +204,6 @@ def evaluate( reward = -1 args = [ str(self.binary), - "t8n", "--input.alloc=stdin", "--input.txs=stdin", "--input.env=stdin", @@ -212,6 +216,9 @@ def evaluate( f"--state.reward={reward}", ] + if self.require_t8n: + args.insert(1, "t8n") + if self.trace: args.append("--trace") @@ -264,6 +271,12 @@ def version(self) -> str: stdout=subprocess.PIPE, ) + if result.returncode != 0: + result = subprocess.run( + [str(self.binary), "--version"], + stdout=subprocess.PIPE, + ) + if result.returncode != 0: raise Exception("failed to evaluate: " + result.stderr.decode()) From e33cd84eefc6e85ff3b9eaa5e82ca9b0ff8cd658 Mon Sep 17 00:00:00 2001 From: spencer-tb Date: Wed, 5 Jul 2023 14:18:27 -0600 Subject: [PATCH 2/2] src/evm_transition_tool: Tox fix. --- src/evm_transition_tool/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/evm_transition_tool/__init__.py b/src/evm_transition_tool/__init__.py index bf5c4e6116..60e4d34e89 100644 --- a/src/evm_transition_tool/__init__.py +++ b/src/evm_transition_tool/__init__.py @@ -273,9 +273,9 @@ def version(self) -> str: if result.returncode != 0: result = subprocess.run( - [str(self.binary), "--version"], - stdout=subprocess.PIPE, - ) + [str(self.binary), "--version"], + stdout=subprocess.PIPE, + ) if result.returncode != 0: raise Exception("failed to evaluate: " + result.stderr.decode())