Skip to content

Commit 82c1d08

Browse files
authored
Merge pull request #5 from ethereum/vc_fetches_data
Make VC driver for signing process
2 parents aa92ae6 + 6ba3301 commit 82c1d08

File tree

4 files changed

+51
-23
lines changed

4 files changed

+51
-23
lines changed
49.1 KB
Loading
40.7 KB
Loading

src/dvspec/eth_node_interface.py

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
SignedBeaconBlock,
77
)
88

9+
from .networking import (
10+
broadcast_threshold_signed_attestation,
11+
broadcast_threshold_signed_block
12+
)
913
from .utils.types import (
1014
AttestationDuty,
1115
BLSSignature,
@@ -66,18 +70,49 @@ def bn_submit_block(block: SignedBeaconBlock) -> None:
6670

6771
# Validator Client Interface
6872

69-
70-
def vc_sign_attestation(attestation_data: AttestationData, attestation_duty: AttestationDuty) -> Attestation:
71-
"""Returns a signed attestations that is constructed using the given attestation data & attestation duty.
72-
This endpoint does not exist in beacon-APIs.
73+
"""
74+
The VC is connected to the BN through the DVC. The DVC pretends to be a proxy for the BN, except
75+
when:
76+
- VC asks for its attestation, block proposal, or sync duties using the following methods:
77+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/getAttesterDuties
78+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/getProposerDuties
79+
- mhttps://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/getSyncCommitteeDuties
80+
- VC asks for new attestation data, block, or sync duty using the following methods:
81+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceAttestationData
82+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceBlockV2
83+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceSyncCommitteeContribution
84+
- VC submits new threshold signed attestation, block proposal, or sync duty using the following methods:
85+
- https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolAttestations
86+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/publishBlock
87+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceSyncCommitteeContribution
88+
"""
89+
90+
91+
def cache_attestation_data_for_vc(attestation_data: AttestationData, attestation_duty: AttestationDuty) -> None:
92+
"""Cache attestation data to provide to VC when it seeks new attestation data using the following method:
93+
https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceAttestationData
7394
"""
74-
# See note about attestation construction here:
75-
# https://github.com/ethereum/beacon-APIs/blame/05c1bc142e1a3fb2a63c79098743776241341d08/validator-flow.md#L35-L37
7695
pass
7796

7897

79-
def vc_sign_block(block: BeaconBlock, proposer_duty: ProposerDuty) -> SignedBeaconBlock:
80-
"""Returns a signed beacon block using the validator index given in the proposer duty.
81-
This endpoint does not exist in beacon-APIs.
98+
def cache_block_for_vc(block: BeaconBlock, proposer_duty: ProposerDuty) -> None:
99+
"""Cache block to provide to VC when it seeks a new block using the following method:
100+
https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceAttestationData
82101
"""
83102
pass
103+
104+
105+
def capture_threshold_signed_attestation(threshold_signed_attestation: Attestation) -> None:
106+
"""Captures a threshold signed attestation provided by the VC and starts the recombination process to
107+
construct a complete signed attestation to submit to the BN. The VC submits the attestation using the
108+
following method: https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolAttestations
109+
"""
110+
broadcast_threshold_signed_attestation(threshold_signed_attestation)
111+
112+
113+
def capture_threhold_signed_block(threshold_signed_block: SignedBeaconBlock) -> None:
114+
"""Captures a threshold signed block provided by the VC and starts the recombination process to
115+
construct a complete signed block to submit to the BN. The VC submits the block using the following method:
116+
https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/publishBlock
117+
"""
118+
broadcast_threshold_signed_block(threshold_signed_block)

src/dvspec/spec.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55

66
from .eth_node_interface import (
77
AttestationDuty,
8+
ProposerDuty,
89
bn_submit_attestation,
910
bn_submit_block,
10-
ProposerDuty,
11-
vc_sign_attestation,
12-
vc_sign_block,
11+
cache_attestation_data_for_vc,
12+
cache_block_for_vc,
1313
)
1414
from .consensus import (
1515
consensus_on_attestation,
1616
consensus_on_block,
1717
)
1818
from .networking import (
19-
broadcast_threshold_signed_attestation,
20-
broadcast_threshold_signed_block,
2119
construct_signed_attestation,
2220
construct_signed_block,
2321
listen_for_threshold_signed_attestations,
@@ -81,11 +79,9 @@ def serve_attestation_duty(attestation_duty: AttestationDuty) -> None:
8179
# Only a single consensus_on_attestation instance should be
8280
# running at any given time
8381
attestation_data = consensus_on_attestation(attestation_duty)
84-
# Threshold sign attestation from local VC
85-
threshold_signed_attestation = vc_sign_attestation(attestation_data, attestation_duty)
8682
# Release lock on consensus_on_attestation here.
87-
# Broadcast threshold signed attestation
88-
broadcast_threshold_signed_attestation(threshold_signed_attestation)
83+
# Cache decided attestation data value to provide to VC
84+
cache_attestation_data_for_vc(attestation_data, attestation_duty)
8985

9086

9187
def serve_proposer_duty(proposer_duty: ProposerDuty) -> None:
@@ -102,12 +98,9 @@ def serve_proposer_duty(proposer_duty: ProposerDuty) -> None:
10298
# Only a single consensus_on_block instance should be
10399
# running at any given time
104100
block = consensus_on_block(proposer_duty)
105-
106-
# Threshold sign block from local VC
107-
threshold_signed_block = vc_sign_block(block, proposer_duty)
108101
# Release lock on consensus_on_block here.
109-
# Broadcast threshold signed block
110-
broadcast_threshold_signed_block(threshold_signed_block)
102+
# Cache decided block value to provide to VC
103+
cache_block_for_vc(block, proposer_duty)
111104

112105

113106
def threshold_attestation_combination() -> None:

0 commit comments

Comments
 (0)