@@ -8,6 +8,7 @@ use anvil_server::ServerConfig;
88use clap:: Parser ;
99use foundry_common:: shell;
1010use foundry_config:: Chain ;
11+ use polkadot_sdk:: sp_core:: H256 ;
1112use rand_08:: { SeedableRng , rngs:: StdRng } ;
1213use std:: { net:: IpAddr , path:: PathBuf , time:: Duration } ;
1314
@@ -134,7 +135,11 @@ impl NodeArgs {
134135 . with_code_size_limit ( self . evm . code_size_limit )
135136 . disable_code_size_limit ( self . evm . disable_code_size_limit )
136137 . with_disable_default_create2_deployer ( self . evm . disable_default_create2_deployer )
137- . with_memory_limit ( self . evm . memory_limit ) ;
138+ . with_memory_limit ( self . evm . memory_limit )
139+ . with_fork_url ( self . fork . fork_url )
140+ . with_fork_block_hash ( self . fork . fork_block_hash )
141+ . with_fork_delay ( self . fork . fork_delay )
142+ . with_fork_retries ( self . fork . fork_retries ) ;
138143
139144 let substrate_node_config = SubstrateNodeConfig :: new ( & anvil_config) ;
140145
@@ -245,6 +250,26 @@ pub struct AnvilEvmArgs {
245250 pub memory_limit : Option < u64 > ,
246251}
247252
253+ #[ derive( Clone , Debug , Parser ) ]
254+ #[ command( next_help_heading = "Fork options" ) ]
255+ pub struct ForkArgs {
256+ /// Fetch state over a remote endpoint instead of starting from an empty state.
257+ #[ arg( long = "fork-url" , short = 'f' , value_name = "URL" ) ]
258+ pub fork_url : Option < String > ,
259+
260+ /// Fetch state from a specific block hash over a remote endpoint.
261+ #[ arg( long, value_name = "BLOCK" ) ]
262+ pub fork_block_hash : Option < H256 > ,
263+
264+ /// Delay between RPC requests in milliseconds to avoid rate limiting.
265+ #[ arg( long, default_value = "0" , value_name = "MS" ) ]
266+ pub fork_delay : u32 ,
267+
268+ /// Maximum number of retries per RPC request.
269+ #[ arg( long, default_value = "3" , value_name = "NUM" ) ]
270+ pub fork_retries : u32 ,
271+ }
272+
248273/// Clap's value parser for genesis. Loads a genesis.json file.
249274fn read_genesis_file ( path : & str ) -> Result < Genesis , String > {
250275 foundry_common:: fs:: read_json_file ( path. as_ref ( ) ) . map_err ( |err| err. to_string ( ) )
0 commit comments