コード例 #1
0
def case1Setup(startedNodes: TestNodeSet):
    nodes = startedNodes
    nodeNames = nodes.nodeNames

    nodeB = nodes.getNode(nodeNames[1])

    # Node B delays self nomination so A's nomination reaches everyone
    nodeB.delaySelfNomination(10)
    # Node B delays nomination from all nodes
    nodeB.nodeIbStasher.delay(delayerMsgTuple(5, Nomination))

    # Add node C and node D
    nodeC = nodes.getNode(nodeNames[2])
    nodeD = nodes.getNode(nodeNames[3])

    # Node C should not try to nominate itself until it gets NOMINATE from B
    nodeC.delaySelfNomination(10)

    # Node D should delay its self nomination for long as it is a slow node
    # and should never win the
    # primary election even if a node maliciously tries to make Node D primary
    nodeD.delaySelfNomination(30)

    # A, C and D should not blacklist B since we are trying to check if
    # multiple nominations from the same node have any impact on
    # the election
    whitelistNode(nodeB.name, [node for node in nodes if node != nodeB],
                  Suspicions.DUPLICATE_NOM_SENT.code)

    return nodes
コード例 #2
0
def setup(txnPoolNodeSet):
    primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
                                 getNonPrimaryReplicas(txnPoolNodeSet, 0)

    faultyRep = nonPrimaryReps[0]
    makeNodeFaulty(
        faultyRep.node,
        partial(sendDuplicate3PhaseMsg, msgType=Commit, count=3, instId=0))

    # The node of the primary replica above should not be blacklisted by any
    # other node since we are simulating multiple COMMIT messages and
    # want to check for a particular suspicion

    whitelistNode(faultyRep.node.name,
                  [node for node in txnPoolNodeSet if node != faultyRep.node],
                  Suspicions.DUPLICATE_CM_SENT.code)

    # If the request is ordered then COMMIT will be rejected much earlier
    for r in [primaryRep, *nonPrimaryReps]:

        def do_nothing(self, commit):
            pass

        r._ordering_service._do_order = types.MethodType(do_nothing, r)

    return adict(primaryRep=primaryRep,
                 nonPrimaryReps=nonPrimaryReps,
                 faultyRep=faultyRep)
コード例 #3
0
def setup(txnPoolNodeSet):
    primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
                                 getNonPrimaryReplicas(txnPoolNodeSet, 0)

    faultyRep = nonPrimaryReps[0]
    makeNodeFaulty(faultyRep.node, partial(sendDuplicate3PhaseMsg,
                                           msgType=Commit, count=3,
                                           instId=0))

    # The node of the primary replica above should not be blacklisted by any
    # other node since we are simulating multiple COMMIT messages and
    # want to check for a particular suspicion

    whitelistNode(faultyRep.node.name,
                  [node for node in txnPoolNodeSet if node != faultyRep.node],
                  Suspicions.DUPLICATE_CM_SENT.code)

    # If the request is ordered then COMMIT will be rejected much earlier
    for r in [primaryRep, *nonPrimaryReps]:
        def do_nothing(self, commit):
            pass

        r.doOrder = types.MethodType(do_nothing, r)

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps,
                 faultyRep=faultyRep)
コード例 #4
0
def case1Setup(startedNodes: TestNodeSet):
    nodes = startedNodes
    nodeNames = nodes.nodeNames

    nodeB = nodes.getNode(nodeNames[1])

    # Node B delays self nomination so A's nomination reaches everyone
    nodeB.delaySelfNomination(10)
    # Node B delays nomination from all nodes
    nodeB.nodeIbStasher.delay(delayerMsgTuple(5, Nomination))

    # Add node C and node D
    nodeC = nodes.getNode(nodeNames[2])
    nodeD = nodes.getNode(nodeNames[3])

    # Node C should not try to nominate itself until it gets NOMINATE from B
    nodeC.delaySelfNomination(10)

    # Node D should delay its self nomination for long as it is a slow node
    # and should never win the
    # primary election even if a node maliciously tries to make Node D primary
    nodeD.delaySelfNomination(30)

    # A, C and D should not blacklist B since we are trying to check if
    # multiple nominations from the same node have any impact on
    # the election
    whitelistNode(nodeB.name,
                  [node for node in nodes if node != nodeB],
                  Suspicions.DUPLICATE_NOM_SENT.code)

    return nodes
コード例 #5
0
def nodeChangesRequest(txnPoolNodeSet):
    alpha = txnPoolNodeSet[0]

    # Alpha should not be blacklisted for Invalid Signature by all other nodes
    whitelistNode(alpha.name,
                  [node for node in txnPoolNodeSet if node != alpha],
                  InvalidSignature.code)
    makeNodeFaulty(alpha, changesRequest, )
コード例 #6
0
def nodeChangesRequest(nodeSet):
    alpha = nodeSet.Alpha

    # Alpha should not be blacklisted for Invalid Signature by all other nodes
    whitelistNode(alpha.name,
                  [node for node in nodeSet if node != alpha],
                  InvalidSignature.code)
    makeNodeFaulty(alpha, changesRequest,)
コード例 #7
0
def txnPoolNodeSet(txnPoolNodeSet):
    delta = txnPoolNodeSet[-1]
    assert not delta.master_replica.isPrimary

    # Alpha should not be blacklisted for Invalid Signature by all other nodes
    whitelistNode(delta.name,
                  [node for node in txnPoolNodeSet if node != delta],
                  InvalidSignature.code)
    makeNodeFaulty(
        delta,
        changesRequest,
    )
    txnPoolNodeSet[2].clientstack.stop()
    return txnPoolNodeSet
コード例 #8
0
def setup(nodeSet, up):
    primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
                                 getNonPrimaryReplicas(nodeSet, 0)

    faultyRep = nonPrimaryReps[0]
    makeNodeFaulty(faultyRep.node, partial(sendDuplicate3PhaseMsg,
                                           msgType=Commit, count=3,
                                           instId=0))

    # The node of the primary replica above should not be blacklisted by any
    # other node since we are simulating multiple COMMIT messages and
    # want to check for a particular suspicion

    whitelistNode(faultyRep.node.name,
                  [node for node in nodeSet if node != faultyRep.node],
                  Suspicions.DUPLICATE_CM_SENT.code)

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps,
                 faultyRep=faultyRep)
コード例 #9
0
def setup(nodeSet, up):
    primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
                                 getNonPrimaryReplicas(nodeSet, 0)

    faultyRep = nonPrimaryReps[0]
    makeNodeFaulty(
        faultyRep.node,
        partial(sendDuplicate3PhaseMsg, msgType=Commit, count=3, instId=0))

    # The node of the primary replica above should not be blacklisted by any
    # other node since we are simulating multiple COMMIT messages and
    # want to check for a particular suspicion

    whitelistNode(faultyRep.node.name,
                  [node for node in nodeSet if node != faultyRep.node],
                  Suspicions.DUPLICATE_CM_SENT.code)

    return adict(primaryRep=primaryRep,
                 nonPrimaryReps=nonPrimaryReps,
                 faultyRep=faultyRep)
コード例 #10
0
def setup(txnPoolNodeSet):
    primaryRep, nonPrimaryReps = getPrimaryReplica(txnPoolNodeSet, 0), \
                                 getNonPrimaryReplicas(txnPoolNodeSet, 0)

    # A non primary replica sends duplicate PREPARE requests to all other
    # replicas
    faultyRep = nonPrimaryReps[0]
    makeNodeFaulty(faultyRep.node, partial(sendDuplicate3PhaseMsg,
                                           msgType=Prepare, count=3,
                                           instId=0))

    # The node of the primary replica above should not be blacklisted by any
    # other node since we are simulating multiple PREPARE messages and
    # want to check for a particular suspicion

    whitelistNode(faultyRep.node.name,
                  [node for node in txnPoolNodeSet if node != faultyRep.node],
                  Suspicions.DUPLICATE_PR_SENT.code)

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps,
                 faultyRep=faultyRep)