Fix python execution 3

This commit is contained in:
Potuz 2024-07-02 21:04:01 -03:00
parent 4500eabf8c
commit d7a199fe09
3 changed files with 38 additions and 24 deletions

View File

@ -156,9 +156,15 @@ def notify_ptc_messages(store: Store, state: BeaconState, payload_attestations:
for payload_attestation in payload_attestations:
indexed_payload_attestation = get_indexed_payload_attestation(state, Slot(state.slot - 1), payload_attestation)
for idx in indexed_payload_attestation.attesting_indices:
on_payload_attestation_message(store,
PayloadAttestationMessage(validator_index=idx,
data=payload_attestation.data, signature=BLSSignature(), is_from_block=True))
on_payload_attestation_message(
store,
PayloadAttestationMessage(
validator_index=idx,
data=payload_attestation.data,
signature=BLSSignature(),
is_from_block=True
)
)
```
### `is_payload_present`
@ -179,7 +185,9 @@ def is_payload_present(store: Store, beacon_block_root: Root) -> bool:
```python
def is_parent_node_full(store: Store, block: BeaconBlock) -> bool:
parent = store.blocks[block.parent_root]
return block.body.signed_execution_payload_header.message.parent_block_hash == parent.body.signed_execution_payload_header.message.block_hash
parent_block_hash = block.body.signed_execution_payload_header.message.parent_block_hash
message_block_hash = parent.body.signed_execution_payload_header.message.block_hash
return parent_block_hash == message_block_hash
```
### Modified `get_ancestor`
@ -497,8 +505,8 @@ def on_tick_per_slot(store: Store, time: uint64) -> None:
### `on_payload_attestation_message`
```python
def on_payload_attestation_message(store: Store,
ptc_message: PayloadAttestationMessage, is_from_block: bool=False) -> None:
def on_payload_attestation_message(
store: Store, ptc_message: PayloadAttestationMessage, is_from_block: bool=False) -> None:
"""
Run ``on_payload_attestation_message`` upon receiving a new ``ptc_message`` directly on the wire.
"""
@ -518,9 +526,14 @@ def on_payload_attestation_message(store: Store,
# Check that the attestation is for the current slot
assert data.slot == get_current_slot(store)
# Verify the signature
assert is_valid_indexed_payload_attestation(state,
IndexedPayloadAttestation(attesting_indices = [ptc_message.validator_index], data = data,
signature = ptc_message.signature))
assert is_valid_indexed_payload_attestation(
state,
IndexedPayloadAttestation(
attesting_indices=[ptc_message.validator_index],
data=data,
signature=ptc_message.signature
)
)
# Update the ptc vote for the block
ptc_index = ptc.index(ptc_message.validator_index)
ptc_vote = store.ptc_vote[data.beacon_block_root]

View File

@ -27,10 +27,10 @@ A validator may be a member of the new Payload Timeliness Committee (PTC) for a
PTC committee selection is only stable within the context of the current and next epoch.
```python
def get_ptc_assignment(state: BeaconState,
def get_ptc_assignment(
state: BeaconState,
epoch: Epoch,
validator_index: ValidatorIndex
) -> Optional[Slot]:
validator_index: ValidatorIndex) -> Optional[Slot]:
"""
Returns the slot during the requested epoch in which the validator with index `validator_index`
is a member of the PTC. Returns None if no assignment is found.
@ -122,7 +122,8 @@ The validator creates `payload_attestation_message` as follows:
Notice that the attester only signs the `PayloadAttestationData` and not the `validator_index` field in the message. Proposers need to aggregate these attestations as described above.
```python
def get_payload_attestation_message_signature(state: BeaconState, attestation: PayloadAttestationMessage, privkey: int) -> BLSSignature:
def get_payload_attestation_message_signature(
state: BeaconState, attestation: PayloadAttestationMessage, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_PTC_ATTESTER, compute_epoch_at_slot(attestation.data.slot))
signing_root = compute_signing_root(attestation.data, domain)
return bls.Sign(privkey, signing_root)