Skip to content

Commit

Permalink
Spec - Validator registration and voluntary exit now stop old duties (#…
Browse files Browse the repository at this point in the history
…318)

* fix validator registration + voluntary exit start duty when prev not finished

* add condition for non-beacon duty

* duplicate_duty_finished.go

* duplicate duty not finished

* change error message

* fix error in tests

* finished.go

* ssv msgs

* TestingValidatorRegistrationBySlot

* VoluntaryExitBySlot

* remove TestingEpoch2

* consensus not started

* finished.go

* fix finished

* remove test one

* tests.json

* fix comment

---------

Co-authored-by: Alon Muroch <[email protected]>
  • Loading branch information
GalRogozinski and alonmuroch authored Nov 7, 2023
1 parent 58f3ed8 commit 36b1d5e
Show file tree
Hide file tree
Showing 17 changed files with 696 additions and 70 deletions.
18 changes: 18 additions & 0 deletions ssv/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ func (b *BaseRunner) baseStartNewDuty(runner Runner, duty *types.Duty) error {
return runner.executeDuty(duty)
}

// baseStartNewBeaconDuty is a base func that all runner implementation can call to start a non-beacon duty
func (b *BaseRunner) baseStartNewNonBeaconDuty(runner Runner, duty *types.Duty) error {
if err := b.ShouldProcessNonBeaconDuty(duty); err != nil {
return errors.Wrap(err, "can't start non-beacon duty")
}
b.baseSetupForNewDuty(duty)
return runner.executeDuty(duty)
}

// basePreConsensusMsgProcessing is a base func that all runner implementation can call for processing a pre-consensus msg
func (b *BaseRunner) basePreConsensusMsgProcessing(runner Runner, signedMsg *types.SignedPartialSignatureMessage) (bool, [][32]byte, error) {
if err := b.ValidatePreConsensusMsg(runner, signedMsg); err != nil {
Expand Down Expand Up @@ -240,3 +249,12 @@ func (b *BaseRunner) ShouldProcessDuty(duty *types.Duty) error {
}
return nil
}

func (b *BaseRunner) ShouldProcessNonBeaconDuty(duty *types.Duty) error {
// assume StartingDuty is not nil if state is not nil
if b.State != nil && b.State.StartingDuty.Slot >= duty.Slot {
return errors.Errorf("duty for slot %d already passed. Current slot is %d", duty.Slot,
b.State.StartingDuty.Slot)
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"ValidatorCommitteeIndex": 0,
"ValidatorSyncCommitteeIndices": null
},
"Finished": false
"Finished": true
},
"Share": {
"OperatorID": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"ValidatorCommitteeIndex": 0,
"ValidatorSyncCommitteeIndices": null
},
"Finished": false
"Finished": true
},
"Share": {
"OperatorID": 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"BaseRunner": {
"State": {
"PreConsensusContainer": {
"Signatures": {},
"Quorum": 3
},
"PostConsensusContainer": {
"Signatures": {},
"Quorum": 3
},
"RunningInstance": null,
"DecidedValue": null,
"StartingDuty": {
"Type": 5,
"PubKey": [
142,
128,
6,
101,
81,
168,
27,
49,
130,
88,
112,
158,
218,
247,
221,
31,
99,
205,
104,
106,
14,
77,
184,
178,
155,
187,
122,
207,
230,
86,
8,
103,
122,
245,
165,
39,
217,
68,
142,
228,
120,
53,
72,
94,
2,
181,
11,
192
],
"Slot": 50,
"ValidatorIndex": 1,
"CommitteeIndex": 0,
"CommitteeLength": 0,
"CommitteesAtSlot": 0,
"ValidatorCommitteeIndex": 0,
"ValidatorSyncCommitteeIndices": null
},
"Finished": false
},
"Share": {
"OperatorID": 1,
"ValidatorPubKey": "joAGZVGoGzGCWHCe2vfdH2PNaGoOTbiym7t6z+ZWCGd69aUn2USO5Hg1SF4CtQvA",
"SharePubKey": "l9lKgR1kSTYFKp0tSs1kcYl0z2eNvv0mcyTI6fjnA0pKa32HeeJ6AZU4w8Qlw+Xn",
"Committee": [
{
"OperatorID": 1,
"PubKey": "l9lKgR1kSTYFKp0tSs1kcYl0z2eNvv0mcyTI6fjnA0pKa32HeeJ6AZU4w8Qlw+Xn"
},
{
"OperatorID": 2,
"PubKey": "przr4wl9dBcbQMcSoDHOsDcds9PEAs8s5pG5Eg87q3XU1W36DzdZFUSZm/GMU1Pt"
},
{
"OperatorID": 3,
"PubKey": "gJDgt2ZqRezF1O90GKyZ8J5sskQCn+pqCn/Mvp7gi8U53g36Zr5rq8hJPdmd0amN"
},
{
"OperatorID": 4,
"PubKey": "p8CidrcKXuM5XH1tJlXtYFKKolLU0h7KX8xSI+UMxCvRaLKAq3q1MXNU3d/PPfnk"
}
],
"Quorum": 3,
"PartialQuorum": 2,
"DomainType": [
0,
0,
3,
1
],
"FeeRecipientAddress": [
83,
89,
83,
181,
166,
4,
0,
116,
148,
140,
241,
133,
234,
167,
210,
171,
189,
102,
128,
143
],
"Graffiti": null
},
"QBFTController": null,
"BeaconNetwork": "prater",
"BeaconRoleType": 5
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"BaseRunner": {
"State": {
"PreConsensusContainer": {
"Signatures": {},
"Quorum": 3
},
"PostConsensusContainer": {
"Signatures": {},
"Quorum": 3
},
"RunningInstance": null,
"DecidedValue": null,
"StartingDuty": {
"Type": 6,
"PubKey": [
142,
128,
6,
101,
81,
168,
27,
49,
130,
88,
112,
158,
218,
247,
221,
31,
99,
205,
104,
106,
14,
77,
184,
178,
155,
187,
122,
207,
230,
86,
8,
103,
122,
245,
165,
39,
217,
68,
142,
228,
120,
53,
72,
94,
2,
181,
11,
192
],
"Slot": 50,
"ValidatorIndex": 1,
"CommitteeIndex": 0,
"CommitteeLength": 0,
"CommitteesAtSlot": 0,
"ValidatorCommitteeIndex": 0,
"ValidatorSyncCommitteeIndices": null
},
"Finished": false
},
"Share": {
"OperatorID": 1,
"ValidatorPubKey": "joAGZVGoGzGCWHCe2vfdH2PNaGoOTbiym7t6z+ZWCGd69aUn2USO5Hg1SF4CtQvA",
"SharePubKey": "l9lKgR1kSTYFKp0tSs1kcYl0z2eNvv0mcyTI6fjnA0pKa32HeeJ6AZU4w8Qlw+Xn",
"Committee": [
{
"OperatorID": 1,
"PubKey": "l9lKgR1kSTYFKp0tSs1kcYl0z2eNvv0mcyTI6fjnA0pKa32HeeJ6AZU4w8Qlw+Xn"
},
{
"OperatorID": 2,
"PubKey": "przr4wl9dBcbQMcSoDHOsDcds9PEAs8s5pG5Eg87q3XU1W36DzdZFUSZm/GMU1Pt"
},
{
"OperatorID": 3,
"PubKey": "gJDgt2ZqRezF1O90GKyZ8J5sskQCn+pqCn/Mvp7gi8U53g36Zr5rq8hJPdmd0amN"
},
{
"OperatorID": 4,
"PubKey": "p8CidrcKXuM5XH1tJlXtYFKKolLU0h7KX8xSI+UMxCvRaLKAq3q1MXNU3d/PPfnk"
}
],
"Quorum": 3,
"PartialQuorum": 2,
"DomainType": [
0,
0,
3,
1
],
"FeeRecipientAddress": [
83,
89,
83,
181,
166,
4,
0,
116,
148,
140,
241,
133,
234,
167,
210,
171,
189,
102,
128,
143
],
"Graffiti": null
},
"QBFTController": null,
"BeaconNetwork": "prater",
"BeaconRoleType": 6
}
}
Loading

0 comments on commit 36b1d5e

Please sign in to comment.