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

Fee controller migration contracts #1299

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

Conversation

EndymionJkb
Copy link
Collaborator

@EndymionJkb EndymionJkb commented Feb 18, 2025

Description

Based on #1307, this is the monorepo part of the ProtocolFeeController migration. It introduces a /governance-scripts package, and adds contracts used for the migration.

Turns out this is actually quite tricky! We might not have thought this all the way through during the original design.

With this in mind, there are two migration scripts. The original motivation for migrating was missing events that made it impossible to track protocol fee exempt pools from the beginning. There are no exempt pools yet, but this would be needed to support them. This PR adds those events - and also another one that will let us easily track pool creators (more on that later).

The first migration (from the one we launched with to the current version) can be simple, since we know there are no pools with creators yet, and no protocol fee exemptions or overrides. Given this, the migration is one-step, and can be performed using only functions available in the original deployment. The only assumption, besides those above, is that all the pools can be migrated within a block. Mainnet now has about 55 pools, so presumably that's not too many, since all we need to pass is the addresses, and they don't need to be stored.

However, future migrations cannot make these assumptions. There will eventually be pool creators, fee exemptions, and overrides. The problem is this state is only written by the Vault at registration time, or by pool creators, and there is no other way to initialize it. Supporting future migrations therefore requires adding some infrastructure to the new ProtocolFeeController so that this state becomes (safely) writeable.

See #1307 for the ProtocolFeeController changes.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Optimization: [ ] gas / [ ] bytecode
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests have 100% code coverage
  • The base branch is either main, or there's a description of how to merge

Issue Resolution

@jubeira jubeira requested review from joaobrunoah and jubeira and removed request for joaobrunoah February 18, 2025 18:45
@jubeira jubeira requested review from joaobrunoah, elshan-eth and jubeira and removed request for jubeira and elshan-eth February 18, 2025 18:45
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.

Thanks for putting this together so quickly @EndymionJkb.

Overall I think it looks good. I do have a few high level comments:

  • I think reviving the script to migrate in stages would be a good idea here. Just set everything offchain, then hit migrate. Governance only grants admin permissions, and the script can only do what was indicated during deployment time. No possibility to leave permissions hanging, nor requirements around granting more permissions.
  • I think there's an issue with the code introduced in registerPool. Not sure why it didn't make any test fail.
  • The implementation for migratePool makes sense. Perhaps we can migrate the bulk of the pools as part of the script but leave that one open (i.e. permissionless). Given that it can only port pools from the old controller only once the behavior seems to be pretty well constrained.

@EndymionJkb EndymionJkb changed the base branch from main to protocol-fee-controller-v2 February 19, 2025 02:10
# Conflicts:
#	pkg/interfaces/contracts/vault/IProtocolFeeController.sol
#	pkg/vault/contracts/ProtocolFeeController.sol
# Conflicts:
#	pkg/pool-stable/test/foundry/E2eBatchSwap.t.sol
#	pkg/pool-stable/test/foundry/E2eErc4626Swaps.t.sol
#	pkg/pool-stable/test/foundry/E2eSwapRateProvider.t.sol
#	pkg/pool-weighted/test/foundry/E2ESwapRateProvider.t.sol
# Conflicts:
#	pkg/pool-weighted/test/foundry/E2eSwap.t.sol
Base automatically changed from protocol-fee-controller-v2 to main February 20, 2025 22:46
# Conflicts:
#	pkg/interfaces/contracts/vault/IProtocolFeeController.sol
#	pkg/vault/contracts/ProtocolFeeController.sol
#	pkg/vault/test/foundry/ProtocolFeeController.t.sol
@EndymionJkb EndymionJkb requested a review from jubeira February 20, 2025 23:49
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