Skip to content

Commit 57cd36c

Browse files
gurukamathdanceratopzmarioevz
authored
chore(deps): remove dependency on ethereum-execution (#1787)
* remove eels dependency * chore(cli,fill): try increasing resolver timeout to fix fails * Revert "chore(cli,fill): try increasing resolver timeout to fix fails" This reverts commit e6243b3. * Fix CI * Use a template for eels_resolutions.json --------- Co-authored-by: danceratopz <[email protected]> Co-authored-by: Mario Vega <[email protected]>
1 parent d5f545f commit 57cd36c

File tree

7 files changed

+466
-40
lines changed

7 files changed

+466
-40
lines changed

.github/configs/eels_resolutions.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
22
"Frontier": {
3-
"path": "../../execution-specs/src/ethereum/frontier"
3+
"path": "$GITHUB_WORKSPACE/execution-specs/"
44
},
55
"Homestead": {
6-
"path": "../../execution-specs/src/ethereum/homestead"
6+
"path": "$GITHUB_WORKSPACE/execution-specs/"
77
},
88
"Byzantium": {
9-
"path": "../../execution-specs/src/ethereum/byzantium"
9+
"path": "$GITHUB_WORKSPACE/execution-specs/"
1010
},
1111
"ConstantinopleFix": {
12-
"path": "../../execution-specs/src/ethereum/constantinople"
12+
"path": "$GITHUB_WORKSPACE/execution-specs/"
1313
},
1414
"Istanbul": {
15-
"path": "../../execution-specs/src/ethereum/istanbul"
15+
"path": "$GITHUB_WORKSPACE/execution-specs/"
1616
},
1717
"Berlin": {
18-
"path": "../../execution-specs/src/ethereum/berlin"
18+
"path": "$GITHUB_WORKSPACE/execution-specs/"
1919
},
2020
"London": {
21-
"path": "../../execution-specs/src/ethereum/london"
21+
"path": "$GITHUB_WORKSPACE/execution-specs/"
2222
},
2323
"Merge": {
24-
"path": "../../execution-specs/src/ethereum/paris"
24+
"path": "$GITHUB_WORKSPACE/execution-specs/"
2525
},
2626
"Shanghai": {
27-
"path": "../../execution-specs/src/ethereum/shanghai"
27+
"path": "$GITHUB_WORKSPACE/execution-specs/"
2828
},
2929
"Cancun": {
30-
"path": "../../execution-specs/src/ethereum/cancun"
30+
"path": "$GITHUB_WORKSPACE/execution-specs/"
3131
},
3232
"Prague": {
3333
"git_url": "https://github.com/ethereum/execution-specs.git",

.github/workflows/tox_verify.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ jobs:
118118
repository: ethereum/execution-specs
119119
ref: fa847a0e48309debee8edc510ceddb2fd5db2f2e
120120
path: execution-specs
121-
sparse-checkout: |
122-
src/ethereum
123121
fetch-depth: 1
124122
- name: Install uv ${{ vars.UV_VERSION }} and python ${{ matrix.python }}
125123
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182
@@ -134,6 +132,9 @@ jobs:
134132
targets: "evmone-t8n"
135133
- name: Build GETH EVM
136134
uses: ./.github/actions/build-evm-client/geth
135+
- name: Update eels_resolutions.json
136+
run: |
137+
sed -i -e "s|\$GITHUB_WORKSPACE|${GITHUB_WORKSPACE}|g" .github/configs/eels_resolutions.json
137138
- name: Run tox - run framework unit tests with pytest
138139
env:
139140
EELS_RESOLUTIONS_FILE: ${{ github.workspace }}/.github/configs/eels_resolutions.json
@@ -161,8 +162,6 @@ jobs:
161162
repository: ethereum/execution-specs
162163
ref: fa847a0e48309debee8edc510ceddb2fd5db2f2e
163164
path: execution-specs
164-
sparse-checkout: |
165-
src/ethereum
166165
fetch-depth: 1
167166
- name: Install uv ${{ vars.UV_VERSION }} and python ${{ matrix.python }}
168167
uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182
@@ -171,6 +170,9 @@ jobs:
171170
cache-dependency-glob: "uv.lock"
172171
version: ${{ vars.UV_VERSION }}
173172
python-version: ${{ matrix.python }}
173+
- name: Update eels_resolutions.json
174+
run: |
175+
sed -i -e "s|\$GITHUB_WORKSPACE|${GITHUB_WORKSPACE}|g" .github/configs/eels_resolutions.json
174176
- name: Run tox - fill tests for deployed forks
175177
env:
176178
EELS_RESOLUTIONS_FILE: ${{ github.workspace }}/.github/configs/eels_resolutions.json

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ classifiers = [
1919
]
2020
dependencies = [
2121
"click>=8.1.0,<9",
22-
"ethereum-execution==1.17.0rc6.dev1",
2322
"hive.py @ git+https://github.com/marioevz/hive.py",
2423
"ethereum-spec-evm-resolver",
2524
"gitpython>=3.1.31,<4",

src/ethereum_test_types/account_types.py

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""Account-related types for Ethereum tests."""
22

3-
from dataclasses import dataclass
4-
from typing import List, Literal
3+
from dataclasses import dataclass, field
4+
from typing import Dict, List, Literal, Optional, Tuple
55

66
from coincurve.keys import PrivateKey
7-
from ethereum.frontier.fork_types import Account as FrontierAccount
8-
from ethereum.frontier.fork_types import Address as FrontierAddress
9-
from ethereum.frontier.state import State, set_account, set_storage, state_root
7+
from ethereum_types.bytes import Bytes20
108
from ethereum_types.numeric import U256, Bytes32, Uint
119
from pydantic import PrivateAttr
1210

@@ -26,8 +24,70 @@
2624
)
2725
from ethereum_test_vm import EVMCodeType
2826

27+
from .trie import EMPTY_TRIE_ROOT, FrontierAccount, Trie, root, trie_get, trie_set
2928
from .utils import keccak256
3029

30+
FrontierAddress = Bytes20
31+
32+
33+
@dataclass
34+
class State:
35+
"""Contains all information that is preserved between transactions."""
36+
37+
_main_trie: Trie[Bytes20, Optional[FrontierAccount]] = field(
38+
default_factory=lambda: Trie(secured=True, default=None)
39+
)
40+
_storage_tries: Dict[Bytes20, Trie[Bytes32, U256]] = field(default_factory=dict)
41+
_snapshots: List[
42+
Tuple[
43+
Trie[Bytes20, Optional[FrontierAccount]],
44+
Dict[Bytes20, Trie[Bytes32, U256]],
45+
]
46+
] = field(default_factory=list)
47+
48+
49+
def set_account(state: State, address: Bytes20, account: Optional[FrontierAccount]) -> None:
50+
"""
51+
Set the `Account` object at an address. Setting to `None` deletes
52+
the account (but not its storage, see `destroy_account()`).
53+
"""
54+
trie_set(state._main_trie, address, account)
55+
56+
57+
def set_storage(state: State, address: Bytes20, key: Bytes32, value: U256) -> None:
58+
"""
59+
Set a value at a storage key on an account. Setting to `U256(0)` deletes
60+
the key.
61+
"""
62+
assert trie_get(state._main_trie, address) is not None
63+
64+
trie = state._storage_tries.get(address)
65+
if trie is None:
66+
trie = Trie(secured=True, default=U256(0))
67+
state._storage_tries[address] = trie
68+
trie_set(trie, key, value)
69+
if trie._data == {}:
70+
del state._storage_tries[address]
71+
72+
73+
def storage_root(state: State, address: Bytes20) -> Bytes32:
74+
"""Calculate the storage root of an account."""
75+
assert not state._snapshots
76+
if address in state._storage_tries:
77+
return root(state._storage_tries[address])
78+
else:
79+
return EMPTY_TRIE_ROOT
80+
81+
82+
def state_root(state: State) -> Bytes32:
83+
"""Calculate the state root."""
84+
assert not state._snapshots
85+
86+
def get_storage_root(address: Bytes20) -> Bytes32:
87+
return storage_root(state, address)
88+
89+
return root(state._main_trie, get_storage_root=get_storage_root)
90+
3191

3292
class EOA(Address):
3393
"""

0 commit comments

Comments
 (0)