Skip to main content

Network helpers for Lido

Project description

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

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 the supplied WEB3_PROVIDER_URI, a correct network will be used. Even an appropriate ABI will be loaded for the chain automatically.

Helpers Provided

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

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

  • validate_keys_mono(operator_data) -> operator_data - validates keys in single process and adds validation results to operator_data

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

  • validate_key([[key,depositSignature]]) -> Boolean - low-level validation function

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

  • 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

  • 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.

How to Use

Use a RPC provider url as an environment variable and run your script:

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, these environment variables can override addresses and ABIs:

  • LIDO_ADDRESS
  • REGISTRY_ADDRESS
  • LIDO_ABI (the file-path to the contract's ABI)
  • REGISTRY_ABI (the file-path to the contract's ABI)

WEB3_PROVIDER_URI=https://eth-mainnet.provider.xx LIDO_ADDRESS=XXX REGISTRY_ADDRESS=XXX LIDO_ABI=xxx.json REGISTRY_ABI=xxx.json example.py

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

Lido-vsmelov-0.2.1.tar.gz (20.2 kB view details)

Uploaded Source

File details

Details for the file Lido-vsmelov-0.2.1.tar.gz.

File metadata

  • Download URL: Lido-vsmelov-0.2.1.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for Lido-vsmelov-0.2.1.tar.gz
Algorithm Hash digest
SHA256 24901783e7444047a256245ed81ed536686981c8cd476058c4f949f8256ad0f8
MD5 50332b95f2836eeac8a766891ef453fe
BLAKE2b-256 7279ad35066cb4a33a40dbcf4e2166a6f264f655f048f14c2892d60600f567a1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page