From bb447b2daa01fecf3bf0ca20c451ac6147f3f8c7 Mon Sep 17 00:00:00 2001
From: Liu-Cheng Xu <xuliuchengxlc@gmail.com>
Date: Sat, 26 Oct 2024 23:43:04 +0800
Subject: [PATCH] Important: unify the insertion of child key values

Before this commit, every commit is an equalvalent rewrite.

This commit modifies the origin logic by moving the child_key_value
in `process_state_verified()` to the same place in `process_state_unverified()`.

Please review this very carefully.
---
 substrate/client/network/sync/src/strategy/state_sync.rs | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/substrate/client/network/sync/src/strategy/state_sync.rs b/substrate/client/network/sync/src/strategy/state_sync.rs
index b1eca8b1f03..7d35411e2b0 100644
--- a/substrate/client/network/sync/src/strategy/state_sync.rs
+++ b/substrate/client/network/sync/src/strategy/state_sync.rs
@@ -150,10 +150,6 @@ where
 				is_top && well_known_keys::is_child_storage_key(key_value.0.as_slice())
 			});
 
-		for key_value in child_key_values {
-			self.insert_child_trie_roots(key_value);
-		}
-
 		let entry = self.state.entry(state_root).or_default();
 
 		if entry.0.len() > 0 && entry.1.len() > 1 {
@@ -165,6 +161,10 @@ where
 			}
 
 			entry.0.extend(top_key_values);
+
+			for key_value in child_key_values {
+				self.insert_child_trie_roots(key_value);
+			}
 		}
 	}
 
-- 
GitLab