Skip to content

Commit a564ff3

Browse files
authored
Leave some header related info for inspection (#7727)
* Leave some system data for inspection There is not much benefit in being active when removing this data. It's actively harmful when one tries to read the block number in runtime APIs in the context of a block. * Update the expected root hash This is excepted since now we persist new members. * Revert extrinsics_root to `take` It's going away in one of the following PRs anyway * Update the state root once again * Update the comment on the storage items that are left in the storage Excluding ExtrinsicsRoot since it's going away
1 parent 69af5ca commit a564ff3

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/lib.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,15 +1013,27 @@ impl<T: Config> Module<T> {
10131013
}
10141014
}
10151015

1016-
/// Remove temporary "environment" entries in storage.
1016+
/// Remove temporary "environment" entries in storage, compute the storage root and return the
1017+
/// resulting header for this block.
10171018
pub fn finalize() -> T::Header {
10181019
ExecutionPhase::kill();
10191020
ExtrinsicCount::kill();
10201021
AllExtrinsicsLen::kill();
10211022

1022-
let number = <Number<T>>::take();
1023-
let parent_hash = <ParentHash<T>>::take();
1024-
let mut digest = <Digest<T>>::take();
1023+
// The following fields
1024+
//
1025+
// - <Events<T>>
1026+
// - <EventCount<T>>
1027+
// - <EventTopics<T>>
1028+
// - <Number<T>>
1029+
// - <ParentHash<T>>
1030+
// - <Digest<T>>
1031+
//
1032+
// stay to be inspected by the client and will be cleared by `Self::initialize`.
1033+
let number = <Number<T>>::get();
1034+
let parent_hash = <ParentHash<T>>::get();
1035+
let mut digest = <Digest<T>>::get();
1036+
10251037
let extrinsics_root = <ExtrinsicsRoot<T>>::take();
10261038

10271039
// move block hash pruning window by one block
@@ -1049,14 +1061,6 @@ impl<T: Config> Module<T> {
10491061
digest.push(item);
10501062
}
10511063

1052-
// The following fields
1053-
//
1054-
// - <Events<T>>
1055-
// - <EventCount<T>>
1056-
// - <EventTopics<T>>
1057-
//
1058-
// stay to be inspected by the client and will be cleared by `Self::initialize`.
1059-
10601064
<T::Header as traits::Header>::new(number, extrinsics_root, storage_root, parent_hash, digest)
10611065
}
10621066

0 commit comments

Comments
 (0)