mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Fast sync child trie support. (#9239)
* state machine proofs. * initial implementation * Remove todo. * Extend test and fix import. * fix no proof, with proof ko. * fix start at logic. * Restore response size. * Rework comments. * Add explicit ref * Use compact proof. * ref change * elaborato on empty change set condition. * KeyValueState renaming. * Do not add two time child trie with same root to sync reply. * rust format * Fix merge. * fix warnings and fmt * fmt * update protocol id to V2
This commit is contained in:
@@ -697,6 +697,8 @@ pub struct FullPeerConfig {
|
||||
pub is_authority: bool,
|
||||
/// Syncing mode
|
||||
pub sync_mode: SyncMode,
|
||||
/// Extra genesis storage.
|
||||
pub extra_storage: Option<sp_core::storage::Storage>,
|
||||
/// Enable transaction indexing.
|
||||
pub storage_chain: bool,
|
||||
}
|
||||
@@ -765,6 +767,11 @@ where
|
||||
(Some(keep_blocks), false) => TestClientBuilder::with_pruning_window(keep_blocks),
|
||||
(None, false) => TestClientBuilder::with_default_backend(),
|
||||
};
|
||||
if let Some(storage) = config.extra_storage {
|
||||
let genesis_extra_storage = test_client_builder.genesis_init_mut().extra_storage();
|
||||
*genesis_extra_storage = storage;
|
||||
}
|
||||
|
||||
if matches!(config.sync_mode, SyncMode::Fast { .. } | SyncMode::Warp) {
|
||||
test_client_builder = test_client_builder.set_no_genesis();
|
||||
}
|
||||
|
||||
@@ -1110,11 +1110,44 @@ fn syncs_state() {
|
||||
sp_tracing::try_init_simple();
|
||||
for skip_proofs in &[false, true] {
|
||||
let mut net = TestNet::new(0);
|
||||
net.add_full_peer_with_config(Default::default());
|
||||
net.add_full_peer_with_config(FullPeerConfig {
|
||||
sync_mode: SyncMode::Fast { skip_proofs: *skip_proofs, storage_chain_mode: false },
|
||||
..Default::default()
|
||||
});
|
||||
let mut genesis_storage: sp_core::storage::Storage = Default::default();
|
||||
genesis_storage.top.insert(b"additional_key".to_vec(), vec![1]);
|
||||
let mut child_data: std::collections::BTreeMap<Vec<u8>, Vec<u8>> = Default::default();
|
||||
for i in 0u8..16 {
|
||||
child_data.insert(vec![i; 5], vec![i; 33]);
|
||||
}
|
||||
let child1 = sp_core::storage::StorageChild {
|
||||
data: child_data.clone(),
|
||||
child_info: sp_core::storage::ChildInfo::new_default(b"child1"),
|
||||
};
|
||||
let child3 = sp_core::storage::StorageChild {
|
||||
data: child_data.clone(),
|
||||
child_info: sp_core::storage::ChildInfo::new_default(b"child3"),
|
||||
};
|
||||
for i in 22u8..33 {
|
||||
child_data.insert(vec![i; 5], vec![i; 33]);
|
||||
}
|
||||
let child2 = sp_core::storage::StorageChild {
|
||||
data: child_data.clone(),
|
||||
child_info: sp_core::storage::ChildInfo::new_default(b"child2"),
|
||||
};
|
||||
genesis_storage
|
||||
.children_default
|
||||
.insert(child1.child_info.storage_key().to_vec(), child1);
|
||||
genesis_storage
|
||||
.children_default
|
||||
.insert(child2.child_info.storage_key().to_vec(), child2);
|
||||
genesis_storage
|
||||
.children_default
|
||||
.insert(child3.child_info.storage_key().to_vec(), child3);
|
||||
let mut config_one = FullPeerConfig::default();
|
||||
config_one.extra_storage = Some(genesis_storage.clone());
|
||||
net.add_full_peer_with_config(config_one);
|
||||
let mut config_two = FullPeerConfig::default();
|
||||
config_two.extra_storage = Some(genesis_storage);
|
||||
config_two.sync_mode =
|
||||
SyncMode::Fast { skip_proofs: *skip_proofs, storage_chain_mode: false };
|
||||
net.add_full_peer_with_config(config_two);
|
||||
net.peer(0).push_blocks(64, false);
|
||||
// Wait for peer 1 to sync header chain.
|
||||
net.block_until_sync();
|
||||
|
||||
Reference in New Issue
Block a user