Skip to content

Commit 48a2bbd

Browse files
committed
Make VC driver for signing process
1 parent aa92ae6 commit 48a2bbd

File tree

4 files changed

+46
-23
lines changed

4 files changed

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

src/dvspec/eth_node_interface.py

Lines changed: 37 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,42 @@ 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 new attestation data or blocks using the following methods:
77+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceAttestationData
78+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceBlockV2
79+
- VC submits new threshold signed attestations or blocks using the following methods:
80+
- https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolAttestations
81+
- https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/publishBlock
82+
"""
83+
84+
def cache_attestation_data_for_vc(attestation_data: AttestationData, attestation_duty: AttestationDuty) -> None:
85+
"""Cache attestation data to provide to VC when it seeks new attestation data using the following method:
86+
https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceAttestationData
7387
"""
74-
# See note about attestation construction here:
75-
# https://github.com/ethereum/beacon-APIs/blame/05c1bc142e1a3fb2a63c79098743776241341d08/validator-flow.md#L35-L37
7688
pass
7789

7890

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.
91+
def cache_block_for_vc(block: BeaconBlock, proposer_duty: ProposerDuty) -> None:
92+
"""Cache block to provide to VC when it seeks a new block using the following method:
93+
https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceAttestationData
8294
"""
8395
pass
96+
97+
98+
def capture_threshold_signed_attestation(threshold_signed_attestation: Attestation) -> None:
99+
"""Captures a threshold signed attestation provided by the VC and starts the recombination process to
100+
construct a complete signed attestation to submit to the BN. The VC submits the attestation using the following method:
101+
https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolAttestations
102+
"""
103+
broadcast_threshold_signed_attestation(threshold_signed_attestation)
104+
105+
106+
def capture_threhold_signed_block(threshold_signed_block: SignedBeaconBlock) -> None:
107+
"""Captures a threshold signed block provided by the VC and starts the recombination process to
108+
construct a complete signed block to submit to the BN. The VC submits the block using the following method:
109+
https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/publishBlock
110+
"""
111+
broadcast_threshold_signed_block(threshold_signed_block)

src/dvspec/spec.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
List,
44
)
55

6+
from eth2spec.phase0.mainnet import Attestation
7+
68
from .eth_node_interface import (
79
AttestationDuty,
10+
ProposerDuty,
811
bn_submit_attestation,
912
bn_submit_block,
10-
ProposerDuty,
11-
vc_sign_attestation,
12-
vc_sign_block,
13+
cache_attestation_data_for_vc,
14+
cache_block_for_vc,
1315
)
1416
from .consensus import (
1517
consensus_on_attestation,
1618
consensus_on_block,
1719
)
1820
from .networking import (
19-
broadcast_threshold_signed_attestation,
20-
broadcast_threshold_signed_block,
2121
construct_signed_attestation,
2222
construct_signed_block,
2323
listen_for_threshold_signed_attestations,
@@ -81,11 +81,9 @@ def serve_attestation_duty(attestation_duty: AttestationDuty) -> None:
8181
# Only a single consensus_on_attestation instance should be
8282
# running at any given time
8383
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)
8684
# Release lock on consensus_on_attestation here.
87-
# Broadcast threshold signed attestation
88-
broadcast_threshold_signed_attestation(threshold_signed_attestation)
85+
# Cache decided attestation data value to provide to VC
86+
cache_block_for_vc(attestation_data, attestation_duty)
8987

9088

9189
def serve_proposer_duty(proposer_duty: ProposerDuty) -> None:
@@ -102,12 +100,9 @@ def serve_proposer_duty(proposer_duty: ProposerDuty) -> None:
102100
# Only a single consensus_on_block instance should be
103101
# running at any given time
104102
block = consensus_on_block(proposer_duty)
105-
106-
# Threshold sign block from local VC
107-
threshold_signed_block = vc_sign_block(block, proposer_duty)
108103
# Release lock on consensus_on_block here.
109-
# Broadcast threshold signed block
110-
broadcast_threshold_signed_block(threshold_signed_block)
104+
# Cache decided block value to provide to VC
105+
cache_attestation_data_for_vc(block, proposer_duty)
111106

112107

113108
def threshold_attestation_combination() -> None:

0 commit comments

Comments
 (0)