Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade alpha.6 #107

Merged
merged 2 commits into from
Apr 22, 2020
Merged
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
1,370 changes: 726 additions & 644 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions cstrml/market/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ serde = { optional = true, version = '1.0.106' }
serde_json = "1.0.51"

# substrate frames
system = { package = 'frame-system', default-features = false, version = '2.0.0-alpha.5' }
frame-support = { default-features = false, version = '2.0.0-alpha.5' }
system = { package = 'frame-system', default-features = false, version = '2.0.0-alpha.6' }
frame-support = { default-features = false, version = '2.0.0-alpha.6' }

# substrate primitives
sp-core = { default-features = false, version = '2.0.0-alpha.5' }
sp-io = { default-features = false, version = '2.0.0-alpha.5' }
sp-runtime = { default-features = false, version = '2.0.0-alpha.5' }
sp-std = { default-features = false, version = '2.0.0-alpha.5' }
sp-core = { default-features = false, version = '2.0.0-alpha.6' }
sp-io = { default-features = false, version = '2.0.0-alpha.6' }
sp-runtime = { default-features = false, version = '2.0.0-alpha.6' }
sp-std = { default-features = false, version = '2.0.0-alpha.6' }

# crust runtime modules
primitives = { package = 'cst-primitives', path = '../../primitives', default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions cstrml/market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ decl_module! {
// Initializing events
// this is needed only if you are using events in your module
fn deposit_event() = default;

/// TODO: organize these parameters into a struct.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
fn store_storage_order(
origin,
dest: <T::Lookup as StaticLookup>::Source,
Expand Down
7 changes: 5 additions & 2 deletions cstrml/market/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use super::*;

use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use frame_support::{
impl_outer_origin, parameter_types, weights::Weight,
traits::{OnFinalize, OnInitialize}
};
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup, OnFinalize, OnInitialize},
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
pub type AccountId = u64;
Expand Down
2 changes: 0 additions & 2 deletions cstrml/market/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use super::*;

use crate::mock::{new_test_ext, run_to_block, Origin, Market};
use frame_support::assert_ok;
use hex;
Expand Down
28 changes: 14 additions & 14 deletions cstrml/staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ safe-mix = { version = "1.0.0", default-features = false }
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }

# substrate frame dependencies
frame-support = { version = '2.0.0-alpha.5', default-features = false }
frame-system = { version = '2.0.0-alpha.5', default-features = false }
pallet-session = { version = '2.0.0-alpha.5', features = ["historical"], default-features = false }
pallet-authorship = { version = '2.0.0-alpha.5', default-features = false }
frame-support = { version = '2.0.0-alpha.6', default-features = false }
frame-system = { version = '2.0.0-alpha.6', default-features = false }
pallet-session = { version = '2.0.0-alpha.6', features = ["historical"], default-features = false }
pallet-authorship = { version = '2.0.0-alpha.6', default-features = false }

# substrate primitives
sp-keyring = { optional = true, version = '2.0.0-alpha.5' }
sp-std = { version = '2.0.0-alpha.5', default-features = false }
sp-phragmen = { version = '2.0.0-alpha.5', default-features = false }
sp-io ={ version = '2.0.0-alpha.5', default-features = false }
sp-runtime = { version = '2.0.0-alpha.5', default-features = false }
sp-staking = { version = '2.0.0-alpha.5', default-features = false }
sp-keyring = { optional = true, version = '2.0.0-alpha.6' }
sp-std = { version = '2.0.0-alpha.6', default-features = false }
sp-phragmen = { version = '2.0.0-alpha.6', default-features = false }
sp-io ={ version = '2.0.0-alpha.6', default-features = false }
sp-runtime = { version = '2.0.0-alpha.6', default-features = false }
sp-staking = { version = '2.0.0-alpha.6', default-features = false }

# crust runtime modules
tee = { package = "cstrml-tee", path = "../tee", default-features = false }
primitives = { package = 'cst-primitives', path = '../../primitives', default-features = false }

[dev-dependencies]
sp-core = '2.0.0-alpha.5'
pallet-balances = '2.0.0-alpha.5'
pallet-timestamp = '2.0.0-alpha.5'
pallet-staking-reward-curve = '2.0.0-alpha.5'
sp-core = '2.0.0-alpha.6'
pallet-balances = '2.0.0-alpha.6'
pallet-timestamp = '2.0.0-alpha.6'
pallet-staking-reward-curve = '2.0.0-alpha.6'

# private crate inside substrate
substrate-test-utils = { version = '2.0.0-alpha.5', git = 'https://github.com/paritytech/substrate.git', rev = 'd1b9ccad107e4899978858de5ddd2868b9777aab'}
Expand Down
2 changes: 1 addition & 1 deletion cstrml/staking/src/inflation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! The staking rate in NPoS is the total amount of tokens staked by nominators and validators,
//! divided by the total token supply.

use sp_runtime::{Perbill, PerThing, traits::AtLeast32Bit, curve::PiecewiseLinear};
use sp_runtime::{Perbill, traits::AtLeast32Bit, curve::PiecewiseLinear};

/// The total payout to all validators (and their nominators) per era.
///
Expand Down
15 changes: 10 additions & 5 deletions cstrml/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ use frame_support::{
storage::IterableStorageMap,
traits::{
Currency, LockIdentifier, LockableCurrency, WithdrawReasons, OnUnbalanced, Imbalance, Get,
Time,
Time, EnsureOrigin
}
};
use pallet_session::historical;
use sp_runtime::{
Perbill, PerThing, RuntimeDebug,
Perbill, RuntimeDebug,
traits::{
Convert, Zero, One, StaticLookup, CheckedSub, Saturating, AtLeast32Bit,
EnsureOrigin, CheckedAdd
CheckedAdd
},
};
use sp_staking::{
Expand Down Expand Up @@ -1891,7 +1891,7 @@ impl <T: Trait> OnOffenceHandler<T::AccountId, pallet_session::historical::Ident
>],
slash_fraction: &[Perbill],
slash_session: SessionIndex,
) {
) -> Result<(), ()> {
let reward_proportion = SlashRewardFraction::get();

let era_now = Self::current_era().unwrap_or(0);
Expand All @@ -1911,7 +1911,7 @@ impl <T: Trait> OnOffenceHandler<T::AccountId, pallet_session::historical::Ident
.filter(|&&(_, ref sesh)| sesh <= &slash_session)
.next()
{
None => return, // before bonding period. defensive - should be filtered out.
None => return Ok(()), // before bonding period. defensive - should be filtered out.
Some(&(ref slash_era, _)) => *slash_era,
}
};
Expand Down Expand Up @@ -1956,6 +1956,11 @@ impl <T: Trait> OnOffenceHandler<T::AccountId, pallet_session::historical::Ident
}
}
}
Ok(())
}

fn can_report() -> bool {
true
}
}

Expand Down
9 changes: 5 additions & 4 deletions cstrml/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use crate::*;
use frame_support::{
assert_ok, impl_outer_origin, parameter_types,
StorageValue, IterableStorageMap,
traits::{Currency, Get, FindAuthor},
traits::{Currency, Get, FindAuthor, OnInitialize},
weights::Weight,
};
use sp_core::{crypto::key_types, H256};
use sp_io;
use sp_runtime::testing::{Header, UintAuthorityId};
use sp_runtime::traits::{Convert, IdentityLookup, OnInitialize, OpaqueKeys, SaturatedConversion};
use sp_runtime::traits::{Convert, IdentityLookup, OpaqueKeys, SaturatedConversion};
use sp_runtime::{KeyTypeId, Perbill};
use sp_staking::{
offence::{OffenceDetails, OnOffenceHandler},
Expand Down Expand Up @@ -159,6 +159,7 @@ impl pallet_session::Trait for Test {
type ValidatorId = AccountId;
type ValidatorIdOf = crate::StashOf<Test>;
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Test, Staking>;
type SessionHandler = TestSessionHandler;
type Keys = UintAuthorityId;
Expand Down Expand Up @@ -583,15 +584,15 @@ pub fn on_offence_in_era(
let bonded_eras = crate::BondedEras::get();
for &(bonded_era, start_session) in bonded_eras.iter() {
if bonded_era == era {
Staking::on_offence(offenders, slash_fraction, start_session);
let _ = Staking::on_offence(offenders, slash_fraction, start_session);
return;
} else if bonded_era > era {
break;
}
}

if Staking::current_era().unwrap_or(0) == era {
Staking::on_offence(
let _ = Staking::on_offence(
offenders,
slash_fraction,
Staking::current_era_start_session_index(),
Expand Down
2 changes: 1 addition & 1 deletion cstrml/staking/src/slashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use super::{
EraIndex, Trait, Module, Store, BalanceOf, Exposure, Perbill, SessionInterface,
NegativeImbalanceOf, UnappliedSlash,
};
use sp_runtime::{traits::{Zero, Saturating}, RuntimeDebug, PerThing};
use sp_runtime::{traits::{Zero, Saturating}, RuntimeDebug};
use frame_support::{
StorageMap, StorageDoubleMap,
traits::{Currency, OnUnbalanced, Imbalance},
Expand Down
7 changes: 3 additions & 4 deletions cstrml/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use crate::mock::*;
use frame_support::{
assert_noop, assert_ok,
dispatch::DispatchError,
traits::{Currency, ReservableCurrency},
traits::{Currency, ReservableCurrency, OnInitialize},
};
use sp_runtime::{
assert_eq_error_rate,
traits::{BadOrigin, OnInitialize},
traits::BadOrigin,
};
use sp_staking::offence::OffenceDetails;
use substrate_test_utils::assert_eq_uvec;
Expand Down Expand Up @@ -369,8 +369,7 @@ fn multi_era_reward_should_work() {
);
assert_eq!(
Balances::total_balance(&21) / 1000000,
(init_balance_21 + total_staking_payout_0 * 1000 / 2001 +
Perbill::from_rational_approximation(stakes_21, 142667657428421) * total_staking_payout_1) / 1000000
(stakes_21 + Perbill::from_rational_approximation(stakes_21, 142667657428421) * total_staking_payout_1) / 1000000
);
});
}
Expand Down
16 changes: 8 additions & 8 deletions cstrml/tee/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ signatory = "0.18.0"
signatory-ring = "0.18.0"

# substrate frame dependencies
frame-support = { default-features = false, version = '2.0.0-alpha.5' }
system = { package = 'frame-system', default-features = false, version = '2.0.0-alpha.5' }
frame-support = { default-features = false, version = '2.0.0-alpha.6' }
system = { package = 'frame-system', default-features = false, version = '2.0.0-alpha.6' }

# substrate primitives
sp-core = { default-features = false, version = '2.0.0-alpha.5' }
sp-io = { default-features = false, version = '2.0.0-alpha.5' }
sp-runtime = { default-features = false, version = '2.0.0-alpha.5' }
sp-runtime-interface = { default-features = false, version = '2.0.0-alpha.5' }
sp-std = { default-features = false, version = '2.0.0-alpha.5' }
sp-core = { default-features = false, version = '2.0.0-alpha.6' }
sp-io = { default-features = false, version = '2.0.0-alpha.6' }
sp-runtime = { default-features = false, version = '2.0.0-alpha.6' }
sp-runtime-interface = { default-features = false, version = '2.0.0-alpha.6' }
sp-std = { default-features = false, version = '2.0.0-alpha.6' }

# crust runtime modules
primitives = { package = 'cst-primitives', path = '../../primitives', default-features = false }

[dev-dependencies]
keyring = { package = "sp-keyring", version = '2.0.0-alpha.5' }
keyring = { package = "sp-keyring", version = '2.0.0-alpha.6' }
hex = '0.4.2'

[features]
Expand Down
4 changes: 3 additions & 1 deletion cstrml/tee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ decl_module! {
// this is needed only if you are using events in your module
fn deposit_event() = default;

fn register_identity(origin, identity: Identity<T::AccountId>) -> DispatchResult {
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
pub fn register_identity(origin, identity: Identity<T::AccountId>) -> DispatchResult {
let who = ensure_signed(origin)?;

// 0. Genesis validators have rights to register themselves
Expand Down Expand Up @@ -154,6 +155,7 @@ decl_module! {
Ok(())
}

#[weight = frame_support::weights::SimpleDispatchInfo::default()]
fn report_works(origin, work_report: WorkReport) -> DispatchResult {
let who = ensure_signed(origin)?;

Expand Down
7 changes: 5 additions & 2 deletions cstrml/tee/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use super::*;

use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use frame_support::{
impl_outer_origin, parameter_types, weights::Weight,
traits::{ OnInitialize, OnFinalize }
};
use keyring::Sr25519Keyring;
use sp_core::{crypto::AccountId32, H256};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup, OnFinalize, OnInitialize},
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};

Expand Down
41 changes: 20 additions & 21 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ log = "0.4.8"
structopt = "0.3.8"

# substrate client dependencies
babe = { version = '0.8.0-alpha.5', package = 'sc-consensus-babe' }
grandpa = { version = "0.8.0-alpha.5", package = "sc-finality-grandpa" }
sc-basic-authorship = '0.8.0-alpha.5'
authority-discovery = { version = '0.8.0-alpha.5', package= 'sc-authority-discovery' }
sc-client = '0.8.0-alpha.5'
sc-client-api = '2.0.0-alpha.5'
sc-cli = '0.8.0-alpha.5'
sc-executor = '0.8.0-alpha.5'
sc-network = '0.8.0-alpha.5'
sc-service = '0.8.0-alpha.5'
sc-transaction-pool = '2.0.0-alpha.5'
babe = { version = '0.8.0-alpha.6', package = 'sc-consensus-babe' }
grandpa = { version = "0.8.0-alpha.6", package = "sc-finality-grandpa" }
sc-basic-authorship = '0.8.0-alpha.6'
authority-discovery = { version = '0.8.0-alpha.6', package= 'sc-authority-discovery' }
sc-client = '0.8.0-alpha.6'
sc-client-api = '2.0.0-alpha.6'
sc-cli = '0.8.0-alpha.6'
sc-executor = '0.8.0-alpha.6'
sc-network = '0.8.0-alpha.6'
sc-service = '0.8.0-alpha.6'
sc-transaction-pool = '2.0.0-alpha.6'

# substrate primitives
sp-transaction-pool = '2.0.0-alpha.5'
sp-core = '2.0.0-alpha.5'
sp-consensus = '0.8.0-alpha.5'
sp-consensus-babe = '0.8.0-alpha.5'
sp-inherents = '2.0.0-alpha.5'
sp-io = '2.0.0-alpha.5'
sp-runtime = '2.0.0-alpha.5'
grandpa-primitives = { package = 'sp-finality-grandpa', version = '2.0.0-alpha.5' }
sp-transaction-pool = '2.0.0-alpha.6'
sp-core = '2.0.0-alpha.6'
sp-consensus = '0.8.0-alpha.6'
sp-consensus-babe = '0.8.0-alpha.6'
sp-inherents = '2.0.0-alpha.6'
sp-io = '2.0.0-alpha.6'
sp-runtime = '2.0.0-alpha.6'
grandpa-primitives = { package = 'sp-finality-grandpa', version = '2.0.0-alpha.6' }

# crust runtime modules
crust-runtime = { path = '../runtime', version = '0.3.0' }
Expand All @@ -47,5 +47,4 @@ cstrml-tee = { path = '../cstrml/tee', version = '0.3.0' }
primitives = { package = 'cst-primitives', path = '../primitives', version = '0.3.0' }

[build-dependencies]
vergen = '3.0.4'
build-script-utils = { version = "2.0.0-alpha.5", package = "substrate-build-script-utils" }
build-script-utils = { version = "2.0.0-alpha.6", package = "substrate-build-script-utils" }
8 changes: 3 additions & 5 deletions node/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use vergen::{generate_cargo_keys, ConstantsFlags};

const ERROR_MSG: &str = "Failed to generate metadata files";
use build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};

fn main() {
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG);
generate_cargo_keys();

build_script_utils::rerun_if_git_head_changed();
rerun_if_git_head_changed();
}
Loading