BeaconDeposit
The contract handling validators deposits. Its events are used by the beacon chain to manage the staking process.
Inherits: IBeaconDeposit, ERC165.
Constants
CREDENTIALS_LENGTH
The length of the credentials, 1 byte prefix + 11 bytes padding + 20 bytes address = 32 bytes.
uint8 public constant CREDENTIALS_LENGTH = 32;
MIN_DEPOSIT_AMOUNT_IN_GWEI
The minimum amount of BERA
to deposit i.e 10_000 ether.
uint64 public constant MIN_DEPOSIT_AMOUNT_IN_GWEI = 10_000 gwei;
PUBLIC_KEY_LENGTH
The length of the public key, PUBLIC_KEY_LENGTH bytes.
uint8 public constant PUBLIC_KEY_LENGTH = 48;
SIGNATURE_LENGTH
The length of the signature, SIGNATURE_LENGTH bytes.
uint8 public constant SIGNATURE_LENGTH = 96;
Structs
QueuedOperator
QueuedOperator is a struct that represents an operator address change request.
struct QueuedOperator {
uint96 queuedTimestamp;
address newOperator;
}
Properties
Name | Type | Description |
---|---|---|
queuedTimestamp | uint96 | The timestamp when the operator change was queued |
newOperator | address | The new operator address |
State Variables
depositCount
The number of deposits that have been made to the contract.
uint64 public depositCount;
genesisDepositsRoot
The hash tree root of the genesis deposits.
Should be set in deployment (predeploy state or constructor).
bytes32 public genesisDepositsRoot;
queuedOperator
The mapping of public keys to operator change requests.
mapping(bytes => QueuedOperator) public queuedOperator;
View Functions
getOperator
Get the operator address for a given pubkey.
Returns zero address if the pubkey is not registered.
function getOperator(bytes calldata pubkey) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator. |
Returns
Name | Type | Description |
---|---|---|
<none> | address | The operator address for the given pubkey. |
Functions
acceptOperatorChange
Accept the operator change of a validator.
Only the new operator can accept the change.
Emits:
function acceptOperatorChange(bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator. |
cancelOperatorChange
Cancel the operator change of a validator.
Only the current operator can cancel the change.
Emits:
function cancelOperatorChange(bytes calldata pubkey) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator. |
deposit
Submit a deposit message to the Beaconchain.
emits the Deposit event upon successful deposit.
Emits:
- Deposit
- OperatorUpdated (only on first deposit)
function deposit(
bytes calldata pubkey,
bytes calldata credentials,
bytes calldata signature,
address operator
)
external
payable;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | is the consensus public key of the validator. |
credentials | bytes | is the withdrawal credentials of the validator. |
signature | bytes | is the signature used only on the first deposit. |
operator | address | is the address of the operator used for POL mechanics. |
requestOperatorChange
Request to change the operator of a validator.
Only the current operator can request a change.
Emits:
function requestOperatorChange(bytes calldata pubkey, address newOperator) external;
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator. |
newOperator | address | The new operator address. |
Events
Deposit
Emitted when a deposit is made.
event Deposit(bytes pubkey, bytes credentials, uint64 amount, bytes signature, uint64 index);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The consensus public key of the validator |
credentials | bytes | The withdrawal credentials of the validator |
amount | uint64 | The amount deposited in Gwei |
signature | bytes | The signature used only on the first deposit |
index | uint64 | The deposit index |
OperatorChangeQueued
Emitted when an operator change is queued.
event OperatorChangeQueued(bytes indexed pubkey, address queuedOperator, address currentOperator, uint256 queuedTimestamp);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator |
queuedOperator | address | The new queued operator address |
currentOperator | address | The current operator address |
queuedTimestamp | uint256 | The timestamp when the change was queued |
OperatorChangeCancelled
Emitted when an operator change is cancelled.
event OperatorChangeCancelled(bytes indexed pubkey);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator |
OperatorUpdated
Emitted when the operator of a validator is updated.
event OperatorUpdated(bytes indexed pubkey, address newOperator, address previousOperator);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | The pubkey of the validator |
newOperator | address | The new operator address |
previousOperator | address | The previous operator address |