-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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) |
There was a problem hiding this comment.
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
// 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| { |
There was a problem hiding this comment.
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.
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, | ||
); |
There was a problem hiding this comment.
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?
There was a problem hiding this 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
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