mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-27 10:54:47 +00:00
parent
15bf3c4258
commit
dac43eb564
@ -29,7 +29,6 @@
|
|||||||
- [`AttestationData`](#attestationdata)
|
- [`AttestationData`](#attestationdata)
|
||||||
- [`AttestationDataAndCustodyBit`](#attestationdataandcustodybit)
|
- [`AttestationDataAndCustodyBit`](#attestationdataandcustodybit)
|
||||||
- [`SlashableAttestation`](#slashableattestation)
|
- [`SlashableAttestation`](#slashableattestation)
|
||||||
- [`DepositInput`](#depositinput)
|
|
||||||
- [`DepositData`](#depositdata)
|
- [`DepositData`](#depositdata)
|
||||||
- [`BeaconBlockHeader`](#beaconblockheader)
|
- [`BeaconBlockHeader`](#beaconblockheader)
|
||||||
- [`Validator`](#validator)
|
- [`Validator`](#validator)
|
||||||
@ -377,7 +376,7 @@ The types are defined topologically to aid in facilitating an executable version
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `DepositInput`
|
#### `DepositData`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
@ -385,21 +384,10 @@ The types are defined topologically to aid in facilitating an executable version
|
|||||||
'pubkey': 'bytes48',
|
'pubkey': 'bytes48',
|
||||||
# Withdrawal credentials
|
# Withdrawal credentials
|
||||||
'withdrawal_credentials': 'bytes32',
|
'withdrawal_credentials': 'bytes32',
|
||||||
# A BLS signature of this `DepositInput`
|
|
||||||
'proof_of_possession': 'bytes96',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `DepositData`
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
# Amount in Gwei
|
# Amount in Gwei
|
||||||
'amount': 'uint64',
|
'amount': 'uint64',
|
||||||
# Timestamp from deposit contract
|
# Container self-signature
|
||||||
'timestamp': 'uint64',
|
'proof_of_possession': 'bytes96',
|
||||||
# Deposit input
|
|
||||||
'deposit_input': DepositInput,
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -512,7 +500,7 @@ The types are defined topologically to aid in facilitating an executable version
|
|||||||
# Index in the deposit tree
|
# Index in the deposit tree
|
||||||
'index': 'uint64',
|
'index': 'uint64',
|
||||||
# Data
|
# Data
|
||||||
'deposit_data': DepositData,
|
'data': DepositData,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -1278,19 +1266,12 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
|
|||||||
Process a deposit from Ethereum 1.0.
|
Process a deposit from Ethereum 1.0.
|
||||||
Note that this function mutates ``state``.
|
Note that this function mutates ``state``.
|
||||||
"""
|
"""
|
||||||
deposit_input = deposit.deposit_data.deposit_input
|
|
||||||
|
|
||||||
# Should equal 8 bytes for deposit_data.amount +
|
|
||||||
# 8 bytes for deposit_data.timestamp +
|
|
||||||
# 176 bytes for deposit_data.deposit_input
|
|
||||||
# It should match the deposit_data in the eth1.0 deposit contract
|
|
||||||
serialized_deposit_data = serialize(deposit.deposit_data)
|
|
||||||
# Deposits must be processed in order
|
# Deposits must be processed in order
|
||||||
assert deposit.index == state.deposit_index
|
assert deposit.index == state.deposit_index
|
||||||
|
|
||||||
# Verify the Merkle branch
|
# Verify the Merkle branch
|
||||||
merkle_branch_is_valid = verify_merkle_branch(
|
merkle_branch_is_valid = verify_merkle_branch(
|
||||||
leaf=hash(serialized_deposit_data),
|
leaf=hash(serialize(deposit.data)), # 48 + 32 + 8 + 96 = 184 bytes serialisation
|
||||||
proof=deposit.proof,
|
proof=deposit.proof,
|
||||||
depth=DEPOSIT_CONTRACT_TREE_DEPTH,
|
depth=DEPOSIT_CONTRACT_TREE_DEPTH,
|
||||||
index=deposit.index,
|
index=deposit.index,
|
||||||
@ -1305,16 +1286,14 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
|
|||||||
state.deposit_index += 1
|
state.deposit_index += 1
|
||||||
|
|
||||||
validator_pubkeys = [v.pubkey for v in state.validator_registry]
|
validator_pubkeys = [v.pubkey for v in state.validator_registry]
|
||||||
pubkey = deposit_input.pubkey
|
pubkey = deposit.data.pubkey
|
||||||
amount = deposit.deposit_data.amount
|
|
||||||
withdrawal_credentials = deposit_input.withdrawal_credentials
|
|
||||||
|
|
||||||
if pubkey not in validator_pubkeys:
|
if pubkey not in validator_pubkeys:
|
||||||
# Verify the proof of possession
|
# Verify the proof of possession
|
||||||
proof_is_valid = bls_verify(
|
proof_is_valid = bls_verify(
|
||||||
pubkey=deposit_input.pubkey,
|
pubkey=pubkey,
|
||||||
message_hash=signed_root(deposit_input),
|
message_hash=signed_root(deposit.data),
|
||||||
signature=deposit_input.proof_of_possession,
|
signature=deposit.data.proof_of_possession,
|
||||||
domain=get_domain(
|
domain=get_domain(
|
||||||
state.fork,
|
state.fork,
|
||||||
get_current_epoch(state),
|
get_current_epoch(state),
|
||||||
@ -1327,7 +1306,7 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
|
|||||||
# Add new validator
|
# Add new validator
|
||||||
validator = Validator(
|
validator = Validator(
|
||||||
pubkey=pubkey,
|
pubkey=pubkey,
|
||||||
withdrawal_credentials=withdrawal_credentials,
|
withdrawal_credentials=deposit.data.withdrawal_credentials,
|
||||||
activation_epoch=FAR_FUTURE_EPOCH,
|
activation_epoch=FAR_FUTURE_EPOCH,
|
||||||
exit_epoch=FAR_FUTURE_EPOCH,
|
exit_epoch=FAR_FUTURE_EPOCH,
|
||||||
withdrawable_epoch=FAR_FUTURE_EPOCH,
|
withdrawable_epoch=FAR_FUTURE_EPOCH,
|
||||||
@ -1337,10 +1316,10 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
|
|||||||
|
|
||||||
# Note: In phase 2 registry indices that have been withdrawn for a long time will be recycled.
|
# Note: In phase 2 registry indices that have been withdrawn for a long time will be recycled.
|
||||||
state.validator_registry.append(validator)
|
state.validator_registry.append(validator)
|
||||||
state.validator_balances.append(amount)
|
state.validator_balances.append(deposit.data.amount)
|
||||||
else:
|
else:
|
||||||
# Increase balance by deposit amount
|
# Increase balance by deposit amount
|
||||||
state.validator_balances[validator_pubkeys.index(pubkey)] += amount
|
state.validator_balances[validator_pubkeys.index(pubkey)] += deposit.data.amount
|
||||||
```
|
```
|
||||||
|
|
||||||
### Routines for updating validator status
|
### Routines for updating validator status
|
||||||
@ -1430,11 +1409,11 @@ The initial deployment phases of Ethereum 2.0 are implemented without consensus
|
|||||||
|
|
||||||
### Deposit arguments
|
### Deposit arguments
|
||||||
|
|
||||||
The deposit contract has a single `deposit` function which takes as argument a SimpleSerialize'd `DepositInput`.
|
The deposit contract has a single `deposit` function which takes as argument a SimpleSerialize'd `DepositData`.
|
||||||
|
|
||||||
### Withdrawal credentials
|
### Withdrawal credentials
|
||||||
|
|
||||||
One of the `DepositInput` fields is `withdrawal_credentials`. It is a commitment to credentials for withdrawals to shards. The first byte of `withdrawal_credentials` is a version number. As of now the only expected format is as follows:
|
One of the `DepositData` fields is `withdrawal_credentials`. It is a commitment to credentials for withdrawals to shards. The first byte of `withdrawal_credentials` is a version number. As of now the only expected format is as follows:
|
||||||
|
|
||||||
* `withdrawal_credentials[:1] == BLS_WITHDRAWAL_PREFIX_BYTE`
|
* `withdrawal_credentials[:1] == BLS_WITHDRAWAL_PREFIX_BYTE`
|
||||||
* `withdrawal_credentials[1:] == hash(withdrawal_pubkey)[1:]` where `withdrawal_pubkey` is a BLS pubkey
|
* `withdrawal_credentials[1:] == hash(withdrawal_pubkey)[1:]` where `withdrawal_pubkey` is a BLS pubkey
|
||||||
|
Loading…
x
Reference in New Issue
Block a user