-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Remove utf-8 string decoding from normalizers #974
Conversation
f4dafc1
to
c4bb22c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a litlte uncomfortable with this change. I think we should instead support the 1x and 2x line concurrently before dropping 1x support entirely. I'm up for being convinced otherwise and I understand that this adds some testing overhead.
My concern is that eth-abi>=2
has a breaking change and anyone who relies on both the web3
library and any low level functionality in the eth-abi
library will be forced to abruptly upgrade their code without us having issued any deprecation warnings.
59878f8
to
a2533a7
Compare
a2533a7
to
2041b5d
Compare
@pipermerriam Updated to add support for eth-abi >=2 without removing support for <2. |
web3/utils/normalizers.py
Outdated
@@ -140,11 +144,14 @@ def abi_ens_resolver(w3, abi_type, val): | |||
|
|||
|
|||
BASE_RETURN_NORMALIZERS = [ | |||
addresses_checksummed, | |||
decode_abi_strings, | |||
addresses_checksummed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nitpick leave the trailing comma.
@@ -184,6 +188,9 @@ def test_call_get_string_value(string_contract, call): | |||
assert result == "Caqalai" | |||
|
|||
|
|||
@pytest.mark.skipif( | |||
LooseVersion(eth_abi.__version__) >= LooseVersion("2"), | |||
reason="eth-abi >=2 does utf-8 string decoding") | |||
def test_call_read_string_variable(string_contract, call): | |||
result = call(contract=string_contract, | |||
contract_function='constValue') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a second test that shows what happens on an ABI decoding error. We should probably do something like capture the eth-abi error and re-raise a generic ValueError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It raises a 'BadFunctionCallOutput' error
@pipermerriam @carver Ready for another review |
setup.py
Outdated
@@ -19,7 +19,7 @@ | |||
install_requires=[ | |||
"toolz>=0.9.0,<1.0.0;implementation_name=='pypy'", | |||
"cytoolz>=0.9.0,<1.0.0;implementation_name=='cpython'", | |||
"eth-abi>=1.1.1,<2", | |||
"eth-abi==2.0.0a1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't require people to upgrade. We especially shouldn't require people to install an alpha dependency in a stable release. eth-abi>=1.1.1,<3
seems like a reasonable choice
9fb151a
to
2cc941e
Compare
@pipermerriam @carver Is this good to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, good to go!
What was wrong?
The eth-abi v2 alpha release adds utf-8 string decoding to the string type decoder. String decoding should therefore be removed from web3 return data normalizers.
Cute Animal Picture