Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ssv/validator_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func NewValidatorRegistrationRunner(
operatorSigner *types.OperatorSigner,
gasLimit uint64,
) (Runner, error) {

if len(share) != 1 {
return nil, errors.New("must have one share")
}
Expand Down
60 changes: 43 additions & 17 deletions types/beacon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
BNRoleValidatorRegistration
BNRoleVoluntaryExit

BNRolePreconfCommitment

BNRoleUnknown = math.MaxUint64
)

Expand All @@ -69,6 +71,8 @@ func (r BeaconRole) String() string {
return "VALIDATOR_REGISTRATION"
case BNRoleVoluntaryExit:
return "VOLUNTARY_EXIT"
case BNRolePreconfCommitment:
return "PRECONF_COMMITMENT"
default:
return "UNDEFINED"
}
Expand Down Expand Up @@ -101,6 +105,32 @@ type ValidatorDuty struct {
ValidatorSyncCommitteeIndices []uint64 `ssz-max:"13"`
}

func (bd *ValidatorDuty) DutySlot() spec.Slot {
return bd.Slot
}

func (bd *ValidatorDuty) RunnerRole() RunnerRole {
return MapDutyToRunnerRole(bd.Type)
}

// GetValidatorIndex returns the validator index
func (bd *ValidatorDuty) GetValidatorIndex() spec.ValidatorIndex {
return bd.ValidatorIndex
}

type CommitteeDuty struct {
Slot spec.Slot
ValidatorDuties []*ValidatorDuty
}

func (cd *CommitteeDuty) DutySlot() spec.Slot {
return cd.Slot
}

func (cd *CommitteeDuty) RunnerRole() RunnerRole {
return RoleCommittee
}

func MapDutyToRunnerRole(dutyRole BeaconRole) RunnerRole {
switch dutyRole {
case BNRoleAttester, BNRoleSyncCommittee:
Expand All @@ -115,38 +145,34 @@ func MapDutyToRunnerRole(dutyRole BeaconRole) RunnerRole {
return RoleValidatorRegistration
case BNRoleVoluntaryExit:
return RoleVoluntaryExit
case BNRolePreconfCommitment:
return RolePreconfCommitment
}
return RoleUnknown
}

func (bd *ValidatorDuty) DutySlot() spec.Slot {
return bd.Slot
}
type PreconfCommitmentDuty [32]byte

func (bd *ValidatorDuty) RunnerRole() RunnerRole {
return MapDutyToRunnerRole(bd.Type)
func (pcd *PreconfCommitmentDuty) DutySlot() spec.Slot {
return 0 // TODO - do we need to specify a proper slot for preconf-commitment here ?
}

// GetValidatorIndex returns the validator index
func (bd *ValidatorDuty) GetValidatorIndex() spec.ValidatorIndex {
return bd.ValidatorIndex
func (pcd *PreconfCommitmentDuty) RunnerRole() RunnerRole {
return RolePreconfCommitment
}

type CommitteeDuty struct {
Slot spec.Slot
ValidatorDuties []*ValidatorDuty
func (pcd *PreconfCommitmentDuty) HashTreeRoot() ([32]byte, error) {
return SSZBytes(pcd[:]).HashTreeRoot()
}

func (cd *CommitteeDuty) DutySlot() spec.Slot {
return cd.Slot
func (pcd *PreconfCommitmentDuty) GetTree() (*ssz.Node, error) {
return SSZBytes(pcd[:]).GetTree()
}

func (cd *CommitteeDuty) RunnerRole() RunnerRole {
return RoleCommittee
func (pcd *PreconfCommitmentDuty) HashTreeRootWith(hh ssz.HashWalker) error {
return SSZBytes(pcd[:]).HashTreeRootWith(hh)
}

//

// Available networks.
const (
// MainNetwork represents the main network.
Expand Down
2 changes: 2 additions & 0 deletions types/consensus_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ func (cid *ValidatorConsensusData) Validate() error {
return errors.New("validator registration has no consensus data")
case BNRoleVoluntaryExit:
return errors.New("voluntary exit has no consensus data")
case BNRolePreconfCommitment:
return errors.New("preconf commitment has no consensus data")
default:
return errors.New("unknown duty role")
}
Expand Down
2 changes: 2 additions & 0 deletions types/partial_sig_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
ValidatorRegistrationPartialSig
// VoluntaryExitPartialSig is a partial signature over a VoluntaryExit object
VoluntaryExitPartialSig
// PreconfCommitmentPartialSig is a partial signature over a PreconfCommitment object
PreconfCommitmentPartialSig
)

type PartialSignatureMessages struct {
Expand Down
4 changes: 4 additions & 0 deletions types/runner_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const (
RoleValidatorRegistration
RoleVoluntaryExit

RolePreconfCommitment

RoleUnknown = -1
)

Expand All @@ -30,6 +32,8 @@ func (r RunnerRole) String() string {
return "VALIDATOR_REGISTRATION_RUNNER"
case RoleVoluntaryExit:
return "VOLUNTARY_EXIT_RUNNER"
case RolePreconfCommitment:
return "PRECONF_COMMITMENT_RUNNER"
default:
return "UNDEFINED"
}
Expand Down