|
| 1 | +from eth2spec.phase0.mainnet import ( |
| 2 | + AttestationData, |
| 3 | + BeaconBlock, |
| 4 | +) |
| 5 | +from dvspec.utils.types import ( |
| 6 | + AttestationDuty, |
| 7 | + ProposerDuty, |
| 8 | + SlashingDB, |
| 9 | +) |
| 10 | +from dvspec.utils.helpers import ( |
| 11 | + is_slashable_attestation_data, |
| 12 | + is_slashable_block, |
| 13 | +) |
| 14 | +from dvspec.consensus import ( |
| 15 | + consensus_is_valid_attestation_data, |
| 16 | + consensus_is_valid_block, |
| 17 | +) |
| 18 | + |
| 19 | +from tests.helpers.eth_node_interface import ( |
| 20 | + bn_produce_attestation_data, |
| 21 | +) |
| 22 | + |
| 23 | + |
| 24 | +""" |
| 25 | +Consensus Specification |
| 26 | +""" |
| 27 | + |
| 28 | + |
| 29 | +def consensus_on_attestation(slashing_db: SlashingDB, attestation_duty: AttestationDuty) -> AttestationData: |
| 30 | + """Consensus protocol between distributed validator nodes for attestation values. |
| 31 | + Returns the decided value. |
| 32 | + If this DV is the leader, it must use `bn_produce_attestation_data` for the proposed value. |
| 33 | + The consensus protocol must use `consensus_is_valid_attestation_data` to determine |
| 34 | + validity of the proposed attestation value. |
| 35 | + """ |
| 36 | + attestation_data = bn_produce_attestation_data(attestation_duty.slot, attestation_duty.committee_index) |
| 37 | + assert consensus_is_valid_attestation_data(slashing_db, attestation_data) |
| 38 | + return attestation_data |
| 39 | + |
| 40 | + |
| 41 | +def consensus_on_block(slashing_db: SlashingDB, proposer_duty: ProposerDuty) -> AttestationData: |
| 42 | + """Consensus protocol between distributed validator nodes for block values. |
| 43 | + Returns the decided value. |
| 44 | + If this DV is the leader, it must use `bn_produce_block` for the proposed value. |
| 45 | + The consensus protocol must use `consensus_is_valid_block` to determine |
| 46 | + validity of the proposed block value. |
| 47 | + """ |
| 48 | + pass |
0 commit comments