Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot get block ranges for dates on arbitrum #309

Open
dlin17 opened this issue Feb 8, 2022 · 3 comments
Open

cannot get block ranges for dates on arbitrum #309

dlin17 opened this issue Feb 8, 2022 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@dlin17
Copy link

dlin17 commented Feb 8, 2022

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)

@medvedev1088
Copy link
Member

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

@sfsf9797
Copy link
Contributor

sfsf9797 commented May 9, 2022

hi @medvedev1088 would you mind checking my pr on this issue? thanks!

@dlin17
Copy link
Author

dlin17 commented Mar 5, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants