Scale trait and move to u32 blocknumbers (#3357)

* Scale trait and move to u32 blocknumbers.

* Fixes

* Cleanups

* Update node/runtime/src/lib.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Fix up some of the factory stuff.

* Update core/sr-primitives/src/traits.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Move Nonce/Index to u32 (#3361)

* Force a non-borked version of upstream crate

* Line lengths and runtime version bump
This commit is contained in:
Gavin Wood
2019-08-11 15:03:06 +02:00
committed by GitHub
parent d1161b7d36
commit 14bb115193
29 changed files with 151 additions and 82 deletions
+13 -13
View File
@@ -39,11 +39,11 @@ pub struct FactoryState<N> {
block_no: N,
mode: Mode,
start_number: u64,
rounds: u64,
round: u64,
block_in_round: u64,
num: u64,
start_number: u32,
rounds: u32,
round: u32,
block_in_round: u32,
num: u32,
}
type Number = <<node_primitives::Block as BlockT>::Header as HeaderT>::Number;
@@ -77,9 +77,9 @@ impl RuntimeAdapter for FactoryState<Number> {
) -> FactoryState<Self::Number> {
FactoryState {
mode,
num: num,
num: num as u32,
round: 0,
rounds,
rounds: rounds as u32,
block_in_round: 0,
block_no: 0,
start_number: 0,
@@ -150,7 +150,7 @@ impl RuntimeAdapter for FactoryState<Number> {
}
fn inherent_extrinsics(&self) -> InherentData {
let timestamp = self.block_no * MINIMUM_PERIOD;
let timestamp = self.block_no as u64 * MINIMUM_PERIOD;
let mut inherent = InherentData::new();
inherent.put_data(timestamp::INHERENT_IDENTIFIER, &timestamp)
@@ -194,12 +194,12 @@ impl RuntimeAdapter for FactoryState<Number> {
// This currently prevents the factory from being used
// without a preceding purge of the database.
if self.mode == Mode::MasterToN || self.mode == Mode::MasterTo1 {
self.block_no()
self.block_no() as Self::Index
} else {
match self.round() {
0 =>
// if round is 0 all transactions will be done with master as a sender
self.block_no(),
self.block_no() as Self::Index,
_ =>
// if round is e.g. 1 every sender account will be new and not yet have
// any transactions done
@@ -215,12 +215,12 @@ impl RuntimeAdapter for FactoryState<Number> {
// TODO get correct phase via api. See #2587.
// This currently prevents the factory from being used
// without a preceding purge of the database.
self.block_no
self.block_no() as Self::Phase
}
}
fn gen_seed_bytes(seed: u64) -> [u8; 32] {
let mut rng: StdRng = SeedableRng::seed_from_u64(seed);
fn gen_seed_bytes(seed: u32) -> [u8; 32] {
let mut rng: StdRng = SeedableRng::seed_from_u64(seed as u64);
let mut seed_bytes = [0u8; 32];
for i in 0..32 {