Skip to content

Commit f383d13

Browse files
committed
wip/postForkBlockProduction
1 parent a43131d commit f383d13

File tree

10 files changed

+3946
-1496
lines changed

10 files changed

+3946
-1496
lines changed

Cargo.lock

Lines changed: 3619 additions & 1477 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ op-alloy-flz = "0.13.1"
275275

276276
## revm
277277
revm = { version = "27.0.3", default-features = false }
278-
revm-inspectors = { version = "0.26.5", features = ["serde"] }
278+
revm-inspectors = { version = "0.27.3", features = ["serde"] }
279279
op-revm = { version = "8.0.3", default-features = false }
280280

281281
## alloy-evm

crates/anvil-polkadot/Cargo.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,19 @@ polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk.git", branch
6464
"substrate-frame-rpc-system",
6565
"substrate-rpc-client",
6666
"substrate-wasm-builder",
67-
"pallet-revive-eth-rpc"
67+
"pallet-revive-eth-rpc",
68+
69+
"sc-consensus-aura",
70+
"polkadot-primitives",
71+
"cumulus-client-parachain-inherent",
72+
"sp-arithmetic",
73+
"cumulus-client-service",
74+
"cumulus-primitives-aura",
75+
#"sp-consensus-aura",
76+
6877
] }
78+
79+
#sc-consensus-manual-seal = { git = "https://github.com/paritytech/polkadot-sdk.git", package = "sc-consensus-manual-seal"}
6980
anvil.workspace = true
7081
anvil-core.workspace = true
7182
anvil-server = { workspace = true, features = ["clap"] }
@@ -99,6 +110,7 @@ alloy-chains.workspace = true
99110
alloy-genesis.workspace = true
100111
alloy-trie.workspace = true
101112
op-alloy-consensus = { workspace = true, features = ["serde"] }
113+
hex = "0.4"
102114

103115
# axum related
104116
axum.workspace = true
@@ -141,6 +153,8 @@ subxt-signer = "0.43.0"
141153
tokio-stream = "0.1.17"
142154
jsonrpsee = "0.24.9"
143155
sqlx = "0.8.6"
156+
indicatif.workspace = true
157+
#sc-consensus-manual-seal = "0.54.0"
144158

145159
[dev-dependencies]
146160
alloy-provider = { workspace = true, features = ["txpool-api"] }

crates/anvil-polkadot/src/cmd.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ pub struct NodeArgs {
9797

9898
#[command(flatten)]
9999
pub server_config: ServerConfig,
100+
101+
#[command(flatten)]
102+
pub fork: ForkArgs,
100103
}
101104

102105
/// The default IPC endpoint
@@ -134,7 +137,9 @@ impl NodeArgs {
134137
.with_code_size_limit(self.evm.code_size_limit)
135138
.disable_code_size_limit(self.evm.disable_code_size_limit)
136139
.with_disable_default_create2_deployer(self.evm.disable_default_create2_deployer)
137-
.with_memory_limit(self.evm.memory_limit);
140+
.with_memory_limit(self.evm.memory_limit)
141+
.with_fork_url(self.fork.fork_url)
142+
.with_fork_block_hash(self.fork.fork_block_hash);
138143

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

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

266+
267+
#[derive(Clone, Debug, Parser)]
268+
#[command(next_help_heading = "Fork options")]
269+
pub struct ForkArgs {
270+
/// Fetch state over a remote endpoint instead of starting from an empty state.
271+
#[arg(
272+
long = "fork-url",
273+
short = 'f',
274+
value_name = "URL",
275+
)]
276+
pub fork_url: Option<String>,
277+
278+
/// Fetch state from a specific block hash over a remote endpoint.
279+
#[arg(long, value_name = "BLOCK")]
280+
pub fork_block_hash: Option<String>,
281+
}
282+
261283
#[cfg(test)]
262284
mod tests {
263285
use super::*;

crates/anvil-polkadot/src/config.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ pub struct AnvilNodeConfig {
298298
pub memory_limit: Option<u64>,
299299
/// Do not print log messages.
300300
pub silent: bool,
301+
/// Fetch state over a remote endpoint instead of starting from an empty state.
302+
pub fork_url: Option<String>,
303+
/// Fetch state from a specific block hash over a remote endpoint.
304+
pub fork_block_hash: Option<String>,
301305
}
302306

303307
impl AnvilNodeConfig {
@@ -506,6 +510,8 @@ impl Default for AnvilNodeConfig {
506510
disable_default_create2_deployer: false,
507511
memory_limit: None,
508512
silent: false,
513+
fork_url: None,
514+
fork_block_hash: None,
509515
}
510516
}
511517
}
@@ -774,6 +780,20 @@ impl AnvilNodeConfig {
774780
self
775781
}
776782

783+
/// Sets the fork url
784+
#[must_use]
785+
pub fn with_fork_url(mut self, fork_url: Option<String>) -> Self {
786+
self.fork_url = fork_url;
787+
self
788+
}
789+
790+
/// Sets the fork block
791+
#[must_use]
792+
pub fn with_fork_block_hash(mut self, fork_block_hash: Option<String>) -> Self {
793+
self.fork_block_hash = fork_block_hash;
794+
self
795+
}
796+
777797
/// Returns the ipc path for the ipc endpoint if any
778798
pub fn get_ipc_path(&self) -> Option<String> {
779799
match &self.ipc_path {

crates/anvil-polkadot/src/substrate_node/service/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use polkadot_sdk::{
1717
use std::{collections::HashMap, sync::Arc};
1818
use substrate_runtime::RuntimeApi;
1919

20+
2021
pub type Client = sc_service::client::Client<Backend, Executor, Block, RuntimeApi>;
2122

2223
pub fn new_client(

crates/anvil-polkadot/src/substrate_node/service/executor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ use polkadot_sdk::{
1616
sp_storage::ChildInfo,
1717
sp_version,
1818
sp_wasm_interface::ExtendedHostFunctions,
19+
cumulus_client_service::ParachainHostFunctions,
1920
};
2021
use std::{cell::RefCell, sync::Arc};
2122

2223
/// Wasm executor which overrides the signature checking host functions for impersonation.
2324
pub type WasmExecutor = sc_executor::WasmExecutor<
2425
ExtendedHostFunctions<
25-
ExtendedHostFunctions<sp_io::SubstrateHostFunctions, SenderAddressRecoveryOverride>,
26+
ExtendedHostFunctions<ParachainHostFunctions, SenderAddressRecoveryOverride>,
2627
PublicKeyToHashOverride,
2728
>,
2829
>;

0 commit comments

Comments
 (0)