1
1
package ssv
2
2
3
3
import (
4
+ "github.com/attestantio/go-eth2-client/api"
4
5
v1 "github.com/attestantio/go-eth2-client/api/v1"
6
+ "github.com/attestantio/go-eth2-client/spec"
5
7
"github.com/attestantio/go-eth2-client/spec/phase0"
6
8
ssz "github.com/ferranbt/fastssz"
7
9
"github.com/pkg/errors"
@@ -18,6 +20,8 @@ type ValidatorRegistrationRunner struct {
18
20
signer types.BeaconSigner
19
21
operatorSigner * types.OperatorSigner
20
22
valCheck qbft.ProposedValueCheckF
23
+
24
+ gasLimit uint64
21
25
}
22
26
23
27
func NewValidatorRegistrationRunner (
@@ -27,6 +31,7 @@ func NewValidatorRegistrationRunner(
27
31
network Network ,
28
32
signer types.BeaconSigner ,
29
33
operatorSigner * types.OperatorSigner ,
34
+ gasLimit uint64 ,
30
35
) (Runner , error ) {
31
36
32
37
if len (share ) != 1 {
@@ -44,6 +49,7 @@ func NewValidatorRegistrationRunner(
44
49
network : network ,
45
50
signer : signer ,
46
51
operatorSigner : operatorSigner ,
52
+ gasLimit : gasLimit ,
47
53
}, nil
48
54
}
49
55
@@ -80,14 +86,20 @@ func (r *ValidatorRegistrationRunner) ProcessPreConsensus(signedMsg *types.Parti
80
86
specSig := phase0.BLSSignature {}
81
87
copy (specSig [:], fullSig )
82
88
83
- // Get share
84
- share := r .GetShare ()
85
- if share == nil {
86
- return errors .New ("no share to get validator public key" )
89
+ registration , err := r .calculateValidatorRegistration (r .BaseRunner .State .StartingDuty .DutySlot ())
90
+ if err != nil {
91
+ return errors .Wrap (err , "could not calculate validator registration" )
92
+ }
93
+
94
+ signed := & api.VersionedSignedValidatorRegistration {
95
+ Version : spec .BuilderVersionV1 ,
96
+ V1 : & v1.SignedValidatorRegistration {
97
+ Message : registration ,
98
+ Signature : specSig ,
99
+ },
87
100
}
88
101
89
- if err := r .beacon .SubmitValidatorRegistration (share .ValidatorPubKey [:],
90
- share .FeeRecipientAddress , specSig ); err != nil {
102
+ if err := r .beacon .SubmitValidatorRegistration (signed ); err != nil {
91
103
return errors .Wrap (err , "could not submit validator registration" )
92
104
}
93
105
@@ -107,7 +119,7 @@ func (r *ValidatorRegistrationRunner) expectedPreConsensusRootsAndDomain() ([]ss
107
119
if r .BaseRunner .State == nil || r .BaseRunner .State .StartingDuty == nil {
108
120
return nil , types .DomainError , errors .New ("no running duty to compute preconsensus roots and domain" )
109
121
}
110
- vr , err := r .calculateValidatorRegistration (r .BaseRunner .State .StartingDuty )
122
+ vr , err := r .calculateValidatorRegistration (r .BaseRunner .State .StartingDuty . DutySlot () )
111
123
if err != nil {
112
124
return nil , types .DomainError , errors .Wrap (err , "could not calculate validator registration" )
113
125
}
@@ -120,7 +132,7 @@ func (r *ValidatorRegistrationRunner) expectedPostConsensusRootsAndDomain() ([]s
120
132
}
121
133
122
134
func (r * ValidatorRegistrationRunner ) executeDuty (duty types.Duty ) error {
123
- vr , err := r .calculateValidatorRegistration (duty )
135
+ vr , err := r .calculateValidatorRegistration (duty . DutySlot () )
124
136
if err != nil {
125
137
return errors .Wrap (err , "could not calculate validator registration" )
126
138
}
@@ -167,7 +179,7 @@ func (r *ValidatorRegistrationRunner) executeDuty(duty types.Duty) error {
167
179
return nil
168
180
}
169
181
170
- func (r * ValidatorRegistrationRunner ) calculateValidatorRegistration (duty types. Duty ) (* v1.ValidatorRegistration , error ) {
182
+ func (r * ValidatorRegistrationRunner ) calculateValidatorRegistration (slot phase0. Slot ) (* v1.ValidatorRegistration , error ) {
171
183
172
184
share := r .GetShare ()
173
185
if share == nil {
@@ -177,11 +189,11 @@ func (r *ValidatorRegistrationRunner) calculateValidatorRegistration(duty types.
177
189
pk := phase0.BLSPubKey {}
178
190
copy (pk [:], share .ValidatorPubKey [:])
179
191
180
- epoch := r .BaseRunner .BeaconNetwork .EstimatedEpochAtSlot (duty . DutySlot () )
192
+ epoch := r .BaseRunner .BeaconNetwork .EstimatedEpochAtSlot (slot )
181
193
182
194
return & v1.ValidatorRegistration {
183
195
FeeRecipient : share .FeeRecipientAddress ,
184
- GasLimit : types . DefaultGasLimit ,
196
+ GasLimit : r . gasLimit ,
185
197
Timestamp : r .BaseRunner .BeaconNetwork .EpochStartTime (epoch ),
186
198
Pubkey : pk ,
187
199
}, nil
0 commit comments