ApeWorX / ape-optimism

Optimism network provider plugin for the Ape Framework
https://www.apeworx.io/
Apache License 2.0
9 stars 9 forks source link

`TransactionNotFound` when deploying contract on optimism #7

Closed merc1er closed 1 year ago

merc1er commented 2 years ago

Environment information

$ ape --version
0.5.1

$ ape plugins list
Installed Plugins:
  trezor      0.1.dev12+g3b23b4f
  optimism    0.5.0a1
  bsc         0.5.0a1
  infura      0.5.0
  vyper       0.5.0

What went wrong?

When deploying a contract (ERC 20) with the command:

ape run scripts/deploy.py --network optimism:mainnet:geth 

I am getting the following error:

web3.exceptions.TransactionNotFound: Transaction with hash: '0x026ecd3e92240d933f8184862c5c5e9033dd4f6bc8a1f5e4038debcf4ba0d000' not found.

The same contract goes through fine on Ethereum (any network). Note that the transaction is correctly sent (etherscan), so it's probably an issue with getting transaction information from web3.

Full traceback:

Traceback (most recent call last):
  File "/Users/cloudfloat/.pyenv/versions/ape/bin/ape", line 8, in <module>
    sys.exit(cli())
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape/_cli.py", line 40, in invoke
    return super().invoke(ctx)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape_run/_cli.py", line 23, in invoke
    return super().invoke(ctx)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape/cli/commands.py", line 18, in invoke
    super().invoke(ctx)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape_run/_cli.py", line 73, in call
    ns["main"]()  # Execute the script
  File "/Users/cloudfloat/Documents/cloud-aud/scripts/deploy.py", line 7, in main
    account.deploy(project.Token)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape/api/accounts.py", line 174, in deploy
    receipt = self.call(txn)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape/api/accounts.py", line 112, in call
    return self.provider.send_transaction(txn)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape/api/providers.py", line 889, in send_transaction
    receipt = self.get_receipt(txn_hash.hex(), required_confirmations=required_confirmations)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/ape/api/providers.py", line 820, in get_receipt
    txn = dict(self.web3.eth.get_transaction(txn_hash))  # type: ignore
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/web3/eth.py", line 749, in get_transaction
    return self._get_transaction(transaction_hash)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/web3/module.py", line 64, in caller
    result = w3.manager.request_blocking(
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/web3/manager.py", line 199, in request_blocking
    return self.formatted_response(
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/web3/manager.py", line 178, in formatted_response
    apply_null_result_formatters(null_result_formatters, response, params)
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/web3/manager.py", line 86, in apply_null_result_formatters
    formatted_resp = pipe(params, null_result_formatters)
  File "cytoolz/functoolz.pyx", line 666, in cytoolz.functoolz.pipe
  File "cytoolz/functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe
  File "/Users/cloudfloat/.pyenv/versions/ape/lib/python3.10/site-packages/web3/_utils/method_formatters.py", line 715, in raise_transaction_not_found
    raise TransactionNotFound(message)
web3.exceptions.TransactionNotFound: Transaction with hash: '0x026ecd3e92240d933f8184862c5c5e9033dd4f6bc8a1f5e4038debcf4ba0d000' not found.

Also, here is my ape-config.yaml (I am using Ankr):

plugins:
  - name: vyper
  - name: optimism

optimism:
  mainnet:
    default_provider: geth

geth:
  optimism:
    mainnet:
      uri: https://rpc.ankr.com/optimism
    testnet:
      uri: https://rpc.ankr.com/optimism_testnet
merc1er commented 1 year ago

One issue seems to be in ape_optimism/ecosystem.py line 75:

if "input" in kwargs:
    kwargs["data"] = decode_hex(kwargs.pop("input"))

should be:

if "input" in kwargs:
    kwargs["data"] = decode_hex(kwargs.pop("hash"))

And other issue seems to be that the RPC returns a NULL_RESPONSE to web3.py (web3/manager.py line 198+).

fubuloubu commented 1 year ago

@merc1er sorry for taking so long, please try #11 when you get a chance to double check my work is working for you