address PR comments

This commit is contained in:
sukantoraymond
2023-04-11 15:26:28 -04:00
parent d9b2ee9e78
commit 6761cb79fa
5 changed files with 602 additions and 607 deletions
+587 -588
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -171,7 +171,7 @@ service ControlService {
}
message SubnetParticipants {
repeated string subnet_participants = 1;
repeated string node_names = 1;
}
message ClusterInfo {
@@ -189,7 +189,7 @@ message ClusterInfo {
// The map of blockchain IDs in "ids.ID" format to its blockchain information.
map<string, CustomChainInfo> custom_chains = 8;
repeated string subnets = 9;
map<string, SubnetParticipants> subnetParticipants = 10;
map<string, SubnetParticipants> subnet_participants = 10;
}
message CustomChainInfo {
+8 -3
View File
@@ -389,11 +389,16 @@ func (lc *localNetwork) updateSubnetInfo(ctx context.Context) error {
if err != nil {
return err
}
var nodeIDList []string
var nodeNameList []string
for _, node := range vdrs {
nodeIDList = append(nodeIDList, node.NodeID.String())
for nodeName, nodeInfo := range lc.nodeInfos {
if nodeInfo.Id == node.NodeID.String() {
nodeNameList = append(nodeNameList, nodeName)
}
}
}
lc.subnetParticipants[subnetID] = nodeIDList
lc.subnetParticipants[subnetID] = nodeNameList
}
for chainID, chainInfo := range lc.customChainIDToInfo {
+1 -1
View File
@@ -397,7 +397,7 @@ func (s *server) updateClusterInfo() {
s.clusterInfo.Subnets = s.network.subnets
s.clusterInfo.SubnetParticipants = make(map[string]*rpcpb.SubnetParticipants)
for subnetID, nodes := range s.network.subnetParticipants {
s.clusterInfo.SubnetParticipants[subnetID] = &rpcpb.SubnetParticipants{SubnetParticipants: nodes}
s.clusterInfo.SubnetParticipants[subnetID] = &rpcpb.SubnetParticipants{NodeNames: nodes}
}
}
+4 -13
View File
@@ -104,22 +104,13 @@ func VerifySubnetHasCorrectParticipants(
subnetID string,
) bool {
if cluster != nil {
var nodeIdsList []string
// Get list of node IDs for nodes added as validator to subnet as configured in subnet participants specs
for nodeName, nodeInfo := range cluster.NodeInfos {
for _, subnetValidatorNodeName := range subnetParticipants {
if nodeName == subnetValidatorNodeName {
nodeIdsList = append(nodeIdsList, nodeInfo.Id)
}
}
}
participatingNodeIds := cluster.SubnetParticipants[subnetID].GetSubnetParticipants()
participatingNodeNames := cluster.SubnetParticipants[subnetID].GetNodeNames()
var nodeIsInList bool
// Check that all subnet validators are equal to the node IDs added as participant in subnet creation
for _, nodeID := range nodeIdsList {
for _, node := range subnetParticipants {
nodeIsInList = false
for _, subnetValidator := range participatingNodeIds {
if nodeID == subnetValidator {
for _, subnetValidator := range participatingNodeNames {
if subnetValidator == node {
nodeIsInList = true
break
}