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

Add comments and update deposit module #877

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 6 additions & 17 deletions contracts/0.8.9/DepositSecurityModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,19 @@ contract DepositSecurityModule {
STAKING_ROUTER = IStakingRouter(_stakingRouter);
DEPOSIT_CONTRACT = IDepositContract(_depositContract);

ATTEST_MESSAGE_PREFIX = keccak256(
abi.encodePacked(
// keccak256("lido.DepositSecurityModule.ATTEST_MESSAGE")
bytes32(0x1085395a994e25b1b3d0ea7937b7395495fb405b31c7d22dbc3976a6bd01f2bf),
block.chainid,
address(this)
)
);

PAUSE_MESSAGE_PREFIX = keccak256(
abi.encodePacked(
// keccak256("lido.DepositSecurityModule.PAUSE_MESSAGE")
bytes32(0x9c4c40205558f12027f21204d6218b8006985b7a6359bcab15404bcc3e3fa122),
block.chainid,
address(this)
)
);
ATTEST_MESSAGE_PREFIX = _computeMessagePrefix(0x1085395a994e25b1b3d0ea7937b7395495fb405b31c7d22dbc3976a6bd01f2bf);
PAUSE_MESSAGE_PREFIX = _computeMessagePrefix(0x9c4c40205558f12027f21204d6218b8006985b7a6359bcab15404bcc3e3fa122);

_setOwner(msg.sender);
_setMaxDeposits(_maxDepositsPerBlock);
_setMinDepositBlockDistance(_minDepositBlockDistance);
_setPauseIntentValidityPeriodBlocks(_pauseIntentValidityPeriodBlocks);
}

function _computeMessagePrefix(bytes32 context) internal view returns (bytes32) {
return keccak256(abi.encodePacked(context, block.chainid, address(this)));
}

/**
* Returns the owner address.
*/
Expand Down
17 changes: 17 additions & 0 deletions contracts/0.8.9/LidoLocator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ contract LidoLocator is ILidoLocator {
oracleDaemonConfig = _assertNonZero(_config.oracleDaemonConfig);
}

/**
* @notice Retrieves core components of the Lido system
* @return Six core component addresses: elRewardsVault, oracleReportSanityChecker,
* stakingRouter, treasury, withdrawalQueue, and withdrawalVault
*/
function coreComponents() external view returns(
address,
address,
Expand All @@ -87,6 +92,12 @@ contract LidoLocator is ILidoLocator {
);
}

/**
* @notice Retrieves oracle-related components used by Lido
* @return Seven oracle-related component addresses: accountingOracle, elRewardsVault,
* oracleReportSanityChecker, burner, withdrawalQueue, withdrawalVault,
* and postTokenRebaseReceiver
*/
function oracleReportComponentsForLido() external view returns(
address,
address,
Expand All @@ -107,6 +118,12 @@ contract LidoLocator is ILidoLocator {
);
}

/**
* @notice Ensures that an address is not zero
* @dev Reverts with a `ZeroAddress` error if the address is zero
* @param _address The address to validate
* @return The validated non-zero address
*/
function _assertNonZero(address _address) internal pure returns (address) {
if (_address == address(0)) revert ZeroAddress();
return _address;
Expand Down
24 changes: 24 additions & 0 deletions contracts/testnets/sepolia/SepoliaDepositAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,18 @@ contract SepoliaDepositAdapter is IDepositContract, Ownable, Versioned {
_transferOwnership(_owner);
}

/**
* @notice Returns the deposit root of the original Sepolia contract
* @return The deposit root as a `bytes32`
*/
function get_deposit_root() external view override returns (bytes32) {
return originalContract.get_deposit_root();
}

/**
* @notice Returns the deposit count from the original Sepolia contract
* @return The deposit count as `bytes`
*/
function get_deposit_count() external view override returns (bytes memory) {
return originalContract.get_deposit_count();
}
Expand All @@ -68,6 +76,10 @@ contract SepoliaDepositAdapter is IDepositContract, Ownable, Versioned {
emit EthReceived(msg.sender, msg.value);
}

/**
* @notice Allows the owner to recover Ether stored in the contract
* @dev Transfers all Ether to the owner's address. Reverts on failure.
*/
function recoverEth() external onlyOwner {
uint256 balance = address(this).balance;
// solhint-disable-next-line avoid-low-level-calls
Expand All @@ -78,6 +90,10 @@ contract SepoliaDepositAdapter is IDepositContract, Ownable, Versioned {
emit EthRecovered(balance);
}

/**
* @notice Allows the owner to recover Bepolia tokens stored in the contract
* @dev Transfers all Bepolia tokens to the owner's address. Reverts on failure.
*/
function recoverBepolia() external onlyOwner {
uint256 bepoliaOwnTokens = originalContract.balanceOf(address(this));
bool success = originalContract.transfer(owner(), bepoliaOwnTokens);
Expand All @@ -87,6 +103,14 @@ contract SepoliaDepositAdapter is IDepositContract, Ownable, Versioned {
emit BepoliaRecovered(bepoliaOwnTokens);
}

/**
* @notice Deposits funds into the original Sepolia deposit contract
* @dev Forwards the deposit call to the original contract and transfers ETH back to the owner. Reverts on failure.
* @param pubkey The public key of the validator
* @param withdrawal_credentials Withdrawal credentials for the deposit
* @param signature Validator's signature
* @param deposit_data_root Root of the deposit data
*/
function deposit(
bytes calldata pubkey,
bytes calldata withdrawal_credentials,
Expand Down