Procházet zdrojové kódy

Merge branch 'babylon' into query-node/integration-fix

Mokhtar Naamani před 4 roky
rodič
revize
7ff05a0401

+ 2 - 2
Cargo.lock

@@ -1993,7 +1993,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node"
-version = "3.4.0"
+version = "3.4.1"
 dependencies = [
  "frame-benchmarking",
  "frame-benchmarking-cli",
@@ -2053,7 +2053,7 @@ dependencies = [
 
 [[package]]
 name = "joystream-node-runtime"
-version = "7.6.0"
+version = "7.7.0"
 dependencies = [
  "frame-benchmarking",
  "frame-executive",

+ 1 - 1
node/Cargo.toml

@@ -3,7 +3,7 @@ authors = ['Joystream contributors']
 build = 'build.rs'
 edition = '2018'
 name = 'joystream-node'
-version = '3.4.0'
+version = '3.4.1'
 default-run = "joystream-node"
 
 [[bin]]

+ 2 - 2
node/src/chain_spec/mod.rs

@@ -316,14 +316,14 @@ pub fn testnet_genesis(
         }),
         working_group_Instance2: Some(StorageWorkingGroupConfig {
             phantom: Default::default(),
-            storage_working_group_mint_capacity: 0,
+            working_group_mint_capacity: 0,
             opening_human_readable_text_constraint: default_text_constraint,
             worker_application_human_readable_text_constraint: default_text_constraint,
             worker_exit_rationale_text_constraint: default_text_constraint,
         }),
         working_group_Instance3: Some(ContentDirectoryWorkingGroupConfig {
             phantom: Default::default(),
-            storage_working_group_mint_capacity: 0,
+            working_group_mint_capacity: 0,
             opening_human_readable_text_constraint: default_text_constraint,
             worker_application_human_readable_text_constraint: default_text_constraint,
             worker_exit_rationale_text_constraint: default_text_constraint,

+ 10 - 2
runtime-modules/content-directory/src/lib.rs

@@ -1092,8 +1092,8 @@ decl_module! {
 
             let entity_values = entity.get_values();
 
-            let unique_property_value_hashes = match StoredValuesForExistingProperties::<T>::from(&class_properties, &entity_values) {
-                Ok(values_for_existing_properties) => values_for_existing_properties.compute_unique_hashes(),
+            let values_for_existing_properties = match StoredValuesForExistingProperties::<T>::from(&class_properties, &entity_values) {
+                Ok(values_for_existing_properties) => values_for_existing_properties,
                 Err(e) => {
                     debug_assert!(false, "Should not fail! {:?}", e);
                     return Err(e.into())
@@ -1104,6 +1104,14 @@ decl_module! {
             // == MUTATION SAFE ==
             //
 
+            let unique_property_value_hashes = values_for_existing_properties.compute_unique_hashes();
+
+            // Calculate entities reference counter side effects for current operation
+            let entities_inbound_rcs_delta = Self::calculate_entities_inbound_rcs_delta(entity_id, values_for_existing_properties, DeltaMode::Decrement);
+
+            // Update InboundReferenceCounter, based on previously calculated entities_inbound_rcs_delta, for each Entity involved
+            Self::update_entities_rcs(&entities_inbound_rcs_delta);
+
             // Remove property value entries, that should be unique on Class level
             Self::remove_unique_property_value_hashes(class_id, unique_property_value_hashes);
 

+ 6 - 0
runtime-modules/content-directory/src/tests/remove_entity.rs

@@ -292,5 +292,11 @@ fn remove_entity_rc_does_not_equal_to_zero() {
             Error::<Runtime>::EntityRcDoesNotEqualToZero,
             number_of_events_before_call,
         );
+
+        // Remove first entity, which have property values referencing second one.
+        assert_ok!(remove_entity(LEAD_ORIGIN, actor, FIRST_ENTITY_ID));
+
+        // Succesfully perform second entity removal
+        assert_ok!(remove_entity(LEAD_ORIGIN, actor, SECOND_ENTITY_ID));
     })
 }

+ 4 - 4
runtime-modules/working-group/src/lib.rs

@@ -328,7 +328,7 @@ decl_storage! {
     }
         add_extra_genesis {
         config(phantom): sp_std::marker::PhantomData<I>;
-        config(storage_working_group_mint_capacity): minting::BalanceOf<T>;
+        config(working_group_mint_capacity): minting::BalanceOf<T>;
         config(opening_human_readable_text_constraint): InputValidationLengthConstraint;
         config(worker_application_human_readable_text_constraint): InputValidationLengthConstraint;
         config(worker_exit_rationale_text_constraint): InputValidationLengthConstraint;
@@ -337,7 +337,7 @@ decl_storage! {
                 config.opening_human_readable_text_constraint,
                 config.worker_application_human_readable_text_constraint,
                 config.worker_exit_rationale_text_constraint,
-                config.storage_working_group_mint_capacity)
+                config.working_group_mint_capacity)
         });
     }
 }
@@ -1483,8 +1483,8 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
         Ok(())
     }
 
-    // Initialize working group constraints and mint.
-    pub(crate) fn initialize_working_group(
+    /// Initialize working group constraints and mint.
+    pub fn initialize_working_group(
         opening_human_readable_text_constraint: InputValidationLengthConstraint,
         worker_application_human_readable_text_constraint: InputValidationLengthConstraint,
         worker_exit_rationale_text_constraint: InputValidationLengthConstraint,

+ 1 - 1
runtime-modules/working-group/src/tests/mock.rs

@@ -156,7 +156,7 @@ pub fn build_test_externalities() -> sp_io::TestExternalities {
 
     crate::GenesisConfig::<Test, TestWorkingGroupInstance> {
         phantom: Default::default(),
-        storage_working_group_mint_capacity: WORKING_GROUP_MINT_CAPACITY,
+        working_group_mint_capacity: WORKING_GROUP_MINT_CAPACITY,
         opening_human_readable_text_constraint: InputValidationLengthConstraint::new(
             WORKING_GROUP_CONSTRAINT_MIN,
             WORKING_GROUP_CONSTRAINT_DIFF,

+ 1 - 1
runtime/Cargo.toml

@@ -4,7 +4,7 @@ edition = '2018'
 name = 'joystream-node-runtime'
 # Follow convention: https://github.com/Joystream/substrate-runtime-joystream/issues/1
 # {Authoring}.{Spec}.{Impl} of the RuntimeVersion
-version = '7.6.0'
+version = '7.7.0'
 
 [dependencies]
 # Third-party dependencies

+ 1 - 1
runtime/src/lib.rs

@@ -75,7 +75,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
     spec_name: create_runtime_str!("joystream-node"),
     impl_name: create_runtime_str!("joystream-node"),
     authoring_version: 7,
-    spec_version: 6,
+    spec_version: 7,
     impl_version: 0,
     apis: crate::runtime_api::EXPORTED_RUNTIME_API_VERSIONS,
     transaction_version: 1,

+ 33 - 3
runtime/src/runtime_api.rs

@@ -1,5 +1,5 @@
 use frame_support::inherent::{CheckInherentsResult, InherentData};
-use frame_support::traits::{KeyOwnerProofSystem, Randomness};
+use frame_support::traits::{KeyOwnerProofSystem, OnRuntimeUpgrade, Randomness};
 use frame_support::unsigned::{TransactionSource, TransactionValidity};
 use pallet_grandpa::fg_primitives;
 use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
@@ -11,6 +11,7 @@ use sp_runtime::{generic, ApplyExtrinsicResult};
 use sp_std::vec::Vec;
 
 use crate::constants::PRIMARY_PROBABILITY;
+use crate::integration::content_directory::ContentDirectoryWorkingGroup;
 use crate::{
     AccountId, AuthorityDiscoveryId, Balance, BlockNumber, EpochDuration, GrandpaAuthorityList,
     GrandpaId, Hash, Index, RuntimeVersion, Signature, VERSION,
@@ -19,6 +20,7 @@ use crate::{
     AllModules, AuthorityDiscovery, Babe, Call, Grandpa, Historical, InherentDataExt,
     RandomnessCollectiveFlip, Runtime, SessionKeys, System, TransactionPayment,
 };
+use frame_support::weights::Weight;
 
 /// The SignedExtension to the basic transaction logic.
 pub type SignedExtra = (
@@ -50,9 +52,37 @@ pub type BlockId = generic::BlockId<Block>;
 /// Unchecked extrinsic type as expected by this runtime.
 pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<AccountId, Call, Signature, SignedExtra>;
 
+// Default Executive type without the RuntimeUpgrade
+// pub type Executive =
+//     frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
+
+/// Custom runtime upgrade handler.
+pub struct CustomOnRuntimeUpgrade;
+impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
+    fn on_runtime_upgrade() -> Weight {
+        let default_text_constraint = crate::working_group::default_text_constraint();
+        let default_content_working_group_mint_capacity = 0;
+
+        ContentDirectoryWorkingGroup::<Runtime>::initialize_working_group(
+            default_text_constraint,
+            default_text_constraint,
+            default_text_constraint,
+            default_content_working_group_mint_capacity,
+        );
+
+        10_000_000 // TODO: adjust weight
+    }
+}
+
 /// Executive: handles dispatch to the various modules.
-pub type Executive =
-    frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
+pub type Executive = frame_executive::Executive<
+    Runtime,
+    Block,
+    system::ChainContext<Runtime>,
+    Runtime,
+    AllModules,
+    CustomOnRuntimeUpgrade,
+>;
 
 /// Export of the private const generated within the macro.
 pub const EXPORTED_RUNTIME_API_VERSIONS: sp_version::ApisVec = RUNTIME_API_VERSIONS;