GithubHelp home page GithubHelp logo

apeworx / ape-optimism Goto Github PK

View Code? Open in Web Editor NEW
9.0 6.0 9.0 51 KB

Optimism network provider plugin for the Ape Framework

Home Page: https://www.apeworx.io/

License: Apache License 2.0

Python 100.00%
python optimism smart-contracts optimism-l2 web3 ape apeworx

ape-optimism's People

Contributors

antazoey avatar dtdang avatar fubuloubu avatar ninjagod1251 avatar notpeopling2day avatar pandadefi avatar z80dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ape-optimism's Issues

`TransactionNotFound` when deploying contract on optimism

Environment information

  • ape and plugin versions:
$ 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
  • Python Version: 3.10.6
  • OS: macOS

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

Optimism `TransactionNotFound` Error

Environment information

  • OS: macOS
  • Python Version: 3.9.15
  • ape and plugin versions:
    • ape: 0.5.9
    • ape-optimism: 0.5.2
$ ape --version
0.5.9

$ ape plugins list
Installed Plugins:
  etherscan    0.5.4
  ens          0.5.1
  optimism     0.5.2
  infura       0.5.3
  solidity     0.5.4
  • Contents of your ape-config.yaml (NOTE: do not post anything private like RPC urls or secrets!):
$ cat ape-config.yaml
name: ape-interact

plugins:
  - name: solidity
  - name: etherscan
  - name: infura
  - name: optimism
  - name: ens

optimism:
  mainnet:
    transaction_acceptance_timeout: 180

What went wrong?

When running two subsequent transactions, the second transaction always fails with the error TransactionNotFound. However, this transaction is actually submitted and confirmed onchain. It fails to receive the receipt for the transaction hash of my second transaction.

Here is some pseudocode for the transactions:

from ape import project, accounts

def main():
    # import account
    account = accounts.load('account')

    # create contract
    contract = project.Contract.at("0x00000000")

    # run functions
    receipt_1 = contract.functionOne(sender=account)
    receipt_2 = contract.functionTwo(sender=account)

This script fails on the line which starts with receipt_2 = when I run it using ape-optimism

Can't fork optimism mainnet

Environment information

  • ape and plugin versions:
$ ape --version
0.7.4
 
$ ape plugins list
 
Installed Plugins
  etherscan 0.7.0
  foundry 0.7.2
  optimism 0.7.0
  solidity 0.7.1
  • Python Version: 3.10.12
  • OS: macOS
File: ape-config.yaml
name: auto-op
plugins:
  - name: optimism
  - name: etherscan
  - name: foundry
  - name: solidity
 
default_ecosystem: optimism
 
optimism:
  default_network: mainnet-fork
  mainnet_fork:
    default_provider: foundry

What went wrong?

ape test --network optimism:mainnet-fork

it is not possible to fork the optimism chain.

INTERNALERROR> ape.exceptions.BlockNotFoundError: Block with ID '0' not found. Reason: The field extraData is 117 bytes, but should be 32. It is quite likely that you are connected to a POA chain. Refer to http://web3py.readthedocs.io/en/stable/middleware.html#proof-of-authority for more details. The full extraData is: HexBytes('0x000000000000000000000000000000000000000000000000000000000000000000000398232e2064f896018496b4b44b3d62751f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')

How can it be fixed?

`ape.reverts()` fails when trying to decode reason

Environment information

Latest ape
macOS

What went wrong?

When using ape.reverts() on a reverted call, you get this error:

class 'OverflowError'> occurred: cannot fit 'int' into an index-sized integer

How can it be fixed?

  • Figure out the decoding differences and network differences and re-assess.

Optimism Plugin Breaks

Environment information

  • ape and plugin versions:
$ ape --version
0.7.16

$ ape plugins list
WARNING: Unprocessed plugin config(s): optimism, hardhat. Plugins may not be installed yet or keys may be mis-spelled.
Installed Plugins
  alchemy      0.7.1
  etherscan    0.7.2
  hardhat      0.7.2
  optimism     0.7.3
  safe         0.7.0b2
  solidity     0.7.2
  • Python Version: 3.9
  • OS: macOS/linux/win ubuntu

What went wrong?

optimism network does not install

Please include information like:

  • what command you ran
    installed eth-ape with pip, then installed the above packages, the result
WARNING: Unprocessed plugin config(s): optimism, hardhat. Plugins may not be installed yet or keys may be mis-spelled.
Traceback (most recent call last):
  File "/app/main.py", line 53, in <module>
    self.startapetest(testType=args.t, targetScript=args.s)
  File "/app/utils/testkit.py", line 31, in startapetest
    self.run_test_script(testType=testType,targetScript=targetScript)
  File "/app/utils/testkit.py", line 34, in run_test_script
    with networks.optimism.mainnet_fork.use_default_provider():
  File "/usr/local/lib/python3.9/site-packages/ape/managers/networks.py", line 316, in __getattr
    raise ApeAttributeError(f"{NetworkManager.__name} has no attribute '{attr_name}'.")
ape.exceptions.ApeAttributeError: NetworkManager has no attribute 'optimism'.

  • the code that caused the failure (see this link for help with formatting code)

ape networks list

  • full output of the error you received

How can it be fixed?

Fill this in if you have ideas on how the bug could be fixed.

DEFAULT_TRANSACTION_TYPE Missing

Environment information

  • ape and plugin versions:
$ ape --version
# ...copy and paste result of above command here...
0.7.7

$ ape plugins list
# ...copy and paste result of above command here...
Installed Plugins
  alchemy      0.7.1
  etherscan    0.7.0
  foundry      0.7.1
  optimism     0.7.1
  safe         0.7.0b1.dev2+g5b61087
  solidity     0.7.1

  • Python Version: 3.9.0
  • OS: macOS/linux/win linux

What went wrong?

Please include information like:

When trying to withdraw eth having weth in a gnosis safe:

with networks.optimism.mainnet.use_default_provider():            
    #fetch safe
    testSafe = "0xMYSAFE"
    accounts.containers["safe"].delete_account("test-safe")
    accounts.containers["safe"].save_account(address=testSafe,alias="test-safe")
    safe = accounts.load("test-safe")
    #fetch deployer
    deployer = accounts.load("test-deployer")
    deployer.set_autosign(True,passphrase=passphrase)
    #setup test tx
    txn = multisend.MultiSend()            
    address = '0x4200000000000000000000000000000000000006'
    abi = '''[{"constant":false,"inputs":[{"internalType":"uint256","name":"wad","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]'''
    apeContract = Contract(address=address,abi=abi)
    txn.add(apeContract.withdraw,1000)
    txn(sender=safe,type=2,gas=0,submit=False)

I get the below error

runcell(0, '/home/thesis/repos/monitor_ape/utils/testkit.py')

runcell(1, '/home/thesis/repos/monitor_ape/utils/testkit.py')
WARNING: Danger! This account will now sign any transaction it's given.
Traceback (most recent call last):

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/utils/basemodel.py:302 in __getattr__
    res = super().__getattribute__(name)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_ethereum/ecosystem.py:337 in default_transaction_type
    ecosystem_default = network.config.DEFAULT_TRANSACTION_TYPE

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/api/config.py:58 in __getattr__
    return super().__getattribute__(attr_name)

AttributeError: 'OptimismConfig' object has no attribute 'DEFAULT_TRANSACTION_TYPE'


The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File ~/repos/monitor_ape/utils/testkit.py:277
    self.run_test_multisend()

  File ~/repos/monitor_ape/utils/testkit.py:270 in run_test_multisend
    txn(sender=safe,type=2,gas=0,submit=False)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/multisend.py:220 in __call__
    return self.handler(b"".join(self.encoded_calls), **txn_kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:354 in __call__
    return contract_transaction(*args, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:288 in __call__
    return kwargs["sender"].call(txn, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/contextlib.py:79 in inner
    return func(*args, **kwds)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:529 in call
    return super().call(txn, **call_kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/api/accounts.py:152 in call
    signed_txn = self.sign_transaction(txn, **signer_options)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:657 in sign_transaction
    sigs_by_signer = self._all_approvals(safe_tx)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:560 in _all_approvals
    approvals.update(self._contract_approvals(safe_tx))

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_safe/accounts.py:548 in _contract_approvals
    safe_tx_hash = self.contract.getTransactionHash(*safe_tx_exec_args)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:198 in __call__
    return ContractCall(

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:98 in __call__
    txn = self.serialize_transaction(*args, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/contracts/base.py:93 in serialize_transaction
    return self.provider.network.ecosystem.encode_transaction(

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_ethereum/ecosystem.py:721 in encode_transaction
    txn = self.create_transaction(receiver=address, **kwargs)

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape_ethereum/ecosystem.py:791 in create_transaction
    version = self.default_transaction_type

  File ~/miniconda3/envs/monitor_fix/lib/python3.9/site-packages/ape/utils/basemodel.py:335 in __getattr__
    raise attr_err from base_err

ApeAttributeError: 'OptimismConfig' object has no attribute 'DEFAULT_TRANSACTION_TYPE'

How can it be fixed?

Fill this in if you have ideas on how the bug could be fixed.
I am not sure i tried including type=2, still doesn't work, only happens when staging a transaction and committing to to the gnosis safe plugin
ApeWorX/ape-safe#31

Unable to configure default local provider

Environment information

Unable to configure the default provider for the local network because the key is not registered

What went wrong?

Local network is missing from the config

How can it be fixed?

Add local to the config

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.