Fix
1. To make it more compatible, update `is_on_time_attestation` argument: replace `attestation: Attestation` with `attestation_data: AttestationData` 2. Fix `get_sample_shard_transition`
This commit is contained in:
parent
c28857e4e1
commit
1a5016157a
|
@ -652,11 +652,11 @@ def get_offset_slots(state: BeaconState, shard: Shard) -> Sequence[Slot]:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def is_on_time_attestation(state: BeaconState,
|
def is_on_time_attestation(state: BeaconState,
|
||||||
attestation: Attestation) -> bool:
|
attestation_data: AttestationData) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if the given attestation is on-time.
|
Check if the given ``attestation_data`` is on-time.
|
||||||
"""
|
"""
|
||||||
return attestation.data.slot == compute_previous_slot(state.slot)
|
return attestation_data.slot == compute_previous_slot(state.slot)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `is_winning_attestation`
|
#### `is_winning_attestation`
|
||||||
|
@ -667,11 +667,11 @@ def is_winning_attestation(state: BeaconState,
|
||||||
committee_index: CommitteeIndex,
|
committee_index: CommitteeIndex,
|
||||||
winning_root: Root) -> bool:
|
winning_root: Root) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if ``attestation`` helped contribute to the successful crosslink of
|
Check if on-time ``attestation`` helped contribute to the successful crosslink of
|
||||||
``winning_root`` formed by ``committee_index`` committee at the current slot.
|
``winning_root`` formed by ``committee_index`` committee.
|
||||||
"""
|
"""
|
||||||
return (
|
return (
|
||||||
is_on_time_attestation(state, attestation)
|
is_on_time_attestation(state, attestation.data)
|
||||||
and attestation.data.index == committee_index
|
and attestation.data.index == committee_index
|
||||||
and attestation.data.shard_transition_root == winning_root
|
and attestation.data.shard_transition_root == winning_root
|
||||||
)
|
)
|
||||||
|
@ -766,7 +766,7 @@ def validate_attestation(state: BeaconState, attestation: Attestation) -> None:
|
||||||
assert attestation.data.source == state.previous_justified_checkpoint
|
assert attestation.data.source == state.previous_justified_checkpoint
|
||||||
|
|
||||||
# Type 1: on-time attestations
|
# Type 1: on-time attestations
|
||||||
if is_on_time_attestation(state, attestation):
|
if is_on_time_attestation(state, attestation.data):
|
||||||
# Correct parent block root
|
# Correct parent block root
|
||||||
assert data.beacon_block_root == get_block_root_at_slot(state, compute_previous_slot(state.slot))
|
assert data.beacon_block_root == get_block_root_at_slot(state, compute_previous_slot(state.slot))
|
||||||
# Correct shard number
|
# Correct shard number
|
||||||
|
@ -941,7 +941,7 @@ def process_crosslinks(state: BeaconState,
|
||||||
# Since the attestations are validated, all `shard_attestations` satisfy `attestation.data.shard == shard`
|
# Since the attestations are validated, all `shard_attestations` satisfy `attestation.data.shard == shard`
|
||||||
shard_attestations = [
|
shard_attestations = [
|
||||||
attestation for attestation in attestations
|
attestation for attestation in attestations
|
||||||
if is_on_time_attestation(state, attestation) and attestation.data.index == committee_index
|
if is_on_time_attestation(state, attestation.data) and attestation.data.index == committee_index
|
||||||
]
|
]
|
||||||
winning_root = process_crosslink_for_shard(
|
winning_root = process_crosslink_for_shard(
|
||||||
state, committee_index, shard_transitions[shard], shard_attestations
|
state, committee_index, shard_transitions[shard], shard_attestations
|
||||||
|
|
|
@ -157,7 +157,7 @@ def get_shard_winning_roots(state: BeaconState,
|
||||||
# All attestations in the block for this committee/shard and are "on time"
|
# All attestations in the block for this committee/shard and are "on time"
|
||||||
shard_attestations = [
|
shard_attestations = [
|
||||||
attestation for attestation in attestations
|
attestation for attestation in attestations
|
||||||
if is_on_time_attestation(state, attestation) and attestation.data.index == committee_index
|
if is_on_time_attestation(state, attestation.data) and attestation.data.index == committee_index
|
||||||
]
|
]
|
||||||
committee = get_beacon_committee(state, on_time_attestation_slot, committee_index)
|
committee = get_beacon_committee(state, on_time_attestation_slot, committee_index)
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ def get_sample_shard_transition(spec, start_slot, block_lengths):
|
||||||
start_slot=start_slot,
|
start_slot=start_slot,
|
||||||
shard_block_lengths=block_lengths,
|
shard_block_lengths=block_lengths,
|
||||||
shard_data_roots=b,
|
shard_data_roots=b,
|
||||||
shard_states=[spec.Root() for x in block_lengths],
|
shard_states=[spec.ShardState() for x in block_lengths],
|
||||||
proposer_signature_aggregate=spec.BLSSignature(),
|
proposer_signature_aggregate=spec.BLSSignature(),
|
||||||
)
|
)
|
||||||
return shard_transition
|
return shard_transition
|
||||||
|
|
Loading…
Reference in New Issue