mirror of https://github.com/poanetwork/quorum.git
added error message when a node not part of network is added is proposed for deactviation
This commit is contained in:
parent
c0d48d90d4
commit
178d7629c4
|
@ -128,7 +128,12 @@ contract Permissions {
|
||||||
function getNodeDetails(string memory enodeId) public view returns (string memory _enodeId, string memory _ipAddrPort, string memory _discPort, string memory _raftPort, NodeStatus _nodeStatus)
|
function getNodeDetails(string memory enodeId) public view returns (string memory _enodeId, string memory _ipAddrPort, string memory _discPort, string memory _raftPort, NodeStatus _nodeStatus)
|
||||||
{
|
{
|
||||||
uint nodeIndex = getNodeIndex(enodeId);
|
uint nodeIndex = getNodeIndex(enodeId);
|
||||||
return (nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort, nodeList[nodeIndex].status);
|
if (nodeIdToIndex[keccak256(abi.encodePacked(enodeId))] != 0){
|
||||||
|
return (nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort, nodeList[nodeIndex].status);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (enodeId, "", "", "", NodeStatus.NotInList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Get node details given index
|
// Get node details given index
|
||||||
function getNodeDetailsFromIndex(uint nodeIndex) public view returns (string memory _enodeId, string memory _ipAddrPort, string memory _discPort, string memory _raftPort, NodeStatus _nodeStatus)
|
function getNodeDetailsFromIndex(uint nodeIndex) public view returns (string memory _enodeId, string memory _ipAddrPort, string memory _discPort, string memory _raftPort, NodeStatus _nodeStatus)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -475,11 +475,15 @@ func (p *PermissionCtrl) populateInitPermission() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update network status to boot completed
|
// update network status to boot completed
|
||||||
err = p.updateNetworkStatus(permissionsSession)
|
err = p.updateNetworkStatus(permissionsSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the default access to ReadOnly
|
||||||
|
types.SetDefaultAccess()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,18 +478,36 @@ func checkNodeDetails(ps *pbind.PermissionsSession, nodeId string, action PermAc
|
||||||
enodeID, discPort, raftPort, ipAddrPort, err := getNodeDetailsFromEnode(nodeId)
|
enodeID, discPort, raftPort, ipAddrPort, err := getNodeDetailsFromEnode(nodeId)
|
||||||
|
|
||||||
cnode, err := ps.GetNodeDetails(enodeID)
|
cnode, err := ps.GetNodeDetails(enodeID)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !(strings.Compare(ipAddrPort, cnode.IpAddrPort) == 0 && strings.Compare(discPort, cnode.DiscPort) == 0 && strings.Compare(raftPort, cnode.RaftPort) == 0) {
|
|
||||||
return errors.New("Details Mismtach"), ErrNodeDetailsMismatch
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeStatus := decodeNodeStatus(cnode.NodeStatus)
|
nodeStatus := decodeNodeStatus(cnode.NodeStatus)
|
||||||
// if node status is Blacklisted no activities are allowed on the same.
|
// if node status is Blacklisted no activities are allowed on the same.
|
||||||
if nodeStatus == "Blacklisted" {
|
if nodeStatus == "Blacklisted" {
|
||||||
return errors.New("Cannot propose blacklisted node"), ErrBlacklistedNode
|
return errors.New("Cannot propose blacklisted node"), ErrBlacklistedNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nodeStatus == "NotInNetwork" && (action == ProposeNodeDeactivation || action == ProposeNodeActivation){
|
||||||
|
return errors.New("operation cannot be performed"), ErrOpNotAllowed
|
||||||
|
}
|
||||||
|
|
||||||
|
newNode := false;
|
||||||
|
if nodeStatus == "NotInNetwork" && len(cnode.IpAddrPort) == 0{
|
||||||
|
newNode = true
|
||||||
|
}
|
||||||
|
detailsMatch := false;
|
||||||
|
if strings.Compare(ipAddrPort, cnode.IpAddrPort) == 0 && strings.Compare(discPort, cnode.DiscPort) == 0 && strings.Compare(raftPort, cnode.RaftPort) == 0 {
|
||||||
|
detailsMatch = true
|
||||||
|
}
|
||||||
|
// if the node is not in network and is being proposed for blacklisting or as a new node
|
||||||
|
// allow the operation. For anyother operation, the node will be in the network and all details
|
||||||
|
// should match
|
||||||
|
if action == ProposeNode || action == ProposeNodeBlacklisting {
|
||||||
|
if !newNode && !detailsMatch {
|
||||||
|
return errors.New("Details Mismtach"), ErrNodeDetailsMismatch
|
||||||
|
}
|
||||||
|
} else if !detailsMatch {
|
||||||
|
return errors.New("Details Mismtach"), ErrNodeDetailsMismatch
|
||||||
|
}
|
||||||
|
|
||||||
// if propose action, check if node status allows the operation
|
// if propose action, check if node status allows the operation
|
||||||
if ((action == ProposeNode && nodeStatus != "NotInNetwork") ||
|
if ((action == ProposeNode && nodeStatus != "NotInNetwork") ||
|
||||||
(action == ProposeNodeDeactivation && nodeStatus != "Approved") ||
|
(action == ProposeNodeDeactivation && nodeStatus != "Approved") ||
|
||||||
|
@ -518,9 +536,8 @@ func checkNodeDetails(ps *pbind.PermissionsSession, nodeId string, action PermAc
|
||||||
return errors.New("Node already proposed"), ErrNodeProposed
|
return errors.New("Node already proposed"), ErrNodeProposed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, ExecSuccess
|
return nil, ExecSuccess
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +683,7 @@ func (s *QuorumControlsAPI) executePermAction(action PermAction, args txArgs) Ex
|
||||||
tx, err = ps.BlacklistNode(enodeID)
|
tx, err = ps.BlacklistNode(enodeID)
|
||||||
|
|
||||||
case SetAccountAccess:
|
case SetAccountAccess:
|
||||||
if (args.accessType > 4){
|
if (args.accessType > 3){
|
||||||
return ErrInvalidAccountAccess
|
return ErrInvalidAccountAccess
|
||||||
}
|
}
|
||||||
if !checkAccountAccess(args.txa.From, args.acctId, args.accessType) {
|
if !checkAccountAccess(args.txa.From, args.acctId, args.accessType) {
|
||||||
|
|
|
@ -49,12 +49,12 @@ func GetAcctAccess(acctId common.Address) AccessType {
|
||||||
return vo.AcctAccess
|
return vo.AcctAccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// return DefaultAccess
|
return DefaultAccess
|
||||||
if AcctMap.Len() == 0 {
|
// if AcctMap.Len() == 0 {
|
||||||
return FullAccess
|
// return FullAccess
|
||||||
} else {
|
// } else {
|
||||||
return ReadOnly
|
// return ReadOnly
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddOrgKey(orgId string, key string) {
|
func AddOrgKey(orgId string, key string) {
|
||||||
|
|
Loading…
Reference in New Issue