drift-labs/driftpy

devnet is not working: Index out of range

Closed this issue · 1 comments

It used to work for me and suddenly it stopped working for me when subscribe to the devnet market. It throws some index out of range.
I thought it might be my code or something but when i tried the example for the fetch all markets it didn't work and gave the same eror

Error :

Traceback (most recent call last):
  File "/home/joker/Documents/work/script-playground/drift_python/devnet_markets.py", line 45, in <module>
    answer = loop.run_until_complete(get_all_market_names())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/joker/Documents/work/script-playground/drift_python/devnet_markets.py", line 23, in get_all_market_names
    all_perps_markets = await drift_client.program.account["PerpMarket"].all()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/anchorpy/program/namespace/account.py", line 208, in all
    account=self._coder.accounts.decode(account_data),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/anchorpy/coder/accounts.py", line 51, in decode
    return self.parse(obj).data
           ^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 288, in parse
    return self.parse_stream(io.BytesIO(data), **contextkw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 300, in parse_stream
    return self._parsereport(stream, context, "(parsing)")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 703, in _parse
    obj = self.subcon._parsereport(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 2275, in _parse
    subobj = sc._parsereport(stream, context, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 3919, in _parse
    return sc._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 2653, in _parse
    return self.subcon._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 703, in _parse
    obj = self.subcon._parsereport(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 2120, in _parse
    subobj = sc._parsereport(stream, context, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 2653, in _parse
    return self.subcon._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 703, in _parse
    obj = self.subcon._parsereport(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 2120, in _parse
    subobj = sc._parsereport(stream, context, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 2653, in _parse
    return self.subcon._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/construct/core.py", line 704, in _parse
    return self._decode(obj, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/borsh_construct/enum.py", line 110, in _decode
    enum_variant = self.enum.getitem(index)
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joker/miniconda3/envs/drift_python/lib/python3.11/site-packages/borsh_construct/enum.py", line 19, in getitem
    return getattr(cls, cls._sumtype_constructor_names[_index])
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
IndexError: list index out of range

I have changed only two things in the example that is env to devnet and used my personal devnet RPC url.

It's fixed now! thank you very much @soundsonacid !