Skip to content

Conversation

@iorveth
Copy link
Contributor

@iorveth iorveth commented Jul 27, 2020

The scope of this PR includes:

  1. New uniqueness feature core logic implementation.
  2. Existing uniqueness failure cases coverage upgrade.
  3. Uniqueness feature failure cases coverage for vector level operations.
  4. Inbound entities reference counting logic related bug fix.
  5. Uniqueness feature enhancement - store only property value hashes instead of actual values.
    Uniqueness feature - store only property value hashes instead of actual values #1123

Closes: #1123, #1021
To minimize merge conflict potential, this PR assumes #1035 will be merged first.

@iorveth iorveth self-assigned this Jul 27, 2020
@iorveth iorveth added content-pallet network-integration-test End-to-end full network integration test bug Something isn't working and removed bug Something isn't working labels Jul 27, 2020
@iorveth iorveth requested a review from bedeho July 27, 2020 18:48
@iorveth iorveth changed the base branch from content_directory_second_try to content_dir_2 July 31, 2020 13:28
@iorveth iorveth changed the base branch from content_dir_2 to content_directory_second_try July 31, 2020 13:28
@bedeho bedeho changed the base branch from content_directory_second_try to master August 4, 2020 09:34
@bedeho bedeho changed the base branch from master to content_dir_2 August 4, 2020 09:34
@bedeho bedeho changed the base branch from content_dir_2 to content_directory_second_try August 4, 2020 09:36
@bedeho bedeho removed the network-integration-test End-to-end full network integration test label Aug 4, 2020
Copy link
Member

@bedeho bedeho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Seems like removal from index was missed a few places, that needs to be added, and tests added that would trigger on failure. Perhaps update tests to fail frist?

  • Note that the network-integration-test is not for any sort of unit testing, even in ther untime, its explicitly for the network wide integration tests which Gleb & Mokhtar currently are working on, it does not apply to this PR, so I removed the label.

//

// Update property values, that should be unique on Class level
Self::add_unique_property_values(class_id, new_unique_property_values);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that there is cleanup processing missing that removes possible old values from the uniqueness index. The tests should be updated to catch this case, and all instances of such missing logic across the extrinsic should be considered.

Copy link
Contributor Author

@iorveth iorveth Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only default non required unique value hashes can be removed on update_entity_property_values operation. Implemented here 883863b#diff-0a165b042aa89a04d896ad36b8a33af5R1027
Additional test coverage for the previously discussed failure case fb19f62

let empty_property_value_vector = Self::clear_property_vector(property_value_vector);

// Ensure provided `Property` with `unique` flag set is `unique` on `Class` level
Self::ensure_property_unique_option_satisfied(class_id, in_class_schema_property_id, &empty_property_value_vector.simplify())?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically a check that there is no empty vector for this, possible, unique property. Lets update the comment to say exactly that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// == MUTATION SAFE ==
//

// Decrease reference counters of involved entities (if some)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be missing the same cleanup of old value from uniquness index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only default non required unique value hashes can be removed, otherwise we only update its respective hash

.get_vec_value()
.get_involved_entities()
.and_then(|involved_entities| involved_entities.get(index_in_property_vector as usize).copied());
// Insert updated propery value into entity_property_values mapping at in_class_schema_property_id.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same cleanup missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only default non required unique value hashes can be removed, otherwise we only update its respective hash.

// == MUTATION SAFE ==
//

// Insert updated property value into entity_property_values mapping at in_class_schema_property_id.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only default non required unique value hashes can be removed, otherwise we only update its respective hash.

@iorveth
Copy link
Contributor Author

iorveth commented Aug 11, 2020

Uniqueness feature enhancement - store only property value hashes instead of actual values.

#1123

Implementation

  1. Core logic - e03886b
  2. Default non required values potential bug fixed 883863b.

@iorveth iorveth requested a review from bedeho August 11, 2020 11:09
Copy link
Member

@bedeho bedeho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically looks correct now, well done!

Just one comment about a minor refactor possibility for clarity, and then what we discussed about loud failure and asserting no error in extrinsics.


/// Compute old and new unique property value hashes.
/// Ensure new property value hashes with `unique` flag set are `unique` on `Class` level
pub fn ensure_property_values_hashes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensure checkers has a name that does not really indicate a clear purpose.

Closer inspection shows that it seems to do three things

  1. check that new property values respect uniquness constraint
  2. if so, compute hashes representing these values values
  3. if so, determine what hashes must be removed from the uniquness index because they represent values that will no longer be in directory.

It seems that only 1 or 2 are really part of the ensure check, and you could perhaps have one checker with a name like ensure_new_property_values_respect_uniquness. It can then return hashes in success case. Then for 3, which is only relevant if you go to mutation, you do the call to compute_old_unique_hashes somewhere else. Could be a standalone call, or it could be inside remove_unique_property_value_hashes or something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, refactored it here 673fcb3
Thank you for the good explanation!

@iorveth iorveth requested a review from bedeho August 15, 2020 00:11
@bedeho bedeho merged commit 5000ca8 into Joystream:content_directory_second_try Aug 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants