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

Improve nesting #235

Merged
merged 10 commits into from
Oct 31, 2022
Merged

Improve nesting #235

merged 10 commits into from
Oct 31, 2022

Conversation

Szegoo
Copy link
Contributor

@Szegoo Szegoo commented Oct 23, 2022

Closes: #223

@ilionic ilionic requested a review from HashWarlock October 23, 2022 18:03
@Szegoo
Copy link
Contributor Author

Szegoo commented Oct 23, 2022

Just realized that this may be a bit early for a review(that is why I deleted the previous message), will ping you when it will be ready :)

@Szegoo Szegoo marked this pull request as draft October 23, 2022 18:05
@ilionic ilionic removed the request for review from HashWarlock October 23, 2022 18:07
@Szegoo Szegoo marked this pull request as ready for review October 24, 2022 16:28
pallets/rmrk-core/src/lib.rs Outdated Show resolved Hide resolved
@Szegoo
Copy link
Contributor Author

Szegoo commented Oct 24, 2022

@ilionic This is ready for review, other than the burn_nft I couldn't find any other functions that have recursion. Are these the only ones?

@ilionic
Copy link
Contributor

ilionic commented Oct 24, 2022

Thanks @Szegoo. That's correct, recursive calls are only related to burning and root owner lookup.
Also please check unit tests:

error[E0046]: not all trait items implemented, missing: `NestingBudget`
   --> pallets/rmrk-market/src/mock.rs:107:1
    |
107 | impl pallet_rmrk_core::Config for Test {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `NestingBudget` in implementation

@@ -73,8 +73,6 @@ pub struct NftChild {
/// Abstraction over a Nft system.
#[allow(clippy::upper_case_acronyms)]
pub trait Nft<AccountId, BoundedString, BoundedResourceVec> {
type MaxRecursions: Get<u32>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need MaxRecursions.

@HashWarlock
Copy link
Contributor

Do we prevent this scenario when sending/minting NFTs to NFTs? If we are able to get a Budget from lookup_root_owner, could we prevent this scenario from happening?

Nested-Logic-Q

@Szegoo
Copy link
Contributor Author

Szegoo commented Oct 26, 2022

If we are able to get a Budget from lookup_root_owner, could we prevent this scenario from happening?

Not sure I understand this totally correctly but did you mean that we should somehow be able to get the Budget that is needed to look up the owner?

Edit: Maybe the functions that deal with budget should make it possible(but optional) to define the budget. For example:

fn property_set(
	sender: T::AccountId,
	collection_id: CollectionId,
        maybe_nft_id: Option<NftId>,
	key: KeyLimitOf<T>,
	value: ValueLimitOf<T>,
        budget: Option<&dyn Budget> // <- we add this to the functions that deal with budget.
) -> DispatchResult {

If the function is called with None we simply use the NestingBudget.
When we add benchmarks the weight could be calculated based on the budget provided.

This would make it possible to look up the owner for any asset(of course it will cost more if the nft is deeply nested)

Edit: AFAIU Doing nft_mint_directly_to_nft will fail if the nft that we are trying to mint up on is too deeply nested. Sorry if I didn't understand you correctly. @HashWarlock

Copy link
Contributor

@HashWarlock HashWarlock left a comment

Choose a reason for hiding this comment

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

LGTM

@ilionic ilionic merged commit cd298ac into rmrk-team:main Oct 31, 2022
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.

Improve nesting / recursive calls
3 participants