eth_abi_lite is a lite fork of `eth_abi`, aiming to support EVM abi encode/decode functionality without external dependencies on `eth_utils`, `eth_typing`, `toolz`, or `cytoolz`
Project description
eth_abi_lite
eth_abi_lite is a lite fork of eth_abi, aiming to support EVM abi encode/decode functionality without external dependencies on eth_utils, eth_typing, toolz, or cytoolz.
eth_abi_lite can be used as a drop-in replacement for eth_abi==3.0.0.
Install with pip install eth_abi_lite
Motivation
- Many packages in the ethereum ecosystem have conflicting version requirements for dependencies such as
eth_utils,eth_typing,toolz, orcytoolz. Removing these dependencies allows a package to be used in more environments. - These dependencies are rather heavy if all you want is basic abi encoding/decoding functionality.
Does eth_abi_lite work the same as eth_abi?
eth_abi_lite can be used as a drop-in replacement for eth_abi==3.0.0. The one functional difference is that eth_abi's low level pad functions are no longer curry-able. In most cases this difference will not be noticed.
eth_abi_lite passes eth_abi's standard test suite when running tox:
...
======================== 751 passed, 3 skipped in 18.45s ========================
____________________________________ summary ____________________________________
py37-core: commands succeeded
py38-core: commands succeeded
py39-core: commands succeeded
py310-core: commands succeeded
congratulations :)
(tests for linting and docs removed)
Is eth_abi_lite faster?
According to testing with tuna on a good laptop:
eth_abi_litetakes about 18 ms to importeth_abitakes about 180 ms to import
eth_abi_lite is faster to import because it loads fewer dependencies. This is useful in the context of cli tools where startup times matter.
Survey of imported items
eth_abi_lite imports the following items from its dependencies:
Items Imported From eth_utils
big_endian_to_intcompose_if_tupleint_to_big_endianis_addressis_booleanis_bytesis_integeris_list_likeis_numberis_textto_canonical_addressto_checksum_addressto_normalized_addressto_tuple
Items Imported From eth_typing
TypeStrDecodable
Items Imported From eth_utils.toolz
toolz.functoolz.curry
The Changes
The changes from eth_abi to eth_abi_lite consist mostly of copying portions of eth_utils and eth_typing.
The basic idea is that every time something is imported from eth_utils or eth_typing, that thing is instead imported from a lite version of that package.
Step 1. Create eth_utils_lite
Copy these items from eth_utils to eth_utils_lite
eth_utils/abi.pyeth_utils/address.pyeth_utils/conversions.pyeth_utils/crypto.pyeth_utils/decorators.pyeth_utils/encoding.pyeth_utils/functional.pyeth_utils/hexadecimal.pyeth_utils/types.py
The only non-mutual dependency in these modules is eth_hash.keccak() in eth_utils/crypto.py. Replace this function with pycryptodome's keccak implementation directly.
Also in eth_utils/functional.py, remove the functions that are decorated by toolz.compose.
It is possible to prune these files more aggressively, but leaving the files unchanged minimizes the chances of introducing bugs.
Step 2. Create eth_typing_lite
Copy these items from eth_typing to eth_typing_lite:
AddressAnyAddressChecksumAddressDecodableHexAddressHexStrPrimitivesTypeStr
These are all of the eth_typing types used by eth_abi_lite and eth_utils_lite.
Step 3. Create eth_abi_lite
- Copy all files from
eth_abiintoeth_abi_lite - Replace all instances of
eth_utilswitheth_utilseth_typingwitheth_typing_liteeth_abiwitheth_abi_lite
- Replace the
toolz.currydecoration oneth_abi.zpadandeth_abi.fpadwithfunctools.partialdecoration.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eth_abi_lite-3.2.0.tar.gz.
File metadata
- Download URL: eth_abi_lite-3.2.0.tar.gz
- Upload date:
- Size: 56.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53e8b4028d671f2aa217ecee85865bb3960b7d54d199eff53f1daeba71dfef5f
|
|
| MD5 |
a467293a735c2d1ddbff5b9a19ad094a
|
|
| BLAKE2b-256 |
aa50cc55803212241bb4768c15b08547632c43d1afcb82ce2daa7b0eed3fefc4
|
File details
Details for the file eth_abi_lite-3.2.0-py3-none-any.whl.
File metadata
- Download URL: eth_abi_lite-3.2.0-py3-none-any.whl
- Upload date:
- Size: 65.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ace29952e7682598446c996e956536847d7951edc3532f41c5c0f3b89784e7e
|
|
| MD5 |
1a7e24a2a8c9d3d90a2642532de43257
|
|
| BLAKE2b-256 |
5ab2ecbcab5a769671448bf813690eac2c21f1fad6f41b2d5713f0b4cbd13f47
|