ApeWorX / silverback

Blockchain automation library, and SDK for the Silverback Platform
https://apeworx.io/silverback
Apache License 2.0
88 stars 10 forks source link

Not a valid TransactionType error with goerli/sepolia testnet #52

Closed 0xcivita closed 8 months ago

0xcivita commented 9 months ago

Environment information

$ ape --version
0.7.7

$ ape plugins list
Installed Plugins
  alchemy      0.7.1
  etherscan    0.7.0
  foundry      0.7.3
  solidity     0.7.1
silverback[dev]==0.3.0

What went wrong?

Attempted to run the example.py file renamed as main.py

$ silverback run "main:app" --network ethereum:sepolia:alchemy

And obtained the following error

ValueError: 3 is not a valid TransactionType

when attempting for both sepolia and goerli. ethereum:mainnet:alchemy runs the example app fine for me.

Full output

$ silverback run "main:app" --network ethereum:sepolia:alchemy
INFO: Loading Silverback App with settings:
  INSTANCE="default"
  BROKER_CLASS="taskiq:InMemoryBroker"
  NETWORK_CHOICE="ethereum:sepolia:alchemy"
INFO: Loaded Silverback App:
  NETWORK="ethereum:sepolia"
  SIGNER=None
WARNING: The polling runner makes a significant amount of requests. Do not use in production over long time periods unless you know what you're doing.
INFO: silverback_startup - Started
INFO: silverback_startup - 0.000s (0.0%)
INFO: `ape-cache` database has not been initialized
Traceback (most recent call last):
  File "~/v1-arbitrageur-bot/.venv/bin/silverback", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/ape/cli/commands.py", line 96, in invoke
    return self._invoke(ctx, provider=provider)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/ape/cli/commands.py", line 133, in _invoke
    return ctx.invoke(self.callback or (lambda: None), **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/silverback/_cli.py", line 100, in run
    asyncio.run(runner.run())
  File "~/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "~/.pyenv/versions/3.11.0/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.pyenv/versions/3.11.0/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/silverback/runner.py", line 129, in run
    await asyncio.gather(*tasks)
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/silverback/runner.py", line 241, in _block_task
    block_task = await block_handler.kiq(block)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/taskiq/decor.py", line 99, in kiq
    return await self.kicker().kiq(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/taskiq/kicker.py", line 130, in kiq
    f"Kicking {self.task_name} with args={args} and kwargs={kwargs}.",
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/pydantic/main.py", line 916, in __repr__
    return f'{self.__repr_name__()}({self.__repr_str__(", ")})'
                                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/pydantic/_internal/_repr.py", line 55, in __repr_str__
    return join_str.join(repr(v) if a is None else f'{a}={v!r}' for a, v in self.__repr_args__())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/pydantic/_internal/_repr.py", line 55, in <genexpr>
    return join_str.join(repr(v) if a is None else f'{a}={v!r}' for a, v in self.__repr_args__())
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/pydantic/main.py", line 935, in __repr_args__
    yield from ((k, getattr(self, k)) for k, v in self.model_computed_fields.items() if v.repr)
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/pydantic/main.py", line 935, in <genexpr>
    yield from ((k, getattr(self, k)) for k, v in self.model_computed_fields.items() if v.repr)
                    ^^^^^^^^^^^^^^^^
  File "~/.pyenv/versions/3.11.0/lib/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/ape/api/providers.py", line 87, in transactions
    return cast(List[TransactionAPI], list(self.query_manager.query(query)))
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/ape_ethereum/provider.py", line 529, in get_transactions_by_block
    yield self.network.ecosystem.create_transaction(**transaction)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/v1-arbitrageur-bot/.venv/lib/python3.11/site-packages/ape_ethereum/ecosystem.py", line 779, in create_transaction
    version = TransactionType(tx_data["type"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.pyenv/versions/3.11.0/lib/python3.11/enum.py", line 695, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.pyenv/versions/3.11.0/lib/python3.11/enum.py", line 1111, in __new__
    raise ve_exc
ValueError: 3 is not a valid TransactionType

How can it be fixed?

Unsure if this is an ape issue or a silverback issue given the error seems to stem from ape_ethereum plugin.

linear[bot] commented 9 months ago

SBK-415 Not a valid TransactionType error with goerli/sepolia testnet

fubuloubu commented 9 months ago

@0xcivita does your script have type=3 somewhere in it? We don't support type 3 transactions (not even sure what EIP that type is)

0xcivita commented 9 months ago

@fubuloubu not that I can see. I pulled example.py from the silverback repo but renamed to main just to test the setup and get started. Removed the event handlers and only kept the new block handler.

Opened the repo up for the script. Works on mainnet though so not sure where the issue is?

fubuloubu commented 9 months ago

@fubuloubu not that I can see. I pulled example.py from the silverback repo but renamed to main just to test the setup and get started. Removed the event handlers and only kept the new block handler.

Opened the repo up for the script. Works on mainnet though so not sure where the issue is?

Can try adding type=2 to your transactions, if that works then maybe it is an improper default somewhere

0xcivita commented 9 months ago

Hm ok, but in the example.py there are no transactions yet? Simply polling for new blocks unless I'm mistaken. There's a call to block.transactions to get number of transactions in a block which executes a query I think, but when I comment this out and simply return context.state.block_count I get the same error.

fubuloubu commented 9 months ago

but when I comment this out

The block.transactions call makes sense, since that indeed executes a query to fetch a range of transactions from the current block, and perhaps there's a new transaction type we are not accounting for yet. However, can you make sure this is indeed commented out in the version of the bot that you are running? Would help us chase down root cause here.

fubuloubu commented 9 months ago

Also if you can somehow figure out which transaction hash it is tripping up on, we can definitely fix the bug by repeating it

fubuloubu commented 9 months ago

Okay, I think I figured it out, EIP-4844 adds new type 3 transactions for blob support: https://eips.ethereum.org/EIPS/eip-4844

fubuloubu commented 9 months ago

Found a relevant txn type that Ape currently does not decode: https://goerli.etherscan.io/tx/0xd2882bae0d79a6c8e0fbf0089bbcb4b2eef3a1365471ad9f779b06a41ba47d3c

0xcivita commented 9 months ago

Oh, that's actually super cool to see on testnet! Guess it's an ape level issue

0xcivita commented 9 months ago

On our end will focus on testing the script on another network until type 3 blob support is in ape :)

fubuloubu commented 9 months ago

Oh, that's actually super cool to see on testnet! Guess it's an ape level issue

yes it is, we are tracking here: https://github.com/ApeWorX/ape/pull/1928

0xcivita commented 9 months ago

nice! will keep an eye out on progress

fubuloubu commented 8 months ago

merged it but didn't release until right now!

upgrade to Ape v0.7.9 please