Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Refactor ownership pallet to transfer ownership of spaces, posts and domains #255

Merged
merged 26 commits into from
Mar 27, 2024

Conversation

F3Joule
Copy link
Member

@F3Joule F3Joule commented Feb 22, 2024

Release Checklist

@F3Joule F3Joule self-assigned this Feb 22, 2024
@F3Joule F3Joule added the enhancement New feature or request label Feb 22, 2024
@F3Joule F3Joule marked this pull request as ready for review February 27, 2024 10:53
@F3Joule F3Joule changed the title feat: Add ownership transfers for domains feat!: Refactor ownership pallet to transfer ownership of spaces, posts and domains Feb 27, 2024
@F3Joule
Copy link
Member Author

F3Joule commented Mar 21, 2024

Extirnsics ordering (metadata comparison) check results:

----------------------------------------------------------------------
Metadata comparison:
Date: Thu 21 Mar 2024 15:11:08 EET
Reference: wss://para.subsocial.network
Target version: subsocial-collator 0.2.2-18df14eead0
Chain: dev
----------------------------------------------------------------------
              [Spec] name: subsocial-parachain
                     spec_version: 41 -> 42
                     transaction_version: 8 -> 9
          [Metadata] version: 14
           [Modules] num: 38
                     [+] modules: Ownership
                     [-] modules: SpaceOwnership
                          [System] idx: 0 (calls: 8, storage: 17)
                 [ParachainSystem] idx: 1 (calls: 4, storage: 22)
                       [Timestamp] idx: 3 (calls: 1, storage: 3)
                        [Balances] idx: 10 (calls: 6, storage: 6)
                        [Treasury] idx: 12 (calls: 5, storage: 5)
               [CollatorSelection] idx: 21 (calls: 5, storage: 6)
                         [Session] idx: 22 (calls: 2, storage: 8)
                         [Vesting] idx: 26 (calls: 5, storage: 3)
                           [Proxy] idx: 27 (calls: 10, storage: 3)
                        [Multisig] idx: 29 (calls: 4, storage: 2)
                       [XcmpQueue] idx: 30 (calls: 9, storage: 11)
                     [PolkadotXcm] idx: 31 (calls: 10, storage: 12)
                        [DmpQueue] idx: 33 (calls: 1, storage: 6)
                         [Domains] idx: 60 (calls: 9, storage: 8)
                          [Energy] idx: 61 (calls: 2, storage: 4)
                       [FreeProxy] idx: 62 (calls: 1, storage: 2)
                  [CreatorStaking] idx: 63 (calls: 14, storage: 13)
                    [EvmAddresses] idx: 64 (calls: 2, storage: 3)
             [ResourceDiscussions] idx: 65 (calls: 2, storage: 2)
                           [Roles] idx: 71 (calls: 8, storage: 6)
                  [AccountFollows] idx: 72 (calls: 3, storage: 4)
                        [Profiles] idx: 73 (calls: 3, storage: 2)
                    [SpaceFollows] idx: 74 (calls: 3, storage: 4)
                          [Spaces] idx: 76 (calls: 4, storage: 4)
                     [PostFollows] idx: 77 (calls: 2, storage: 4)
                           [Posts] idx: 78 (calls: 6, storage: 6)
                       [Reactions] idx: 79 (calls: 6, storage: 5)
                            [Sudo] idx: 255 (calls: 4, storage: 2)

------------------------------ SUMMARY -------------------------------
⚠️ This filter is here to help spotting changes that should be reviewed carefully.
⚠️ It catches only index changes, deletions and value decreases.
## Deletions
 13: [-] modules: SpaceOwnership
46: 13: [-] modules: SpaceOwnership
71: [-] modules: SpaceOwnership

## Index changes
 n/a
## Decreases
 n/a
----------------------------------------------------------------------

Copy link
Member

Choose a reason for hiding this comment

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

Rename to ownership_utils.rs?

Copy link
Member Author

@F3Joule F3Joule Mar 22, 2024

Choose a reason for hiding this comment

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

All appropriate renames will be considered in a separate pull request.

/// Account is already an owner of a space.
AlreadyASpaceOwner,
/// Account is already an owner of an entity.
AlreadyOwner,
/// Cannot transfer ownership, because a space is registered as an active creator.
ActiveCreatorCannotTransferOwnership,
Copy link
Member

Choose a reason for hiding this comment

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

This error is pretty specific to Creator Staking.
But from another side, we are cleaning up creator staking and this should not be relevant anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

As the creator staking logic still exists on a chain, we should consider it properly. Once creator-staking is removed/refactored, we will eliminate this error case.

@@ -108,7 +108,7 @@ fn accept_pending_ownership_should_fail_if_origin_is_already_an_owner() {

assert_noop!(
_accept_pending_ownership(Some(RuntimeOrigin::signed(ACCOUNT1)), None),
SpaceOwnershipError::<TestRuntime>::AlreadyASpaceOwner
SpaceOwnershipError::<TestRuntime>::NotAllowedToAcceptOwnershipTransfer,
Copy link
Member

Choose a reason for hiding this comment

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

why renamed?

Copy link
Member Author

@F3Joule F3Joule Mar 22, 2024

Choose a reason for hiding this comment

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

Previously this error was related to space ownership, from now on we need more generalized error for it.
We can do CurrentOwnerCannotAcceptOwnershipTransfer, then this error will be more specific.

pallets/space-ownership/tests/src/tests.rs Outdated Show resolved Hide resolved
runtime/src/lib.rs Outdated Show resolved Hide resolved
pallets/posts/src/functions.rs Outdated Show resolved Hide resolved
pallets/space-ownership/src/lib.rs Show resolved Hide resolved
pallets/space-ownership/src/lib.rs Outdated Show resolved Hide resolved
pallets/domains/src/lib.rs Outdated Show resolved Hide resolved
pallets/domains/src/lib.rs Outdated Show resolved Hide resolved
@F3Joule F3Joule requested a review from siman March 27, 2024 11:30
@F3Joule
Copy link
Member Author

F3Joule commented Mar 27, 2024

Try-runtime results:

2024-03-27 16:29:39 initialized state externalities with storage root 0xbd86c261ca929f32d420c60785413d9549c8b14244b6a0c44e20de711f429c46 and state_version V0
2024-03-27 16:29:40 original spec: RuntimeString::Owned("subsocial-parachain")-41, code hash: 90df05114de5eab279cbf617e0a797f55d66ed586ad54806deba4fa144cf3b69
2024-03-27 16:29:40 new spec: RuntimeString::Owned("subsocial-parachain")-42, code hash: ea701508ee019da2283b7b5d3001ba80bf3aa41484dd0c51ba9445c71e9b1019
2024-03-27 16:29:40 Running migration to clean-up the old pallet name SpaceOwnership
2024-03-27 16:29:40 Removed 6 records from the old pallet SpaceOwnership
2024-03-27 16:29:40 ⚠️ ParachainSystem declares internal migrations (which *might* execute). On-chain `StorageVersion(2)` vs current storage version `StorageVersion(2)`
2024-03-27 16:29:40 ⚠️ XcmpQueue declares internal migrations (which *might* execute). On-chain `StorageVersion(3)` vs current storage version `StorageVersion(2)`
2024-03-27 16:29:40 ⚠️ PolkadotXcm declares internal migrations (which *might* execute). On-chain `StorageVersion(0)` vs current storage version `StorageVersion(1)`
2024-03-27 16:29:40 ⚠️ DmpQueue declares internal migrations (which *might* execute). On-chain `StorageVersion(2)` vs current storage version `StorageVersion(1)`
2024-03-27 16:29:41 TryRuntime_on_runtime_upgrade executed without errors. Consumed weight = (500200000000 ps, 5242880 byte), total weight = (500000000000 ps, 5242880 byte) (100.04 %, 100.00 %).

@F3Joule F3Joule merged commit ed4da8c into main Mar 27, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants