Skip to content

Commit

Permalink
Upgrade to current version in the deployment script (#42)
Browse files Browse the repository at this point in the history
* Fix initial version in deployment script

* Unset Foundry RPC URL before running Forge tests
  • Loading branch information
DrZoltanFazekas authored Feb 11, 2025
1 parent 72ee0c2 commit cf2bef2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ You will see an output like this:
Proxy deployed: 0x7A0b7e6D24eDe78260c9ddBD98e828B0e11A8EA2
Implementation deployed: 0x7C623e01c5ce2e313C223ef2aEc1Ae5C6d12D9DD
Owner is 0x15fc323DFE5D5DCfbeEdc25CEcbf57f676634d77
New implementation deployed: 0xFf6d41b0567d7368e60B064F4dCbd6681cBC31A7
Upgraded to version: 0.3.0
```

Expand All @@ -70,7 +69,7 @@ The output will look like this:
Upgrading from version: 0.3.0
Owner is 0x15fc323DFE5D5DCfbeEdc25CEcbf57f676634d77
New implementation deployed: 0x64Fa96a67910956141cc481a43f242C045c10165
Upgraded to version: 0.3.3
Upgraded to version: 0.3.4
```

If you want to check the current version your contract was upgraded to, run
Expand All @@ -90,7 +89,7 @@ forge script script/Configure.s.sol --broadcast --legacy --sig "commissionRate(a

The output will contain the following information:
```
Running version: 0.3.3
Running version: 0.3.4
Commission rate: 0.0%
New commission rate: 10.0%
```
Expand All @@ -117,7 +116,7 @@ forge script script/Configure.s.sol --broadcast --legacy --sig "commissionReceiv

The output will contain the following information:
```
Running version: 0.3.3
Running version: 0.3.4
Commission receiver: 0x15fc323DFE5D5DCfbeEdc25CEcbf57f676634d77
New commission receiver: 0xeA78aAE5Be606D2D152F00760662ac321aB8F017
```
Expand Down Expand Up @@ -208,7 +207,7 @@ with the private key of delegator account. It's important to make sure the accou

The output will look like this for liquid staking:
```
Running version: 0.3.3
Running version: 0.3.4
Current stake: 10000000000000000000000000 wei
Current rewards: 110314207650273223687 wei
LST address: 0x9e5c257D1c6dF74EaA54e58CdccaCb924669dc83
Expand All @@ -217,7 +216,7 @@ The output will look like this for liquid staking:
```
and like this for the non-liquid variant:
```
Running version: 0.3.3
Running version: 0.3.4
Current stake: 10000000000000000000000000 wei
Current rewards: 110314207650273223687 wei
Staker balance before: 99899145245801454561224 wei
Expand All @@ -244,7 +243,7 @@ using the private key of an account that holds some LST in case of the liquid va

The output will look like this for liquid staking:
```
Running version: 0.3.3
Running version: 0.3.4
Current stake: 10000000000000000000000000 wei
Current rewards: 331912568306010928520 wei
LST address: 0x9e5c257D1c6dF74EaA54e58CdccaCb924669dc83
Expand All @@ -253,7 +252,7 @@ The output will look like this for liquid staking:
```
and like this for the non-liquid variant:
```
Running version: 0.3.3
Running version: 0.3.4
Current stake: 10000000000000000000000000 wei
Current rewards: 331912568306010928520 wei
Staker balance before: 99698814298179759361224 wei
Expand All @@ -268,7 +267,7 @@ with the private key of the account that unstaked in the previous step.

The output will look like this:
```
Running version: 0.3.3
Running version: 0.3.4
Staker balance before: 99698086421983460161224 wei
Staker balance after: 99798095485861371162343 wei
```
Expand Down Expand Up @@ -321,10 +320,12 @@ Staking pool operators are encouraged to fork and adapt the above contracts to i

The tests included in this repository should also be adjusted and extended accordingly. They can be executed by running
```bash
unset FOUNDRY_ETH_RPC_URL
forge test
```
or
```bash
unset FOUNDRY_ETH_RPC_URL
forge test -vv
```
if you want to see the values calculated in the tests.
Expand Down
10 changes: 10 additions & 0 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ contract Deploy is Script {
delegation.owner()
);

bytes memory reinitializerCall = abi.encodeWithSignature(
"reinitialize(uint64)",
1
);

delegation.upgradeToAndCall(
implementation,
reinitializerCall
);

(uint24 major, uint24 minor, uint24 patch) = delegation.decodedVersion();
console.log("Upgraded to version: %s.%s.%s",
uint256(major),
Expand Down
2 changes: 1 addition & 1 deletion src/BaseDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract contract BaseDelegation is IDelegation, PausableUpgradeable, Ownable2St
// contract file names remain the same across all versions
// so that the upgrade script does not need to be modified
// to import the new version each time there is one
uint64 internal immutable VERSION = encodeVersion(0, 3, 3);
uint64 internal immutable VERSION = encodeVersion(0, 3, 4);

function version() public view returns(uint64) {
return _getInitializedVersion();
Expand Down
1 change: 0 additions & 1 deletion src/LiquidDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ contract LiquidDelegation is BaseDelegation, ILiquidDelegation {
__BaseDelegation_init(initialOwner);
LiquidDelegationStorage storage $ = _getLiquidDelegationStorage();
$.lst = address(new NonRebasingLST(address(this), name, symbol));
migrate(1);
}

// called when stake withdrawn from the deposit contract is claimed
Expand Down
1 change: 0 additions & 1 deletion src/NonLiquidDelegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ contract NonLiquidDelegation is BaseDelegation, INonLiquidDelegation {

function initialize(address initialOwner) public initializer {
__BaseDelegation_init(initialOwner);
migrate(1);
}

// called when stake withdrawn from the deposit contract is claimed
Expand Down

0 comments on commit cf2bef2

Please sign in to comment.