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

Refactor ManagedPool constructor arguments #2078

Merged
merged 5 commits into from
Dec 1, 2022

Conversation

nventuro
Copy link
Contributor

Description

This modifies the constructor of ManagedPool and ManagedPoolSettings so that there's more structs and fewer variables, reducing stack pressure and allowing us to add more constructor parameters.

We now have three structs:

  • one for Settings params
  • one for factory-provided params (e.g. the Vault, the WeightedMath contract, the pause durations, etc)
  • one for non-settings user-provided params (e.g. name)

This means the factory can create its params while the user provides the other two structs. The owner is standalone since the factory will likely create the owner, so we don't want to put it in the structs.

We could alternatively have the factory have its own structs, decoupled from the Pool's (which makes a lot of sense), but that was a bigger change.


This was much more painful than it should've been, and debugging it was extremely annoying, having to chase params and deployments in multiple places. It shows our helpers are in dire need of modernization - WeightedPoolDeployer is an unholy abomination that is capable of deploying a bajillion unrelated things in multiple incompatible ways, and needs to head to the chopping block.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests are included for all code paths
  • The base branch is either master, or there's a description of how to merge

Issue Resolution

Part of #2042

@jubeira
Copy link
Contributor

jubeira commented Nov 30, 2022

I have an alternative in the works as part of the solution for #2026 that also reduces the stack pressure, but it's a bit more extensive to all pools (not just managed). I did a 'similar' argument split in the settings in #2075 when trying to add the version, but the result is pretty ugly: adding the version there doesn't feel right (with this split here it could work though).

While I think the split in this PR makes sense overall, I think we'll need some more work when we add the version to every pool. Can we hold this one for a bit and compare to the broader refactor?

@jubeira
Copy link
Contributor

jubeira commented Nov 30, 2022

@nventuro can we please evaluate this and #2080 in parallel? I think #2080 should also solve the stack pressure and give you more room, while also solving the version for good.

Again, we can also proceed with this and deal with the version later, but at some point when we move the version to the base layer we won't be able to dodge a larger refactor (weighted and stable are also tight with the stack).

Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

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

LGTM! Just one comment regarding JS types.

At a conceptual level I find it a bit weird to group name and symbol in a struct that applies just to managed, but for the purposes of this PR it should be fine. I do like the concept of factory vs user provided params 👍

@@ -204,11 +204,8 @@ export type ManagedPoolRights = {
};

export type ManagedPoolParams = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider refactoring these types so that they match the ones in the contracts.

This one e.g. is the settings params, and we are missing the new ManagedPoolParams and ManagedPoolConfigParams.

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 didn't do the refactor because I'm not a fan of how this ended up working (as mentioned in the original comment), and would rather change how this whole thing works tbh.

@nventuro
Copy link
Contributor Author

We don't actually need to worry about factory vs user provided, since we don't have to expose that same struct on the factory. We could (should) have entirely different structs for create, and decouple that from the Pool's constructor (which is never called directly by a user).

In this case it was convenient however, since we don't have said decoupling ready. But it doesn't have to remain this way.

Copy link
Collaborator

@EndymionJkb EndymionJkb left a comment

Choose a reason for hiding this comment

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

I especially like isolating the factory (Config) params.

We might have burned the branch name prematurely though; I'm sure there will be worse things later. It does seem like every time we breathe on this code we need to struggle for hours fitting it into the stack, so any help with that is very welcome. I call dibs on '-and-the-horse-it-rode-in-on'

address owner,
uint256 pauseWindowDuration,
uint256 bufferPeriodDuration
address[] memory asssetManagers,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
address[] memory asssetManagers,
address[] memory assetManagers,

Copy link
Contributor

Choose a reason for hiding this comment

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

🐍

params.tokens,
params.assetManagers
settingsParams.tokens,
asssetManagers
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
asssetManagers
assetManagers

@@ -54,7 +55,6 @@ export type WeightedPoolDeployment = {
owner?: string;
admin?: SignerWithAddress;
from?: SignerWithAddress;
mockContractName?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also be removed from TypesConverter.ts.

@nventuro nventuro merged commit 38a8381 into master Dec 1, 2022
@nventuro nventuro deleted the i-hate-solc-and-everything-with-it branch December 1, 2022 15:11
@jubeira jubeira mentioned this pull request Dec 6, 2022
9 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.

4 participants