Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Hentschel <[email protected]>
  • Loading branch information
zhangchiqing and AlexHentschel committed Sep 19, 2024
1 parent 5ce965a commit ceb3ee2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmd/bootstrap/cmd/rootblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ func rootBlock(cmd *cobra.Command, args []string) {
log.Fatal().Err(err).Msg("invalid epoch timing config")
}

// Read partner node's information and internal node's information.
// With "internal nodes" we reference nodes, whose private keys we have. In comparison,
// for "partner nodes" we generally do not have their keys. However, we allow some overlap,
// in that we tolerate a configuration where information about an "internal node" is also
// duplicated in the list of "partner nodes".
log.Info().Msg("collecting partner network and staking keys")
rawPartnerNodes, err := common.ReadFullPartnerNodeInfos(log, flagPartnerWeights, flagPartnerNodeInfoDir)
if err != nil {
Expand All @@ -160,6 +165,10 @@ func rootBlock(cmd *cobra.Command, args []string) {

log.Info().Msg("")

// we now convert to the strict meaning of: "internal nodes" vs "partner nodes"
// • "internal nodes" we have they private keys for
// • "partner nodes" we don't have the keys for
// • both sets are disjoint (no common nodes)
log.Info().Msg("remove internal partner nodes")
partnerNodes := common.FilterInternalPartners(rawPartnerNodes, internalNodes)
log.Info().Msgf("removed %d internal partner nodes", len(rawPartnerNodes)-len(partnerNodes))
Expand Down
3 changes: 2 additions & 1 deletion cmd/util/cmd/common/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ func internalWeightsByAddress(log zerolog.Logger, config string) map[string]uint
return weights
}

// Reject any partner nodes that are in the internal node list.
// FilterInternalPartners returns the `partners`, dropping any entries that are also in `internal`
// Formally, this function implements the set difference `partners \ internal`.
func FilterInternalPartners(partners []bootstrap.NodeInfo, internal []bootstrap.NodeInfo) []bootstrap.NodeInfo {
lookup := make(map[flow.Identifier]struct{})
for _, node := range internal {
Expand Down

0 comments on commit ceb3ee2

Please sign in to comment.