Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Latest commit

 

History

History
26 lines (20 loc) · 1.75 KB

README.md

File metadata and controls

26 lines (20 loc) · 1.75 KB

web3-async-attempts

A set of completely unfactored (i.e., flat, nearly-offensive, ugly) Python scripts that demonstrate a variety of attempts to utilize either asynchronous or parallel processing with Web3.py .

This is a reduced set of all the attempts.

General Flow

All scripts try to perform the same basic work:

  1. Perform a GraphQL query to obtain a subset of Uniswap V3 liquidity pools;
  2. Use Web3.py HTTP provider to make contract calls for slot0 data of liquidity pools;
  3. Use Web3.py HTTP provider to make contract calls for tick bitmap data of liquidity pools; and
  4. Process the results somehow (typically just printing the final results out).

Note: Web3.py's asynchronous HTTP provider does not allow for contract call operations, so we had to utilize the regular HTTP provider with these attempts.

Script descriptions

  • web3-iteration.py is the most basic approach, kind of a control to measure (completely unscientifically) the other script performance against.
  • web3_parallelized.py is probably the most effective way to make many HTTP provider based calls against the blockchain since it utilizes concurrent.futures, which allows for true parallel processing, not just asynchronous processing.
  • web3_futures.py utilizes an asyncio futures approach to try and perform asynchronous processing of these requests.
  • web3_create_futures.py is like web3_futures.py, but uses a slightly different approach.
  • web3_async_gather.py uses the standard gather approach for asyncio, to generate tasks that are supposedly run asynchronously.

--> You need to replace the value of W3_HTTP_PROVIDER with whatever Web3 HTTP provider endpoint URL (or its environmental variable) you plan to use.