@@ -31,6 +31,12 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage,
3131 _;
3232 }
3333
34+ /// @dev Modifier to confirm the sender is whitelisted.
35+ modifier onlyWhitelistedStaker () {
36+ require (whitelistedStakers[msg .sender ], IVanillaRegistry.SenderIsNotWhitelistedStaker (msg .sender ));
37+ _;
38+ }
39+
3440 /// @dev See https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract
3541 /// @custom:oz-upgrades-unsafe-allow constructor
3642 constructor () {
@@ -69,7 +75,7 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage,
6975 * @param blsPubKeys The validator BLS public keys to stake.
7076 */
7177 function stake (bytes [] calldata blsPubKeys ) external payable
72- onlyValidBLSPubKeys (blsPubKeys) whenNotPaused () {
78+ onlyValidBLSPubKeys (blsPubKeys) onlyWhitelistedStaker () whenNotPaused () {
7379 _stake (blsPubKeys, msg .sender );
7480 }
7581
@@ -90,7 +96,7 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage,
9096 * @dev A staking entry must already exist for each provided BLS pubkey.
9197 * @param blsPubKeys The BLS public keys to add stake to.
9298 */
93- function addStake (bytes [] calldata blsPubKeys ) external payable whenNotPaused () {
99+ function addStake (bytes [] calldata blsPubKeys ) external payable onlyWhitelistedStaker () whenNotPaused () {
94100 _addStake (blsPubKeys);
95101 }
96102
@@ -180,6 +186,26 @@ contract VanillaRegistry is IVanillaRegistry, VanillaRegistryStorage,
180186 FeePayout.transferToRecipient (slashingFundsTracker);
181187 }
182188
189+ /// @dev Enables the owner to whitelist stakers.
190+ function whitelistStakers (address [] calldata stakers ) external onlyOwner {
191+ uint256 len = stakers.length ;
192+ for (uint256 i = 0 ; i < len; ++ i) {
193+ require (! whitelistedStakers[stakers[i]], IVanillaRegistry.StakerAlreadyWhitelisted (stakers[i]));
194+ whitelistedStakers[stakers[i]] = true ;
195+ emit StakerWhitelisted (msg .sender , stakers[i]);
196+ }
197+ }
198+
199+ /// @dev Enables the owner to remove stakers from the whitelist.
200+ function removeWhitelistedStakers (address [] calldata stakers ) external onlyOwner {
201+ uint256 len = stakers.length ;
202+ for (uint256 i = 0 ; i < len; ++ i) {
203+ require (whitelistedStakers[stakers[i]], IVanillaRegistry.StakerNotWhitelisted (stakers[i]));
204+ whitelistedStakers[stakers[i]] = false ;
205+ emit StakerRemovedFromWhitelist (msg .sender , stakers[i]);
206+ }
207+ }
208+
183209 /// @dev Returns true if a validator is considered "opted-in" to mev-commit via this registry.
184210 function isValidatorOptedIn (bytes calldata valBLSPubKey ) external view returns (bool ) {
185211 return _isValidatorOptedIn (valBLSPubKey);
0 commit comments