Closed barakman closed 6 months ago
Alchemy node used for testing all of this. See the relevant documentation here.
Thanks for the detailed issue @barakman. I have a draft PR up for getting this resolved. I should be able to wrap it up by tomorrow.
Thanks for the detailed issue @barakman. I have a draft PR up for getting this resolved. I should be able to wrap it up by tomorrow.
Thank you for your quick handling of this. Note that this is probably an API breaking change for anyone using that function, since as far as I understand, you've changed the structure of its output.
BTW, if that is indeed the case, then you can probably revert some of your fixes in the documentation. Specifically, where the documentation describes this is part in the output of that function:
'accessList': [
AttributeDict({
'address': '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
'storageKeys': [
HexBytes('0x0000000000000000000000000000000000000000000000000000000000000003'),
HexBytes('0x0000000000000000000000000000000000000000000000000000000000000007'),
]
}),
AttributeDict({
'address': '0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413',
'storageKeys': []
}),
],
If the AttributeDict
and HexBytes
are really part of this output, then I'd expect txn
to become illegal (cannot be unmarshalled by Go, or something similar to that) as a result of setting txn['accessList']
to that output.
since as far as I understand, you've changed the structure of its output.
This is not the case. Request formatters were added to properly handle the case where storage keys may be bytes
or HexBytes
.
Should eth-account
support this merge request?
In my case, even eth-account == 0.13.0 couldn't validate the HexBytes in "storageKeys"
return transaction, self.bot_account.sign_transaction(transaction).raw_transaction
.venv-311\Lib\site-packages\eth_account\signers\local.py:84: in sign_transaction
return self._publicapi.sign_transaction(transaction_dict, self.key, blobs=blobs)
.venv-311\Lib\site-packages\eth_utils\decorators.py:20: in _wrapper
return self.method(objtype, *args, **kwargs)
.venv-311\Lib\site-packages\eth_account\account.py:801: in sign_transaction
) = sign_transaction_dict(account._key_obj, sanitized_transaction, blobs=blobs)
.venv-311\Lib\site-packages\eth_account\_utils\signing.py:32: in sign_transaction_dict
unsigned_transaction = serializable_unsigned_transaction_from_dict(
.venv-311\Lib\site-packages\eth_account\_utils\legacy_transactions.py:43: in serializable_unsigned_transaction_from_dict
return TypedTransaction.from_dict(transaction_dict, blobs=blobs)
.venv-311\Lib\site-packages\eth_account\typed_transactions\typed_transaction.py:97: in from_dict
transaction=transaction.from_dict(dictionary, blobs=blobs),
.venv-311\Lib\site-packages\eth_account\typed_transactions\dynamic_fee_transaction.py:147: in from_dict
....
cls.assert_valid_fields(dictionary)
if not all(valid_fields.values()):
invalid = {
key: dictionary[key] for key, valid in valid_fields.items() if not valid
}
> raise TypeError(f"Transaction had invalid fields: {repr(invalid)}")
E TypeError: Transaction had invalid fields: {'accessList': [AttributeDict({'address': ....
.venv-311\Lib\site-packages\eth_account\typed_transactions\dynamic_fee_transaction.py:133: TypeError
That check doesn't allow HexBytes
in storageKey.
What happened?
These are the input and output of function
create_access_list
according to the official documentation:Input Example:
Output Example:
There are several problems here, both in the documentation, and in the actual behavior of the function.
Problem 1 (should be fixed in the documentation):
The input should be the entire transaction dictionary, and not just the keys in the example, including:
It is possible that some of them, like 'from' and 'chainId', can be omitted. But it seems that at least the majority of them should be included. Otherwise, the function throws errors such as
intrinsic gas too low
, etc.Problem 2 (should be fixed either in the documentation or in the code):
The output dictionary does not have a key named 'gas', but a key named 'gasUsed'.
Problem 3 (should be fixed in the code):
The value of the output 'accessList' is not a list of
dict
items, but a list ofAttributeDict
items. Moreover, the value of each 'storageKeys' is not a list ofstr
items, but a list ofHexBytes
items. This makes it impossible to just take the output 'accessList' and add it to the input transaction like this:Instead, one needs to do something like:
Code that produced the error
No response
Full error output
No response
Fill this section in if you know how this could or should be fixed
No response
web3 Version
6.16.0
Python Version
3.9.13
Operating System
MacOS
Output from
pip freeze