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

If hardhat forks takes longer than expected to start, ape crashes #111

Open
sajal opened this issue Nov 15, 2022 · 0 comments
Open

If hardhat forks takes longer than expected to start, ape crashes #111

sajal opened this issue Nov 15, 2022 · 0 comments

Comments

@sajal
Copy link

sajal commented Nov 15, 2022

Environment information

  • ape and plugin versions:
$ ape --version
0.5.5.dev9+gec67e5a8

$ ape plugins list
Installed Plugins:
  hardhat     0.5.2
  vyper       0.5.1
  alchemy     0.5.2
  polygon     0.5.1a1
  • Python Version: 3.10.4
  • OS: linux : Linux sajal-thinkpad 5.15.0-39-generic #42-Ubuntu SMP Thu Jun 9 23:42:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

What went wrong?

When using hardhat in forking mode (eth mainnet) with following config

hardhat:
  fork:
    ethereum:
      mainnet:
        upstream_provider: alchemy
        block_number: 15936703
  fork_request_timeout: 1200

and following test case

import ape

import pytest

def test_vitalik_balance():
    assert ape.api.address.Address("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045").balance == 739992029493125111147

with following command WEB3_ETHEREUM_MAINNET_ALCHEMY_API_KEY="REMOVED" ape test --network :mainnet-fork:hardhat -v DEBUG tests/test_Fork.py

The result is random.

How can it be fixed?

My thoughts are that sometimes hardhat takes longer than expected(especially given that I'm 300ms away from alchemy) to start listening on port 8545 and connection refused error is not handled anywhere. Some experiments shows that if we catch the error here things work fine.

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