Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Add EVM tests #43

Closed
wants to merge 8 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## cargo
/target
## npm
node_modules
**/node_modules

# Test data
test-data
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ futures = { version = "0.3" }
jsonrpsee = { version = "0.15", features = ["server"] }
log = { version = "0.4" }
serde = { version = "1.0", features = ["derive"] }
async-trait = "0.1"

# cumulus
cumulus-client-cli = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.30" }
Expand Down Expand Up @@ -65,6 +66,7 @@ sc-chain-spec = { git = "https://github.com/paritytech/substrat
sc-cli = { features = ["wasmtime"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30", optional = true }
sc-executor = { features = ["wasmtime"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" }
Expand Down Expand Up @@ -97,6 +99,10 @@ try-runtime-cli = { git = "https://github.com/paritytech/substrat
[features]
default = []

manual-seal = [
"sc-consensus-manual-seal",
]

runtime-benchmarks = [
# darwinia
"darwinia-runtime/runtime-benchmarks",
Expand Down
1 change: 1 addition & 0 deletions node/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ fn main() {
substrate_build_script_utils::generate_cargo_keys();
substrate_build_script_utils::rerun_if_git_head_changed();
}

29 changes: 29 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,22 @@ pub struct EthArgs {
/// Maximum fee history cache size.
#[clap(long, default_value = "2048")]
pub fee_history_limit: u64,

/// Choose sealing method.
#[cfg(feature = "manual-seal")]
#[clap(long, arg_enum, ignore_case = true)]
pub sealing: Sealing,
}

impl EthArgs {
pub fn build_eth_rpc_config(&self) -> EthRpcConfig {
EthRpcConfig {
eth_statuses_cache: self.eth_statuses_cache,
eth_log_block_cache: self.eth_log_block_cache,
max_past_logs: self.max_past_logs,
fee_history_limit: self.fee_history_limit,
#[cfg(feature = "manual-seal")]
sealing: self.sealing,
}
}
}
Expand All @@ -157,4 +165,25 @@ pub struct EthRpcConfig {

/// Maximum fee history cache size.
pub max_past_logs: u32,

/// Choose sealing method.
#[cfg(feature = "manual-seal")]
pub sealing: Sealing,
}

/// Available Sealing methods.
#[cfg(feature = "manual-seal")]
#[derive(Debug, Copy, Clone, clap::ArgEnum)]
pub enum Sealing {
// Seal using rpc method.
Manual,
// Seal when transaction is executed.
Instant,
}

#[cfg(feature = "manual-seal")]
impl Default for Sealing {
fn default() -> Sealing {
Sealing::Manual
}
}
7 changes: 5 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ pub fn run() -> Result<()> {
let runner = cli.create_runner(cmd)?;

runner.sync_run(|config| {
let PartialComponents { client, other: (frontier_backend, ..), .. } =
let PartialComponents { client, other: (_, frontier_backend, ..), .. } =
service::new_partial::<RuntimeApi, DarwiniaRuntimeExecutor>(
&config,
&cli.eth_args.build_eth_rpc_config(),
Expand Down Expand Up @@ -470,7 +470,10 @@ pub fn run() -> Result<()> {
log::info!("Parachain id: {:?}", id);
log::info!("Parachain Account: {}", parachain_account);
log::info!("Parachain genesis state: {}", genesis_state);
log::info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
log::info!(
"Is collating: {}",
if config.role.is_authority() { "yes" } else { "no" }
);

crate::service::start_parachain_node(
config,
Expand Down
18 changes: 18 additions & 0 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
use std::sync::Arc;
// darwinia
use dc_primitives::*;
// substrate
#[cfg(feature = "manual-seal")]
use sc_consensus_manual_seal::rpc::{ManualSeal, ManualSealApiServer};

/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpsee::RpcModule<()>;
Expand Down Expand Up @@ -59,6 +62,10 @@ pub struct FullDeps<C, P, A: sc_transaction_pool::ChainApi> {
pub overrides: Arc<fc_rpc::OverrideHandle<Block>>,
/// Cache for Ethereum block data.
pub block_data_cache: Arc<fc_rpc::EthBlockDataCacheTask<Block>>,
/// Manual seal command sink
#[cfg(feature = "manual-seal")]
pub command_sink:
Option<futures::channel::mpsc::Sender<sc_consensus_manual_seal::rpc::EngineCommand<Hash>>>,
}

/// Instantiate all RPC extensions.
Expand Down Expand Up @@ -111,6 +118,8 @@ where
fee_history_cache_limit,
overrides,
block_data_cache,
#[cfg(feature = "manual-seal")]
command_sink,
} = deps;

module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
Expand Down Expand Up @@ -169,5 +178,14 @@ where
)?;
module.merge(Web3::new(client).into_rpc())?;

#[cfg(feature = "manual-seal")]
if let Some(command_sink) = command_sink {
module.merge(
// We provide the rpc handler with the sending end of the channel to allow the rpc
// send EngineCommands to the background block authorship task.
ManualSeal::new(command_sink).into_rpc(),
)?;
}

Ok(module)
}
Loading