refactor(DeploymentConfig): remove proxy implementation address

This was a bandaid solution to easily allow for upgrade scripts.
We've changed those now to expect environment variables instead.
This allows us to change the dependencies without committing them to
version control.
This commit is contained in:
r4bbit
2025-04-02 11:55:22 +02:00
parent 22feed8dba
commit 309d765731
11 changed files with 57 additions and 60 deletions

View File

@@ -10,7 +10,7 @@
|-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------|
| fallback | 746 | 142733 | 190919 | 190943 | 447 |
| fallback | 746 | 142734 | 190919 | 190943 | 447 |
╰-------------------------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╯
╭-----------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -18,13 +18,13 @@
+===============================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| 4773681 | 23120 | | | | |
| 4734998 | 22941 | | | | |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| | | | | | |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-----------------------------------------------------+-----------------+---------+---------+---------+---------|
| run | 3975779 | 3975779 | 3975779 | 3975779 | 106 |
| run | 3956429 | 3956429 | 3956429 | 3956429 | 106 |
╰-----------------------------------------------------+-----------------+---------+---------+---------+---------╯
╭-----------------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -32,13 +32,13 @@
+=====================================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| 4547651 | 22072 | | | | |
| 4508300 | 21890 | | | | |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| | | | | | |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-----------------------------------------------------------+-----------------+---------+---------+---------+---------|
| runForTest | 3778602 | 3778602 | 3778602 | 3778602 | 10 |
| runForTest | 3759238 | 3759238 | 3759238 | 3759238 | 10 |
╰-----------------------------------------------------------+-----------------+---------+---------+---------+---------╯
╭-------------------------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -46,13 +46,13 @@
+=============================================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|-------------------------------------------------------------------+-----------------+---------+---------+---------+---------|
| 8398642 | 40053 | | | | |
| 8359938 | 39874 | | | | |
|-------------------------------------------------------------------+-----------------+---------+---------+---------+---------|
| | | | | | |
|-------------------------------------------------------------------+-----------------+---------+---------+---------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|-------------------------------------------------------------------+-----------------+---------+---------+---------+---------|
| run | 7319311 | 7319311 | 7319311 | 7319311 | 93 |
| run | 7299960 | 7299960 | 7299960 | 7299960 | 93 |
╰-------------------------------------------------------------------+-----------------+---------+---------+---------+---------╯
╭---------------------------------------------------------+-----------------+-----+--------+-----+---------╮
@@ -60,13 +60,13 @@
+==========================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| 0 | 9183 | | | | |
| 0 | 9022 | | | | |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| | | | | | |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|---------------------------------------------------------+-----------------+-----+--------+-----+---------|
| activeNetworkConfig | 597 | 597 | 597 | 597 | 320 |
| activeNetworkConfig | 455 | 455 | 455 | 455 | 320 |
╰---------------------------------------------------------+-----------------+-----+--------+-----+---------╯
╭---------------------------------------------------------------------+-----------------+---------+---------+---------+---------╮
@@ -74,7 +74,7 @@
+===============================================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|---------------------------------------------------------------------+-----------------+---------+---------+---------+---------|
| 5849117 | 28144 | | | | |
| 5871906 | 28253 | | | | |
|---------------------------------------------------------------------+-----------------+---------+---------+---------+---------|
| | | | | | |
|---------------------------------------------------------------------+-----------------+---------+---------+---------+---------|
@@ -184,7 +184,7 @@
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| getAccountVaults | 5230 | 5230 | 5230 | 5230 | 4 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| getVault | 1823 | 6610 | 1823 | 15823 | 4182 |
| getVault | 1823 | 6596 | 1823 | 15823 | 4182 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| initialize | 92752 | 92752 | 92752 | 92752 | 93 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -192,7 +192,7 @@
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| leave | 88837 | 88837 | 88837 | 88837 | 1 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| lock | 7040 | 42555 | 45950 | 84893 | 1034 |
| lock | 7040 | 42498 | 45950 | 84893 | 1034 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| migrateToVault | 9294 | 51723 | 16883 | 163832 | 4 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -220,17 +220,17 @@
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| setTrustedCodehash | 24238 | 24238 | 24238 | 24238 | 93 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| stake | 2639 | 128942 | 59967 | 225838 | 2668 |
| stake | 2639 | 129085 | 59967 | 225838 | 2668 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| stakedBalanceOf | 2622 | 2622 | 2622 | 2622 | 1 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMP | 805 | 1257 | 1257 | 1710 | 6 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMPAccrued | 385 | 1072 | 385 | 2385 | 4162 |
| totalMPAccrued | 385 | 1070 | 385 | 2385 | 4162 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMPStaked | 429 | 1115 | 429 | 2429 | 4165 |
| totalMPStaked | 429 | 1113 | 429 | 2429 | 4165 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| totalMaxMP | 407 | 1094 | 407 | 2407 | 4162 |
| totalMaxMP | 407 | 1092 | 407 | 2407 | 4162 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| totalRewardsAccrued | 407 | 407 | 407 | 407 | 3 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -238,15 +238,15 @@
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| totalShares | 597 | 597 | 597 | 597 | 6 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| totalStaked | 408 | 1094 | 408 | 2408 | 4169 |
| totalStaked | 408 | 1092 | 408 | 2408 | 4169 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| unstake | 38969 | 41446 | 38995 | 75006 | 269 |
| unstake | 38969 | 41472 | 38995 | 75006 | 269 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| updateAccount | 347677 | 347677 | 347677 | 347677 | 1 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| updateGlobalState | 15820 | 25876 | 29230 | 29230 | 8 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| updateVault | 31948 | 34031 | 31948 | 110579 | 1024 |
| updateVault | 31948 | 34054 | 31948 | 110579 | 1024 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
| upgradeTo | 10279 | 10895 | 10279 | 12745 | 4 |
|--------------------------------------------+-----------------+--------+--------+--------+---------|
@@ -274,7 +274,7 @@
|----------------------------------------+-----------------+--------+--------+--------+---------|
| leave | 12161 | 124868 | 66517 | 354279 | 4 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| lock | 12091 | 57976 | 61416 | 100356 | 1035 |
| lock | 12091 | 57919 | 61416 | 100356 | 1035 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| migrateToVault | 24782 | 75606 | 32371 | 212902 | 4 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
@@ -282,13 +282,13 @@
|----------------------------------------+-----------------+--------+--------+--------+---------|
| register | 12718 | 78090 | 78644 | 78644 | 366 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| stake | 12071 | 162801 | 75460 | 281406 | 2669 |
| stake | 12071 | 163003 | 75460 | 281406 | 2669 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| stakeManager | 369 | 369 | 369 | 369 | 365 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| trustStakeManager | 7580 | 7580 | 7580 | 7580 | 1 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| unstake | 12048 | 57761 | 54438 | 106028 | 270 |
| unstake | 12048 | 57787 | 54438 | 106028 | 270 |
|----------------------------------------+-----------------+--------+--------+--------+---------|
| withdraw | 20733 | 20733 | 20733 | 20733 | 1 |
╰----------------------------------------+-----------------+--------+--------+--------+---------╯
@@ -304,7 +304,7 @@
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| fallback | 708 | 6329 | 2301 | 374054 | 23163 |
| fallback | 708 | 6326 | 2301 | 374054 | 23163 |
|----------------------------------------------------+-----------------+------+--------+--------+---------|
| implementation | 346 | 2345 | 2346 | 2346 | 4349 |
╰----------------------------------------------------+-----------------+------+--------+--------+---------╯
@@ -330,7 +330,7 @@
+===============================================================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| 1204853 | 6015 | | | | |
| 1204853 | 6207 | | | | |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
| | | | | | |
|------------------------------------------------------------------------------------------+-----------------+-------+--------+-------+---------|
@@ -404,17 +404,17 @@
+==================================================================================================+
| Deployment Cost | Deployment Size | | | | |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| 770657 | 3987 | | | | |
| 770741 | 3987 | | | | |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| | | | | | |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| Function Name | Min | Avg | Median | Max | # Calls |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| approve | 29075 | 31500 | 29183 | 46259 | 2668 |
| approve | 29075 | 31502 | 29183 | 46259 | 2668 |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| balanceOf | 561 | 1352 | 561 | 2561 | 4956 |
| balanceOf | 561 | 1351 | 561 | 2561 | 4956 |
|---------------------------------------------+-----------------+-------+--------+-------+---------|
| mint | 33964 | 37135 | 34072 | 68248 | 2677 |
| mint | 33964 | 37136 | 34072 | 68248 | 2677 |
╰---------------------------------------------+-----------------+-------+--------+-------+---------╯
╭-----------------------------------------------------------------------------+-----------------+--------+--------+--------+---------╮

View File

@@ -6,15 +6,15 @@ EmergencyExitTest:test_EmergencyExitToAlternateAddress() (gas: 432421)
EmergencyExitTest:test_EmergencyExitWithLock() (gas: 430501)
EmergencyExitTest:test_EmergencyExitWithRewards() (gas: 418391)
EmergencyExitTest:test_OnlyOwnerCanEnableEmergencyMode() (gas: 39176)
FuzzTests:testFuzz_AccrueMP(uint128,uint64,uint64) (runs: 1000, μ: 372274, ~: 342639)
FuzzTests:testFuzz_AccrueMP_Relock(uint128,uint64,uint64,uint64) (runs: 1000, μ: 473256, ~: 444746)
FuzzTests:testFuzz_EmergencyExit(uint256,uint256) (runs: 1000, μ: 495593, ~: 486579)
FuzzTests:testFuzz_Lock(uint256,uint64) (runs: 1000, μ: 726644, ~: 725709)
FuzzTests:testFuzz_Relock(uint256,uint64,uint64) (runs: 1000, μ: 386617, ~: 362902)
FuzzTests:testFuzz_AccrueMP(uint128,uint64,uint64) (runs: 1000, μ: 373456, ~: 342655)
FuzzTests:testFuzz_AccrueMP_Relock(uint128,uint64,uint64,uint64) (runs: 1000, μ: 472165, ~: 444746)
FuzzTests:testFuzz_EmergencyExit(uint256,uint256) (runs: 1000, μ: 495256, ~: 486543)
FuzzTests:testFuzz_Lock(uint256,uint64) (runs: 1000, μ: 726736, ~: 725709)
FuzzTests:testFuzz_Relock(uint256,uint64,uint64) (runs: 1000, μ: 384630, ~: 362893)
FuzzTests:testFuzz_Rewards(uint256,uint256,uint256,uint16,uint16) (runs: 1000, μ: 594630, ~: 595934)
FuzzTests:testFuzz_Stake(uint256,uint64) (runs: 1000, μ: 288214, ~: 260814)
FuzzTests:testFuzz_Unstake(uint128,uint64,uint16,uint128) (runs: 1000, μ: 475988, ~: 448228)
FuzzTests:testFuzz_UpdateVault(uint128,uint64,uint64) (runs: 1000, μ: 372297, ~: 342662)
FuzzTests:testFuzz_Stake(uint256,uint64) (runs: 1000, μ: 288633, ~: 260818)
FuzzTests:testFuzz_Unstake(uint128,uint64,uint16,uint128) (runs: 1000, μ: 476844, ~: 448237)
FuzzTests:testFuzz_UpdateVault(uint128,uint64,uint64) (runs: 1000, μ: 373479, ~: 342678)
IntegrationTest:testStakeFoo() (gas: 1362727)
KarmaNFTTest:testApproveNotAllowed() (gas: 10507)
KarmaNFTTest:testGetApproved() (gas: 10531)
@@ -44,10 +44,10 @@ KarmaTest:testRemoveKarmaDistributorOnlyOwner() (gas: 88798)
KarmaTest:testRemoveUnknownKarmaDistributor() (gas: 41398)
KarmaTest:testTotalSupply() (gas: 331725)
KarmaTest:testTransfersNotAllowed() (gas: 40241)
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 9594708)
LeaveTest:test_LeaveShouldProperlyUpdateAccounting() (gas: 9617526)
LeaveTest:test_RevertWhenStakeManagerIsTrusted() (gas: 332331)
LeaveTest:test_TrustNewStakeManager() (gas: 9650451)
LockTest:test_LockFailsWithInvalidPeriod(uint256) (runs: 1000, μ: 382883, ~: 382908)
LeaveTest:test_TrustNewStakeManager() (gas: 9673268)
LockTest:test_LockFailsWithInvalidPeriod(uint256) (runs: 1000, μ: 382886, ~: 382908)
LockTest:test_LockFailsWithNoStake() (gas: 88865)
LockTest:test_LockFailsWithZero() (gas: 342393)
LockTest:test_LockMultipleTimesExceedMaxLock() (gas: 624582)
@@ -121,7 +121,7 @@ UnstakeTest:test_UnstakeOneAccountAndRewards() (gas: 467580)
UnstakeTest:test_UnstakeOneAccountWithLockUpAndAccruedMP() (gas: 560332)
UpdateVaultTest:test_UpdateAccount() (gas: 2391077)
UpgradeTest:test_RevertWhenNotOwner() (gas: 3562509)
UpgradeTest:test_UpgradeStakeManager() (gas: 9486617)
UpgradeTest:test_UpgradeStakeManager() (gas: 9509435)
VaultRegistrationTest:test_VaultRegistration() (gas: 63138)
WithdrawTest:testOwner() (gas: 15296)
WithdrawTest:test_CannotWithdrawStakedFunds() (gas: 347979)

View File

@@ -11,7 +11,7 @@ import { Karma } from "../src/Karma.sol";
contract DeployKarmaScript is BaseScript {
function run() public returns (Karma, DeploymentConfig) {
DeploymentConfig deploymentConfig = new DeploymentConfig(broadcaster);
(address deployer,,) = deploymentConfig.activeNetworkConfig();
(address deployer,) = deploymentConfig.activeNetworkConfig();
vm.startBroadcast(deployer);

View File

@@ -22,7 +22,7 @@ contract DeployKarmaNFTScript is BaseScript {
function _run(address karmaAddress) public returns (KarmaNFT, INFTMetadataGenerator, DeploymentConfig) {
DeploymentConfig deploymentConfig = new DeploymentConfig(broadcaster);
(address deployer,,) = deploymentConfig.activeNetworkConfig();
(address deployer,) = deploymentConfig.activeNetworkConfig();
vm.startBroadcast(deployer);

View File

@@ -10,7 +10,7 @@ import { INFTMetadataGenerator } from "../src/interfaces/INFTMetadataGenerator.s
contract DeployMetadataGenerator is BaseScript {
function run() public returns (INFTMetadataGenerator, DeploymentConfig) {
DeploymentConfig deploymentConfig = new DeploymentConfig(broadcaster);
(address deployer,,) = deploymentConfig.activeNetworkConfig();
(address deployer,) = deploymentConfig.activeNetworkConfig();
vm.startBroadcast(deployer);
string memory svgPrefix =

View File

@@ -15,7 +15,7 @@ import { VaultFactory } from "../src/VaultFactory.sol";
contract DeployStakeManagerScript is BaseScript {
function run() public returns (StakeManager, VaultFactory, DeploymentConfig) {
DeploymentConfig deploymentConfig = new DeploymentConfig(broadcaster);
(address deployer, address stakingToken,) = deploymentConfig.activeNetworkConfig();
(address deployer, address stakingToken) = deploymentConfig.activeNetworkConfig();
bytes memory initializeData = abi.encodeCall(StakeManager.initialize, (deployer, stakingToken));

View File

@@ -12,7 +12,6 @@ contract DeploymentConfig is Script {
struct NetworkConfig {
address deployer;
address stakingToken;
address currentImplProxy;
}
NetworkConfig public activeNetworkConfig;
@@ -44,23 +43,15 @@ contract DeploymentConfig is Script {
function getOrCreateAnvilEthConfig() public returns (NetworkConfig memory) {
MockToken stakingToken = new MockToken("Staking Token", "ST");
return NetworkConfig({ deployer: deployer, stakingToken: address(stakingToken), currentImplProxy: address(0) });
return NetworkConfig({ deployer: deployer, stakingToken: address(stakingToken) });
}
function getSepoliaConfig() public view returns (NetworkConfig memory) {
return NetworkConfig({
deployer: deployer,
stakingToken: SNT_ADDRESS_SEPOLIA,
currentImplProxy: STAKING_MANAGER_PROXY_ADDRESS_SEPOLIA
});
return NetworkConfig({ deployer: deployer, stakingToken: SNT_ADDRESS_SEPOLIA });
}
function getStatusNetworkSepoliaConfig() public view returns (NetworkConfig memory) {
return NetworkConfig({
deployer: deployer,
stakingToken: SNT_ADDRESS_STATUS_NETWORK_SEPOLIA,
currentImplProxy: address(0)
});
return NetworkConfig({ deployer: deployer, stakingToken: SNT_ADDRESS_STATUS_NETWORK_SEPOLIA });
}
// This function is a hack to have it excluded by `forge coverage` until

View File

@@ -8,9 +8,15 @@ import { IStakeManagerProxy } from "../src/interfaces/IStakeManagerProxy.sol";
import { DeploymentConfig } from "./DeploymentConfig.s.sol";
contract UpgradeStakeManagerScript is BaseScript {
error StakeManagerProxyAddressNotSet();
function run() public returns (address) {
address currentImplProxy = vm.envAddress("STAKE_MANAGER_PROXY_ADDRESS");
if (currentImplProxy == address(0)) {
revert StakeManagerProxyAddressNotSet();
}
DeploymentConfig deploymentConfig = new DeploymentConfig(broadcaster);
(address deployer,, address currentImplProxy) = deploymentConfig.activeNetworkConfig();
(address deployer,) = deploymentConfig.activeNetworkConfig();
return runWithAdminAndProxy(deployer, IStakeManagerProxy(currentImplProxy));
}

View File

@@ -21,7 +21,7 @@ contract KarmaTest is Test {
DeployKarmaScript karmaDeployment = new DeployKarmaScript();
(Karma _karma, DeploymentConfig deploymentConfig) = karmaDeployment.run();
karma = _karma;
(address deployer,,) = deploymentConfig.activeNetworkConfig();
(address deployer,) = deploymentConfig.activeNetworkConfig();
owner = deployer;
distributor1 = new KarmaDistributorMock();

View File

@@ -39,7 +39,7 @@ contract StakeManagerTest is StakeMath, Test {
DeployKarmaScript karmaDeployment = new DeployKarmaScript();
(StakeManager stakeManager, VaultFactory _vaultFactory, DeploymentConfig deploymentConfig) = deployment.run();
(address _deployer, address _stakingToken,) = deploymentConfig.activeNetworkConfig();
(address _deployer, address _stakingToken) = deploymentConfig.activeNetworkConfig();
streamer = stakeManager;
stakingToken = MockToken(_stakingToken);

View File

@@ -34,7 +34,7 @@ contract StakeVaultTest is Test {
DeployStakeManagerScript deployment = new DeployStakeManagerScript();
(StakeManager stakeManager, VaultFactory _vaultFactory, DeploymentConfig deploymentConfig) = deployment.run();
(, address _stakingToken,) = deploymentConfig.activeNetworkConfig();
(, address _stakingToken) = deploymentConfig.activeNetworkConfig();
streamer = stakeManager;
stakingToken = MockToken(_stakingToken);