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

anvil feat: support forking at transaction level #5810

Open
ChinW opened this issue Sep 11, 2023 · 4 comments
Open

anvil feat: support forking at transaction level #5810

ChinW opened this issue Sep 11, 2023 · 4 comments
Labels
good first issue Good for newcomers T-feature Type: feature

Comments

@ChinW
Copy link

ChinW commented Sep 11, 2023

Component

Anvil

Describe the feature you would like

hi team, like #3262

would like also have this feature in anvil project, also happy with some guidance to contribute back.

by the way, I would like to confirm my below understanding of forking:

I am forking eth network with block number by using private eth full node, found out multicall is very slow in this environment (couple minutes, > 5 minutes), while same calls on latest block number (no forking) is very very fast (<1 minute).

Is it because inside the box, the local forking node is actually requesting the remote full node with lots of getStorageAt request, so that make it slow. If true, I guess if I put the local forking test program into the full node machine, it should be much much faster. Is my understanding correct?

Additional context

No response

@ChinW ChinW added the T-feature Type: feature label Sep 11, 2023
@mattsse
Copy link
Member

mattsse commented Sep 11, 2023

we already have this functionality in forge, which we could also enable in anvil

I am forking eth network with block number by using private eth full node, found out multicall is very slow in this environment (couple minutes, > 5 minutes), while same calls on latest block number (no forking) is very very fast (<1 minute).

if you're using a local node without any rate limits, ptal at the --no-rate-limit setting

@mattsse mattsse added the good first issue Good for newcomers label Sep 11, 2023
@dhiraj0911
Copy link

@ChinW can you assign this issue to me

@ChinW
Copy link
Author

ChinW commented Sep 23, 2023

@mattsse hi, I wonder if you know, when using vm.createSelectFork(rpcUrl, vm.parseBytes32(txId)), will this also apply rate-limit at default? I didnt see how to disable rate limit by vm.XXXXX function

@mattsse
Copy link
Member

mattsse commented Sep 23, 2023

good point, this currently does not use the no rate limit option

/// Creates a new fork
///
/// This will establish a new `Provider` to the endpoint and return the Fork Backend
async fn create_fork(
mut fork: CreateFork,
retries: u32,
backoff: u64,
) -> eyre::Result<(CreatedFork, Handler)> {
let provider = Arc::new(
ProviderBuilder::new(fork.url.as_str())
.max_retry(retries)
.initial_backoff(backoff)
.compute_units_per_second(fork.evm_opts.get_compute_units_per_second())
.build()?,
);

let retries = self.retries;
let backoff = self.backoff;
// need to create a new fork
let task = Box::pin(create_fork(fork, retries, backoff));

and uses fixed values for some reason

retries: 8,
// 800ms
backoff: 800,

we definitely want support for this, I think the easiest way would be to use the values of the CreateFork argument instead here

fn create_fork(&mut self, fork: CreateFork, sender: CreateSender) {

via createfork.evm_opts.no_rpc_rate_limit

this would be an easy fix, do you want to take this @ChinW ?

converting this into an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers T-feature Type: feature
Projects
No open projects
Status: Todo
Development

No branches or pull requests

3 participants