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: add resetting removal charge fee #119

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions GAS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
| src/CSAccounting.sol:CSAccounting contract | | | | | |
|--------------------------------------------|-----------------|--------|--------|--------|---------|
| Function Name | min | avg | median | max | # calls |
| ADD_BOND_CURVE_ROLE | 275 | 275 | 275 | 275 | 160 |
| RESET_BOND_CURVE_ROLE | 296 | 296 | 296 | 296 | 200 |
| SET_BOND_CURVE_ROLE | 252 | 252 | 252 | 252 | 200 |
| ADD_BOND_CURVE_ROLE | 275 | 275 | 275 | 275 | 161 |
| RESET_BOND_CURVE_ROLE | 296 | 296 | 296 | 296 | 201 |
| SET_BOND_CURVE_ROLE | 252 | 252 | 252 | 252 | 201 |
| addBondCurve | 121302 | 121302 | 121302 | 121302 | 5 |
| getActualLockedBond | 559 | 665 | 719 | 719 | 3 |
| getBondAmountByKeysCount | 1325 | 1421 | 1325 | 1588 | 145 |
Expand All @@ -14,7 +14,7 @@
| getRequiredBondForNextKeys | 10130 | 33338 | 52630 | 53156 | 13 |
| getRequiredBondForNextKeysWstETH | 59024 | 59024 | 59024 | 59024 | 2 |
| getUnbondedKeysCount | 7752 | 24214 | 15752 | 46252 | 238 |
| grantRole | 118364 | 118367 | 118364 | 118376 | 560 |
| grantRole | 118364 | 118367 | 118364 | 118376 | 563 |


| src/CSEarlyAdoption.sol:CSEarlyAdoption contract | | | | | |
Expand Down Expand Up @@ -63,20 +63,20 @@
| DEFAULT_ADMIN_ROLE | 327 | 327 | 327 | 327 | 1 |
| DEPOSIT_SIZE | 285 | 285 | 285 | 285 | 10 |
| EL_REWARDS_STEALING_FINE | 328 | 328 | 328 | 328 | 5 |
| INITIALIZE_ROLE | 285 | 285 | 285 | 285 | 207 |
| INITIALIZE_ROLE | 285 | 285 | 285 | 285 | 208 |
| INITIAL_SLASHING_PENALTY | 352 | 352 | 352 | 352 | 3 |
| MAX_SIGNING_KEYS_BEFORE_PUBLIC_RELEASE | 315 | 315 | 315 | 315 | 1 |
| MODULE_MANAGER_ROLE | 328 | 328 | 328 | 328 | 204 |
| PAUSE_ROLE | 329 | 329 | 329 | 329 | 161 |
| PENALIZE_ROLE | 284 | 284 | 284 | 284 | 160 |
| MODULE_MANAGER_ROLE | 328 | 328 | 328 | 328 | 205 |
| PAUSE_ROLE | 329 | 329 | 329 | 329 | 162 |
| PENALIZE_ROLE | 284 | 284 | 284 | 284 | 161 |
| RECOVERER_ROLE | 305 | 305 | 305 | 305 | 5 |
| REPORT_EL_REWARDS_STEALING_PENALTY_ROLE | 286 | 286 | 286 | 286 | 162 |
| RESUME_ROLE | 308 | 308 | 308 | 308 | 161 |
| SETTLE_EL_REWARDS_STEALING_PENALTY_ROLE | 328 | 328 | 328 | 328 | 162 |
| STAKING_ROUTER_ROLE | 283 | 283 | 283 | 283 | 183 |
| VERIFIER_ROLE | 327 | 327 | 327 | 327 | 164 |
| REPORT_EL_REWARDS_STEALING_PENALTY_ROLE | 286 | 286 | 286 | 286 | 163 |
| RESUME_ROLE | 308 | 308 | 308 | 308 | 162 |
| SETTLE_EL_REWARDS_STEALING_PENALTY_ROLE | 328 | 328 | 328 | 328 | 163 |
| STAKING_ROUTER_ROLE | 315 | 315 | 315 | 315 | 184 |
| VERIFIER_ROLE | 327 | 327 | 327 | 327 | 165 |
| accounting | 470 | 470 | 470 | 470 | 1 |
| activatePublicRelease | 23726 | 46545 | 46677 | 46677 | 174 |
| activatePublicRelease | 23726 | 46545 | 46677 | 46677 | 175 |
| addNodeOperatorETH | 26187 | 603792 | 547331 | 1072493 | 145 |
| addNodeOperatorStETH | 26952 | 367369 | 535320 | 539835 | 3 |
| addNodeOperatorWstETH | 26974 | 379438 | 553131 | 558210 | 3 |
Expand All @@ -87,7 +87,7 @@
| cleanDepositQueue | 26304 | 36076 | 33834 | 53080 | 12 |
| confirmNodeOperatorManagerAddressChange | 23668 | 28993 | 29053 | 34142 | 5 |
| confirmNodeOperatorRewardAddressChange | 23713 | 33103 | 33992 | 38940 | 6 |
| decreaseOperatorVettedKeys | 24802 | 91377 | 107417 | 155133 | 15 |
| decreaseOperatorVettedKeys | 24834 | 91409 | 107449 | 155165 | 15 |
| depositQueueItem | 646 | 1246 | 646 | 2646 | 10 |
| earlyAdoption | 471 | 471 | 471 | 471 | 1 |
| getNodeOperator | 2236 | 9866 | 8236 | 20236 | 276 |
Expand All @@ -97,14 +97,14 @@
| getNonce | 380 | 680 | 380 | 2380 | 40 |
| getStakingModuleSummary | 618 | 2751 | 2618 | 4618 | 15 |
| getType | 383 | 383 | 383 | 383 | 1 |
| grantRole | 26942 | 51434 | 51450 | 51450 | 1547 |
| grantRole | 26942 | 51434 | 51450 | 51450 | 1556 |
| hasRole | 725 | 725 | 725 | 725 | 2 |
| isPaused | 419 | 819 | 419 | 2419 | 5 |
| normalizeQueue | 30255 | 54734 | 54734 | 79213 | 2 |
| obtainDepositData | 24421 | 107050 | 96713 | 158508 | 43 |
| onExitedAndStuckValidatorsCountsUpdated | 23638 | 23671 | 23671 | 23704 | 2 |
| onRewardsMinted | 23932 | 32087 | 26167 | 46163 | 3 |
| onWithdrawalCredentialsChanged | 23684 | 23717 | 23717 | 23750 | 2 |
| obtainDepositData | 24453 | 107082 | 96745 | 158540 | 43 |
| onExitedAndStuckValidatorsCountsUpdated | 23670 | 23703 | 23703 | 23736 | 2 |
| onRewardsMinted | 23964 | 32119 | 26199 | 46195 | 3 |
| onWithdrawalCredentialsChanged | 23782 | 25268 | 25011 | 27011 | 3 |
| pauseFor | 23988 | 45359 | 47497 | 47497 | 11 |
| proposeNodeOperatorManagerAddressChange | 24143 | 42592 | 53582 | 53582 | 9 |
| proposeNodeOperatorRewardAddressChange | 24143 | 33411 | 36460 | 36460 | 10 |
Expand All @@ -113,23 +113,23 @@
| recoverERC20 | 31840 | 48855 | 48855 | 65870 | 2 |
| recoverEther | 23740 | 26033 | 26033 | 28326 | 2 |
| recoverStETHShares | 69884 | 69884 | 69884 | 69884 | 1 |
| removalCharge | 2408 | 2408 | 2408 | 2408 | 1 |
| removalCharge | 408 | 1408 | 1408 | 2408 | 2 |
| removeKeys | 24026 | 145260 | 172276 | 240257 | 15 |
| reportELRewardsStealingPenalty | 24305 | 120509 | 136813 | 146818 | 14 |
| resetNodeOperatorManagerAddress | 23712 | 31857 | 31334 | 38464 | 5 |
| resume | 23707 | 26619 | 26619 | 29532 | 2 |
| revokeRole | 29529 | 29529 | 29529 | 29529 | 1 |
| setAccounting | 24268 | 46387 | 46497 | 46497 | 203 |
| setAccounting | 24268 | 46388 | 46497 | 46497 | 204 |
| setEarlyAdoption | 24006 | 38634 | 46475 | 46475 | 8 |
| setRemovalCharge | 23981 | 46928 | 47071 | 47083 | 162 |
| setRemovalCharge | 23981 | 46959 | 47101 | 47113 | 163 |
| settleELRewardsStealingPenalty | 24668 | 67429 | 38718 | 112093 | 7 |
| submitInitialSlashing | 24058 | 97674 | 134135 | 135035 | 12 |
| submitWithdrawal | 24283 | 121293 | 140959 | 234679 | 14 |
| unsafeUpdateValidatorsCount | 24231 | 61209 | 35897 | 159781 | 10 |
| updateExitedValidatorsCount | 24779 | 58480 | 47457 | 110185 | 11 |
| updateRefundedValidatorsCount | 24060 | 27647 | 27647 | 31234 | 2 |
| updateStuckValidatorsCount | 24756 | 72971 | 60488 | 138450 | 13 |
| updateTargetValidatorsLimits | 24247 | 118162 | 137399 | 210319 | 19 |
| unsafeUpdateValidatorsCount | 24263 | 61241 | 35929 | 159813 | 10 |
| updateExitedValidatorsCount | 24811 | 58512 | 47489 | 110217 | 11 |
| updateRefundedValidatorsCount | 24092 | 27679 | 27679 | 31266 | 2 |
| updateStuckValidatorsCount | 24788 | 73003 | 60520 | 138482 | 13 |
| updateTargetValidatorsLimits | 24279 | 118194 | 137431 | 210351 | 19 |


| src/CSVerifier.sol:CSVerifier contract | | | | | |
Expand Down
11 changes: 9 additions & 2 deletions src/CSModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
error MaxSigningKeysCountExceeded();
}

contract CSModule is

Check warning on line 136 in src/CSModule.sol

View workflow job for this annotation

GitHub Actions / Linters

Contract has 19 states declarations but allowed no more than 15
ICSModule,
CSModuleBase,
AccessControl,
Expand Down Expand Up @@ -253,6 +253,10 @@
function setRemovalCharge(
uint256 amount
) external onlyRole(MODULE_MANAGER_ROLE) {
_setRemovalCharge(amount);
}

function _setRemovalCharge(uint256 amount) internal {
removalCharge = amount;
emit RemovalChargeSet(amount);
}
Expand Down Expand Up @@ -865,7 +869,7 @@
function onExitedAndStuckValidatorsCountsUpdated()
external
onlyRole(STAKING_ROUTER_ROLE)
{

Check warning on line 872 in src/CSModule.sol

View workflow job for this annotation

GitHub Actions / Linters

Code contains empty blocks
// Nothing to do, rewards are distributed by a performance oracle.
}

Expand Down Expand Up @@ -933,8 +937,8 @@
/// @notice Validator private key might be lost
function voluntaryEjectValidator(
uint256 nodeOperatorId,
uint256 startIndex,

Check warning on line 940 in src/CSModule.sol

View workflow job for this annotation

GitHub Actions / Linters

Variable "startIndex" is unused
uint256 keysCount

Check warning on line 941 in src/CSModule.sol

View workflow job for this annotation

GitHub Actions / Linters

Variable "keysCount" is unused
) external onlyExistingNodeOperator(nodeOperatorId) {
onlyNodeOperatorManager(nodeOperatorId);
// TODO: implement
Expand Down Expand Up @@ -1132,12 +1136,15 @@
return (nodeOperatorId << 128) | keyIndex;
}

/// @notice Called when withdrawal credentials changed by DAO
/// @notice Called when withdrawal credentials changed by DAO and resets the keys removal charge
/// @dev Changing the WC means that the current keys in the queue are not valid anymore and can't be vetted to deposit
/// So, the removal charge should be reset to 0 to allow the node operator to remove the keys without any charge.
/// Then the DAO should set the new removal charge.
function onWithdrawalCredentialsChanged()
external
onlyRole(STAKING_ROUTER_ROLE)
{
// TODO: implement it
_setRemovalCharge(0);
}

function _addSigningKeys(
Expand Down
11 changes: 11 additions & 0 deletions test/CSModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,17 @@ contract CsmProposeNodeOperatorManagerAddressChange is CSMCommon {
}
}

contract CsmOnWithdrawalCredentialsChanged is CSMCommon {
function test_onWithdrawalCredentialsChanged() public {
vm.expectEmit(true, true, false, true, address(csm));
emit RemovalChargeSet(0 ether);
csm.onWithdrawalCredentialsChanged();

uint256 removalChargeAfter = csm.removalCharge();
assertEq(removalChargeAfter, 0 ether);
}
}

contract CsmConfirmNodeOperatorManagerAddressChange is CSMCommon {
function test_confirmNodeOperatorManagerAddressChange() public {
uint256 noId = createNodeOperator();
Expand Down
Loading