Skip to content

Commit 86a8122

Browse files
authored
Merge pull request #1953 from carver/upgrade-py-trie
Upgrade py-trie to v2-alpha.3, and eth-utils to v1.9.4
2 parents 718391d + af9d35a commit 86a8122

File tree

4 files changed

+46
-29
lines changed

4 files changed

+46
-29
lines changed

eth/tools/_utils/normalization.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
HexStr,
3434
)
3535

36-
from eth_utils import (
36+
from eth_utils.curried import (
37+
apply_formatter_if,
38+
apply_formatter_to_array,
3739
apply_formatters_to_dict,
3840
big_endian_to_int,
3941
decode_hex,
42+
hexstr_if_str,
4043
is_0x_prefixed,
4144
is_bytes,
4245
is_hex,
@@ -48,7 +51,6 @@
4851
to_dict,
4952
ValidationError,
5053
)
51-
import eth_utils.curried
5254

5355
from eth.constants import (
5456
CREATE_CONTRACT_ADDRESS,
@@ -128,7 +130,7 @@ def normalize_to_address(value: AnyStr) -> Address:
128130
return CREATE_CONTRACT_ADDRESS
129131

130132

131-
robust_decode_hex = eth_utils.curried.hexstr_if_str(to_bytes)
133+
robust_decode_hex = hexstr_if_str(to_bytes)
132134

133135

134136
#
@@ -247,7 +249,7 @@ def state_definition_to_dict(state_definition: GeneralState) -> AccountState:
247249
"nonce": normalize_int,
248250
"storage": normalize_storage
249251
}, required=[])),
250-
eth_utils.curried.apply_formatter_if(
252+
apply_formatter_if(
251253
lambda s: isinstance(s, Iterable) and not isinstance(s, Mapping),
252254
state_definition_to_dict
253255
),
@@ -271,13 +273,13 @@ def state_definition_to_dict(state_definition: GeneralState) -> AccountState:
271273

272274

273275
normalize_main_transaction_group = dict_normalizer({
274-
"data": eth_utils.curried.apply_formatter_to_array(normalize_bytes),
275-
"gasLimit": eth_utils.curried.apply_formatter_to_array(normalize_int),
276+
"data": apply_formatter_to_array(normalize_bytes),
277+
"gasLimit": apply_formatter_to_array(normalize_int),
276278
"gasPrice": normalize_int,
277279
"nonce": normalize_int,
278280
"secretKey": normalize_bytes,
279281
"to": normalize_to_address,
280-
"value": eth_utils.curried.apply_formatter_to_array(normalize_int),
282+
"value": apply_formatter_to_array(normalize_int),
281283
})
282284

283285

@@ -306,14 +308,16 @@ def state_definition_to_dict(state_definition: GeneralState) -> AccountState:
306308
"gasLimit": normalize_int,
307309
"value": normalize_int,
308310
})
309-
normalize_call_creates = eth_utils.curried.apply_formatter_to_array(normalize_call_create_item)
311+
normalize_call_creates: Callable[[Iterable[Any]], Iterable[Any]]
312+
normalize_call_creates = apply_formatter_to_array(normalize_call_create_item)
310313

311314
normalize_log_item = dict_normalizer({
312315
"address": to_canonical_address,
313-
"topics": eth_utils.curried.apply_formatter_to_array(normalize_int),
316+
"topics": apply_formatter_to_array(normalize_int),
314317
"data": normalize_bytes,
315318
})
316-
normalize_logs = eth_utils.curried.apply_formatter_to_array(normalize_log_item)
319+
normalize_logs: Callable[[Iterable[Any]], Iterable[Any]]
320+
normalize_logs = apply_formatter_to_array(normalize_log_item)
317321

318322

319323
normalize_main_environment = dict_normalizer({

eth/tools/fixtures/fillers/formatters.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
from typing import (
2+
Any,
3+
Callable,
4+
List,
5+
)
6+
17
from eth_utils.curried import (
8+
apply_formatter_to_array,
9+
apply_formatters_to_dict,
210
apply_formatters_to_sequence,
311
encode_hex,
412
to_checksum_address,
513
to_hex,
614
)
715

816
from eth_utils.toolz import curried
9-
import eth_utils.curried
1017

1118

12-
environment_formatter = eth_utils.curried.apply_formatters_to_dict({
19+
environment_formatter = apply_formatters_to_dict({
1320
"currentCoinbase": to_checksum_address,
1421
"previousHash": encode_hex,
1522
"currentNumber": to_hex,
@@ -19,35 +26,37 @@
1926
})
2027

2128

29+
storage_item_formatter: Callable[[List[Any]], List[Any]]
2230
storage_item_formatter = apply_formatters_to_sequence([to_hex, to_hex])
2331
storage_formatter = curried.itemmap(storage_item_formatter)
2432

2533

26-
account_state_formatter = eth_utils.curried.apply_formatters_to_dict({
34+
account_state_formatter = apply_formatters_to_dict({
2735
"balance": to_hex,
2836
"nonce": to_hex,
2937
"code": encode_hex,
3038
"storage": storage_formatter,
3139
})
3240

3341

42+
state_item_formatter: Callable[[List[Any]], List[Any]]
3443
state_item_formatter = apply_formatters_to_sequence([to_checksum_address, account_state_formatter])
3544
state_formatter = curried.itemmap(state_item_formatter)
3645

3746

38-
transaction_group_formatter = eth_utils.curried.apply_formatters_to_dict({
47+
transaction_group_formatter = apply_formatters_to_dict({
3948
# all transaction types
4049
"to": to_checksum_address,
41-
"data": eth_utils.curried.apply_formatter_to_array(encode_hex),
42-
"gasLimit": eth_utils.curried.apply_formatter_to_array(to_hex),
50+
"data": apply_formatter_to_array(encode_hex),
51+
"gasLimit": apply_formatter_to_array(to_hex),
4352
"gasPrice": to_hex,
4453
"nonce": to_hex,
4554
"secretKey": encode_hex,
46-
"value": eth_utils.curried.apply_formatter_to_array(to_hex),
55+
"value": apply_formatter_to_array(to_hex),
4756
})
4857

4958

50-
execution_formatter = eth_utils.curried.apply_formatters_to_dict({
59+
execution_formatter = apply_formatters_to_dict({
5160
"address": to_checksum_address,
5261
"origin": to_checksum_address,
5362
"caller": to_checksum_address,
@@ -59,13 +68,14 @@
5968
})
6069

6170

62-
expect_element_formatter = eth_utils.curried.apply_formatters_to_dict({
71+
expect_element_formatter = apply_formatters_to_dict({
6372
"result": state_formatter
6473
})
65-
expect_formatter = eth_utils.curried.apply_formatter_to_array(expect_element_formatter)
74+
expect_formatter: Callable[[List[Any]], List[Any]]
75+
expect_formatter = apply_formatter_to_array(expect_element_formatter)
6676

6777

68-
test_formatter = eth_utils.curried.apply_formatters_to_dict({
78+
test_formatter = apply_formatters_to_dict({
6979
"env": environment_formatter,
7080
"pre": state_formatter,
7181
"transaction": transaction_group_formatter,
@@ -75,27 +85,28 @@
7585
filler_formatter = curried.valmap(test_formatter)
7686

7787

78-
state_post_formatter = eth_utils.curried.apply_formatters_to_dict({
88+
state_post_formatter = apply_formatters_to_dict({
7989
"hash": encode_hex
8090
})
8191

8292

83-
filled_state_test_formatter = curried.valmap(eth_utils.curried.apply_formatters_to_dict({
93+
filled_state_test_formatter = curried.valmap(apply_formatters_to_dict({
8494
"env": environment_formatter,
8595
"pre": state_formatter,
8696
"transaction": transaction_group_formatter,
8797
"post": state_post_formatter,
8898
}))
8999

90-
call_create_item_formatter = eth_utils.curried.apply_formatters_to_dict({
100+
call_create_item_formatter = apply_formatters_to_dict({
91101
"data": encode_hex,
92102
"destination": to_checksum_address,
93103
"gasLimit": to_hex,
94104
"value": to_hex,
95105
})
96-
call_creates_formatter = eth_utils.curried.apply_formatter_to_array(call_create_item_formatter)
106+
call_creates_formatter: Callable[[List[Any]], List[Any]]
107+
call_creates_formatter = apply_formatter_to_array(call_create_item_formatter)
97108

98-
filled_vm_test_formatter = curried.valmap(eth_utils.curried.apply_formatters_to_dict({
109+
filled_vm_test_formatter = curried.valmap(apply_formatters_to_dict({
99110
"env": environment_formatter,
100111
"pre": state_formatter,
101112
"exec": execution_formatter,

newsfragments/1953.misc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Upgrade py-trie to v2.0.0-alpha.3 for a dependency fix, and eth-utils to v1.9.4 for a type-check
2+
fix.

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
"eth-bloom>=1.0.3,<2.0.0",
1111
"eth-keys>=0.2.1,<0.4.0",
1212
"eth-typing>=2.2.0,<3.0.0",
13-
"eth-utils>=1.8.0,<2.0.0",
13+
"eth-utils>=1.9.4,<2.0.0",
1414
"lru-dict>=1.1.6",
1515
"mypy_extensions>=0.4.1,<1.0.0",
1616
"py-ecc>=1.4.7,<5.0.0",
1717
"pyethash>=0.1.27,<1.0.0",
1818
"rlp>=1.1.0,<2.0.0",
19-
"trie==2.0.0-alpha.2",
19+
"trie==2.0.0-alpha.3",
2020
],
2121
# The eth-extra sections is for libraries that the evm does not
2222
# explicitly need to function and hence should not depend on.
@@ -54,7 +54,7 @@
5454
# Sphinx pined to `<1.8.0`: https://github.com/sphinx-doc/sphinx/issues/3494
5555
"Sphinx>=1.5.5,<1.8.0",
5656
"sphinx_rtd_theme>=0.1.9",
57-
"sphinxcontrib-asyncio>=0.2.0",
57+
"sphinxcontrib-asyncio>=0.2.0,<0.3",
5858
"towncrier>=19.2.0, <20",
5959
],
6060
'dev': [

0 commit comments

Comments
 (0)