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

Pallet pools registry #974

Closed
wants to merge 67 commits into from
Closed

Pallet pools registry #974

wants to merge 67 commits into from

Conversation

gruberb
Copy link
Contributor

@gruberb gruberb commented Sep 14, 2022

Closes #956

@gruberb gruberb added D7-essential Pull request essentially changes code. New Release needed. Audit would be nice. D5-breaks-api Pull request changes public api. Document changes publicly. crcl-runtime Circle runtime related. D8 - migration labels Sep 14, 2022
@NunoAlexandre
Copy link
Contributor

@gruberb do we have a timeline to get this merged?

@NunoAlexandre NunoAlexandre mentioned this pull request Sep 20, 2022
7 tasks
@gruberb
Copy link
Contributor Author

gruberb commented Sep 20, 2022

@gruberb do we have a timeline to get this merged?

This will be a bigger change. In the first version, we are aiming to move out the create, update and set_metadata extrinsic of pools and move them to pools-registry. It's a bigger refactor, with possible migrations involved, so I hope in 2 weeks? I am still not up-to-speed on everything so takes a bit of time.

Do you have a pressing issue which requires this change to be done sooner?

@mikiquantum mikiquantum changed the base branch from parachain to main September 23, 2022 22:59
Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

Just a first look at formal stuff. Cargo and license. In general everywhere license on top ^^

@gruberb gruberb marked this pull request as ready for review October 19, 2022 09:12
@mustermeiszer
Copy link
Collaborator

Are we planning on bringing this in in this state and iterate over it?

@gruberb
Copy link
Contributor Author

gruberb commented Oct 19, 2022

Are we planning on bringing this in in this state and iterate over it?

It depends... the full re-write on bringing pallet-pools to state where we have pools-registry and pools-system takes some time. I ran against a few walls, and once the code is done, we have to re-write almost all tests, re-run benchmarks etc. My gut feeling tells me this takes longer than the 2 weeks we are eying to get these changes in.

So one idea from @offerijns was to have a first step, have the events and the first extrinsics in pools-registry, and then in the next iteration, do the slightly bigger change.

Copy link
Contributor

@thea-leake thea-leake left a comment

Choose a reason for hiding this comment

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

LGTM, I have a few questions, but nothing blocking :)

assert_eq!(pool.parameters.min_epoch_time, SECS_PER_DAY);
assert_eq!(pool.parameters.max_nav_age, SECS_PER_HOUR);
}
// create {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be nice to have a comment explaining why this section is here but commented out, but I'm fine with it as is.

@NunoAlexandre NunoAlexandre self-requested a review October 21, 2022 07:55
@NunoAlexandre
Copy link
Contributor

@gruberb I would like to review this before it gets merged. Can I do that today or Monday?

@gruberb
Copy link
Contributor Author

gruberb commented Oct 21, 2022

@gruberb I would like to review this before it gets merged. Can I do that today or Monday?

Sorry, yes, this could be back in Draft. I am currently updating the tests, and then it could be merged. So yeah, Monday/Tuesday is totally fine, hope to get this in by Wednesday next week!

Copy link
Contributor

@hieronx hieronx left a comment

Choose a reason for hiding this comment

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

First pass mostly with a bunch of small naming/comments changes

Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

Left some comments where changes are needed. I would also not bring in the weight changes with this PR. We should have a separate PR for updating the weights of the runtimes. WDYT?

Comment on lines +132 to +135
pub pool_admin: PoolAdminRoles,
pub currency_admin: CurrencyAdminRoles,
pub permissioned_asset_holder: PermissionedCurrencyHolders<Now, MinDelay, Moment>,
pub tranche_investor: TrancheInvestors<Now, MinDelay, TrancheId, Moment>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need them public? Not against it, just curious and wondering if we should make it an API with methods on the struct rather than making them public.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's all because we have cfg-types and cfg-traits. Inside cfg-traits, we depend on cfg-types. To prevent a circular dependency, we can't rely on cfg-traits inside cfg-types. Which moves the impl traits out of types and into traits. We need to test the impl functions inside traits.

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 know if my answer makes sense. I also don't like, but for how we currently structure everything, it's hard not to make them public (with testing and everything).

Copy link
Collaborator

Choose a reason for hiding this comment

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

At the current commit of main. There is solely a dev dependency that is not even used. I am not sure, where the issue came from. But I think we can agree, that traits is stand alone and types can depend on traits and implement them.

@gruberb
Copy link
Contributor Author

gruberb commented Oct 27, 2022

Left some comments where changes are needed. I would also not bring in the weight changes with this PR. We should have a separate PR for updating the weights of the runtimes. WDYT?

Yeah, I test ran the weights to see if they are working. Reverted them back to the previous values 👍

Copy link
Collaborator

@mustermeiszer mustermeiszer left a comment

Choose a reason for hiding this comment

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

We need to rethink about this restructuring made here. And I have the feeling this is too rushed to bring this in in this state.

Comment on lines +132 to +135
pub pool_admin: PoolAdminRoles,
pub currency_admin: CurrencyAdminRoles,
pub permissioned_asset_holder: PermissionedCurrencyHolders<Now, MinDelay, Moment>,
pub tranche_investor: TrancheInvestors<Now, MinDelay, TrancheId, Moment>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

At the current commit of main. There is solely a dev dependency that is not even used. I am not sure, where the issue came from. But I think we can agree, that traits is stand alone and types can depend on traits and implement them.

Comment on lines +371 to +387
impl TrancheCurrency<PoolId, TrancheId> for TrancheCurrencyT {
fn generate(pool_id: PoolId, tranche_id: TrancheId) -> Self {
Self {
pool_id,
tranche_id,
}
}

fn of_pool(&self) -> PoolId {
self.pool_id
}

fn of_tranche(&self) -> TrancheId {
self.tranche_id
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

This must not be 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.

The problem started when we moved pub trait PoolMutate<... into cfg-traits. This trait depends on TrancheInput and PoolChanges. Therefore, we need to depend on cfg-types inside cfg-traits.

Self::deposit_event(Event::UpdateRegistered { pool_id });

match state {
UpdateState::NoExecution => (),
Copy link
Collaborator

Choose a reason for hiding this comment

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

When would this happen? And what does this signal?

Copy link
Contributor Author

@gruberb gruberb Oct 27, 2022

Choose a reason for hiding this comment

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

Well if we do a Result<(UpdateState, PostDispatchInfo), DispatchErrorWithPostInfo> from fn update(), we need this. We have three different valid returns in this function, NoExecution is one of them. We also return this weight if we don't execute (if nothing changed):

Some(T::WeightInfo::update_no_execution(0)).into(),

Comment on lines +326 to +332
match T::ModifyPool::execute_update(pool_id) {
Ok(res) => {
Self::deposit_event(Event::UpdateExecuted { pool_id });
Ok(res)
}
Err(e) => Err(e),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

T::ModifyPool::execute_update(pool_id).map(|res| {
   Self::deposit_event(Event::UpdateExecuted { pool_id });
   res
})

Copy link
Contributor

Choose a reason for hiding this comment

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

We really want inspect, but alas it's not stable yet rust-lang/rust#91345

Comment on lines +1403 to +1406
impl<T: Config>
PoolMutate<
T::AccountId,
T::Balance,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is an impl file for trait impls.

@gruberb
Copy link
Contributor Author

gruberb commented Oct 27, 2022

Decided that the last changes into main threw quite a few things off with this PR. So I will close this, and jerry-pick just the relevant changes related to pallet-pool-registry and open up a new PR.

@gruberb gruberb closed this Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crcl-runtime Circle runtime related. D5-breaks-api Pull request changes public api. Document changes publicly. D7-essential Pull request essentially changes code. New Release needed. Audit would be nice.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create pools-registry pallet
6 participants