Skip to content

Commit

Permalink
Runtime Upgrade (#444)
Browse files Browse the repository at this point in the history
* update: rpc

* update: deps

* update: types

* fix: CAP

* update: bump version

* update: deps

* update: switch branch to darwinia-master

* update: deps

* add: claims module id

* update: spec version
  • Loading branch information
AurevoirXavier authored May 18, 2020
1 parent 013bf17 commit 3331246
Show file tree
Hide file tree
Showing 15 changed files with 412 additions and 316 deletions.
658 changes: 356 additions & 302 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 @@ -4,7 +4,7 @@ path = "src/main.rs"

[package]
name = "darwinia"
version = "0.5.7"
version = "0.5.8"
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia node implementation in Rust"
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "darwinia-cli"
version = "0.5.7"
version = "0.5.8"
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia Client Node"
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "darwinia-primitives"
version = "0.5.7"
version = "0.5.8"
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia node runtime primitives"
edition = "2018"
Expand Down
3 changes: 2 additions & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "darwinia-rpc"
version = "0.5.7"
version = "0.5.8"
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia node rpc"
edition = "2018"
Expand All @@ -23,6 +23,7 @@ pallet-transaction-payment-rpc = { git = "https://github.com/darwinia-network/su
substrate-frame-rpc-system = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.6" }
# darwinia frame
darwinia-balances-rpc = { git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-staking-rpc = { git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
# substrate client
sc-client-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.6" }
sc-rpc = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.6" }
9 changes: 7 additions & 2 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// --- std ---
use std::sync::Arc;
// --- darwinia ---
use darwinia_primitives::{AccountId, Balance, Block, Nonce};
use darwinia_primitives::{AccountId, Balance, Block, Nonce, Power};

/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpc_core::IoHandler<sc_rpc::Metadata>;
Expand All @@ -19,6 +19,7 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UE>,
C::Api: darwinia_balances_rpc::BalancesRuntimeApi<Block, AccountId, Balance>,
C::Api: darwinia_staking_rpc::StakingRuntimeApi<Block, AccountId, Power>,
P: 'static + Sync + Send + sp_transaction_pool::TransactionPool,
UE: 'static + Send + Sync + codec::Codec,
{
Expand All @@ -27,6 +28,7 @@ where
use substrate_frame_rpc_system::{FullSystem, SystemApi};
// --- darwinia ---
use darwinia_balances_rpc::{Balances, BalancesApi};
use darwinia_staking_rpc::{Staking, StakingApi};

let mut io = jsonrpc_core::IoHandler::default();
io.extend_with(SystemApi::to_delegate(FullSystem::new(
Expand All @@ -36,7 +38,9 @@ where
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
client.clone(),
)));
io.extend_with(BalancesApi::to_delegate(Balances::new(client)));
io.extend_with(BalancesApi::to_delegate(Balances::new(client.clone())));
io.extend_with(StakingApi::to_delegate(Staking::new(client)));

io
}

Expand All @@ -54,6 +58,7 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UE>,
C::Api: darwinia_balances_rpc::BalancesRuntimeApi<Block, AccountId, Balance>,
C::Api: darwinia_staking_rpc::StakingRuntimeApi<Block, AccountId, Power>,
P: 'static + Send + Sync + sp_transaction_pool::TransactionPool,
F: 'static + sc_client_api::light::Fetcher<Block>,
UE: 'static + Send + Sync + codec::Codec,
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "darwinia-runtime-common"
version = "0.5.7"
version = "0.5.8"
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia node runtime common"
edition = "2018"
Expand Down
4 changes: 3 additions & 1 deletion runtime/crab/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "crab-runtime"
version = "0.5.7"
version = "0.5.8"
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia node runtime for Crab network"
edition = "2018"
Expand Down Expand Up @@ -65,6 +65,7 @@ darwinia-eth-backing = { default-features = false, git = "https://github.com/dar
darwinia-eth-relay = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-eth-offchain = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-staking = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-staking-rpc-runtime-api = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-treasury = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-header-mmr = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
# darwinia runtime
Expand Down Expand Up @@ -133,6 +134,7 @@ std = [
"darwinia-eth-offchain/std",
"darwinia-header-mmr/std",
"darwinia-staking/std",
"darwinia-staking-rpc-runtime-api/std",
"darwinia-treasury/std",
# darwinia runtime
"darwinia-runtime-common/std",
Expand Down
11 changes: 11 additions & 0 deletions runtime/crab/darwinia_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
"r": "Balance",
"k": "Balance"
},
"SpanRecord": {
"slashed": "RKT",
"paid_out": "RKT"
},
"__[pallet.bridge.eth]__": {},
"EthTransactionIndex": "(H256, u64)",
"EthHeaderBrief": {
Expand Down Expand Up @@ -168,5 +172,12 @@
"MerkleMountainRangeRootLog": {
"prefix": "[u8; 4; Prefix]",
"mmr_root": "Hash"
},
"__[node.rpc]__": {},
"BalancesRuntimeDispatchInfo": {
"usable_balance": "Balance"
},
"StakingRuntimeDispatchInfo": {
"power": "Power"
}
}
11 changes: 11 additions & 0 deletions runtime/crab/polkadot_compatible_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
"r": "Balance",
"k": "Balance"
},
"SpanRecord": {
"slashed": "RKT",
"paid_out": "RKT"
},
"__[pallet.bridge.eth]__": {},
"EthTransactionIndex": "(H256, u64)",
"EthHeaderBrief": {
Expand Down Expand Up @@ -178,5 +182,12 @@
"MerkleMountainRangeRootLog": {
"prefix": "[u8; 4; Prefix]",
"mmr_root": "Hash"
},
"__[node.rpc]__": {},
"BalancesRuntimeDispatchInfo": {
"usable_balance": "Balance"
},
"StakingRuntimeDispatchInfo": {
"power": "Power"
}
}
2 changes: 1 addition & 1 deletion runtime/crab/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub mod currency {
pub const MILLI: Balance = 1_000 * MICRO;
pub const COIN: Balance = 1_000 * MILLI;

pub const CAP: Balance = 1_000_000_000 * COIN;
pub const CAP: Balance = 10_000_000_000 * COIN;
pub const TOTAL_POWER: Power = 1_000_000_000;
}

Expand Down
11 changes: 10 additions & 1 deletion runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use darwinia_eth_relay::EthNetworkType;
use darwinia_primitives::*;
use darwinia_runtime_common::*;
use darwinia_staking::EraIndex;
use darwinia_staking_rpc_runtime_api::RuntimeDispatchInfo as StakingRuntimeDispatchInfo;

type Ring = Balances;

Expand All @@ -67,7 +68,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("Crab"),
impl_name: create_runtime_str!("Crab"),
authoring_version: 0,
spec_version: 0,
spec_version: 1,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 0,
Expand Down Expand Up @@ -537,10 +538,12 @@ impl darwinia_treasury::Trait for Runtime {
}

parameter_types! {
pub const ClaimsModuleId: ModuleId = ModuleId(*b"da/claim");
pub const Prefix: &'static [u8] = b"Pay RINGs to the Crab account:";
}
impl darwinia_claims::Trait for Runtime {
type Event = Event;
type ModuleId = ClaimsModuleId;
type Prefix = Prefix;
type RingCurrency = Ring;
}
Expand Down Expand Up @@ -880,6 +883,12 @@ impl_runtime_apis! {
}
}

impl darwinia_staking_rpc_runtime_api::StakingApi<Block, AccountId, Power> for Runtime {
fn power_of(account: AccountId) -> StakingRuntimeDispatchInfo<Power> {
Staking::power_of_rpc(account)
}
}

// TODO: benchmark
// #[cfg(feature = "runtime-benchmarks")]
// impl frame_benchmarking::Benchmark<Block> for Runtime {
Expand Down
5 changes: 3 additions & 2 deletions service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "darwinia-service"
version = "0.5.7"
version = "0.5.8"
authors = ["Darwinia Network <hello@darwinia.network>"]
description = "Darwinia node service"
edition = "2018"
Expand Down Expand Up @@ -36,8 +36,9 @@ pallet-im-online = { git = "https://github.com/darwinia-network/substrate.git",
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.6" }
substrate-prometheus-endpoint = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.6" }
# darwinia frame
array-bytes = { git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-balances-rpc-runtime-api = { git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-support = { git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
darwinia-staking-rpc-runtime-api = { git = "https://github.com/darwinia-network/darwinia-common.git", branch = "darwinia-master" }
# substrate client
sc-authority-discovery = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.6" }
sc-basic-authorship = { git = "https://github.com/darwinia-network/substrate.git", tag = "v2.0.0-alpha.darwinia.6" }
Expand Down
2 changes: 1 addition & 1 deletion service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use sp_consensus_babe::AuthorityId as BabeId;
use sp_core::{crypto::UncheckedInto, sr25519, Pair, Public};
use sp_runtime::{traits::IdentifyAccount, Perbill};
// --- darwinia ---
use array_bytes::fixed_hex_bytes_unchecked;
use crab_runtime::{constants::currency::COIN as CRING, GenesisConfig as CrabGenesisConfig};
use darwinia_primitives::{AccountId, AccountPublic, Balance};
use darwinia_support::bytes_thing::fixed_hex_bytes_unchecked;

const CKTON: Balance = CRING;
const CRAB_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
Expand Down
4 changes: 3 additions & 1 deletion service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use sp_api::ConstructRuntimeApi;
use sp_runtime::traits::BlakeTwo256;
use substrate_prometheus_endpoint::Registry;
// --- darwinia ---
use darwinia_primitives::{AccountId, Balance, Nonce};
use darwinia_primitives::{AccountId, Balance, Nonce, Power};

native_executor_instance!(
pub CrabExecutor,
Expand All @@ -47,6 +47,7 @@ pub trait RuntimeApiCollection<Extrinsic: 'static + Send + Sync + codec::Codec>:
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance, Extrinsic>
+ darwinia_balances_rpc_runtime_api::BalancesApi<Block, AccountId, Balance>
+ darwinia_staking_rpc_runtime_api::StakingApi<Block, AccountId, Power>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
Expand All @@ -66,6 +67,7 @@ where
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance, Extrinsic>
+ darwinia_balances_rpc_runtime_api::BalancesApi<Block, AccountId, Balance>
+ darwinia_staking_rpc_runtime_api::StakingApi<Block, AccountId, Power>
+ sp_api::Metadata<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
Expand Down

0 comments on commit 3331246

Please sign in to comment.