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

feat: lookup network in evmchains; plugin-less networks, adhoc networks w/ correct name #2328

Merged
merged 5 commits into from
Nov 4, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Oct 19, 2024

What I did

  • Make it so if you connect to a network Ape hasn't an installed plugin for, it will look it up in evmchains and "just work"
  • Make it so if you use a custom network e.g. connecting using a URL only, and that network is found in evmchains, it will set the correct names for the network

How I did it

Use evmchains library.

How to verify it

First, I have no plugin for moonbeam installed, but yet i can do this:

ape console --network moonbeam

and it "just works"

Second, if I connect to a URL in the same fashion:

ape console --network "https://moonriver.unitedbloc.com"

Not only does it work (did before), but the network name and stuff is correct:

In [1]: provider.network.name
Out[1]: 'moonriver'

In [2]: provider.network.ecosystem.name
Out[2]: 'moonbeam'

taa daaaa

Checklist

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

@antazoey antazoey changed the title feat: able to connect to networks by name alone, even when not configured or installed feat: lookup network in evmchains; plugin-less networks, adhoc networks w/ correct name Oct 25, 2024
@antazoey antazoey marked this pull request as ready for review October 25, 2024 20:06
@antazoey
Copy link
Member Author

Failing test only happens on Web3>=6.20.2 not on 6.20.1 (which is what i was using locally)

@antazoey
Copy link
Member Author

:<

fubuloubu
fubuloubu previously approved these changes Oct 31, 2024
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.

I feel like this could do with a little extra testing from @bitwise-constructs

Copy link
Contributor

@bitwise-constructs bitwise-constructs left a comment

Choose a reason for hiding this comment

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

This looks good, I confirmed that custom network names still take precedence over names in evmchains

@bitwise-constructs
Copy link
Contributor

bitwise-constructs commented Nov 4, 2024

Although I was digging more into the custom network names and I'm not clear on how that works.

If I set up one in my yaml like this

networks:
  custom:
    - name: scroll                    
      chain_id: 109                   
      ecosystem: shibarium            
      base_ecosystem_plugin: ethereum  
      default_provider: node          

and then call ape console --network scroll then as it evaluates, first it will check if it exists in the ecosystems of the NetworkManager, where this custom network is present but it is under its ecosystem value shibarium, not its custom network name scroll

(Pdb) self.ecosystem_names
{'ethereum', 'shibarium'}

but if I change the call to ape console --network shibarium to target the correct custom network, then the value in there doesn't have chain_id from the custom network config, it only has it in _networks_from_evmchains

(Pdb) self.ecosystems["shibarium"].__dict__
{'name': 'shibarium', 'request_header': {'User-Agent': 'ape-ethereum ape-shibarium'}, 'fee_token_symbol': 'ETH', 'fee_token_decimals': 18, '_networks_from_plugins': {}, '_networks_from_evmchains': {'mainnet': <shibarium:mainnet chain_id=109>, 'puppynet': <shibarium:puppynet chain_id=157>}}

@antazoey
Copy link
Member Author

antazoey commented Nov 4, 2024

@bitwise-constructs Networks are the middle value in --network triplet, so when you do --network scroll, you are actually saying scroll:: (treating it like an ecosystem). And since there isn't an ecosystem configured or installed named scroll, it will look it up in evm-chains.

To use your custom network shibarium:scroll, you would do --network shibarium:scroll.

note: scroll is not a network on shibarium so youd be a bit hacky here, also because of that you would have to configure a URI for it

@antazoey antazoey enabled auto-merge (squash) November 4, 2024 14:53
@antazoey antazoey merged commit f833e46 into ApeWorX:main Nov 4, 2024
16 checks passed
@antazoey antazoey deleted the feat/easy-net branch November 4, 2024 14:55
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