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

v2.0.0 #321

Closed
wants to merge 11 commits into from
1,541 changes: 753 additions & 788 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bin/node-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ node-template-runtime = { path = "../runtime" }
# crates
codec = { package = "parity-scale-codec", version = "1.3.5" }
futures = { version = "0.3.5" }
jsonrpc-core = { version = "14.2.0" }
jsonrpc-pubsub = { version = "14.2.0" }
jsonrpc-core = { version = "15.0.0" }
jsonrpc-pubsub = { version = "15.0.0" }
log = { version = "0.4.11" }
structopt = { version = "0.3.16" }
tokio = { version = "0.2.22", optional = true, features = ["rt-threaded"] }
Expand Down
6 changes: 3 additions & 3 deletions bin/node-template/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pub struct Cli {
/// Possible subcommands of the main binary.
#[derive(Debug, StructOpt)]
pub enum Subcommand {
/// A set of base subcommands handled by `sc_cli`.
#[structopt(flatten)]
Base(sc_cli::Subcommand),
// aki: /// A set of base subcommands handled by `sc_cli`.
// #[structopt(flatten)]
// Base(sc_cli::Subcommand),

/// Key management cli utilities
Key(KeySubcommand),
Expand Down
27 changes: 14 additions & 13 deletions bin/node-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ pub fn run() -> sc_cli::Result<()> {
_ => service::node_template_new_full(config).map(|(components, _)| components),
})
}
Some(Subcommand::Base(subcommand)) => {
let runtime = cli.create_runner(subcommand)?;
let chain_spec = &runtime.config().chain_spec;

set_default_ss58_version(chain_spec);

runtime.run_subcommand(subcommand, |config| {
service::new_chain_ops::<
service::node_template_runtime::RuntimeApi,
service::NodeTemplateExecutor,
>(config)
})
}
// aki:
// Some(Subcommand::Base(subcommand)) => {
// let runtime = cli.create_runner(subcommand)?;
// let chain_spec = &runtime.config().chain_spec;
//
// set_default_ss58_version(chain_spec);
//
// runtime.run_subcommand(subcommand, |config| {
// service::new_chain_ops::<
// service::node_template_runtime::RuntimeApi,
// service::NodeTemplateExecutor,
// >(config)
// })
// }
Some(Subcommand::Key(cmd)) => cmd.run(),
Some(Subcommand::Sign(cmd)) => cmd.run(),
Some(Subcommand::Verify(cmd)) => cmd.run(),
Expand Down
16 changes: 11 additions & 5 deletions bin/node-template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@ pub struct BabeDeps {
}

/// Extra dependencies for GRANDPA
pub struct GrandpaDeps {
pub struct GrandpaDeps<B> {
/// Voting round info.
pub shared_voter_state: sc_finality_grandpa::SharedVoterState,
/// Authority set info.
pub shared_authority_set: sc_finality_grandpa::SharedAuthoritySet<Hash, BlockNumber>,
/// Receives notifications about justification events from Grandpa.
pub justification_stream: sc_finality_grandpa::GrandpaJustificationStream<Block>,
/// Subscription manager to keep track of pubsub subscribers.
pub subscriptions: jsonrpc_pubsub::manager::SubscriptionManager,
pub subscriptions: sc_rpc::SubscriptionTaskExecutor,
/// Finality proof provider.
pub finality_provider: Arc<sc_finality_grandpa::FinalityProofProvider<B, Block>>,
}

/// Full client dependencies.
pub struct FullDeps<C, P, SC> {
pub struct FullDeps<C, P, SC, B> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
Expand All @@ -66,7 +68,7 @@ pub struct FullDeps<C, P, SC> {
/// BABE specific dependencies.
pub babe: BabeDeps,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps,
pub grandpa: GrandpaDeps<B>,
}

/// Light client extra dependencies.
Expand All @@ -82,7 +84,7 @@ pub struct LightDeps<C, F, P> {
}

/// Instantiate all RPC extensions.
pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension
pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension
where
C: 'static + Send + Sync,
C: ProvideRuntimeApi<Block>,
Expand All @@ -97,6 +99,8 @@ where
C::Api: darwinia_staking_rpc::StakingRuntimeApi<Block, AccountId, Power>,
P: 'static + sp_transaction_pool::TransactionPool,
SC: 'static + sp_consensus::SelectChain<Block>,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
{
// --- substrate ---
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
Expand Down Expand Up @@ -147,13 +151,15 @@ where
shared_authority_set,
justification_stream,
subscriptions,
finality_provider,
} = grandpa;
io.extend_with(sc_finality_grandpa_rpc::GrandpaApi::to_delegate(
GrandpaRpcHandler::new(
shared_authority_set,
shared_voter_state,
justification_stream,
subscriptions,
finality_provider,
),
));
}
Expand Down
25 changes: 15 additions & 10 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use sc_finality_grandpa::{
};
use sc_service::{
config::{KeystoreConfig, PrometheusConfig},
BuildNetworkParams, Configuration, Error as ServiceError, NoopRpcExtensionBuilder,
BuildNetworkParams, Configuration, Error as ServiceError,
PartialComponents, SpawnTasksParams, TaskManager, TelemetryConnectionSinks,
};
use sc_transaction_pool::{BasicPool, FullPool};
Expand All @@ -35,12 +35,13 @@ use sp_trie::PrefixedMemoryDB;
use substrate_prometheus_endpoint::Registry;
// --- darwinia ---
use crate::rpc::{
self, BabeDeps, DenyUnsafe, FullDeps, GrandpaDeps, LightDeps, RpcExtension, SubscriptionManager,
self, BabeDeps, DenyUnsafe, FullDeps, GrandpaDeps, LightDeps, RpcExtension,
};
use node_template_runtime::{
opaque::Block,
primitives::{AccountId, Balance, Hash, Nonce, Power},
};
use sc_rpc::SubscriptionTaskExecutor;

type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
Expand Down Expand Up @@ -151,7 +152,7 @@ fn new_partial<RuntimeApi, Executor>(
DefaultImportQueue<Block, FullClient<RuntimeApi, Executor>>,
FullPool<Block, FullClient<RuntimeApi, Executor>>,
(
impl Fn(DenyUnsafe, SubscriptionManager) -> RpcExtension,
impl Fn(DenyUnsafe, SubscriptionTaskExecutor) -> RpcExtension,
(
BabeBlockImport<
Block,
Expand All @@ -161,7 +162,10 @@ fn new_partial<RuntimeApi, Executor>(
LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
BabeLink<Block>,
),
GrandpaSharedVoterState,
(
GrandpaSharedVoterState,
Arc<GrandpaFinalityProofProvider<FullBackend, Block>>,
),
),
>,
ServiceError,
Expand Down Expand Up @@ -215,8 +219,10 @@ where
let justification_stream = grandpa_link.justification_stream();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = GrandpaSharedVoterState::empty();
let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
let import_setup = (babe_import.clone(), grandpa_link, babe_link.clone());
let rpc_setup = shared_voter_state.clone();
let rpc_setup = (shared_voter_state.clone(), finality_proof_provider.clone());
let babe_config = babe_link.config().clone();
let shared_epoch_changes = babe_link.epoch_changes().clone();
let rpc_extensions_builder = {
Expand All @@ -241,6 +247,7 @@ where
shared_authority_set: shared_authority_set.clone(),
justification_stream: justification_stream.clone(),
subscriptions,
finality_provider: finality_proof_provider.clone(),
},
};

Expand Down Expand Up @@ -289,8 +296,7 @@ where
other: (rpc_extensions_builder, import_setup, rpc_setup),
} = new_partial::<RuntimeApi, Executor>(&mut config)?;
let prometheus_registry = config.prometheus_registry().cloned();
let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
let (shared_voter_state, finality_proof_provider) = rpc_setup;
let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(BuildNetworkParams {
config: &config,
Expand Down Expand Up @@ -333,7 +339,6 @@ where
})?;

let (block_import, link_half, babe_link) = import_setup;
let shared_voter_state = rpc_setup;

if role.is_authority() {
let can_author_with = CanAuthorWithNativeVersion::new(client.executor().clone());
Expand Down Expand Up @@ -485,12 +490,12 @@ where
client: client.clone(),
pool: transaction_pool.clone(),
};
let rpc_extension = rpc::create_light(light_deps);
let _rpc_extension = rpc::create_light(light_deps);

sc_service::spawn_tasks(SpawnTasksParams {
on_demand: Some(on_demand),
remote_blockchain: Some(backend.remote_blockchain()),
rpc_extensions_builder: Box::new(NoopRpcExtensionBuilder(rpc_extension)),
rpc_extensions_builder: Box::new(|_, _| ()),
task_manager: &mut task_manager,
telemetry_connection_sinks: TelemetryConnectionSinks::default(),
config,
Expand Down
40 changes: 32 additions & 8 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,20 +457,25 @@ impl frame_system::Trait for Runtime {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = Version;
type ModuleToIndex = ModuleToIndex;
type PalletInfo = ();
type AccountData = AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = weights::frame_system::WeightInfo;
}

parameter_types! {
pub const MaxScheduledPerBlock: u32 = 50;
}

impl pallet_scheduler::Trait for Runtime {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumBlockWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = ();
}

Expand All @@ -493,6 +498,7 @@ impl pallet_babe::Trait for Runtime {
)>>::IdentificationTuple;
type HandleEquivocation =
pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
type WeightInfo = ();
}

parameter_types! {
Expand Down Expand Up @@ -625,7 +631,6 @@ impl pallet_offences::Trait for Runtime {
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type WeightSoftLimit = OffencesWeightSoftLimit;
type WeightInfo = ();
}

impl pallet_session::historical::Trait for Runtime {
Expand Down Expand Up @@ -679,6 +684,7 @@ impl pallet_grandpa::Trait for Runtime {
type KeyOwnerProofSystem = Historical;
type HandleEquivocation =
pallet_grandpa::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
type WeightInfo = ();
}

parameter_types! {
Expand Down Expand Up @@ -755,18 +761,22 @@ impl darwinia_democracy::Trait for Runtime {
parameter_types! {
pub const CouncilMotionDuration: BlockNumber = 3 * DAYS;
pub const CouncilMaxProposals: u32 = 100;
pub const CouncilMaxMembers: u32 = 100;
pub const TechnicalMotionDuration: BlockNumber = 3 * DAYS;
pub const TechnicalMaxProposals: u32 = 100;
pub const TechnicalMaxMembers: u32 = 100;
}
// Make sure that there are no more than `MAX_MEMBERS` members elected via elections-phragmen.
const_assert!(DesiredMembers::get() <= pallet_collective::MAX_MEMBERS);
// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen.
const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());
type CouncilCollective = pallet_collective::Instance0;
impl pallet_collective::Trait<CouncilCollective> for Runtime {
type Origin = Origin;
type Proposal = Call;
type Event = Event;
type MotionDuration = CouncilMotionDuration;
type MaxProposals = CouncilMaxProposals;
type MaxMembers = CouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = ();
}
type TechnicalCollective = pallet_collective::Instance1;
Expand All @@ -776,6 +786,8 @@ impl pallet_collective::Trait<TechnicalCollective> for Runtime {
type Event = Event;
type MotionDuration = TechnicalMotionDuration;
type MaxProposals = TechnicalMaxProposals;
type MaxMembers = TechnicalMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = ();
}

Expand Down Expand Up @@ -839,7 +851,13 @@ parameter_types! {
pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 1 * COIN;
pub const TipReportDepositPerByte: Balance = 1 * MILLI;
pub const DataDepositPerByte: Balance = 1 * MILLI;
pub const BountyDepositBase: Balance = 1 * COIN;
pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;
pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;
pub const MaximumReasonLength: u32 = 16384;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: Balance = 5 * COIN;
}
impl darwinia_treasury::Trait for Runtime {
type ModuleId = TreasuryModuleId;
Expand All @@ -851,15 +869,21 @@ impl darwinia_treasury::Trait for Runtime {
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type TipReportDepositPerByte = TipReportDepositPerByte;
type DataDepositPerByte = DataDepositPerByte;
type Event = Event;
type RingProposalRejection = Treasury;
type KtonProposalRejection = Treasury;
type RingOnSlash = Treasury;
type KtonOnSlash = Treasury;
type ProposalBond = ProposalBond;
type RingProposalBondMinimum = RingProposalBondMinimum;
type KtonProposalBondMinimum = KtonProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type MaximumReasonLength = MaximumReasonLength;
type RingBurnDestination = ();
// TODO
type KtonBurnDestination = ();
Expand Down
4 changes: 2 additions & 2 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ impl DatabaseConfig {
.unwrap_or(origin_data_base_cache_size.unwrap_or(128)),
}
}
Database::SubDb => sc_service::config::DatabaseConfig::SubDb { path },
// aki: Database::SubDb => sc_service::config::DatabaseConfig::SubDb { path },
Database::ParityDb => sc_service::config::DatabaseConfig::ParityDb { path },
}
} else {
Expand All @@ -689,7 +689,7 @@ enum Database {
// Facebooks RocksDB
RocksDb,
// Subdb. https://github.com/paritytech/subdb/
SubDb,
// aki: SubDb,
// ParityDb. https://github.com/paritytech/parity-db/
ParityDb,
}
Expand Down
6 changes: 3 additions & 3 deletions frame/balances/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ version = "1.0.0"
[dependencies]
# crates
codec = { package = "parity-scale-codec", version = "1.3.5" }
jsonrpc-core = "14.2.0"
jsonrpc-core-client = "14.2.0"
jsonrpc-derive = "14.2.1"
jsonrpc-core = "15.0.0"
jsonrpc-core-client = "15.0.0"
jsonrpc-derive = "15.0.0"
# darwinia
darwinia-balances-rpc-runtime-api = { path = "./runtime-api" }
# substrate
Expand Down
2 changes: 1 addition & 1 deletion frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ impl<T: Subtrait<I>, I: Instance> frame_system::Trait for ElevatedTrait<T, I> {
type MaximumBlockLength = T::MaximumBlockLength;
type AvailableBlockRatio = T::AvailableBlockRatio;
type Version = T::Version;
type ModuleToIndex = T::ModuleToIndex;
type PalletInfo = T::PalletInfo;
type AccountData = T::AccountData;
type OnNewAccount = T::OnNewAccount;
type OnKilledAccount = T::OnKilledAccount;
Expand Down
2 changes: 1 addition & 1 deletion frame/balances/src/tests_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl frame_system::Trait for Test {
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
type ModuleToIndex = ();
type PalletInfo = ();
type AccountData = AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = Ring;
Expand Down
Loading