Skip to content

Commit

Permalink
fix: exluced proxyAdmin when fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
0xvv committed Dec 5, 2024
1 parent c852012 commit b3f58fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/forge-std
5 changes: 2 additions & 3 deletions src/contracts/StakingContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,6 @@ contract StakingContract {
address _dispatcher
) internal {
bytes32 publicKeyRoot = _getPubKeyRoot(_publicKey);
address withdrawer = _getWithdrawer(publicKeyRoot);
_revertIfSanctioned(msg.sender);
bytes32 feeRecipientSalt = sha256(abi.encodePacked(_prefix, publicKeyRoot));
address implementation = StakingContractStorageLib.getFeeRecipientImplementation();
Expand All @@ -1002,7 +1001,7 @@ contract StakingContract {
}
}

function _revertIfSanctionedOrBlocked(address account) internal {
function _revertIfSanctionedOrBlocked(address account) internal view {
address sanctionsOracle = StakingContractStorageLib.getSanctionsOracle();
if (sanctionsOracle != address(0)) {
if (ISanctionsOracle(sanctionsOracle).isSanctioned(account)) {
Expand All @@ -1014,7 +1013,7 @@ contract StakingContract {
}
}

function _revertIfSanctioned(address account) internal {
function _revertIfSanctioned(address account) internal view {
address sanctionsOracle = StakingContractStorageLib.getSanctionsOracle();
if (sanctionsOracle != address(0)) {
if (ISanctionsOracle(sanctionsOracle).isSanctioned(account)) {
Expand Down
12 changes: 9 additions & 3 deletions src/test/StakingContract.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,7 @@ contract StakingContractBehindProxyTest is Test {

SanctionsOracle oracle;

address internal proxyAdmin = address(42);
event ExitRequest(address caller, bytes pubkey);

function setUp() public {
Expand All @@ -2065,17 +2066,17 @@ contract StakingContractBehindProxyTest is Test {
address cldImpl = address(new ConsensusLayerFeeDispatcher(1));
address stakingContractImpl = address(new StakingContract());

stakingContract = StakingContract(payable(address(new TUPProxy(stakingContractImpl, address(12345), ""))));
stakingContract = StakingContract(payable(address(new TUPProxy(stakingContractImpl, proxyAdmin, ""))));

eld = ExecutionLayerFeeDispatcher(
payable(
address(new TUPProxy(eldImpl, address(1), abi.encodeWithSignature("initELD(address)", stakingContract)))
address(new TUPProxy(eldImpl, proxyAdmin, abi.encodeWithSignature("initELD(address)", stakingContract)))
)
);

cld = ConsensusLayerFeeDispatcher(
payable(
address(new TUPProxy(cldImpl, address(1), abi.encodeWithSignature("initCLD(address)", stakingContract)))
address(new TUPProxy(cldImpl, proxyAdmin, abi.encodeWithSignature("initCLD(address)", stakingContract)))
)
);

Expand Down Expand Up @@ -2178,6 +2179,7 @@ contract StakingContractBehindProxyTest is Test {
}

function test_deposit_withsanctions_senderSanctioned(address user) public {
vm.assume(user != proxyAdmin);
oracle.setSanction(user, true);

vm.prank(admin);
Expand All @@ -2192,6 +2194,8 @@ contract StakingContractBehindProxyTest is Test {
}

function test_deposit_withSanctions_SenderClear(address user) public {
vm.assume(user != proxyAdmin);

vm.prank(admin);
stakingContract.setSanctionsOracle(address(oracle));

Expand All @@ -2203,6 +2207,8 @@ contract StakingContractBehindProxyTest is Test {
}

function test_deposit_BlockedUser(address user) public {
vm.assume(user != proxyAdmin);

vm.prank(admin);
stakingContract.blockAccount(user, "");

Expand Down

0 comments on commit b3f58fb

Please sign in to comment.