From 43f4f5e35336070743f679709ba4824324422cd6 Mon Sep 17 00:00:00 2001 From: Joshua Primero Date: Tue, 3 Oct 2023 21:36:11 -0500 Subject: [PATCH 1/4] Add object_count to system db checker --- radix-engine-interface/src/types/blueprint.rs | 2 +- radix-engine/src/system/checkers/system_db_checker.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/radix-engine-interface/src/types/blueprint.rs b/radix-engine-interface/src/types/blueprint.rs index 58a62f50000..10c986bbc0d 100644 --- a/radix-engine-interface/src/types/blueprint.rs +++ b/radix-engine-interface/src/types/blueprint.rs @@ -96,7 +96,7 @@ pub struct KeyValueStoreInfo { pub generic_substitutions: KeyValueStoreGenericSubstitutions, } -#[derive(Clone, PartialEq, Eq, Hash, ScryptoSbor, ManifestSbor)] +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, ScryptoSbor, ManifestSbor)] pub struct BlueprintId { pub package_address: PackageAddress, pub blueprint_name: String, diff --git a/radix-engine/src/system/checkers/system_db_checker.rs b/radix-engine/src/system/checkers/system_db_checker.rs index 6c991c3962e..648900264b9 100644 --- a/radix-engine/src/system/checkers/system_db_checker.rs +++ b/radix-engine/src/system/checkers/system_db_checker.rs @@ -58,6 +58,7 @@ pub struct NodeCounts { pub interior_node_count: usize, pub package_count: usize, pub blueprint_count: usize, + pub object_count: BTreeMap, } #[derive(Debug)] @@ -166,12 +167,14 @@ impl ApplicationChecker for () { pub struct SystemDatabaseChecker { application_checker: A, + object_count: BTreeMap, } impl SystemDatabaseChecker { pub fn new(checker: A) -> SystemDatabaseChecker { SystemDatabaseChecker { application_checker: checker, + object_count: btreemap!(), } } } @@ -183,6 +186,7 @@ where fn default() -> Self { Self { application_checker: A::default(), + object_count: btreemap!(), } } } @@ -253,6 +257,8 @@ impl SystemDatabaseChecker { .map_err(SystemDatabaseCheckError::NodeError)?; } + node_counts.object_count.extend(self.object_count.clone()); + let system_checker_results = SystemDatabaseCheckerResults { node_counts, partition_count, @@ -265,7 +271,7 @@ impl SystemDatabaseChecker { } fn check_node( - &self, + &mut self, reader: &SystemDatabaseReader, node_id: &NodeId, node_counts: &mut NodeCounts, @@ -388,6 +394,9 @@ impl SystemDatabaseChecker { ObjectType::Owned => {} } + let count = self.object_count.entry(object_info.blueprint_info.blueprint_id.clone()).or_insert(0usize); + count.add_assign(&1); + SystemNodeCheckerState { node_id: *node_id, node_type: SystemNodeType::Object { From 04184ecaa276600420038e8ee6edd840eefab2e3 Mon Sep 17 00:00:00 2001 From: Joshua Primero Date: Thu, 5 Oct 2023 13:55:59 -0500 Subject: [PATCH 2/4] Index by package_address --- radix-engine/src/system/checkers/system_db_checker.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/radix-engine/src/system/checkers/system_db_checker.rs b/radix-engine/src/system/checkers/system_db_checker.rs index 648900264b9..2bcfbf0d78d 100644 --- a/radix-engine/src/system/checkers/system_db_checker.rs +++ b/radix-engine/src/system/checkers/system_db_checker.rs @@ -58,7 +58,7 @@ pub struct NodeCounts { pub interior_node_count: usize, pub package_count: usize, pub blueprint_count: usize, - pub object_count: BTreeMap, + pub object_count: BTreeMap>, } #[derive(Debug)] @@ -167,7 +167,7 @@ impl ApplicationChecker for () { pub struct SystemDatabaseChecker { application_checker: A, - object_count: BTreeMap, + object_count: BTreeMap>, } impl SystemDatabaseChecker { @@ -394,8 +394,9 @@ impl SystemDatabaseChecker { ObjectType::Owned => {} } - let count = self.object_count.entry(object_info.blueprint_info.blueprint_id.clone()).or_insert(0usize); - count.add_assign(&1); + self.object_count.entry(object_info.blueprint_info.blueprint_id.package_address) + .or_default().entry(object_info.blueprint_info.blueprint_id.blueprint_name.clone()) + .or_default().add_assign(&1); SystemNodeCheckerState { node_id: *node_id, From e2ba1dfcde5b1a49ddefce494be06d459b2913ff Mon Sep 17 00:00:00 2001 From: Joshua Primero Date: Fri, 13 Oct 2023 13:26:18 -0500 Subject: [PATCH 3/4] Add scrypto global component count --- .../src/system/checkers/system_db_checker.rs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/radix-engine/src/system/checkers/system_db_checker.rs b/radix-engine/src/system/checkers/system_db_checker.rs index 2bcfbf0d78d..3f1388fee0e 100644 --- a/radix-engine/src/system/checkers/system_db_checker.rs +++ b/radix-engine/src/system/checkers/system_db_checker.rs @@ -58,6 +58,7 @@ pub struct NodeCounts { pub interior_node_count: usize, pub package_count: usize, pub blueprint_count: usize, + pub scrypto_global_component_count: usize, pub object_count: BTreeMap>, } @@ -167,6 +168,7 @@ impl ApplicationChecker for () { pub struct SystemDatabaseChecker { application_checker: A, + scrypto_global_component_count: usize, object_count: BTreeMap>, } @@ -174,6 +176,7 @@ impl SystemDatabaseChecker { pub fn new(checker: A) -> SystemDatabaseChecker { SystemDatabaseChecker { application_checker: checker, + scrypto_global_component_count: 0usize, object_count: btreemap!(), } } @@ -186,6 +189,7 @@ where fn default() -> Self { Self { application_checker: A::default(), + scrypto_global_component_count: 0usize, object_count: btreemap!(), } } @@ -257,6 +261,7 @@ impl SystemDatabaseChecker { .map_err(SystemDatabaseCheckError::NodeError)?; } + node_counts.scrypto_global_component_count = self.scrypto_global_component_count; node_counts.object_count.extend(self.object_count.clone()); let system_checker_results = SystemDatabaseCheckerResults { @@ -394,9 +399,22 @@ impl SystemDatabaseChecker { ObjectType::Owned => {} } - self.object_count.entry(object_info.blueprint_info.blueprint_id.package_address) - .or_default().entry(object_info.blueprint_info.blueprint_id.blueprint_name.clone()) - .or_default().add_assign(&1); + if node_id.entity_type() == EntityType::GlobalGenericComponent { + self.scrypto_global_component_count += 1; + } + + self.object_count + .entry(object_info.blueprint_info.blueprint_id.package_address) + .or_default() + .entry( + object_info + .blueprint_info + .blueprint_id + .blueprint_name + .clone(), + ) + .or_default() + .add_assign(&1); SystemNodeCheckerState { node_id: *node_id, From 15e4a350e7739ded9bf5058a4dbeed5d4aa6595f Mon Sep 17 00:00:00 2001 From: Joshua Primero Date: Fri, 13 Oct 2023 14:31:44 -0500 Subject: [PATCH 4/4] Add native global component counter --- .../src/system/checkers/package_royalty_db_checker.rs | 2 +- radix-engine/src/system/checkers/system_db_checker.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/radix-engine/src/system/checkers/package_royalty_db_checker.rs b/radix-engine/src/system/checkers/package_royalty_db_checker.rs index bf424d08127..d8ccba922c4 100644 --- a/radix-engine/src/system/checkers/package_royalty_db_checker.rs +++ b/radix-engine/src/system/checkers/package_royalty_db_checker.rs @@ -39,7 +39,7 @@ where value: &Vec, ) { // Ignore if the module id is not the royalty module. - if module_id == ModuleId::Royalty { + if module_id != ModuleId::Royalty { return; } diff --git a/radix-engine/src/system/checkers/system_db_checker.rs b/radix-engine/src/system/checkers/system_db_checker.rs index 3f1388fee0e..b5f92b1be64 100644 --- a/radix-engine/src/system/checkers/system_db_checker.rs +++ b/radix-engine/src/system/checkers/system_db_checker.rs @@ -59,6 +59,7 @@ pub struct NodeCounts { pub package_count: usize, pub blueprint_count: usize, pub scrypto_global_component_count: usize, + pub native_global_component_count: usize, pub object_count: BTreeMap>, } @@ -169,6 +170,7 @@ impl ApplicationChecker for () { pub struct SystemDatabaseChecker { application_checker: A, scrypto_global_component_count: usize, + native_global_component_count: usize, object_count: BTreeMap>, } @@ -177,6 +179,7 @@ impl SystemDatabaseChecker { SystemDatabaseChecker { application_checker: checker, scrypto_global_component_count: 0usize, + native_global_component_count: 0usize, object_count: btreemap!(), } } @@ -190,6 +193,7 @@ where Self { application_checker: A::default(), scrypto_global_component_count: 0usize, + native_global_component_count: 0usize, object_count: btreemap!(), } } @@ -262,6 +266,7 @@ impl SystemDatabaseChecker { } node_counts.scrypto_global_component_count = self.scrypto_global_component_count; + node_counts.native_global_component_count = self.native_global_component_count; node_counts.object_count.extend(self.object_count.clone()); let system_checker_results = SystemDatabaseCheckerResults { @@ -399,8 +404,10 @@ impl SystemDatabaseChecker { ObjectType::Owned => {} } - if node_id.entity_type() == EntityType::GlobalGenericComponent { + if node_id.entity_type().unwrap() == EntityType::GlobalGenericComponent { self.scrypto_global_component_count += 1; + } else if node_id.is_global_component() { + self.native_global_component_count += 1; } self.object_count