Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xenowits committed Nov 4, 2022
1 parent ee1fe32 commit 30c2c2f
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions testutil/validatormock/synccomm.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,32 +159,6 @@ func (s *SyncCommMember) Aggregate(ctx context.Context, slot eth2p0.Slot) error
return nil
}

// getSubcommittees returns the subcommittee indexes for the provided sync committee duty.
func getSubcommittees(ctx context.Context, eth2Cl eth2client.SpecProvider, duty eth2v1.SyncCommitteeDuty) ([]eth2p0.CommitteeIndex, error) {
spec, err := eth2Cl.Spec(ctx)
if err != nil {
return nil, err
}

commSize, ok := spec["SYNC_COMMITTEE_SIZE"].(uint64)
if !ok {
return nil, errors.New("invalid SYNC_COMMITTEE_SIZE")
}

subnetCount, ok := spec["SYNC_COMMITTEE_SUBNET_COUNT"].(uint64)
if !ok {
return nil, errors.New("invalid SYNC_COMMITTEE_SUBNET_COUNT")
}

var subcommittees []eth2p0.CommitteeIndex
for _, idx := range duty.ValidatorSyncCommitteeIndices {
subcommIdx := uint64(idx) / commSize / subnetCount
subcommittees = append(subcommittees, eth2p0.CommitteeIndex(subcommIdx))
}

return subcommittees, nil
}

// prepareSyncCommDuties returns sync committee duties for the epoch.
func prepareSyncCommDuties(ctx context.Context, eth2Cl eth2wrap.Client, vals validators, epoch eth2p0.Epoch) (syncDuties, error) {
if len(vals) == 0 {
Expand Down Expand Up @@ -233,7 +207,7 @@ func prepareSyncSelections(ctx context.Context, eth2Cl eth2wrap.Client, signFunc

var selections []*eth2exp.SyncCommitteeSelection
for _, duty := range duties {
subcommIdxs, err := getSubcommittees(ctx, eth2Cl, *duty)
subcommIdxs, err := getSubcommittees(ctx, eth2Cl, duty)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -271,6 +245,32 @@ func prepareSyncSelections(ctx context.Context, eth2Cl eth2wrap.Client, signFunc
return eth2Cl.AggregateSyncCommitteeSelections(ctx, selections)
}

// getSubcommittees returns the subcommittee indexes for the provided sync committee duty.
func getSubcommittees(ctx context.Context, eth2Cl eth2client.SpecProvider, duty *eth2v1.SyncCommitteeDuty) ([]eth2p0.CommitteeIndex, error) {
spec, err := eth2Cl.Spec(ctx)
if err != nil {
return nil, err
}

commSize, ok := spec["SYNC_COMMITTEE_SIZE"].(uint64)
if !ok {
return nil, errors.New("invalid SYNC_COMMITTEE_SIZE")
}

subnetCount, ok := spec["SYNC_COMMITTEE_SUBNET_COUNT"].(uint64)
if !ok {
return nil, errors.New("invalid SYNC_COMMITTEE_SUBNET_COUNT")
}

var subcommittees []eth2p0.CommitteeIndex
for _, idx := range duty.ValidatorSyncCommitteeIndices {
subcommIdx := uint64(idx) / commSize / subnetCount
subcommittees = append(subcommittees, eth2p0.CommitteeIndex(subcommIdx))
}

return subcommittees, nil
}

// submitSyncMessage submits signed sync committee messages for desired slot.
func submitSyncMessage(ctx context.Context, eth2Cl eth2wrap.Client, slot eth2p0.Slot, signFunc SignFunc, duties syncDuties) error {
if len(duties) == 0 {
Expand Down

0 comments on commit 30c2c2f

Please sign in to comment.