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

TypeError: 'NoneType' object is not subscriptable for certain Fork URLs #361

Open
antazoey opened this issue Jan 3, 2025 · 0 comments
Open

Comments

@antazoey
Copy link

antazoey commented Jan 3, 2025

Some fork URLs I try occasionally lead to uncaught exception that doesn't help me know what was wrong enough.
For example, the RPC: https://rpc2.sepolia.org

lead to

/Users/az/virtualenvs/ape/lib/python3.12/site-packages/boa/vm/fork.py:139: in __init__
    super().__init__(caching_rpc, block_identifier, *args, **kwargs2)
/Users/az/virtualenvs/ape/lib/python3.12/site-packages/boa/vm/fork.py:156: in __init__
    self._block_number = to_int(self._block_info["number"])
E   TypeError: 'NoneType' object is not subscriptable
--------------------------------------------------------------------------- Captured stdout setup ---------------------------------------------------------------------------
INFO:     Connecting to existing Geth node at https://rpc2.sepolia.org.
---------------------------------------------------------------------------- Captured log setup -----------------------------------------------------------------------------
INFO     ape:provider.py:1601 Connecting to existing Geth node at https://rpc2.sepolia.org.
========================================================================== short test summary info ==========================================================================
ERROR tests/test_fork_provider.py::test_block_identifier - TypeError: 'NoneType' object is not subscriptable

Maybe this is a "light" node or something.

Here is the code with the exception:

        self._block_info = self._rpc.fetch_uncached(
            "eth_getBlockByNumber", [block_identifier, False]
        )
        self._block_number = to_int(self._block_info["number"])

so block_info is None for some reason.

I don't know what the exact problem is so I don't know what to suggest, but maybe something like:

        self._block_info = self._rpc.fetch_uncached(
            "eth_getBlockByNumber", [block_identifier, False]
        )
        if self._block_info is None:
            raise ValueError("Your RPC does not have the block ID specified.")

        self._block_number = to_int(self._block_info["number"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant