-
Notifications
You must be signed in to change notification settings - Fork 16
Pectra upgrade #115
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
base: master
Are you sure you want to change the base?
Pectra upgrade #115
Changes from 33 commits
2a4e501
d5b1a1e
607aa38
03e6b6d
0a81b7e
bddc349
1f7b508
f5f8a40
8c82c52
8926347
7000731
01ba5b2
acd617c
d6d18be
a64a585
3d7aaae
8937e08
3d35d5f
b7e7d56
199b7d2
b0e59aa
cb996fa
4ae75c3
7f0f5c2
8bb6958
aeed0e2
717a387
d162236
5f3132e
8d365bd
d7ccb26
28790a0
a76adec
7883612
141628f
40b352c
c6cbc18
7b29240
efb9440
9c42d19
5a9bd38
e2158ec
1fca25b
8282259
95811ed
e8cc1a9
c1cdf1e
991d558
1f36dca
079872a
09690ce
9b62be5
6b187f7
899b73e
f392b1b
a71569f
86afa4b
202c7f1
0b4a2b8
37fff25
27dea10
50536f7
7b53076
ec3e5fe
9d2251f
c104f39
48c5b53
4e44801
eab8cfc
495ac9d
bf0c713
a19d9a0
5501856
f3dafab
8d546b1
522f503
e7fb64e
76a3233
c90f5da
e181e10
fad967d
b982b2e
3c16eb3
3599a63
59f2899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { PufferVaultV5 } from "./PufferVaultV5.sol"; | |
import { RestakingOperator } from "./RestakingOperator.sol"; | ||
import { IPufferModuleManager } from "./interface/IPufferModuleManager.sol"; | ||
import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol"; | ||
import { Address } from "@openzeppelin/contracts/utils/Address.sol"; | ||
import { Create2 } from "@openzeppelin/contracts/utils/Create2.sol"; | ||
import { AccessManagedUpgradeable } from | ||
"@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol"; | ||
|
@@ -26,6 +27,9 @@ import { PufferModule } from "./PufferModule.sol"; | |
* @custom:security-contact security@puffer.fi | ||
*/ | ||
contract PufferModuleManager is IPufferModuleManager, AccessManagedUpgradeable, UUPSUpgradeable { | ||
using Address for address; | ||
using Address for address payable; | ||
|
||
address public immutable PUFFER_MODULE_BEACON; | ||
address public immutable RESTAKING_OPERATOR_BEACON; | ||
address public immutable PUFFER_PROTOCOL; | ||
|
@@ -239,6 +243,54 @@ contract PufferModuleManager is IPufferModuleManager, AccessManagedUpgradeable, | |
emit PufferModuleUndelegated(moduleName); | ||
} | ||
|
||
/** | ||
* @notice Upgrades the given validators to consolidating (0x02) | ||
* @param moduleName The name of the module | ||
* @param pubkeys The pubkeys of the validators to upgrade | ||
* @dev The function does not check that the pubkeys belong to the module | ||
* @dev Restricted to the DAO | ||
* @dev According to EIP-7251 there is a fee for each validator consolidation request (See https://eips.ethereum.org/EIPS/eip-7251#fee-calculation) | ||
* The fee is paid in the msg.value of this function. Since the fee is not fixed and might change, the excess amount is refunded | ||
* to the caller from the EigenPod | ||
*/ | ||
function upgradeToConsolidating(bytes32 moduleName, bytes[] calldata pubkeys) external payable virtual restricted { | ||
address moduleAddress = IPufferProtocol(PUFFER_PROTOCOL).getModuleAddress(moduleName); | ||
|
||
PufferModule(payable(moduleAddress)).requestConsolidation{ value: msg.value }(pubkeys, pubkeys); | ||
|
||
emit PufferModuleUpgradedToConsolidating(moduleName, pubkeys); | ||
} | ||
|
||
/** | ||
* @notice Requests a withdrawal for the given validators. This withdrawal can be total or partial. | ||
* If the amount is 0, the withdrawal is total and the validator will be fully exited. | ||
* If it is a partial withdrawal, the validator should not be below 32 ETH or the request will be ignored. | ||
* @param moduleName The name of the module | ||
* @param pubkeys The pubkeys of the validators to withdraw | ||
* @param gweiAmounts The amounts of the validators to withdraw, in Gwei | ||
* @dev Restricted to the VALIDATOR_EXITOR role and the PufferProtocol | ||
* @dev According to EIP-7002 there is a fee for each validator withdrawal request (See https://eips.ethereum.org/assets/eip-7002/fee_analysis) | ||
* The fee is paid in the msg.value of this function. Since the fee is not fixed and might change, the excess amount will be kept in the PufferModule | ||
*/ | ||
function requestWithdrawal(bytes32 moduleName, bytes[] calldata pubkeys, uint64[] calldata gweiAmounts) | ||
external | ||
payable | ||
virtual | ||
restricted | ||
{ | ||
if (pubkeys.length == 0) { | ||
revert InputArrayLengthZero(); | ||
} | ||
if (pubkeys.length != gweiAmounts.length) { | ||
revert InputArrayLengthMismatch(); | ||
} | ||
Comment on lines
+282
to
+286
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are doing the validations here, and we have a very similar validations in PufferProtocol, should we remove the validations from PufferProtocol? The TX reverts either way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed with explanation from other comment |
||
address moduleAddress = IPufferProtocol(PUFFER_PROTOCOL).getModuleAddress(moduleName); | ||
|
||
PufferModule(payable(moduleAddress)).requestWithdrawal{ value: msg.value }(pubkeys, gweiAmounts); | ||
|
||
emit WithdrawalRequested(moduleName, pubkeys, gweiAmounts); | ||
} | ||
|
||
/** | ||
* @notice Calls the callRegisterOperatorToAVS function on the target restaking operator | ||
* @param restakingOperator is the address of the restaking operator | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual
means this function can be overridden by other contracts, is this intended?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really necessary IMO, but most of the functions in this contracts are virtual, so I followed suit