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

Fix Audit 6.10 Disable initializers #52

Merged
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
4 changes: 4 additions & 0 deletions src/RewardsReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ contract RewardsReceiver is Initializable, AccessControlUpgradeable {
//---------------------------------- INITIALIZATION ----------------------------------
//--------------------------------------------------------------------------------------

constructor() {
_disableInitializers();
}

/// @notice Configuration for contract initialization.
struct Init {
address admin;
Expand Down
3 changes: 1 addition & 2 deletions src/ynETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ contract ynETH is IynETH, ynBase, IStakingEvents {
address[] pauseWhitelist;
}

constructor(
) {
constructor() {
_disableInitializers();
}

Expand Down
32 changes: 22 additions & 10 deletions test/foundry/integration/IntegrationBaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,34 @@ contract IntegrationBaseTest is Test, Utils {
TransparentUpgradeableProxy rewardsDistributorProxy;
TransparentUpgradeableProxy stakingNodesManagerProxy;
TransparentUpgradeableProxy yieldNestOracleProxy;
TransparentUpgradeableProxy executionLayerReceiverProxy;
TransparentUpgradeableProxy consensusLayerReceiverProxy;

// Initializing RewardsDistributor contract and creating its proxy
rewardsDistributor = new RewardsDistributor();
yneth = new ynETH();
stakingNodesManager = new StakingNodesManager();
yieldNestOracle = new YieldNestOracle();
ynlsd = new ynLSD();

executionLayerReceiver = new RewardsReceiver();
consensusLayerReceiver = new RewardsReceiver();

rewardsDistributorProxy = new TransparentUpgradeableProxy(address(rewardsDistributor), actors.PROXY_ADMIN_OWNER, "");
rewardsDistributor = RewardsDistributor(payable(rewardsDistributorProxy));


ynethProxy = new TransparentUpgradeableProxy(address(yneth), actors.PROXY_ADMIN_OWNER, "");
stakingNodesManagerProxy = new TransparentUpgradeableProxy(address(stakingNodesManager), actors.PROXY_ADMIN_OWNER, "");
yieldNestOracleProxy = new TransparentUpgradeableProxy(address(yieldNestOracle), actors.PROXY_ADMIN_OWNER, "");
ynLSDProxy = new TransparentUpgradeableProxy(address(ynlsd), actors.PROXY_ADMIN_OWNER, "");

executionLayerReceiverProxy = new TransparentUpgradeableProxy(address(executionLayerReceiver), actors.PROXY_ADMIN_OWNER, "");
consensusLayerReceiverProxy = new TransparentUpgradeableProxy(address(consensusLayerReceiver), actors.PROXY_ADMIN_OWNER, "");

executionLayerReceiver = RewardsReceiver(payable(executionLayerReceiverProxy));
consensusLayerReceiver = RewardsReceiver(payable(consensusLayerReceiverProxy));

// Wrapping proxies with their respective interfaces
yneth = ynETH(payable(ynethProxy));
stakingNodesManager = StakingNodesManager(payable(stakingNodesManagerProxy));
Expand Down Expand Up @@ -173,17 +186,7 @@ contract IntegrationBaseTest is Test, Utils {
}

function setupRewardsDistributor() public {
executionLayerReceiver = new RewardsReceiver();
consensusLayerReceiver = new RewardsReceiver();
RewardsDistributor.Init memory rewardsDistributorInit = RewardsDistributor.Init({
admin: actors.ADMIN,
executionLayerReceiver: executionLayerReceiver,
consensusLayerReceiver: consensusLayerReceiver,
feesReceiver: payable(actors.FEE_RECEIVER),
ynETH: IynETH(address(yneth))
});

rewardsDistributor.initialize(rewardsDistributorInit);
RewardsReceiver.Init memory rewardsReceiverInit = RewardsReceiver.Init({
admin: actors.ADMIN,
withdrawer: address(rewardsDistributor)
Expand All @@ -192,6 +195,15 @@ contract IntegrationBaseTest is Test, Utils {
executionLayerReceiver.initialize(rewardsReceiverInit);
consensusLayerReceiver.initialize(rewardsReceiverInit);
vm.stopPrank();

RewardsDistributor.Init memory rewardsDistributorInit = RewardsDistributor.Init({
admin: actors.ADMIN,
executionLayerReceiver: executionLayerReceiver,
consensusLayerReceiver: consensusLayerReceiver,
feesReceiver: payable(actors.FEE_RECEIVER),
ynETH: IynETH(address(yneth))
});
rewardsDistributor.initialize(rewardsDistributorInit);
}

function setupStakingNodesManager() public {
Expand Down
8 changes: 7 additions & 1 deletion test/foundry/integration/StakingNodesManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,17 @@ contract StakingNodesManagerValidators is IntegrationBaseTest {
(IStakingNodesManager.ValidatorData[] memory validatorData,) = makeTestValidators(depositAmount);
// try to create a bad deposit root
bytes32 depositRoot = depositContractEth2.get_deposit_root();
bytes memory withdrawalCredentials = stakingNodesManager.getWithdrawalCredentials(validatorData[0].nodeId);

bytes32 depositDataRoot = stakingNodesManager.generateDepositRoot(
validatorData[0].publicKey,
validatorData[0].signature,
withdrawalCredentials, 32 ether
);
vm.prank(actors.VALIDATOR_MANAGER);
vm.expectRevert(abi.encodeWithSelector(
StakingNodesManager.DepositDataRootMismatch.selector,
0x7be1a5aee0180c84f2d1b0ef721fb62bf323ee9aabeac0bd5bb551da1782f805,
depositDataRoot,
validatorData[0].depositDataRoot)
);
stakingNodesManager.registerValidators(depositRoot, validatorData);
Expand Down
Loading