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

Migrate token ownership to separate storage map #724

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

JasonTulp
Copy link
Contributor

@JasonTulp JasonTulp commented Oct 26, 2023

This PR moves token ownership in the NFT pallet to it's own map. This allows for easier querying of the collection_info struct and avoids massive delays when querying large sets of data. The owned_tokens RPC call should be used to get ownership information for individual accounts.

Jira link: TRN-240
Note, also fixes TRN-225

@@ -280,13 +280,13 @@ where
current_owner: &T::AccountId,
new_owner: &T::AccountId,
) -> DispatchResult {
let collection_info = pallet_nft::CollectionInfo::<T>::get(collection_id)
let ownership_info = pallet_nft::OwnershipInfo::<T>::get(collection_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

wonder if we can remove this FuturepassMigrator code now. maybe in a separate PR.

…-ownership

# Conflicts:
#	pallet/nft/src/types.rs
#	runtime/src/migrations/mod.rs
@JasonTulp JasonTulp marked this pull request as ready for review November 21, 2023 22:59
// Construct ownership info out of old ownership info
let token_ownership_old = collection_info.owned_tokens;
let mut token_ownership_new = TokenOwnership::default();
token_ownership_old.iter().for_each(|ownership| {
Copy link
Contributor

@surangap surangap Nov 22, 2023

Choose a reason for hiding this comment

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

What are the maximum entries we expect here for the largest collection on mainnet?. might need to do a simple calculation for the memory requirement?
fork testing on mainnet with prod hardware constraint would also do.

Comment on lines +189 to +195
let collection_id_key = Twox64Concat::hash(&collection_id.encode());
Map::unsafe_storage_put::<TokenOwnership<AccountId, MaxTokensPerCollection>>(
b"Nft",
b"OwnershipInfo",
&collection_id_key,
token_ownership_new,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we use normal put here?

Copy link
Contributor

@surangap surangap left a comment

Choose a reason for hiding this comment

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

looks good. added some comments on the migrations. might be a heavy migration.

…-ownership

# Conflicts:
#	pallet/nft/src/tests.rs
@JasonTulp JasonTulp mentioned this pull request Mar 19, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants