-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add functions to register and exit/remove the ssv validator
- Loading branch information
1 parent
2c448bb
commit 5d5e9cb
Showing
12 changed files
with
272 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IDepositContract { | ||
/// @notice A processed deposit event. | ||
event DepositEvent( | ||
bytes pubkey, | ||
bytes withdrawal_credentials, | ||
bytes amount, | ||
bytes signature, | ||
bytes index | ||
); | ||
|
||
/// @notice Submit a Phase 0 DepositData object. | ||
/// @param pubkey A BLS12-381 public key. | ||
/// @param withdrawal_credentials Commitment to a public key for withdrawals. | ||
/// @param signature A BLS12-381 signature. | ||
/// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object. | ||
/// Used as a protection against malformed input. | ||
function deposit( | ||
bytes calldata pubkey, | ||
bytes calldata withdrawal_credentials, | ||
bytes calldata signature, | ||
bytes32 deposit_data_root | ||
) external payable; | ||
|
||
/// @notice Query the current deposit root hash. | ||
/// @return The deposit root hash. | ||
function get_deposit_root() external view returns (bytes32); | ||
|
||
/// @notice Query the current deposit count. | ||
/// @return The deposit count encoded as a little endian 64-bit number. | ||
function get_deposit_count() external view returns (bytes memory); | ||
} |
37 changes: 37 additions & 0 deletions
37
contracts/contracts/mocks/BeaconChainDepositContractMock.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
contract BeaconChainDepositContractMock { | ||
/// @notice A processed deposit event. | ||
event DepositEvent( | ||
bytes pubkey, | ||
bytes withdrawal_credentials, | ||
bytes amount, | ||
bytes signature, | ||
bytes index | ||
); | ||
|
||
/// @notice Submit a Phase 0 DepositData object. | ||
/// @param pubkey A BLS12-381 public key. | ||
/// @param withdrawal_credentials Commitment to a public key for withdrawals. | ||
/// @param signature A BLS12-381 signature. | ||
/// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object. | ||
/// Used as a protection against malformed input. | ||
function deposit( | ||
bytes calldata pubkey, | ||
bytes calldata withdrawal_credentials, | ||
bytes calldata signature, | ||
bytes32 deposit_data_root | ||
) external payable { | ||
// Extended ABI length checks since dynamic types are used. | ||
require(pubkey.length == 48, "DepositContract: invalid pubkey length"); | ||
require(withdrawal_credentials.length == 32, "DepositContract: invalid withdrawal_credentials length"); | ||
require(signature.length == 96, "DepositContract: invalid signature length"); | ||
|
||
// Check deposit amount | ||
require(msg.value >= 1 ether, "DepositContract: deposit value too low"); | ||
require(msg.value % 1 gwei == 0, "DepositContract: deposit value not multiple of gwei"); | ||
uint deposit_amount = msg.value / 1 gwei; | ||
require(deposit_amount <= type(uint64).max, "DepositContract: deposit value too high"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.