Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Unsupported Web3 Methods #342

Closed
0xJchen opened this issue Sep 13, 2023 · 4 comments
Closed

Unsupported Web3 Methods #342

0xJchen opened this issue Sep 13, 2023 · 4 comments

Comments

@0xJchen
Copy link

0xJchen commented Sep 13, 2023

(base) ➜  mev-inspect-py git:(main) ✗ ./mev inspect 13850154
Inspecting block 13850154
Skipping virtualenv creation, as specified in config file.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/flashbot/.local/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/flashbot/.local/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/flashbot/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/flashbot/.local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/app/mev_inspect/concurrency.py", line 18, in wrapper
    loop.run_until_complete(f(*args, **kwargs))
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/app/cli.py", line 45, in inspect_block_command
    await inspector.inspect_single_block(
  File "/app/mev_inspect/inspector.py", line 56, in inspect_single_block
    return await inspect_block(
  File "/app/mev_inspect/inspect_block.py", line 68, in inspect_block
    await inspect_many_blocks(
  File "/app/mev_inspect/inspect_block.py", line 105, in inspect_many_blocks
    block = await create_from_block_number(
  File "/app/mev_inspect/block.py", line 31, in create_from_block_number
    block_timestamp, receipts, traces, base_fee_per_gas = await asyncio.gather(
  File "/app/mev_inspect/block.py", line 73, in _find_or_fetch_block_receipts
    return await _fetch_block_receipts(w3, block_number)
  File "/app/mev_inspect/block.py", line 110, in _fetch_block_receipts
    receipts_json = await w3.eth.get_block_receipts(block_number)
  File "/home/flashbot/.local/lib/python3.9/site-packages/web3/module.py", line 72, in caller
    result = await w3.manager.coro_request(method_str,
  File "/home/flashbot/.local/lib/python3.9/site-packages/web3/manager.py", line 203, in coro_request
    return self.formatted_response(response,
  File "/home/flashbot/.local/lib/python3.9/site-packages/web3/manager.py", line 168, in formatted_response
    raise ValueError(response["error"])
ValueError: {'code': -32602, 'message': 'Invalid params', 'data': 'invalid type: integer `13850154`, expected a string at line 1 column 8'}
command terminated with exit code 1

In the poetry file, it shows it is using web3=5.23 while I tried this version locally and there's no method called get_block_receipts. Has anyone met a similar problem before?

@0xJchen 0xJchen changed the title Unsupported W而不 Unsupported Web3 Methods Sep 13, 2023
@0xr3x
Copy link

0xr3x commented Sep 18, 2023

I've seen this before, and it is to do with the RPC you are using. Try using an ANKR RPC! :)

@0xr3x
Copy link

0xr3x commented Sep 18, 2023

#319

@0xJchen
Copy link
Author

0xJchen commented Sep 18, 2023

#319

Hi ser, thanks for poiting it out. It went smoothly with ankr rpc :)

I am now testing it with my RETH node with trace API enabled. The strange thing is that the error seems have to do with get_block_receipts method in web3.eth module?

@0xJchen
Copy link
Author

0xJchen commented Sep 19, 2023

#319

Solved this problem by modifying the block number from int to dex in block.py

async def _fetch_block_timestamp(w3, block_number: int) -> int:
    block_json = await w3.eth.get_block(hex(block_number))
    return block_json["timestamp"]


async def _fetch_block_receipts(w3, block_number: int) -> List[Receipt]:
    receipts_json = await w3.eth.get_block_receipts(hex(block_number))
    return [Receipt(**receipt) for receipt in receipts_json]


async def _fetch_block_traces(w3, block_number: int) -> List[Trace]:
    traces_json = await w3.eth.trace_block(hex(block_number))
    return [Trace(**trace_json) for trace_json in traces_json]

Is it standard practice to pass block numbers as integers, as used in the codebase?

@0xJchen 0xJchen closed this as completed Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants