Skip to content

Conversation

@3esmit
Copy link
Contributor

@3esmit 3esmit commented Aug 18, 2025

Description

Introduce a new migration system for StakeVault being able to migrate on its own.
Fixes #242

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Added natspec comments?
  • Ran pnpm adorno?
  • Ran pnpm verify?

Copy link
Collaborator

@0x-r4bbit 0x-r4bbit left a comment

Choose a reason for hiding this comment

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

@3esmit I left some comments here.

Overall, I'm not really sure what's the benefit of this change.
To me it looks like we're introducing more complexity than necessary.

  • StakeVault now has a VaultFactory dependency
  • StakeVault now needs an additional migrate() function
  • StakeVault still calls into StakeManager (which I think is necessary anyway)

The only thing we seem to gain from this is that StakeManager doesn't have to call into StakeVault.migrateFromVault() anymore at the cost of needing additional checks in migrateToVault().

Are there any other things I'm missing here?
If not, I'm not sure this is improving the current code.

@gravityblast I'd also like your opinion on this.

}

if (STAKING_TOKEN.balanceOf(address(newVaultAddr)) < vaultData[migrateTo].stakedBalance) {
revert StakeManager__InvalidMigration();
Copy link
Collaborator

Choose a reason for hiding this comment

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

The check in L:384 is vacuous because in L:380 we already require that vaultData[migrateTo].stakedBalance == 0. STAKING_TOKEN.balanceOf(address(newVaultAddr)) can therefore never be < vault[migrateTo].stakedBalance

function migrateToVault(address migrateTo) external onlyNotEmergencyMode onlyTrustedCodehash onlyRegisteredVault {
if (vaultOwners[migrateTo] == address(0)) {
revert StakeManager__InvalidVault();
revert StakeManager__InvalidMigration();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason we're introducing a breaking change in the errors being emitted?

@3esmit
Copy link
Contributor Author

3esmit commented Aug 20, 2025

StakeVault now has a VaultFactory dependency

That is better than StakeManager depending on StakeVault, because VaultFactory code can be considered StakeVault code.

StakeVault now needs an additional migrate() function

Actually it's a new initializer, which can only be called on non initialized Clones, so its like an "overloaded constructor".

StakeVault still calls into StakeManager (which I think is necessary anyway)

The goal is to StakeManager be independent of StakeVault, as possible. Ideally, StakeManager should not even know StakeVault ABI. This would make the code more future proof and better testable.

@0x-r4bbit
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

Propose different vault migration system

3 participants