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

fix: properly detect, specify, and handle connecting forked network to non-fork [APE-1393] #156

Merged
merged 10 commits into from
Sep 15, 2023

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Sep 14, 2023

What I did

  • add method to get metadata, which included a fork object that is None when not a fork
  • Raises error when connecting fork to non fork like we use to, but use new way that is not as bugged
  • Allow setting the host per forked network so you can do that if you want
  • Removed a deprecated part from the README
  • Removes unneeded code
  • Updates lint dependencies

fixes: ApeWorX/ape#1467

How I did it

How to verify it

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@vany365 vany365 changed the title fix: remove deprecated parts fix: remove deprecated parts [APE-1393] Sep 14, 2023
@antazoey
Copy link
Member Author

Partially addresses: ApeWorX/ape#1467

@antazoey antazoey changed the title fix: remove deprecated parts [APE-1393] fix: properly detect and handle connecting forked network to non-fork [APE-1393] Sep 15, 2023
if not self.metadata.forked_network:
# This will fail when trying to connect hardhat-fork to
# a non-forked network.
raise HardhatProviderError(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we had an issue with the genesis block on certain networks, which is why we had to switch to logging as an error instead, with hopes to someday having a better way. Now, hardhat has a metadata RPC that we can use to deduce whether the network is a fork, so we can put back this error.

See this comment for historical reference: #32 (comment)

"Network is no a fork. "
"Hardhat is likely already running on the local network. "
"Try using config:\n\n(ape-config.yaml)\n```\nhardhat:\n "
"host: auto\n```\n\nso that multiple processes can automatically "
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this message should prevent the user from being misled so much, and even has a suggestion for how to fix.
this is the part that fixes ApeWorX/ape#1467

@antazoey antazoey changed the title fix: properly detect and handle connecting forked network to non-fork [APE-1393] fix: properly detect, specify, and handle connecting forked network to non-fork [APE-1393] Sep 15, 2023
@@ -176,26 +175,6 @@ def test_contract_revert_custom_exception(owner, get_contract_type, accounts):
assert err.value.inputs == {"addr": accounts[7].address, "counter": 123}


def test_contract_dev_message(owner, get_contract_type):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, we can longer run this test without installing ape-vyper, maybe we will find a way to have a less integration-y test

Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid

@antazoey antazoey merged commit e6b818d into ApeWorX:main Sep 15, 2023
13 checks passed
@antazoey antazoey deleted the fix/update-readme branch September 15, 2023 19:28
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

Successfully merging this pull request may close these issues.

Unable to read mainnet contract on a forked network using pytest mark [APE-1016]
3 participants