mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-14 12:46:06 +00:00
Update 0_beacon-chain.md
This commit is contained in:
parent
d282a36c63
commit
82ecc8c868
@ -261,7 +261,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
|||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
# Proposer index
|
# Proposer index
|
||||||
'proposer_index': 'uint24',
|
'proposer_index': 'uint64',
|
||||||
# First proposal data
|
# First proposal data
|
||||||
'proposal_data_1': ProposalSignedData,
|
'proposal_data_1': ProposalSignedData,
|
||||||
# First proposal signature
|
# First proposal signature
|
||||||
@ -291,7 +291,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
|||||||
```python
|
```python
|
||||||
{
|
{
|
||||||
# Validator indices
|
# Validator indices
|
||||||
'validator_indices': '[uint24]',
|
'validator_indices': '[uint64]',
|
||||||
# Custody bitfield
|
# Custody bitfield
|
||||||
'custody_bitfield': 'bytes',
|
'custody_bitfield': 'bytes',
|
||||||
# Attestation data
|
# Attestation data
|
||||||
@ -402,7 +402,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
|||||||
# Minimum slot for processing exit
|
# Minimum slot for processing exit
|
||||||
'slot': 'uint64',
|
'slot': 'uint64',
|
||||||
# Index of the exiting validator
|
# Index of the exiting validator
|
||||||
'validator_index': 'uint24',
|
'validator_index': 'uint64',
|
||||||
# Validator signature
|
# Validator signature
|
||||||
'signature': 'bytes96',
|
'signature': 'bytes96',
|
||||||
}
|
}
|
||||||
@ -588,15 +588,15 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git
|
|||||||
|
|
||||||
We define the following Python custom types for type hinting and readability:
|
We define the following Python custom types for type hinting and readability:
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | SSZ equivalent | Description |
|
||||||
| - | - | - |
|
| - | - | - |
|
||||||
| `SlotNumber` | unsigned 64-bit integer | the number of a slot |
|
| `SlotNumber` | `uint64` | a slot number |
|
||||||
| `ShardNumber` | unsigned 64-bit integer | the number of a shard |
|
| `ShardNumber` | `uint64` | a shard number |
|
||||||
| `ValidatorIndex` | unsigned 24-bit integer | the index number of a validator in the registry |
|
| `ValidatorIndex` | `uint64` | an index in the validator registry |
|
||||||
| `Gwei` | unsigned 64-bit integer | an amount in Gwei |
|
| `Gwei` | `uint64` | an amount in Gwei |
|
||||||
| `Bytes32` | 32-byte data | binary data with 32-byte length |
|
| `Bytes32` | `bytes32` | 32 bytes of binary data |
|
||||||
| `BLSPubkey` | 48-byte data | a public key in BLS signature scheme |
|
| `BLSPubkey` | `bytes48` | a BLS public key |
|
||||||
| `BLSSignature` | 96-byte data | a signature in BLS signature scheme |
|
| `BLSSignature` | `bytes96` | a BLS signature |
|
||||||
|
|
||||||
## Ethereum 1.0 deposit contract
|
## Ethereum 1.0 deposit contract
|
||||||
|
|
||||||
@ -1058,7 +1058,7 @@ def get_attestation_participants(state: BeaconState,
|
|||||||
participants = []
|
participants = []
|
||||||
for i, validator_index in enumerate(crosslink_committee):
|
for i, validator_index in enumerate(crosslink_committee):
|
||||||
aggregation_bit = get_bitfield_bit(bitfield, i)
|
aggregation_bit = get_bitfield_bit(bitfield, i)
|
||||||
if aggregation_bit == 1:
|
if aggregation_bit == 0b1:
|
||||||
participants.append(validator_index)
|
participants.append(validator_index)
|
||||||
return participants
|
return participants
|
||||||
```
|
```
|
||||||
@ -1121,7 +1121,7 @@ def verify_bitfield(bitfield: bytes, committee_size: int) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
for i in range(committee_size + 1, committee_size - committee_size % 8 + 8):
|
for i in range(committee_size + 1, committee_size - committee_size % 8 + 8):
|
||||||
if get_bitfield_bit(bitfield, i) != 0:
|
if get_bitfield_bit(bitfield, i) == 0b1:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -1142,7 +1142,7 @@ def verify_slashable_vote(state: BeaconState, slashable_vote: SlashableVote) ->
|
|||||||
|
|
||||||
for i in range(len(slashable_vote.validator_indices) - 1):
|
for i in range(len(slashable_vote.validator_indices) - 1):
|
||||||
if slashable_vote.validator_indices[i] >= slashable_vote.validator_indices[i + 1]:
|
if slashable_vote.validator_indices[i] >= slashable_vote.validator_indices[i + 1]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not verify_bitfield(slashable_vote.custody_bitfield, len(slashable_vote.validator_indices)):
|
if not verify_bitfield(slashable_vote.custody_bitfield, len(slashable_vote.validator_indices)):
|
||||||
return False
|
return False
|
||||||
@ -1153,7 +1153,7 @@ def verify_slashable_vote(state: BeaconState, slashable_vote: SlashableVote) ->
|
|||||||
custody_bit_0_indices = []
|
custody_bit_0_indices = []
|
||||||
custody_bit_1_indices = []
|
custody_bit_1_indices = []
|
||||||
for i, validator_index in enumerate(slashable_vote.validator_indices):
|
for i, validator_index in enumerate(slashable_vote.validator_indices):
|
||||||
if get_bitfield_bit(slashable_vote.custody_bitfield, i) == 0:
|
if get_bitfield_bit(slashable_vote.custody_bitfield, i) == 0b0:
|
||||||
custody_bit_0_indices.append(validator_index)
|
custody_bit_0_indices.append(validator_index)
|
||||||
else:
|
else:
|
||||||
custody_bit_1_indices.append(validator_index)
|
custody_bit_1_indices.append(validator_index)
|
||||||
@ -1164,8 +1164,8 @@ def verify_slashable_vote(state: BeaconState, slashable_vote: SlashableVote) ->
|
|||||||
bls_aggregate_pubkeys([state.validator_registry[i].pubkey for i in custody_bit_1_indices]),
|
bls_aggregate_pubkeys([state.validator_registry[i].pubkey for i in custody_bit_1_indices]),
|
||||||
],
|
],
|
||||||
messages=[
|
messages=[
|
||||||
hash_tree_root(AttestationDataAndCustodyBit(slashable_vote.data, 0)),
|
hash_tree_root(AttestationDataAndCustodyBit(attestation_data=slashable_vote.data, custody_bit=0b0)),
|
||||||
hash_tree_root(AttestationDataAndCustodyBit(slashable_vote.data, 1)),
|
hash_tree_root(AttestationDataAndCustodyBit(attestation_data=slashable_vote.data, custody_bit=0b1)),
|
||||||
],
|
],
|
||||||
signature=slashable_vote.aggregate_signature,
|
signature=slashable_vote.aggregate_signature,
|
||||||
domain=get_domain(state.fork, slashable_vote.data.slot, DOMAIN_ATTESTATION),
|
domain=get_domain(state.fork, slashable_vote.data.slot, DOMAIN_ATTESTATION),
|
||||||
@ -1554,15 +1554,15 @@ For each `attestation` in `block.body.attestations`:
|
|||||||
* Verify bitfields and aggregate signature:
|
* Verify bitfields and aggregate signature:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
assert attestation.custody_bitfield == 0 # [TO BE REMOVED IN PHASE 1]
|
assert attestation.custody_bitfield == b'\x00' * len(attestation.custody_bitfield) # [TO BE REMOVED IN PHASE 1]
|
||||||
|
|
||||||
for i in range(len(crosslink_committee)):
|
for i in range(len(crosslink_committee)):
|
||||||
if get_bitfield_bit(attestation.aggregation_bitfield) == 0:
|
if get_bitfield_bit(attestation.aggregation_bitfield) == 0b0:
|
||||||
assert get_bitfield_bit(attestation.custody_bitfield) == 0
|
assert get_bitfield_bit(attestation.custody_bitfield) == 0b0
|
||||||
|
|
||||||
participants = get_attestation_participants(state, attestation.data, attestation.aggregation_bitfield)
|
participants = get_attestation_participants(state, attestation.data, attestation.aggregation_bitfield)
|
||||||
custody_bit_0_participants = get_attestation_participants(state, attestation.data, attestation.custody_bitfield)
|
custody_bit_1_participants = get_attestation_participants(state, attestation.data, attestation.custody_bitfield)
|
||||||
custody_bit_1_participants = [i in participants for i not in custody_bit_0_participants]
|
custody_bit_0_participants = [i in participants for i not in custody_bit_1_participants]
|
||||||
|
|
||||||
assert bls_verify_multiple(
|
assert bls_verify_multiple(
|
||||||
pubkeys=[
|
pubkeys=[
|
||||||
@ -1570,8 +1570,8 @@ For each `attestation` in `block.body.attestations`:
|
|||||||
bls_aggregate_pubkeys([state.validator_registry[i].pubkey for i in custody_bit_1_participants]),
|
bls_aggregate_pubkeys([state.validator_registry[i].pubkey for i in custody_bit_1_participants]),
|
||||||
],
|
],
|
||||||
messages=[
|
messages=[
|
||||||
hash_tree_root(AttestationDataAndCustodyBit(data=attestation.data, custody_bit=0)),
|
hash_tree_root(AttestationDataAndCustodyBit(data=attestation.data, custody_bit=0b0)),
|
||||||
hash_tree_root(AttestationDataAndCustodyBit(data=attestation.data, custody_bit=1)),
|
hash_tree_root(AttestationDataAndCustodyBit(data=attestation.data, custody_bit=0b1)),
|
||||||
],
|
],
|
||||||
signature=attestation.aggregate_signature,
|
signature=attestation.aggregate_signature,
|
||||||
domain=get_domain(state.fork, attestation.data.slot, DOMAIN_ATTESTATION),
|
domain=get_domain(state.fork, attestation.data.slot, DOMAIN_ATTESTATION),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user