kill post_finalise (#121)

* kill post_finalise

* update wasm runtimes
This commit is contained in:
Robert Habermeier
2018-04-12 13:17:43 +02:00
committed by Gav Wood
parent 46e3c32e49
commit bdf156d35e
17 changed files with 26 additions and 52 deletions
@@ -104,9 +104,6 @@ impl<
// any final checks
Self::final_checks(&header);
// any stuff that we do after taking the storage root.
Self::post_finalise(&header);
}
/// Finalise the block - it is up the caller to ensure that all header fields are valid
@@ -116,11 +113,7 @@ impl<
// setup extrinsics
<system::Module<System>>::derive_extrinsics();
let header = <system::Module<System>>::finalise();
Self::post_finalise(&header);
header
<system::Module<System>>::finalise()
}
/// Apply outside of the block execution function.
@@ -170,12 +163,6 @@ impl<
header.state_root().check_equal(&storage_root);
assert!(header.state_root() == &storage_root, "Storage root must match that calculated.");
}
fn post_finalise(header: &System::Header) {
// store the header hash in storage; we can't do it before otherwise there would be a
// cyclic dependency.
<system::Module<System>>::record_block_hash(header);
}
}
#[cfg(test)]
+1 -15
View File
@@ -94,6 +94,7 @@ impl<T: Trait> Module<T> {
// populate environment.
<Number<T>>::put(number);
<ParentHash<T>>::put(parent_hash);
<BlockHash<T>>::insert(*number - One::one(), parent_hash);
<ExtrinsicsRoot<T>>::put(txs_root);
<RandomSeed<T>>::put(Self::calculate_random());
<ExtrinsicIndex<T>>::put(0);
@@ -119,21 +120,6 @@ impl<T: Trait> Module<T> {
<Digest<T>>::put(l);
}
/// Records a particular block number and hash combination.
pub fn record_block_hash<H: traits::Header<Number = T::BlockNumber, Hash = T::Hash>>(header: &H) {
// store the header hash in storage; we can't do it before otherwise there would be a
// cyclic dependency.
let h = T::Hashing::hash_of(header);
<BlockHash<T>>::insert(header.number(), &h);
Self::initialise(&(*header.number() + One::one()), &h, &Default::default());
}
/// Initializes the state following the determination of the genesis block.
pub fn initialise_genesis_state<H: traits::Header<Number = T::BlockNumber, Hash = T::Hash>>(header: &H) {
Self::record_block_hash(header);
}
/// Calculate the current block's random seed.
fn calculate_random() -> T::Hash {
assert!(Self::block_number() > Zero::zero(), "Block number may never be zero");