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

RPC calls to non-localhosts are slow #4658

Closed
2 tasks done
moubctez opened this issue Mar 28, 2023 · 5 comments
Closed
2 tasks done

RPC calls to non-localhosts are slow #4658

moubctez opened this issue Mar 28, 2023 · 5 comments
Labels
first issue A good way to start contributing T-bug Type: bug

Comments

@moubctez
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (6c1eee9 2023-03-27T11:13:24.314347Z)

What command(s) is the bug in?

forge create

Operating System

macOS (Intel)

Describe the bug

I have anvil running on 0.0.0.0.

I benchmark forge create

time forge create --offline --rpc-url=http://127.0.0.1:8545 --private-key=…
1.958u 0.247s 0:00.79 277.2% 1+0k 0+0io 0pf+0w

time forge create --offline --rpc-url=http://192.168.0.123:8545 --private-key=…
1.931u 0.246s 0:06.69 32.4% 1+0k 0+0io 0pf+0w

Why the second invocation takes about 7 seconds to execute, providing 192.168.0.123 points to the same anvil service?

Same story with --rpc-url=http://anvil:8545 and 127.0.0.1 anvil in /etc/hosts.

@moubctez moubctez added the T-bug Type: bug label Mar 28, 2023
@gakonst gakonst added this to Foundry Mar 28, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Mar 28, 2023
@mattsse
Copy link
Member

mattsse commented Mar 28, 2023

the second invocation takes about 7 seconds to execute,

this looks like interval that's being used for checking for tx receipt etc.

https://github.com/foundry-rs/foundry/blob/master/common/src/provider.rs

for localhost, we can assume that we can just Hit the node with lots of requests.

I guess we can add a setting for this and also tune the defaults a bit.

And we also should exempt 0.0.0.0 from this and treat it as local, basically any IP range that is local:

https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html#method.is_link_local

@mattsse mattsse added the first issue A good way to start contributing label Mar 28, 2023
@loocapro
Copy link
Contributor

I'd like to pick this up.

I can see already some conditional logic that changes the behaviour from local to not local here.

The is_local_endpoint function from ethers_providers only does a pattern match on the endpoint string, checking only for 2 specific cases.

How do you want me to proceed?
@mattsse

@mattsse
Copy link
Member

mattsse commented Apr 13, 2023

@loocapro
Copy link
Contributor

Ok cool! Shall I open an issue on ethers-rs and link it back to here?

@Evalir
Copy link
Member

Evalir commented Jul 1, 2023

Closing—the upstream fix is now in foundry and rpc calls should not be slow anymore (quickly tested and seemed fast enough).

@Evalir Evalir closed this as completed Jul 1, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first issue A good way to start contributing T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

4 participants