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

feat(script): add deployment script for new StakeManagers #72

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

0x-r4bbit
Copy link
Collaborator

This is needed to deploy individual new StakeManager instances in both, production environment and testing.

The script can be used as follows:

Within tests, to get a new StakeManager instance that has a reference to an older StakeManager instance, run:

function setUp() public virtual override {
    super.setUp();
    DeployMigrationStakeManager deployment = new DeployMigrationStakeManager(address(stakeManager), stakeToken);
    newStakeManager = deployment.run();
}

Where address(stakeManager) is the address of the current StakeManager and stakeToken is the address of the stake token.

To deploy a new instance from the CLI using forge, one can make use of the PREV_STAKE_MANAGER and STAKE_TOKEN_ADDRESS environment variables like this:

$ PREV_STAKE_MANAGER=0x123 STAKE_TOKEN_ADDRES=0x456 forge script script/DeployMigrationStakeManager.s.sol

The script will revert when STAKE_TOKEN_ADDRESS is address(0).

Closes #71

Checklist

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

  • Added natspec comments?
  • Ran forge snapshot?
  • Ran pnpm gas-report?
  • Ran pnpm lint?
  • Ran forge test?
  • Ran pnpm verify?

@0x-r4bbit 0x-r4bbit mentioned this pull request Feb 28, 2024
6 tasks

if (stakeToken == address(0)) {
revert DeployMigrationStakeManager_InvalidStakeTokenAddress();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Theoretically, we can extend this and say, if prevStakeManager != address(0), then we query the stakeToken() address from the old manager.

This is needed to deploy individual new `StakeManager` instances in
both, production environment and testing.

The script can be used as follows:

Within tests, to get a new `StakeManager` instance that has a reference
to an older `StakeManager` instance, run:

```solidity
function setUp() public virtual override {
    super.setUp();
    DeployMigrationStakeManager deployment = new DeployMigrationStakeManager(address(stakeManager), stakeToken);
    newStakeManager = deployment.run();
}
```

Where `address(stakeManager)` is the address of the current
`StakeManager` and `stakeToken` is the address of the stake token.

To deploy a new instance from the CLI using `forge`, one can make use of
the `PREV_STAKE_MANAGER` and `STAKE_TOKEN_ADDRESS` environment variables
like this:

```sh
$ PREV_STAKE_MANAGER=0x123 STAKE_TOKEN_ADDRES=0x456 forge script script/DeployMigrationStakeManager.s.sol
```

The script will revert when `STAKE_TOKEN_ADDRESS` is `address(0)`.

Closes #71
@0x-r4bbit 0x-r4bbit force-pushed the feat/stakemanager-deployscript branch from 94d37d1 to a860f8f Compare February 28, 2024 12:59
}

vm.startBroadcast(broadcaster);
StakeManager stakeManager = new StakeManager(stakeToken, prevStakeManager);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another thing I've just realised, it probably makes sense to extend this so that it automatically activates migration in the old manager.

If we make this part of this script, however, it's probably less usable in the testing context (which I think would be fine, as in tests we can always just do new StakeManager() individually.

Let me know what you think.

@3esmit 3esmit merged commit d397466 into develop Feb 29, 2024
6 of 7 checks passed
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.

Introduce deploy script for stakemanager migration
2 participants