Comments (2)
How do you only load the last N blocks? This code wants to loads only last 5 blocks i believe, however it errors when adding new blocks.
reorg_mon = JSONRPCReorganisationMonitor(web3, check_depth=30) reorg_mon.load_initial_block_headers(block_count=5) while True: try: # Figure out the next good unscanned block range, # and fetch block headers and timestamps for this block range chain_reorg_resolution = reorg_mon.update_chain() if chain_reorg_resolution.reorg_detected: logger.info(f"Chain reorganisation data updated: {chain_reorg_resolution}") # Read specified events in block range for log_result in read_events( web3, start_block=chain_reorg_resolution.latest_block_with_good_data + 1, end_block=chain_reorg_resolution.last_live_block, filter=filter, notify=None, chunk_size=100, context=token_cache, extract_timestamps=None, reorg_mon=reorg_mon, ): pass
INFO:eth_defi.event_reader.reorganisation_monitor:figure_reorganisation_and_new_blocks(), range 17,285,423 - 17,285,443, last block we have is 17,285,443, check depth is 20 ERROR: LoadError: Python: AssertionError: Blocks must be added in order. Last block we have: 17285443, the new record is: BlockHeader(block_number=17285423, block_hash='0x8d481922bd607150c9f3299004a113e44955327770ab04ed10de115e2172d6fe', timestamp=1684400615) Python stacktrace: [1] add_block @ eth_defi.event_reader.reorganisation_monitor ~/Library/Caches/pypoetry/virtualenvs/cryptopy-5siZoxZ4-py3.10/lib/python3.10/site-packages/eth_defi/event_reader/reorganisation_monitor.py:324 [2] figure_reorganisation_and_new_blocks @ eth_defi.event_reader.reorganisation_monitor ~/Library/Caches/pypoetry/virtualenvs/cryptopy-5siZoxZ4-py3.10/lib/python3.10/site-packages/eth_defi/event_reader/reorganisation_monitor.py:396 [3] update_chain
Thank you for reporting this to us!
The reason your script failed was the check_depth
is 30, which is higher than initial loaded block count 5.
So what happened was:
- The reorganisation monitor loaded 5 block headers into it's block map
- The while loop started, it ran
reorg_mon.update_chain()
, which tried to check the specified depth of 30 last read blocks:web3-ethereum-defi/eth_defi/event_reader/reorganisation_monitor.py
Lines 383 to 386 in d47802c
- The block range it tried to read didn't exist in block map, so it tried to add and failed
This is more or less undocumented feature, so I will either add a warning for this particular case or add some assert to prevent it to happen
from web3-ethereum-defi.
I just close this as there has not been any further comments.
from web3-ethereum-defi.
Related Issues (20)
- Low-level transactions to open and close Aave positions
- Low-level transactions to open and close short - involves selling the borrowed tokens on an exchange like Uniswap v2 and v3
- Most things do not work? HOT 1
- Ankr specific timestamp reader HOT 1
- Better tracking for Uniswap v3 price estimation
- ValueError: {'code': -32000, 'message': 'the method eth_sendTransaction does not exist/is not available'} HOT 1
- More selective number → string conversion in `fetch_aave_reserves_shapshot` HOT 1
- Something wierd with the log HOT 1
- how to use analyse_trade_by_hash()? HOT 1
- Closed
- Aave deposit function HOT 2
- Handle chain reorg in event reader HOT 4
- Support Uniswap v3 swap
- Support Uniswap V3 increaseLiquidity() and decreaseLiquidity() HOT 1
- Enzyme walkthrough test suite
- fix eth_defi uniswap_v2 tests
- Uniswap V3 swap doesn't show up in API documentation HOT 1
- Websocket support HOT 1
- Aave position management code
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web3-ethereum-defi.