Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
fix compile
  • Loading branch information
zqhxuyuan committed Mar 23, 2022
commit a08f613b570366ae3ad75a80461c05a485fa7316
470 changes: 280 additions & 190 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ cumulus-primitives-utility = { git = "https://github.com/paritytech//cumulus", r
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech//cumulus", rev = "b1e91afb7421309b203d7627b736d9bcf58260eb" }
parachain-info = { git = "https://github.com/paritytech//cumulus", rev = "b1e91afb7421309b203d7627b736d9bcf58260eb" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech//cumulus", rev = "b1e91afb7421309b203d7627b736d9bcf58260eb" }
cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech//cumulus", rev = "b1e91afb7421309b203d7627b736d9bcf58260eb" }
cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech//cumulus", rev = "b1e91afb7421309b203d7627b736d9bcf58260eb" }
cumulus-test-relay-validation-worker-provider = { git = "https://github.com/paritytech//cumulus", rev = "b1e91afb7421309b203d7627b736d9bcf58260eb" }
statemine-runtime = { git = "https://github.com/paritytech//cumulus", rev = "b1e91afb7421309b203d7627b736d9bcf58260eb" }
Expand Down
19 changes: 10 additions & 9 deletions modules/earning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@ authors = ["Acala Developers"]
edition = "2021"

[dependencies]
codec = { package = "parity-scale-codec", version = "2.3.1", default-features = false }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
scale-info = { version = "2.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.136", optional = true }

frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false }

orml-traits = { package = "orml-traits", path = "../../orml/traits", default-features = false }

support = { package = "module-support", path = "../support", default-features = false }
primitives = { package = "acala-primitives", path = "../../primitives", default-features = false }

paste = "1.0"

[dev-dependencies]
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ path = "src/main.rs"

[dependencies]
futures = "0.3.15"
parity-util-mem = { version = "0.11.0", default-features = false, features = ["jemalloc-global"] }
parity-util-mem = { version = "0.11", default-features = false, features = ["jemalloc-global"] }
acala-cli = { path = "cli" }
acala-service = { path = "service" }

Expand Down
3 changes: 2 additions & 1 deletion node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ pub fn run() -> sc_cli::Result<()> {
let runner = cli.create_runner(&cli.run.normalize())?;
let chain_spec = &runner.config().chain_spec;
let is_mandala_dev = chain_spec.is_mandala_dev();
let collator_options = cli.run.collator_options();

set_default_ss58_version(chain_spec);

Expand Down Expand Up @@ -495,7 +496,7 @@ pub fn run() -> sc_cli::Result<()> {

with_runtime_or_err!(config.chain_spec, {
{
service::start_node::<RuntimeApi, Executor>(config, polkadot_config, id)
service::start_node::<RuntimeApi, Executor>(config, polkadot_config, collator_options, id)
.await
.map(|r| r.0)
.map_err(Into::into)
Expand Down
3 changes: 3 additions & 0 deletions node/e2e-tests/test-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jsonrpc-core = "18.0.0"
log = "0.4.14"
futures = { package = "futures", version = "0.3", features = ["compat"] }
hex-literal = "0.3.1"
url = "2.2.2"

# Substrate dependencies
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
Expand Down Expand Up @@ -59,6 +60,7 @@ polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "r
polkadot-test-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }

# Cumulus dependencies
cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
Expand All @@ -69,6 +71,7 @@ cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/c
cumulus-test-relay-validation-worker-provider = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }

runtime-common = { path = "../../../runtime/common" }
node-runtime = { package = "mandala-runtime", path = "../../../runtime/mandala" }
Expand Down
14 changes: 13 additions & 1 deletion node/e2e-tests/test-service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct TestNodeBuilder {
storage_update_func_relay_chain: Option<Box<dyn Fn()>>,
consensus: Consensus,
seal_mode: SealMode,
relay_chain_full_node_url: Option<Url>,
}

impl TestNodeBuilder {
Expand All @@ -55,6 +56,7 @@ impl TestNodeBuilder {
storage_update_func_relay_chain: None,
consensus: Consensus::Aura,
seal_mode: SealMode::ParaSeal,
relay_chain_full_node_url: None,
}
}

Expand Down Expand Up @@ -149,6 +151,12 @@ impl TestNodeBuilder {
self
}

/// Connect to full node via RPC.
pub fn use_external_relay_chain_node_at_url(mut self, network_address: Url) -> Self {
self.relay_chain_full_node_url = Some(network_address);
self
}

/// Build the [`TestNode`].
pub async fn build(self) -> TestNode {
let parachain_config = node_config(
Expand All @@ -172,6 +180,10 @@ impl TestNodeBuilder {

relay_chain_config.network.node_name = format!("{} (relay chain)", relay_chain_config.network.node_name);

let collator_options = CollatorOptions {
relay_chain_rpc_url: self.relay_chain_full_node_url,
};

let multiaddr = parachain_config.network.listen_addresses[0].clone();
let (task_manager, client, network, rpc_handlers, transaction_pool, backend, seal_sink) = match self.seal_mode {
SealMode::DevInstantSeal | SealMode::DevAuraSeal => {
Expand All @@ -186,6 +198,7 @@ impl TestNodeBuilder {
parachain_config,
self.collator_key,
relay_chain_config,
collator_options,
self.para_id,
self.wrap_announce_block,
|_| Ok(Default::default()),
Expand Down Expand Up @@ -283,7 +296,6 @@ pub fn node_config(
state_cache_child_ratio: None,
state_pruning: PruningMode::ArchiveAll,
keep_blocks: KeepBlocks::All,
transaction_storage: TransactionStorageMode::BlockBody,
chain_spec: spec,
wasm_method: WasmExecutionMethod::Interpreted,
// NOTE: we enforce the use of the native runtime to make the errors more debuggable
Expand Down
12 changes: 7 additions & 5 deletions node/e2e-tests/test-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod service;
use futures::channel::{mpsc, oneshot};
use std::{future::Future, sync::Arc, time::Duration};

use cumulus_client_cli::CollatorOptions;
use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
use cumulus_client_consensus_common::{ParachainCandidate, ParachainConsensus};
use cumulus_client_network::BlockAnnounceValidator;
Expand All @@ -32,7 +33,9 @@ use cumulus_client_service::{
StartFullNodeParams,
};
use cumulus_primitives_core::ParaId;
use cumulus_relay_chain_inprocess_interface::RelayChainLocal;
use cumulus_relay_chain_inprocess_interface::RelayChainInProcessInterface;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;

use frame_system_rpc_runtime_api::AccountNonceApi;
use futures::{channel::mpsc::Sender, SinkExt};
Expand All @@ -52,7 +55,7 @@ use sc_network::{config::TransportConfig, multiaddr, NetworkService};
use sc_service::{
config::{
DatabaseSource, KeepBlocks, KeystoreConfig, MultiaddrWithPeerId, NetworkConfiguration, OffchainWorkerConfig,
PruningMode, TransactionStorageMode, WasmExecutionMethod,
PruningMode, WasmExecutionMethod,
},
BasePath, ChainSpec, Configuration, PartialComponents, Role, RpcHandlers, SpawnTasksParams, TFullBackend,
TFullCallExecutor, TFullClient, TaskManager,
Expand All @@ -73,9 +76,8 @@ use sp_runtime::{
};
use sp_state_machine::{BasicExternalities, Ext};
use sp_trie::PrefixedMemoryDB;
use substrate_test_client::{
sp_consensus::SlotData, BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput,
};
use substrate_test_client::{BlockchainEventsExt, RpcHandlersExt, RpcTransactionError, RpcTransactionOutput};
use url::Url;

use node_primitives::{signature::AcalaMultiSignature, AccountId, Address, Balance, Signature};
use node_runtime::{Block, BlockId, Hash, Header, Runtime, RuntimeApi, SignedExtra};
Expand Down
88 changes: 55 additions & 33 deletions node/e2e-tests/test-service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn new_partial(
}
SealMode::DevAuraSeal => {
// aura import queue
let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;

(
sc_consensus_aura::import_queue::<sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _>(
Expand All @@ -85,10 +85,11 @@ pub fn new_partial(
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
*timestamp,
slot_duration,
);
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);

Ok((
timestamp,
Expand All @@ -111,9 +112,9 @@ pub fn new_partial(
let create_inherent_data_providers = Box::new(move |_, _| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration.slot_duration(),
slot_duration,
);

Ok((timestamp, slot))
Expand Down Expand Up @@ -210,11 +211,11 @@ pub async fn start_dev_node(

match seal_mode {
SealMode::DevInstantSeal => {
let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let create_inherent_data_providers = Box::new(move |_, _| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Expand Down Expand Up @@ -243,7 +244,7 @@ pub async fn start_dev_node(
SealMode::DevAuraSeal => {
// aura
let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
let slot_duration = sc_consensus_aura::slot_duration(&*client)?.slot_duration();
let slot_duration = sc_consensus_aura::slot_duration(&*client)?;
let aura = sc_consensus_aura::start_aura::<
sp_consensus_aura::sr25519::AuthorityPair,
_,
Expand All @@ -267,7 +268,7 @@ pub async fn start_dev_node(
create_inherent_data_providers: move |_, ()| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
let slot = sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
Expand Down Expand Up @@ -332,6 +333,35 @@ pub async fn start_dev_node(
))
}

async fn build_relay_chain_interface(
relay_chain_config: Configuration,
collator_key: Option<CollatorPair>,
collator_options: CollatorOptions,
task_manager: &mut TaskManager,
) -> RelayChainResult<Arc<dyn RelayChainInterface + 'static>> {
if let Some(relay_chain_url) = collator_options.relay_chain_rpc_url {
return Ok(Arc::new(RelayChainRPCInterface::new(relay_chain_url).await?) as Arc<_>);
}

let relay_chain_full_node = polkadot_test_service::new_full(
relay_chain_config,
if let Some(ref key) = collator_key {
polkadot_service::IsCollator::Yes(key.clone())
} else {
polkadot_service::IsCollator::Yes(CollatorPair::generate().0)
},
None,
)?;

task_manager.add_child(relay_chain_full_node.task_manager);
Ok(Arc::new(RelayChainInProcessInterface::new(
relay_chain_full_node.client.clone(),
relay_chain_full_node.backend.clone(),
Arc::new(Mutex::new(Box::new(relay_chain_full_node.network.clone()))),
relay_chain_full_node.overseer_handle.clone(),
)) as Arc<_>)
}

/// Start a node with the given parachain `Configuration` and relay chain `Configuration`.
///
/// This is the actual implementation that is abstract over the executor and the runtime api.
Expand All @@ -340,6 +370,7 @@ pub async fn start_node_impl<RB>(
parachain_config: Configuration,
collator_key: Option<CollatorPair>,
relay_chain_config: Configuration,
collator_options: CollatorOptions,
para_id: ParaId,
wrap_announce_block: Option<Box<dyn FnOnce(AnnounceBlockFn) -> AnnounceBlockFn>>,
rpc_ext_builder: RB,
Expand Down Expand Up @@ -370,32 +401,22 @@ where
let transaction_pool = params.transaction_pool.clone();
let mut task_manager = params.task_manager;

let relay_chain_full_node = polkadot_test_service::new_full(
let client = params.client.clone();
let backend = params.backend.clone();
let backend_for_node = backend.clone();

let relay_chain_interface = build_relay_chain_interface(
relay_chain_config,
if let Some(ref key) = collator_key {
polkadot_service::IsCollator::Yes(key.clone())
} else {
polkadot_service::IsCollator::Yes(CollatorPair::generate().0)
},
None,
collator_key.clone(),
collator_options.clone(),
&mut task_manager,
)
.await
.map_err(|e| match e {
polkadot_service::Error::Sub(x) => x,
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
s => s.to_string().into(),
})?;

let client = params.client.clone();
let backend = params.backend.clone();
let backend_for_node = backend.clone();

let relay_chain_interface = Arc::new(RelayChainLocal::new(
relay_chain_full_node.client.clone(),
relay_chain_full_node.backend.clone(),
Arc::new(Mutex::new(Box::new(relay_chain_full_node.network.clone()))),
relay_chain_full_node.overseer_handle.clone(),
));
task_manager.add_child(relay_chain_full_node.task_manager);

let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
let block_announce_validator_builder = move |_| Box::new(block_announce_validator) as Box<_>;

Expand Down Expand Up @@ -510,9 +531,9 @@ where
let time = sp_timestamp::InherentDataProvider::from_system_time();

let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_duration(
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*time,
slot_duration.slot_duration(),
slot_duration,
);

let parachain_inherent = parachain_inherent.ok_or_else(|| {
Expand Down Expand Up @@ -567,6 +588,7 @@ where
// the recovery delay of pov-recovery. We don't want to wait for too
// long on the full node to recover, so we reduce this time here.
relay_chain_slot_duration: Duration::from_millis(6),
collator_options,
};

start_full_node(params)?;
Expand Down
2 changes: 2 additions & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "pol
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }

cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-client-network = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-client-service = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
Expand All @@ -68,6 +69,7 @@ cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/cumul
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-relay-chain-inprocess-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
cumulus-relay-chain-rpc-interface = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }

polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.18" }
Expand Down
Loading