-
Notifications
You must be signed in to change notification settings - Fork 198
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
Optimize to_checksum_address
function
#269
Conversation
Pull Request Test Coverage Report for Build 2508862086
💛 - Coveralls |
4641772
to
c6b498a
Compare
Related to safe-global/safe-pm#89 |
norm_address[i].upper() | ||
if int(address_hash[i], 16) > 7 | ||
else norm_address[i] |
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'd add a link to https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md as a comment
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.
Nice, done @mikhailxyz
c6b498a
to
1578363
Compare
@@ -888,9 +892,9 @@ def retrieve_fallback_handler( | |||
self.address, | |||
self.FALLBACK_HANDLER_STORAGE_SLOT, | |||
block_identifier=block_identifier, | |||
)[-20:] | |||
)[-20:].rjust(20, b"\0") |
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.
Why needs left padding?
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.
Because get_storage
ignores leading zeroes, I don't really know why
061ded5
to
2ac4059
Compare
While developing Safe Tx Service we found out that a lot of time was spent on converting addresses from `bytes` to `ChecksumAddress`. Biggest part of this time was overhead added on `eth_utils` library to `keccak256` function. So we decided to use `pysha3` library (way faster than `pycryptodome`) directly. That's why we implemented new methods: - fast_keccak - fast_keccak_hex - fast_keccak_hex - fast_to_checksum_address - fast_bytes_to_checksum_address - fast_is_checksum_address This is also very relevant for the `EthereumAddressV2Field`, as it stores addresses as `bytes` on database and returns them as `ChecksumAddress` Related to: - ethereum/eth-utils#95 - ethereum/eth-hash#35
2ac4059
to
c3f2f15
Compare
While developing Safe Tx Service we found out that a lot of time was spent on converting addresses from
bytes
toChecksumAddress
. Biggest part of this time was overhead added oneth_utils
library tokeccak256
function.So we decided to use
pysha3
library (way faster thanpycryptodome
) directly. That's why we implemented new methods:This is also very relevant for the
EthereumAddressV2Field
, as it stores addresses asbytes
on database and returns them asChecksumAddress
Related to: