Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix -v --version t8n args for different t8ns #192

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/evm_transition_tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class EvmTransitionTool(TransitionTool):
binary: Path
cached_version: Optional[str] = None
trace: bool
require_t8n: bool = True

def __init__(
self,
Expand All @@ -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():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this check it does not seem reliable

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(
Expand All @@ -199,7 +204,6 @@ def evaluate(
reward = -1
args = [
str(self.binary),
"t8n",
"--input.alloc=stdin",
"--input.txs=stdin",
"--input.env=stdin",
Expand All @@ -212,6 +216,9 @@ def evaluate(
f"--state.reward={reward}",
]

if self.require_t8n:
args.insert(1, "t8n")

if self.trace:
args.append("--trace")

Expand Down Expand Up @@ -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())

Expand Down