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
This commit is contained in:
Sergei Shulepov authored and GitHub committed 2020-12-15 19:07:04 +00:00
1 parent 688227ef48
commit 581e723a11
2 files changed
+17 -13

No files matched your search

+1 -1
View File
@@ -753,7 +753,7 @@ mod tests {
header: Header {
parent_hash: [69u8; 32].into(),
number: 1,
state_root: hex!("6a3ad91caba5b8ac15c325a36d7568adf6a7e49321865de7527b851d870343d4").into(),
state_root: hex!("ba1a82a264b8007e0c04c9ea35e541593daad08b6e2bf7c0a6780a67d1c55018").into(),
extrinsics_root: hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314").into(),
digest: Digest { logs: vec![], },
},
+16 -12
View File
@@ -1013,15 +1013,27 @@ impl<T: Config> Module<T> {
}
}
/// Remove temporary "environment" entries in storage.
/// Remove temporary "environment" entries in storage, compute the storage root and return the
/// resulting header for this block.
pub fn finalize() -> T::Header {
ExecutionPhase::kill();
ExtrinsicCount::kill();
AllExtrinsicsLen::kill();
let number = <Number<T>>::take();
let parent_hash = <ParentHash<T>>::take();
let mut digest = <Digest<T>>::take();
// The following fields
//
// - <Events<T>>
// - <EventCount<T>>
// - <EventTopics<T>>
// - <Number<T>>
// - <ParentHash<T>>
// - <Digest<T>>
//
// stay to be inspected by the client and will be cleared by `Self::initialize`.
let number = <Number<T>>::get();
let parent_hash = <ParentHash<T>>::get();
let mut digest = <Digest<T>>::get();
let extrinsics_root = <ExtrinsicsRoot<T>>::take();
// move block hash pruning window by one block
@@ -1049,14 +1061,6 @@ impl<T: Config> Module<T> {
digest.push(item);
}
// The following fields
//
// - <Events<T>>
// - <EventCount<T>>
// - <EventTopics<T>>
//
// stay to be inspected by the client and will be cleared by `Self::initialize`.
<T::Header as traits::Header>::new(number, extrinsics_root, storage_root, parent_hash, digest)
}