Skip to content

Commit

Permalink
GetValidatorSet uses GetCurrentValidators
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkaplan13 committed Oct 25, 2023
1 parent a0c3ca4 commit f93dc95
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion relayer/canonical_validator_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,38 @@ func (v *CanonicalValidatorClient) GetValidatorSet(
height uint64,
subnetID ids.ID,
) (map[ids.NodeID]*validators.GetValidatorOutput, error) {
return v.client.GetValidatorsAt(ctx, subnetID, height)
// Get the current subnet validators. These validators are not expected to include
// BLS signing information given that addPermissionlessValidatorTx is only used to
// add primary network validators.
subnetVdrs, err := v.client.GetCurrentValidators(ctx, subnetID, nil)
if err != nil {
return nil, err
}

// Look up the primary network validators of the NodeIDs validating the subnet
// in order to get their BLS keys.
res := make(map[ids.NodeID]*validators.GetValidatorOutput, len(subnetVdrs))
subnetNodeIDs := make([]ids.NodeID, 0, len(subnetVdrs))
for _, subnetVdr := range subnetVdrs {
subnetNodeIDs = append(subnetNodeIDs, subnetVdr.NodeID)
res[subnetVdr.NodeID] = &validators.GetValidatorOutput{
NodeID: subnetVdr.NodeID,
Weight: subnetVdr.Weight,
}
}
primaryVdrs, err := v.client.GetCurrentValidators(ctx, ids.Empty, subnetNodeIDs)
if err != nil {
return nil, err
}

// Set the BLS keys of the result.
for _, primaryVdr := range primaryVdrs {
vdr, ok := res[primaryVdr.NodeID]
if !ok {
continue
}
vdr.PublicKey = primaryVdr.Signer.Key()
}

return res, nil
}

0 comments on commit f93dc95

Please sign in to comment.