mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Rewrap all comments to 100 line width (#9490)
* reformat everything again * manual formatting * last manual fix * Fix build
This commit is contained in:
@@ -147,8 +147,8 @@ where
|
||||
|mut map: BTreeMap<&[u8], (ExtrinsicIndex<Number>, Vec<u32>)>, (k, extrinsics)| {
|
||||
match map.entry(k) {
|
||||
Entry::Vacant(entry) => {
|
||||
// ignore temporary values (values that have null value at the end of operation
|
||||
// AND are not in storage at the beginning of operation
|
||||
// ignore temporary values (values that have null value at the end of
|
||||
// operation AND are not in storage at the beginning of operation
|
||||
if let Some(child_info) = child_info.as_ref() {
|
||||
if !overlay
|
||||
.child_storage(child_info, k)
|
||||
@@ -177,8 +177,8 @@ where
|
||||
));
|
||||
},
|
||||
Entry::Occupied(mut entry) => {
|
||||
// we do not need to check for temporary values here, because entry is Occupied
|
||||
// AND we are checking it before insertion
|
||||
// we do not need to check for temporary values here, because entry is
|
||||
// Occupied AND we are checking it before insertion
|
||||
let entry_extrinsics = &mut entry.get_mut().1;
|
||||
entry_extrinsics.extend(extrinsics.into_iter());
|
||||
entry_extrinsics.sort();
|
||||
@@ -246,11 +246,12 @@ where
|
||||
));
|
||||
},
|
||||
Entry::Occupied(mut entry) => {
|
||||
// DigestIndexValue must be sorted. Here we are relying on the fact that digest_build_iterator()
|
||||
// returns blocks in ascending order => we only need to check for duplicates
|
||||
// DigestIndexValue must be sorted. Here we are relying on the fact that
|
||||
// digest_build_iterator() returns blocks in ascending order => we only
|
||||
// need to check for duplicates
|
||||
//
|
||||
// is_dup_block could be true when key has been changed in both digest block
|
||||
// AND other blocks that it covers
|
||||
// is_dup_block could be true when key has been changed in both digest
|
||||
// block AND other blocks that it covers
|
||||
let is_dup_block = entry.get().1.last() == Some(&digest_build_block);
|
||||
if !is_dup_block {
|
||||
entry.get_mut().1.push(digest_build_block.clone());
|
||||
|
||||
@@ -39,7 +39,8 @@ pub struct BuildCache<H, N> {
|
||||
/// Map of changes trie root => set of storage keys that are in this trie.
|
||||
/// The `Option<Vec<u8>>` in inner `HashMap` stands for the child storage key.
|
||||
/// If it is `None`, then the `HashSet` contains keys changed in top-level storage.
|
||||
/// If it is `Some`, then the `HashSet` contains keys changed in child storage, identified by the key.
|
||||
/// If it is `Some`, then the `HashSet` contains keys changed in child storage, identified by
|
||||
/// the key.
|
||||
changed_keys: HashMap<H, HashMap<Option<PrefixedStorageKey>, HashSet<StorageKey>>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,12 @@ pub fn digest_build_iterator<'a, Number: BlockNumber>(
|
||||
/// required for inclusion into changes trie of given block.
|
||||
#[derive(Debug)]
|
||||
pub struct DigestBuildIterator<Number: BlockNumber> {
|
||||
/// Block we're building changes trie for. It could (logically) be a post-end block if we are creating
|
||||
/// skewed digest.
|
||||
/// Block we're building changes trie for. It could (logically) be a post-end block if we are
|
||||
/// creating skewed digest.
|
||||
block: Number,
|
||||
/// Block that is a last block where current configuration is active. We have never yet created anything
|
||||
/// after this block => digest that we're creating can't reference any blocks that are >= end.
|
||||
/// Block that is a last block where current configuration is active. We have never yet created
|
||||
/// anything after this block => digest that we're creating can't reference any blocks that are
|
||||
/// >= end.
|
||||
end: Number,
|
||||
/// Interval of L1 digest blocks.
|
||||
digest_interval: u32,
|
||||
@@ -445,7 +446,8 @@ mod tests {
|
||||
256, 512, 768, 1024, 1280,
|
||||
// level3 MUST point to previous 16-1 level1 digests, BUT there are only 3:
|
||||
1296, 1312, 1328,
|
||||
// level3 MUST be a level1 digest of 16-1 previous blocks, BUT there are only 9:
|
||||
// level3 MUST be a level1 digest of 16-1 previous blocks, BUT there are only
|
||||
// 9:
|
||||
1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337,
|
||||
]
|
||||
.iter()
|
||||
@@ -467,8 +469,9 @@ mod tests {
|
||||
[
|
||||
// level3 MUST point to previous 16-1 level2 digests, BUT there are only 5:
|
||||
256, 512, 768, 1024, 1280,
|
||||
// level3 MUST point to previous 16-1 level1 digests, BUT there are NO ANY L1-digests:
|
||||
// level3 MUST be a level1 digest of 16-1 previous blocks, BUT there are only 3:
|
||||
// level3 MUST point to previous 16-1 level1 digests, BUT there are NO ANY
|
||||
// L1-digests: level3 MUST be a level1 digest of 16-1 previous blocks, BUT
|
||||
// there are only 3:
|
||||
1281, 1282, 1283,
|
||||
]
|
||||
.iter()
|
||||
|
||||
@@ -279,7 +279,8 @@ where
|
||||
if let Some(blocks) = blocks? {
|
||||
if let Ok(blocks) = <DigestIndexValue<Number>>::decode(&mut &blocks[..]) {
|
||||
// filter level0 blocks here because we tend to use digest blocks,
|
||||
// AND digest block changes could also include changes for out-of-range blocks
|
||||
// AND digest block changes could also include changes for out-of-range
|
||||
// blocks
|
||||
let begin = self.begin.clone();
|
||||
let end = self.end.number.clone();
|
||||
let config = self.config.clone();
|
||||
|
||||
@@ -63,9 +63,11 @@ pub type ChildIndexValue = Vec<u8>;
|
||||
pub enum InputPair<Number: BlockNumber> {
|
||||
/// Element of { key => set of extrinsics where key has been changed } element mapping.
|
||||
ExtrinsicIndex(ExtrinsicIndex<Number>, ExtrinsicIndexValue),
|
||||
/// Element of { key => set of blocks/digest blocks where key has been changed } element mapping.
|
||||
/// Element of { key => set of blocks/digest blocks where key has been changed } element
|
||||
/// mapping.
|
||||
DigestIndex(DigestIndex<Number>, DigestIndexValue<Number>),
|
||||
/// Element of { childtrie key => Childchange trie } where key has been changed } element mapping.
|
||||
/// Element of { childtrie key => Childchange trie } where key has been changed } element
|
||||
/// mapping.
|
||||
ChildIndex(ChildIndex<Number>, ChildIndexValue),
|
||||
}
|
||||
|
||||
|
||||
@@ -153,8 +153,8 @@ pub struct State<'a, H, Number> {
|
||||
/// Configuration that is active at given block.
|
||||
pub config: Configuration,
|
||||
/// Configuration activation block number. Zero if it is the first configuration on the chain,
|
||||
/// or number of the block that have emit NewConfiguration signal (thus activating configuration
|
||||
/// starting from the **next** block).
|
||||
/// or number of the block that have emit NewConfiguration signal (thus activating
|
||||
/// configuration starting from the **next** block).
|
||||
pub zero: Number,
|
||||
/// Underlying changes tries storage reference.
|
||||
pub storage: &'a dyn Storage<H, Number>,
|
||||
@@ -276,8 +276,8 @@ where
|
||||
let parent = state.storage.build_anchor(parent_hash).map_err(|_| ())?;
|
||||
let block = parent.number.clone() + One::one();
|
||||
|
||||
// prepare configuration range - we already know zero block. Current block may be the end block if configuration
|
||||
// has been changed in this block
|
||||
// prepare configuration range - we already know zero block. Current block may be the end block
|
||||
// if configuration has been changed in this block
|
||||
let is_config_changed =
|
||||
match changes.storage(sp_core::storage::well_known_keys::CHANGES_TRIE_CONFIG) {
|
||||
Some(Some(new_config)) => new_config != &state.config.encode()[..],
|
||||
@@ -290,7 +290,8 @@ where
|
||||
end: if is_config_changed { Some(block.clone()) } else { None },
|
||||
};
|
||||
|
||||
// storage errors are considered fatal (similar to situations when runtime fetches values from storage)
|
||||
// storage errors are considered fatal (similar to situations when runtime fetches values from
|
||||
// storage)
|
||||
let (input_pairs, child_input_pairs, digest_input_blocks) = maybe_panic(
|
||||
prepare_input::<B, H, Number>(
|
||||
backend,
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! The best way to understand how this iterator works is to imagine some 2D terrain that have some mountains
|
||||
//! (digest changes tries) and valleys (changes tries for regular blocks). There are gems (blocks) beneath the
|
||||
//! terrain. Given the request to find all gems in the range [X1; X2] this iterator will return **minimal set**
|
||||
//! of points at the terrain (mountains and valleys) inside this range that have to be drilled down to
|
||||
//! search for gems.
|
||||
//! The best way to understand how this iterator works is to imagine some 2D terrain that have some
|
||||
//! mountains (digest changes tries) and valleys (changes tries for regular blocks). There are gems
|
||||
//! (blocks) beneath the terrain. Given the request to find all gems in the range [X1; X2] this
|
||||
//! iterator will return **minimal set** of points at the terrain (mountains and valleys) inside
|
||||
//! this range that have to be drilled down to search for gems.
|
||||
|
||||
use crate::changes_trie::{BlockNumber, ConfigurationRange};
|
||||
use num_traits::One;
|
||||
@@ -50,9 +50,9 @@ pub fn surface_iterator<'a, Number: BlockNumber>(
|
||||
/// Surface iterator - only traverses top-level digests from given range and tries to find
|
||||
/// all valid digest changes.
|
||||
///
|
||||
/// Iterator item is the tuple of (last block of the current point + digest level of the current point).
|
||||
/// Digest level is Some(0) when it is regular block, is Some(non-zero) when it is digest block and None
|
||||
/// if it is skewed digest block.
|
||||
/// Iterator item is the tuple of (last block of the current point + digest level of the current
|
||||
/// point). Digest level is Some(0) when it is regular block, is Some(non-zero) when it is digest
|
||||
/// block and None if it is skewed digest block.
|
||||
pub struct SurfaceIterator<'a, Number: BlockNumber> {
|
||||
config: ConfigurationRange<'a, Number>,
|
||||
begin: Number,
|
||||
|
||||
@@ -573,9 +573,9 @@ where
|
||||
|
||||
if let Some((root, is_empty, _)) = root {
|
||||
let root = root.encode();
|
||||
// We store update in the overlay in order to be able to use 'self.storage_transaction'
|
||||
// cache. This is brittle as it rely on Ext only querying the trie backend for
|
||||
// storage root.
|
||||
// We store update in the overlay in order to be able to use
|
||||
// 'self.storage_transaction' cache. This is brittle as it rely on Ext only querying
|
||||
// the trie backend for storage root.
|
||||
// A better design would be to manage 'child_storage_transaction' in a
|
||||
// similar way as 'storage_transaction' but for each child trie.
|
||||
if is_empty {
|
||||
|
||||
@@ -206,7 +206,8 @@ mod execution {
|
||||
NativeWhenPossible,
|
||||
/// Use the given wasm module.
|
||||
AlwaysWasm,
|
||||
/// Run with both the wasm and the native variant (if compatible). Report any discrepancy as an error.
|
||||
/// Run with both the wasm and the native variant (if compatible). Report any discrepancy
|
||||
/// as an error.
|
||||
Both,
|
||||
/// First native, then if that fails or is not possible, wasm.
|
||||
NativeElseWasm,
|
||||
@@ -230,10 +231,12 @@ mod execution {
|
||||
/// otherwise fall back to the wasm.
|
||||
NativeWhenPossible,
|
||||
/// Use the given wasm module. The backend on which code is executed code could be
|
||||
/// trusted to provide all storage or not (i.e. the light client cannot be trusted to provide
|
||||
/// for all storage queries since the storage entries it has come from an external node).
|
||||
/// trusted to provide all storage or not (i.e. the light client cannot be trusted to
|
||||
/// provide for all storage queries since the storage entries it has come from an external
|
||||
/// node).
|
||||
AlwaysWasm(BackendTrustLevel),
|
||||
/// Run with both the wasm and the native variant (if compatible). Call `F` in the case of any discrepancy.
|
||||
/// Run with both the wasm and the native variant (if compatible). Call `F` in the case of
|
||||
/// any discrepancy.
|
||||
Both(F),
|
||||
/// First native, then if that fails or is not possible, wasm.
|
||||
NativeElseWasm,
|
||||
@@ -278,12 +281,14 @@ mod execution {
|
||||
ExecutionManager::NativeElseWasm
|
||||
}
|
||||
|
||||
/// Evaluate to ExecutionManager::AlwaysWasm with trusted backend, without having to figure out the type.
|
||||
/// Evaluate to ExecutionManager::AlwaysWasm with trusted backend, without having to figure out
|
||||
/// the type.
|
||||
fn always_wasm<E, R: Decode>() -> ExecutionManager<DefaultHandler<R, E>> {
|
||||
ExecutionManager::AlwaysWasm(BackendTrustLevel::Trusted)
|
||||
}
|
||||
|
||||
/// Evaluate ExecutionManager::AlwaysWasm with untrusted backend, without having to figure out the type.
|
||||
/// Evaluate ExecutionManager::AlwaysWasm with untrusted backend, without having to figure out
|
||||
/// the type.
|
||||
fn always_untrusted_wasm<E, R: Decode>() -> ExecutionManager<DefaultHandler<R, E>> {
|
||||
ExecutionManager::AlwaysWasm(BackendTrustLevel::Untrusted)
|
||||
}
|
||||
@@ -390,8 +395,8 @@ mod execution {
|
||||
///
|
||||
/// Returns the SCALE encoded result of the executed function.
|
||||
pub fn execute(&mut self, strategy: ExecutionStrategy) -> Result<Vec<u8>, Box<dyn Error>> {
|
||||
// We are not giving a native call and thus we are sure that the result can never be a native
|
||||
// value.
|
||||
// We are not giving a native call and thus we are sure that the result can never be a
|
||||
// native value.
|
||||
self.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>(
|
||||
strategy.get_manager(),
|
||||
None,
|
||||
|
||||
@@ -21,7 +21,8 @@ use super::changeset::OverlayedMap;
|
||||
use sp_core::offchain::OffchainOverlayedChange;
|
||||
use sp_std::prelude::Vec;
|
||||
|
||||
/// In-memory storage for offchain workers recoding changes for the actual offchain storage implementation.
|
||||
/// In-memory storage for offchain workers recoding changes for the actual offchain storage
|
||||
/// implementation.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct OffchainOverlayedChanges(OverlayedMap<(Vec<u8>, Vec<u8>), OffchainOverlayedChange>);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user