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

prevent dispatching if validator owner is sanctioned #107

Merged
merged 1 commit into from
Jan 20, 2025
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
Binary file added .yarn/install-state.gz
Binary file not shown.
13 changes: 12 additions & 1 deletion src/contracts/StakingContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,20 @@ contract StakingContract {

/// @notice Retrieve withdrawer of public key root
/// @notice In case the validator is not enabled, it will return address(0)
/// @notice In case the owner of the validator is sanctioned, it will revert
/// @param _publicKeyRoot Hash of the public key
function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address) {
return _getWithdrawer(_publicKeyRoot);
address withdrawer = _getWithdrawer(_publicKeyRoot);
if (withdrawer == address(0)) {
return address(0);
}
address sanctionsOracle = StakingContractStorageLib.getSanctionsOracle();
if (sanctionsOracle != address(0)) {
if (ISanctionsOracle(sanctionsOracle).isSanctioned(withdrawer)) {
revert AddressSanctioned(withdrawer);
}
}
return withdrawer;
}

/// @notice Retrieve whether the validator exit has been requested
Expand Down
29 changes: 29 additions & 0 deletions src/test/StakingContract.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3291,4 +3291,33 @@ contract StakingContractBehindProxyTest is Test {
vm.prank(admin);
stakingContract.blockAccount(bob, PUBKEY_2);
}

error AddressSanctioned(address addr);

function test_withdraw_from_recipient_owner_sanctioned() public {
vm.prank(admin);
stakingContract.setSanctionsOracle(address(oracle));
assertFalse(oracle.isSanctioned(bob));

vm.deal(bob, 32 ether);

vm.prank(bob);
stakingContract.deposit{value: 32 ether}();

address clfr = stakingContract.getCLFeeRecipient(PUBKEY_1);
vm.deal(clfr, 1 ether);

vm.prank(bob);
// First withdrawal deploy the recipient such that afterwards it's possible to trigger
// the withdrawal from the recipient directly
stakingContract.withdrawCLFee(PUBKEY_1);

oracle.setSanction(bob, true);

vm.deal(clfr, 1 ether);

vm.prank(bob);
vm.expectRevert(abi.encodeWithSignature("AddressSanctioned(address)", bob));
IFeeRecipient(clfr).withdraw();
}
}
Loading