Skip to content

Commit

Permalink
evm_transition_tool: accept fork_name
Browse files Browse the repository at this point in the history
Co-authored-by: danceratopz <danceratopz@gmail.com>
  • Loading branch information
marioevz and danceratopz committed Jul 25, 2023
1 parent 294fadd commit 713ea63
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/ethereum_test_tools/spec/blockchain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def make_block(
alloc=previous_alloc,
txs=to_json(txs),
env=to_json(env),
fork=fork,
block_number=Number(env.number),
block_timestamp=Number(env.timestamp),
fork_name=fork.fork(
block_number=Number(env.number), timestamp=Number(env.timestamp)
),
chain_id=chain_id,
reward=fork.get_reward(Number(env.number), Number(env.timestamp)),
eips=eips,
Expand Down
4 changes: 1 addition & 3 deletions src/ethereum_test_tools/spec/state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ def make_blocks(
alloc=to_json(Alloc(self.pre)),
txs=to_json(txs),
env=to_json(env),
fork=fork,
block_number=Number(env.number),
block_timestamp=Number(env.timestamp),
fork_name=fork.fork(block_number=Number(env.number), timestamp=Number(env.timestamp)),
chain_id=chain_id,
reward=fork.get_reward(Number(env.number), Number(env.timestamp)),
eips=eips,
Expand Down
6 changes: 2 additions & 4 deletions src/evm_transition_tool/besu.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,18 @@ def evaluate(
alloc: Any,
txs: Any,
env: Any,
fork: Fork,
block_number: int,
block_timestamp: int,
fork_name: str,
chain_id: int = 1,
reward: int = 0,
eips: Optional[List[int]] = None,
debug_output_path: str = "",
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""
Executes `evm t8n` with the specified arguments.
"""
if not self.process:
self.start_server()

fork_name = fork.fork(block_number, block_timestamp)
if eips is not None:
fork_name = "+".join([fork_name] + [str(eip) for eip in eips])

Expand Down
5 changes: 1 addition & 4 deletions src/evm_transition_tool/evmone.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def evaluate(
alloc: Any,
txs: Any,
env: Any,
fork: Fork,
block_number: int,
block_timestamp: int,
fork_name: str,
chain_id: int = 1,
reward: int = 0,
eips: Optional[List[int]] = None,
Expand All @@ -61,7 +59,6 @@ def evaluate(
"""
Executes `evmone-t8n` with the specified arguments.
"""
fork_name = fork.fork(block_number, block_timestamp)
if eips is not None:
fork_name = "+".join([fork_name] + [str(eip) for eip in eips])

Expand Down
5 changes: 1 addition & 4 deletions src/evm_transition_tool/geth.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def evaluate(
alloc: Any,
txs: Any,
env: Any,
fork: Fork,
block_number: int,
block_timestamp: int,
fork_name: str,
chain_id: int = 1,
reward: int = 0,
eips: Optional[List[int]] = None,
Expand All @@ -60,7 +58,6 @@ def evaluate(
"""
Executes `evm t8n` with the specified arguments.
"""
fork_name = fork.fork(block_number, block_timestamp)
if eips is not None:
fork_name = "+".join([fork_name] + [str(eip) for eip in eips])

Expand Down
11 changes: 6 additions & 5 deletions src/evm_transition_tool/tests/test_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,17 @@ def test_evm_t8n(t8n: TransitionTool, test_dir: str) -> None:
print(expected_path)
alloc = json.load(alloc)
txs = json.load(txs)
env = json.load(env)
env_json = json.load(env)
expected = json.load(exp)

result_alloc, result = t8n.evaluate(
alloc=alloc,
txs=txs,
env=env,
fork=Berlin,
block_number=0,
block_timestamp=0,
env=env_json,
fork_name=Berlin.fork(
block_number=int(env_json["currentNumber"], 0),
timestamp=int(env_json["currentTimestamp"], 0),
),
)
print(result)
assert result_alloc == expected.get("alloc")
Expand Down
12 changes: 3 additions & 9 deletions src/evm_transition_tool/transition_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ def evaluate(
alloc: Any,
txs: Any,
env: Any,
fork: Fork,
block_number: int,
block_timestamp: int,
fork_name: str,
chain_id: int = 1,
reward: int = 0,
eips: Optional[List[int]] = None,
Expand Down Expand Up @@ -232,9 +230,7 @@ def calc_state_root(self, *, alloc: Any, fork: Fork, debug_output_path: str = ""
alloc=alloc,
txs=[],
env=env,
fork=fork,
block_number=0,
block_timestamp=0,
fork_name=fork.fork(block_number=0, timestamp=0),
debug_output_path=debug_output_path,
)
state_root = result.get("stateRoot")
Expand Down Expand Up @@ -276,9 +272,7 @@ def calc_withdrawals_root(
alloc={},
txs=[],
env=env,
fork=fork,
block_number=0,
block_timestamp=0,
fork_name=fork.fork(block_number=0, timestamp=0),
debug_output_path=debug_output_path,
)
withdrawals_root = result.get("withdrawalsRoot")
Expand Down

0 comments on commit 713ea63

Please sign in to comment.