Skip to main content

Lido

This library consolidates various functions to efficiently load network data for Lido, validate node operator keys and find key duplicates.

Installation

This library is available on PyPi:

pip install lido

Quickstart

from web3 import Web3
from lido import Lido
w3 = Web3(...)
lido = Lido(w3)
operators = lido.fetch_and_validate()

Main Features

Multicall Function Calls

Instead of making network requests one-by-one, this library combines many requests into one RPC call. It uses banteg/multicall.py, a Python wrapper for makerdao/multicall.

Multiprocess Signature Validations

When using validate_keys_multi(), this library spreads processing of key signature validations to all system cores.

Automatic Testnet / Mainnet Switching

Depending on which network is configured in web3 object, a set of contracts will be used. Even an appropriate ABI will be loaded for the chain automatically.

Helpers Provided

  • lido.get_operators_data() -> operator_data - load node operator data

  • lido.get_operators_keys(operator_data) -> operator_data - fetches and adds keys to operator_data

  • lido.validate_keys_mono(operator_data, strict = False) -> operator_data - validates keys in single process and adds validation results to operator_data

  • lido.validate_keys_multi(operator_data, strict = False) -> operator_data - validates keys in multiple processes and adds validation results to operator_data, requires a main function (see example)

  • lido.validate_key_list_multi(operator_data, strict = False) -> [] - same as validate_keys_multi(), but returns a list of invalid keys

  • lido.validate_key(chain_id, key, withdrawal_credentials) -> Boolean - low-level validation function, doesn't check for correct chain_id and withdrawal_credentials for a Lido deployment. For most use-cases use validate_keys_multi or validate_key_list_multi instead

  • lido.find_duplicates(operator_data) -> operator_data - finds duplicate keys and adds results to operator_data

  • lido.fetch_and_validate() -> operator_data - combines fetching operator data and running all validations on it - useful when you would be running all validations on data anyway

  • lido.get_stats() -> stats - fetches various constants from Lido contract, but you can even pass a list of functions to fetch eg get_stats(["isStopped"])

You can mix and match these functions, but make sure to use get_operators_data() first.

Notes

  1. Signature validation will be skipped if its results are already present in operator_data. This way you can safely load validation results from cache and add ["valid_signature"] = Boolean to already checked keys.

  2. Signature validation functions are accounting for previous withdrawal credentials by default. However, if you are building a fresh key validator it is vitally important to enable strict mode by setting strict argument of the functions to True. This way new keys with old withdrawal credentials won't pass validation.

Running an example script

The example script uses web3.auto, so use a RPC provider url as an environment variable to run it:

WEB3_PROVIDER_URI=https://eth-mainnet.provider.xx example.py

See example.py for a complete example, make sure to use a main function and a script entry point check when using validate_keys_multi() or fetch_and_validate().

Options

If you are testing a new deployment of Lido, you can override addresses and ABIs with constructor of Lido object. Also you can configure the maximum number of calls agregated to one multicall:

lido = Lido(
    w3,
    lido_address=LIDO_ADDRESS,
    registry_address=REGISTRY_ADDRESS,
    lido_abi_path=LIDO_ABI, # the file-path to the contract's ABI
    registry_abi_path=REGISTRY_ABI, # the file-path to the contract's ABI
    max_multicall=MAX_MULTICALL)

Metadata

Release files for lido 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lido 1.1.0
File Size Uploaded Provenance Actions
lido-1.1.0.tar.gz 22.8 kB Without provenance Details for lido-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lido 1.1.0
File Interpreter ABI Platform Actions
lido-1.1.0-py3-none-any.whl Python 3 none any Details for lido-1.1.0-py3-none-any.whl

Total release size: 53.3 kB

Release files / lido-1.1.0.tar.gz

Download URL lido-1.1.0.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
83ca3b654b793403e55b8098a9e7b67cd19129b9b5e799d70f1fa3340fcd1123
BLAKE2b-256 checksum
How to use checksums
a31258abee53041c1847ccb17e67126eb22b5c6a29e3376f8a60dc43c4b8bf4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.6 Darwin/20.5.0

Release files / lido-1.1.0-py3-none-any.whl

Download URL lido-1.1.0-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c54f9f09f5292cc167676f384e8c1f9950ea76354f0b79fa3f618997db8ef44c
BLAKE2b-256 checksum
How to use checksums
eaf889eca4946bb533d2f3e727cf601f9371a5f91be5bddae01cf285c82ca6c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.9.6 Darwin/20.5.0

Security for lido 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page