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: issue when switching providers when disconnecting [APE-1460] #1700

Merged
merged 19 commits into from
Oct 30, 2023

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Oct 13, 2023

What I did

fixed bug with Disconnect => reconnect with new settings was bugged when using the same Python session.
also adds settings object which is useful for getting all provider settings mashed together.
Also, fixes an issue where settings were not updated when connecting to an already-connected provider with new settings.

note: as I was fixing this, I had some random failing tests pop up; bugs highlighted with the networks yaml not actually filtering. I had to fix this in order to get a passing build on this PR.

That caused this PR to be a little out of scope but I don't think it is worth opening more PRs at this point; it is all network related anyway.

How I did it

Delete provider from connected providers when disconnecting

How to verify it

in combo with

ApeWorX/ape-foundry#74

you can do:

In [4]: with networks.parse_network_choice("ethereum:local:foundry", provider_settings={"port": 8999}) as prv:
   ...:     print(prv.uri)
http://127.0.0.1:8999

You can even switch multiple times to have many ongoing foundrys:

with networks.parse_network_choice("ethereum:local:foundry", provider_settings={"port": 8999}) as prv:
   ...:     print(prv.uri)
   ...:     with networks.parse_network_choice("ethereum:local:foundry", provider_settings={"port": 8993}) as prv2:
   ...:         print(prv.uri)
   ...:         print(prv2.uri)

Outputs:

INFO: Connecting to existing 'anvil' process.
http://127.0.0.1:8999
WARNING: `port` setting is deprecated. Please use `host` key that includes the port.
INFO: Starting 'anvil' process.
http://127.0.0.1:8999
http://127.0.0.1:8993

Checklist

  • All changes are completed
  • New test cases have been added
  • Documentation has been updated

@vany365 vany365 changed the title fix: issue when switching providers when disconnecting fix: issue when switching providers when disconnecting [APE-1460] Oct 13, 2023
@antazoey antazoey marked this pull request as draft October 13, 2023 21:12
@antazoey
Copy link
Member Author

antazoey commented Oct 13, 2023

im still working something out in foundry..

  • done

src/ape/api/providers.py Outdated Show resolved Hide resolved
@antazoey
Copy link
Member Author

update: making progress on this but haven't completed or am ready to push yet but hoping to have something cleaned up soon. Apologies for the delay!

@antazoey antazoey marked this pull request as ready for review October 26, 2023 14:07
@antazoey antazoey marked this pull request as draft October 26, 2023 22:23
@antazoey antazoey marked this pull request as ready for review October 26, 2023 22:25
@antazoey
Copy link
Member Author

Somehow it works with hardhat but I think some more updates are needed there anyway.

@fubuloubu
Copy link
Member

checked this out in working with https://github.com/ApeWorX/silverback/tree/feat/add-backtesting

seems to work!

src/ape/api/providers.py Outdated Show resolved Hide resolved
@antazoey antazoey enabled auto-merge (squash) October 30, 2023 20:55
Copy link
Contributor

@NotPeopling2day NotPeopling2day left a comment

Choose a reason for hiding this comment

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

Apologies about the formatting on the suggestion :/

@antazoey antazoey merged commit 84f9ae6 into ApeWorX:main Oct 30, 2023
14 checks passed
@antazoey antazoey deleted the fix/refactor-networks branch October 30, 2023 21:36
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.

3 participants