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

Audit 3 fix #37

Merged
merged 24 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f89a9d9
OracleFeeDistributor__ClientBasisPointsShouldBeHigherThan5000
sanbir Jul 10, 2023
bbff409
fix 1. Rewards can be accounted as collateral
sanbir Jul 18, 2023
04de59a
fix 2. The slashed validator’s stake gets split between client, refer…
sanbir Jul 19, 2023
d180529
fix 3. Null basis points will lead to the lock of funds
sanbir Jul 19, 2023
9ddd011
fix 4. Client’s collateral can be distributed as rewards
sanbir Jul 20, 2023
49db303
fix 5. Possible ddos of an expiration time
sanbir Jul 20, 2023
82053a9
test_OracleFeeDistributor_withdraw_with_the_same_proof
sanbir Jul 21, 2023
80a9a4b
fix H6 test_OracleFeeDistributor_withdraw_after_emergencyEtherRecover…
sanbir Jul 21, 2023
05bf2d6
fix M3 An incorrect distribution of rewards in case of _sendValue revert
sanbir Jul 24, 2023
cf26f32
fix M4 s_defaultClientBasisPoints should be restricted
sanbir Jul 24, 2023
29984b6
fix M5 Non-existing _feeDistributorInstance can be rejected
sanbir Jul 24, 2023
401457f
fix M8 recoverEther function shouldn’t be called with gas restrictions
sanbir Jul 24, 2023
54acad9
fix M11 A failed send to to address in recoverEther leads to over-dis…
sanbir Jul 24, 2023
c60cd0c
fix M12 The ServiceRejected status is ignored in the addEth and makeB…
sanbir Jul 24, 2023
eec0556
fix M13 ClientConfig.basisPoints equal to 100% at OracleFeeDistributo…
sanbir Jul 24, 2023
162f0da
fix M14 P2pOrgUnlimitedEthDepositor.refundAll() can be blocked for an…
sanbir Jul 24, 2023
3d15938
fix L1 A newOwner can be the current owner
sanbir Jul 24, 2023
60323bc
fix L2 Zero address can be valid
sanbir Jul 24, 2023
f039c9a
fix L3 ERC721 safeTransferFrom is not safe
sanbir Jul 24, 2023
e26cdf7
fix L5 chainId can replace the flag
sanbir Jul 24, 2023
ab0a2a5
fix L6. A missing zero address check
sanbir Jul 24, 2023
a1fae62
fix L7. referrerConfig.basisPoints can be set to 0, even if referrerC…
sanbir Jul 24, 2023
f63f55a
fix typos
sanbir Jul 24, 2023
51b296d
fix typos
sanbir Jul 24, 2023
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
Next Next commit
OracleFeeDistributor__ClientBasisPointsShouldBeHigherThan5000
  • Loading branch information
sanbir committed Jul 10, 2023
commit f89a9d94e6e9ff8a9c86b17c9ce5c4e8bac2df3d
2 changes: 1 addition & 1 deletion contracts/feeDistributor/BaseFeeDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract contract BaseFeeDistributor is Erc4337Account, OwnableTokenRecoverer, O
function initialize(
FeeRecipient calldata _clientConfig,
FeeRecipient calldata _referrerConfig
) external onlyFactory {
) public virtual onlyFactory {
if (_clientConfig.recipient == address(0)) {
revert FeeDistributor__ZeroAddressClient();
}
Expand Down
15 changes: 15 additions & 0 deletions contracts/feeDistributor/OracleFeeDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ error OracleFeeDistributor__WaitForEnoughRewardsToWithdraw();
/// @notice clientOnlyClRewards can only be set once
error OracleFeeDistributor__CannotResetClientOnlyClRewards();

/// @notice Client basis points should be higher than 5000
error OracleFeeDistributor__ClientBasisPointsShouldBeHigherThan5000();

/// @title FeeDistributor accepting EL rewards only but splitting them with consideration of CL rewards
/// @dev CL rewards are received by the client directly since client's address is ETH2 withdrawal credentials
contract OracleFeeDistributor is BaseFeeDistributor {
Expand Down Expand Up @@ -56,6 +59,18 @@ contract OracleFeeDistributor is BaseFeeDistributor {
i_oracle = IOracle(_oracle);
}

/// @inheritdoc IFeeDistributor
function initialize(
FeeRecipient calldata _clientConfig,
FeeRecipient calldata _referrerConfig
) public override {
if (_clientConfig.basisPoints <= 5000) {
revert OracleFeeDistributor__ClientBasisPointsShouldBeHigherThan5000();
}

super.initialize(_clientConfig, _referrerConfig);
}

/// @notice Set clientOnlyClRewards to a new value
/// @param _clientOnlyClRewards new value of clientOnlyClRewards
/// @dev may be needed when attaching this FeeDistributor to an existing validator.
Expand Down
31 changes: 24 additions & 7 deletions test/foundry/Integration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,24 @@ contract Integration is Test {
function test_OracleFeeDistributor_Creation_Without_Depositor() public {
console.log("testOracleFeeDistributorCreationWithoutDepositor started");

address newFeeDistributorAddress = deployOracleFeeDistributorCreationWithoutDepositor();
address newFeeDistributorAddress;

vm.startPrank(operatorAddress);
vm.expectRevert(OracleFeeDistributor__ClientBasisPointsShouldBeHigherThan5000.selector);
newFeeDistributorAddress = factory.createFeeDistributor(
address(oracleFeeDistributorTemplate),
FeeRecipient({
recipient: clientWcAddress,
basisPoints: 4000
}),
FeeRecipient({
recipient: payable(address(0)),
basisPoints: 0
})
);
vm.stopPrank();

newFeeDistributorAddress = deployOracleFeeDistributorCreationWithoutDepositor();

assertEq(newFeeDistributorAddress, oracleFeeDistributorInstanceAddress);

Expand Down Expand Up @@ -399,13 +416,13 @@ contract Integration is Test {
newFeeDistributorAddress = factory.createFeeDistributor(
address(oracleFeeDistributorTemplate),
FeeRecipient({
recipient: clientWcAddress,
basisPoints: defaultClientBasisPoints
}),
recipient: clientWcAddress,
basisPoints: defaultClientBasisPoints
}),
FeeRecipient({
recipient: payable(address(0)),
basisPoints: 0
})
recipient: payable(address(0)),
basisPoints: 0
})
);

vm.stopPrank();
Expand Down