Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,096 changes: 3,619 additions & 1,477 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ op-alloy-flz = "0.13.1"

## revm
revm = { version = "27.0.3", default-features = false }
revm-inspectors = { version = "0.26.5", features = ["serde"] }
revm-inspectors = { version = "0.27.3", features = ["serde"] }
op-revm = { version = "8.0.3", default-features = false }

## alloy-evm
Expand Down
16 changes: 15 additions & 1 deletion crates/anvil-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,19 @@ polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk.git", branch
"substrate-frame-rpc-system",
"substrate-rpc-client",
"substrate-wasm-builder",
"pallet-revive-eth-rpc"
"pallet-revive-eth-rpc",

"sc-consensus-aura",
"polkadot-primitives",
"cumulus-client-parachain-inherent",
"sp-arithmetic",
"cumulus-client-service",
"cumulus-primitives-aura",
#"sp-consensus-aura",

] }

#sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.git", package = "sc-consensus-manual-seal"}
anvil.workspace = true
anvil-core.workspace = true
anvil-server = { workspace = true, features = ["clap"] }
Expand Down Expand Up @@ -99,6 +110,7 @@ alloy-chains.workspace = true
alloy-genesis.workspace = true
alloy-trie.workspace = true
op-alloy-consensus = { workspace = true, features = ["serde"] }
hex = "0.4"

# axum related
axum.workspace = true
Expand Down Expand Up @@ -141,6 +153,8 @@ subxt-signer = "0.43.0"
tokio-stream = "0.1.17"
jsonrpsee = "0.24.9"
sqlx = "0.8.6"
indicatif.workspace = true
#sc-consensus-manual-seal = "0.54.0"

[dev-dependencies]
alloy-provider = { workspace = true, features = ["txpool-api"] }
Expand Down
24 changes: 23 additions & 1 deletion crates/anvil-polkadot/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ pub struct NodeArgs {

#[command(flatten)]
pub server_config: ServerConfig,

#[command(flatten)]
pub fork: ForkArgs,
}

/// The default IPC endpoint
Expand Down Expand Up @@ -134,7 +137,9 @@ impl NodeArgs {
.with_code_size_limit(self.evm.code_size_limit)
.disable_code_size_limit(self.evm.disable_code_size_limit)
.with_disable_default_create2_deployer(self.evm.disable_default_create2_deployer)
.with_memory_limit(self.evm.memory_limit);
.with_memory_limit(self.evm.memory_limit)
.with_fork_url(self.fork.fork_url)
.with_fork_block_hash(self.fork.fork_block_hash);

let substrate_node_config = SubstrateNodeConfig::new(&anvil_config);

Expand Down Expand Up @@ -258,6 +263,23 @@ fn duration_from_secs_f64(s: &str) -> Result<Duration, String> {
Duration::try_from_secs_f64(s).map_err(|e| e.to_string())
}


#[derive(Clone, Debug, Parser)]
#[command(next_help_heading = "Fork options")]
pub struct ForkArgs {
/// Fetch state over a remote endpoint instead of starting from an empty state.
#[arg(
long = "fork-url",
short = 'f',
value_name = "URL",
)]
pub fork_url: Option<String>,

/// Fetch state from a specific block hash over a remote endpoint.
#[arg(long, value_name = "BLOCK")]
pub fork_block_hash: Option<String>,
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
20 changes: 20 additions & 0 deletions crates/anvil-polkadot/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ pub struct AnvilNodeConfig {
pub memory_limit: Option<u64>,
/// Do not print log messages.
pub silent: bool,
/// Fetch state over a remote endpoint instead of starting from an empty state.
pub fork_url: Option<String>,
/// Fetch state from a specific block hash over a remote endpoint.
pub fork_block_hash: Option<String>,
}

impl AnvilNodeConfig {
Expand Down Expand Up @@ -506,6 +510,8 @@ impl Default for AnvilNodeConfig {
disable_default_create2_deployer: false,
memory_limit: None,
silent: false,
fork_url: None,
fork_block_hash: None,
}
}
}
Expand Down Expand Up @@ -774,6 +780,20 @@ impl AnvilNodeConfig {
self
}

/// Sets the fork url
#[must_use]
pub fn with_fork_url(mut self, fork_url: Option<String>) -> Self {
self.fork_url = fork_url;
self
}

/// Sets the fork block
#[must_use]
pub fn with_fork_block_hash(mut self, fork_block_hash: Option<String>) -> Self {
self.fork_block_hash = fork_block_hash;
self
}

/// Returns the ipc path for the ipc endpoint if any
pub fn get_ipc_path(&self) -> Option<String> {
match &self.ipc_path {
Expand Down
1 change: 1 addition & 0 deletions crates/anvil-polkadot/src/substrate_node/service/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use polkadot_sdk::{
use std::{collections::HashMap, sync::Arc};
use substrate_runtime::RuntimeApi;


pub type Client = sc_service::client::Client<Backend, Executor, Block, RuntimeApi>;

pub fn new_client(
Expand Down
3 changes: 2 additions & 1 deletion crates/anvil-polkadot/src/substrate_node/service/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ use polkadot_sdk::{
sp_storage::ChildInfo,
sp_version,
sp_wasm_interface::ExtendedHostFunctions,
cumulus_client_service::ParachainHostFunctions,
};
use std::{cell::RefCell, sync::Arc};

/// Wasm executor which overrides the signature checking host functions for impersonation.
pub type WasmExecutor = sc_executor::WasmExecutor<
ExtendedHostFunctions<
ExtendedHostFunctions<sp_io::SubstrateHostFunctions, SenderAddressRecoveryOverride>,
ExtendedHostFunctions<ParachainHostFunctions, SenderAddressRecoveryOverride>,
PublicKeyToHashOverride,
>,
>;
Expand Down
Loading
Loading