-
Notifications
You must be signed in to change notification settings - Fork 242
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
enhancement: factor out a type from access lists #960
base: master
Are you sure you want to change the base?
Conversation
This looks like pretty much exactly what I had in mind! |
If this is good, I can do it for |
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've been playing around with this PR a bit, and it's looking great!
I think it should be rebased on top of #968. That branch can handle nested dataclasses better than master
, and you shouldn't need the encode_access_list
and decode_access_list
helpers there.
That said, there's going to be a bit more work involved in this refactor. You'll need to use the Access
type in tests near, for example, here:
((address1, (hash1, hash2)), (address2, tuple())), |
There are a few other required changes, like dealing with unpacking here:
execution-specs/src/ethereum/shanghai/fork.py
Lines 620 to 624 in c854868
if isinstance(tx, (AccessListTransaction, FeeMarketTransaction)): | |
for address, keys in tx.access_list: | |
preaccessed_addresses.add(address) | |
for key in keys: | |
preaccessed_storage_keys.add((address, key)) |
mypy is your best friend when doing refactoring. The easiest way to run it in this project is:
$ tox -e static
y_parity: U256 | ||
r: U256 | ||
s: U256 | ||
|
||
|
||
# Helper function to handle the RLP encoding of the Access class instances. |
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.
# Helper function to handle the RLP encoding of the Access class instances. |
return tuple((access.account, access.slots) for access in access_list) | ||
|
||
|
||
# Helper function to handle the RLP decoding of the Access class instances. |
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.
# Helper function to handle the RLP decoding of the Access class instances. |
I'm back to continue working on this |
8d08d53
to
a91b66b
Compare
6702712
to
c2a769b
Compare
Took the liberty of rebasing and running |
src/ethereum/cancun/transactions.py
Outdated
TX_BASE_COST = 21000 | ||
TX_DATA_COST_PER_NON_ZERO = 16 | ||
TX_DATA_COST_PER_ZERO = 4 | ||
TX_CREATE_COST = 32000 | ||
TX_ACCESS_LIST_ADDRESS_COST = 2400 | ||
TX_ACCESS_LIST_STORAGE_KEY_COST = 1900 |
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.
Was removing these intentional?
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 don't think so. Fixed it 🙂
Thanks. Running |
What seems to be the problem?
Does it return errors on an unmodified |
What was wrong?
Because it's repeated in several different transaction types, the
Tuple[Address, Tuple[Bytes32, ...]]
portion should be promoted to its own type.Related to Issue #
Fixes #947
How was it fixed?
This PR refactors the access list type used in various transaction classes to reduce redundancy and improve maintainability. Specifically, it introduces a new
Access
class to represent theaccess_list
structure, which is used in multiple transaction types.Updated Transaction Classes
RLP Encoding and Decoding Adjustments:
Cute Animal Picture