ethereum-etl
ethereum-etl copied to clipboard
cannot get block ranges for dates on arbitrum
When trying to extract blocks from an Arbitrum RPC, get_block_range_for_date
for most dates I've tried, e.g. ethereumetl get_block_range_for_date -d 2021-06-01
. Issue appears to be that Arbitrum blocks can have the same timestamps, e.g. blocks 148 through 151. This is the traceback:
File "/home/ubuntu/.local/bin/ethereumetl", line 8, in <module>
sys.exit(cli())
File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/ubuntu/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/cli/get_block_range_for_date.py", line 53, in get_block_range_for_date
start_block, end_block = eth_service.get_block_range_for_date(date)
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/eth_service.py", line 37, in get_block_range_for_date
return self.get_block_range_for_timestamps(start_datetime.timestamp(), end_datetime.timestamp())
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/eth_service.py", line 46, in get_block_range_for_timestamps
start_block_bounds = self._graph_operations.get_bounds_for_y_coordinate(start_timestamp)
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/graph_operations.py", line 40, in get_bounds_for_y_coordinate
result = self._get_bounds_for_y_coordinate_recursive(y, *initial_bounds)
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/graph_operations.py", line 87, in _get_bounds_for_y_coordinate_recursive
return self._get_bounds_for_y_coordinate_recursive(y, *bounds)
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/graph_operations.py", line 87, in _get_bounds_for_y_coordinate_recursive
return self._get_bounds_for_y_coordinate_recursive(y, *bounds)
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/graph_operations.py", line 87, in _get_bounds_for_y_coordinate_recursive
return self._get_bounds_for_y_coordinate_recursive(y, *bounds)
[Previous line repeated 4 more times]
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/graph_operations.py", line 77, in _get_bounds_for_y_coordinate_recursive
estimation2_x = interpolate(*points, y)
File "/home/ubuntu/.local/lib/python3.8/site-packages/ethereumetl/service/graph_operations.py", line 117, in interpolate
raise ValueError('The y coordinate for points is the same {}, {}'.format(point1, point2))
ValueError: The y coordinate for points is the same (148,1622485166), (151,1622485166)
Good catch. A solution should be ported from blockchain-etl-common where such case is handled https://github.com/blockchain-etl/blockchain-etl-common/blob/master/blockchainetl_common/graph/graph_operations.py
hi @medvedev1088 would you mind checking my pr on this issue? thanks!
Bumping this old issue. I think this has been partially addressed in some of the more recent updates. However, it will still fail on the boundaries when there are multiple blocks that happen on 11:59:59.
e.g.
ethereumetl get_block_range_for_date -d 2023-02-18 -p https://arb-mainnet.g.alchemy.com/v2/YourAPIKey
will produce 61929538,62254802
and
ethereumetl get_block_range_for_date -d 2023-02-19 -p https://arb-mainnet.g.alchemy.com/v2/YourAPIKey
will produce 62254806,62584042
.
Note the missing three blocks between 62254802 and 62254806. These three blocks all have the same timestamp as 62254802, which is 2023-02:18 23:59:59 UTC.