mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 15:15:16 -05:00
More fixes
This commit is contained in:
@@ -577,7 +577,7 @@ The types are defined topologically to aid in facilitating an executable version
|
||||
# Randomness and committees
|
||||
'latest_randao_mixes': ['bytes32', LATEST_RANDAO_MIXES_LENGTH],
|
||||
'latest_start_shard': 'uint64',
|
||||
|
||||
|
||||
# Finality
|
||||
'previous_epoch_attestations': [PendingAttestation],
|
||||
'current_epoch_attestations': [PendingAttestation],
|
||||
@@ -651,7 +651,7 @@ Note: We aim to migrate to a S[T/N]ARK-friendly hash function in a future Ethere
|
||||
```python
|
||||
def get_temporary_block_header(block: BeaconBlock) -> BeaconBlockHeader:
|
||||
"""
|
||||
Return the block header corresponding to a block with ``state_root`` set to ``ZERO_HASH``.
|
||||
Return the block header corresponding to a block with ``state_root`` set to ``ZERO_HASH``.
|
||||
"""
|
||||
return BeaconBlockHeader(
|
||||
slot=block.slot,
|
||||
@@ -796,7 +796,7 @@ def get_permuted_index(index: int, list_size: int, seed: Bytes32) -> int:
|
||||
"""
|
||||
assert index < list_size
|
||||
assert list_size <= 2**40
|
||||
|
||||
|
||||
for round in range(SHUFFLE_ROUND_COUNT):
|
||||
pivot = bytes_to_int(hash(seed + int_to_bytes1(round))[0:8]) % list_size
|
||||
flip = (pivot - index) % list_size
|
||||
@@ -1659,7 +1659,7 @@ def get_winning_crosslink_and_attesting_indices(state: BeaconState, epoch: Epoch
|
||||
) for a in pending_attestations if a.data.shard == shard]
|
||||
|
||||
if len(candidate_crosslinks) == 0:
|
||||
return Crosslink(GENESIS_EPOCH, ZERO_HASH, ZERO_HASH), []
|
||||
return Crosslink(epoch=GENESIS_EPOCH, crosslink_data_root=ZERO_HASH, previous_crosslink_root=ZERO_HASH), []
|
||||
|
||||
def get_attestations_for(crosslink_data_root) -> List[PendingAttestation]:
|
||||
return [a for a in pending_attestations if a.data.shard == shard and a.data.crosslink_data_root == crosslink_data_root]
|
||||
@@ -1899,7 +1899,7 @@ def update_registry(state: BeaconState) -> None:
|
||||
], key=lambda index: state.validator_registry[index].activation_eligibility_epoch)
|
||||
|
||||
for index in activation_queue[:get_churn_limit(state)]:
|
||||
activate_validator(state, index, is_genesis=False)
|
||||
activate_validator(state, index, is_genesis=False)
|
||||
|
||||
state.latest_start_shard = (
|
||||
state.latest_start_shard +
|
||||
|
||||
@@ -309,7 +309,7 @@ def process_chunk_challenge(state: BeaconState,
|
||||
responder = state.validator_registry[challenge.responder_index]
|
||||
assert responder.exit_epoch >= get_current_epoch(state) - MAX_CHUNK_CHALLENGE_DELAY
|
||||
# Verify the responder participated in the attestation
|
||||
attesters = get_attestation_participants(state, attestation.data, attestation.aggregation_bitfield)
|
||||
attesters = get_attesting_indices(state, attestation.data, attestation.aggregation_bitfield)
|
||||
assert challenge.responder_index in attesters
|
||||
# Verify the challenge is not a duplicate
|
||||
for record in state.custody_chunk_challenge_records:
|
||||
@@ -359,9 +359,9 @@ def process_bit_challenge(state: BeaconState,
|
||||
# Verify the attestation is eligible for challenging
|
||||
responder = state.validator_registry[challenge.responder_index]
|
||||
min_challengeable_epoch = responder.exit_epoch - EPOCHS_PER_CUSTODY_PERIOD * (1 + responder.max_reveal_lateness)
|
||||
assert min_challengeable_epoch <= slot_to_epoch(challenge.attestation.data.slot)
|
||||
assert min_challengeable_epoch <= slot_to_epoch(challenge.attestation.data.slot)
|
||||
# Verify the responder participated in the attestation
|
||||
attesters = get_attestation_participants(state, attestation.data, attestation.aggregation_bitfield)
|
||||
attesters = get_attesting_indices(state, attestation.data, attestation.aggregation_bitfield)
|
||||
assert challenge.responder_index in attesters
|
||||
# A validator can be the challenger or responder for at most one challenge at a time
|
||||
for record in state.custody_bit_challenge_records:
|
||||
|
||||
@@ -299,7 +299,7 @@ Set `attestation.data = attestation_data` where `attestation_data` is the `Attes
|
||||
* Set `aggregation_bitfield[index_into_committee // 8] |= 2 ** (index_into_committee % 8)`.
|
||||
* Set `attestation.aggregation_bitfield = aggregation_bitfield`.
|
||||
|
||||
_Note_: Calling `get_attestation_participants(state, attestation.data, attestation.aggregation_bitfield)` should return a list of length equal to 1, containing `validator_index`.
|
||||
_Note_: Calling `get_attesting_indices(state, attestation.data, attestation.aggregation_bitfield)` should return a list of length equal to 1, containing `validator_index`.
|
||||
|
||||
##### Custody bitfield
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from eth2spec.phase0.spec import (
|
||||
# functions
|
||||
convert_to_indexed,
|
||||
get_active_validator_indices,
|
||||
get_attestation_participants,
|
||||
get_attesting_indices,
|
||||
get_block_root,
|
||||
get_crosslink_committee_for_attestation,
|
||||
get_current_epoch,
|
||||
@@ -300,7 +300,7 @@ def get_valid_attestation(state, slot=None):
|
||||
custody_bitfield=custody_bitfield,
|
||||
aggregate_signature=EMPTY_SIGNATURE,
|
||||
)
|
||||
participants = get_attestation_participants(
|
||||
participants = get_attesting_indices(
|
||||
state,
|
||||
attestation.data,
|
||||
attestation.aggregation_bitfield,
|
||||
|
||||
Reference in New Issue
Block a user