コード例 #1
0
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in G, Z:
        makeNodeFaulty(node, changesRequest)
    return adict(faulties=(G, Z))
コード例 #2
0
def setup(txnPoolNodeSet):
    A = txnPoolNodeSet[-2]
    B = txnPoolNodeSet[-1]
    for node in A, B:
        makeNodeFaulty(node, partial(delaysPrePrepareProcessing, delay=60))
        # node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #3
0
def setup(startedNodes):
    A = startedNodes.Alpha
    B = startedNodes.Beta
    for node in A, B:
        makeNodeFaulty(node, changesRequest)
        node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #4
0
def setup(startedNodes):
    # Making nodes faulty such that no primary is chosen
    G = startedNodes.Gamma
    # Delaying nomination to avoid becoming primary
    # G.delaySelfNomination(10)
    makeNodeFaulty(G, partial(delaysPrePrepareProcessing, delay=60))
    return adict(faulty=G)
def setup(txnPoolNodeSet):
    E = txnPoolNodeSet[-3]
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in E, G, Z:
        makeNodeFaulty(node, changesRequest)
    return adict(faulties=(E, G, Z))
コード例 #6
0
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    G = txnPoolNodeSet[-1]
    # Delaying nomination to avoid becoming primary
    # G.delaySelfNomination(10)
    makeNodeFaulty(G, partial(delaysPrePrepareProcessing, delay=60))
    return adict(faulty=G)
コード例 #7
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)
コード例 #8
0
def setup(startedNodes):
    A = startedNodes.Alpha
    B = startedNodes.Beta
    for node in A, B:
        makeNodeFaulty(node, changesRequest)
        node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #9
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)
コード例 #10
0
def evilNodes(txnPoolNodeSet):
    # Delay processing of PRE-PREPARE messages for 90
    # seconds since the timeout for checking sufficient commits is 60 seconds
    for node in nodes_by_rank(txnPoolNodeSet)[-faultyNodes:]:
        makeNodeFaulty(
            node, changesRequest, partial(
                delaysPrePrepareProcessing, delay=90))
コード例 #11
0
def setup(startedNodes):
    A = startedNodes.Gamma
    B = startedNodes.Zeta
    for node in A, B:
        makeNodeFaulty(node, partial(delaysPrePrepareProcessing, delay=60))
        # node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #12
0
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in G, Z:
        makeNodeFaulty(node, changesRequest)
        # node.delaySelfNomination(10)
    return adict(faulties=(G, Z))
コード例 #13
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,)
コード例 #14
0
def setup(startedNodes):
    A = startedNodes.Alpha
    B = startedNodes.Beta
    for node in A, B:
        makeNodeFaulty(node,
                       partial(delaysPrePrepareProcessing, delay=60))
        node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #15
0
def setup(startedNodes):
    # Making nodes faulty such that no primary is chosen
    G = startedNodes.Gamma
    Z = startedNodes.Zeta
    for node in G, Z:
        makeNodeFaulty(node, changesRequest)
        # node.delaySelfNomination(10)
    return adict(faulties=(G, Z))
コード例 #16
0
def setup(startedNodes):
    G = startedNodes.Gamma
    Z = startedNodes.Zeta
    for node in G, Z:
        makeNodeFaulty(node, partial(delaysPrePrepareProcessing, delay=60))
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(G, Z))
コード例 #17
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, )
コード例 #18
0
def setup(txnPoolNodeSet):
    # A = startedNodes.Alpha
    # B = startedNodes.Beta
    A, B = nodes_by_rank(txnPoolNodeSet)[-2:]
    for node in A, B:
        makeNodeFaulty(node, changesRequest,
                       partial(delaysPrePrepareProcessing, delay=90))
    return adict(faulties=(A, B))
コード例 #19
0
def setup(txnPoolNodeSet):
    A = txnPoolNodeSet[-2]
    B = txnPoolNodeSet[-1]
    for node in A, B:
        makeNodeFaulty(node,
                       partial(delaysPrePrepareProcessing, delay=60))
        # node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #20
0
def setup(txnPoolNodeSet):
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in G, Z:
        makeNodeFaulty(node, partial(delaysPrePrepareProcessing, delay=60))
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(G, Z))
コード例 #21
0
def setup(startedNodes):
    E = startedNodes.Eta
    Z = startedNodes.Gamma
    Z = startedNodes.Zeta
    for node in E, Z, Z:
        makeNodeFaulty(node, changesRequest)
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(E, Z, Z))
コード例 #22
0
def setup(txnPoolNodeSet):
    # A = startedNodes.Alpha
    # B = startedNodes.Beta
    A, B = nodes_by_rank(txnPoolNodeSet)[-2:]
    for node in A, B:
        makeNodeFaulty(node, changesRequest,
                       partial(delaysPrePrepareProcessing, delay=90))
        # node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #23
0
def setup(startedNodes):
    A = startedNodes.Alpha
    B = startedNodes.Beta
    G = startedNodes.Gamma
    for node in A, B, G:
        makeNodeFaulty(node, changesRequest, partial(delaysPrePrepareProcessing,
                                                     delay=90))
        node.delaySelfNomination(10)
    return adict(faulties=(A, B, G))
コード例 #24
0
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    A = txnPoolNodeSet[-2]
    B = txnPoolNodeSet[-1]
    # Delay processing of PRE-PREPARE messages by Alpha and Beta for 90
    # seconds since the timeout for checking sufficient commits is 60 seconds
    makeNodeFaulty(A, partial(delaysPrePrepareProcessing, delay=90))
    makeNodeFaulty(B, partial(delaysPrePrepareProcessing, delay=90))
    return adict(faulties=(A, B))
コード例 #25
0
def setup(nodeSet, up):
    primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
        getNonPrimaryReplicas(nodeSet, 0)

    # The primary replica would send PRE-PREPARE messages with incorrect digest
    makeNodeFaulty(primaryRep.node, partial(send3PhaseMsgWithIncorrectDigest,
                                            msgType=PrePrepare))

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps)
コード例 #26
0
def setup(txnPoolNodeSet):
    E = txnPoolNodeSet[-3]
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in E, G, Z:
        makeNodeFaulty(node, changesRequest)
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(E, G, Z))
コード例 #27
0
def setup(nodeSet, up):
    primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
                                 getNonPrimaryReplicas(nodeSet, 0)

    # The primary replica would send PRE-PREPARE messages with incorrect digest
    makeNodeFaulty(primaryRep.node, partial(send3PhaseMsgWithIncorrectDigest,
                                            msgType=PrePrepare))

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps)
コード例 #28
0
def setup(startedNodes):
    A = startedNodes.Alpha
    B = startedNodes.Beta
    G = startedNodes.Gamma
    for node in A, B, G:
        makeNodeFaulty(node, changesRequest,
                       partial(delaysPrePrepareProcessing, delay=90))
        node.delaySelfNomination(10)
    return adict(faulties=(A, B, G))
コード例 #29
0
def setup(txnPoolNodeSet):
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in G, Z:
        makeNodeFaulty(node,
                       partial(delaysPrePrepareProcessing, delay=60))
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(G, Z))
コード例 #30
0
def setup(startedNodes):
    # A = startedNodes.Alpha
    # B = startedNodes.Beta
    A, B = startedNodes.nodes_by_rank[-2:]
    for node in A, B:
        makeNodeFaulty(node, changesRequest,
                       partial(delaysPrePrepareProcessing, delay=90))
        # node.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #31
0
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    A = txnPoolNodeSet[-3]
    B = txnPoolNodeSet[-2]
    G = txnPoolNodeSet[-1]
    for node in A, B, G:
        makeNodeFaulty(
            node, changesRequest, partial(
                delaysPrePrepareProcessing, delay=90))
    return adict(faulties=(A, B, G))
コード例 #32
0
def setup(nodeSet, up):
    primaryRep = getPrimaryReplica(nodeSet, 0)
    nonPrimaryReps = getNonPrimaryReplicas(nodeSet, 0)

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

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

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

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps,
                 faultyRep=faultyRep)
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    E = txnPoolNodeSet[-3]
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in E, G, Z:
        makeNodeFaulty(
            node, changesRequest,
            partial(delaysPrePrepareProcessing, delay=delayPrePrepareSec))
    return adict(faulties=(E, G, Z))
コード例 #35
0
def setup(startedNodes):
    A = startedNodes.Alpha
    B = startedNodes.Beta
    # Delay processing of PRE-PREPARE messages by Alpha and Beta for 90
    # seconds since the timeout for checking sufficient commits is 60 seconds
    makeNodeFaulty(A, partial(delaysPrePrepareProcessing, delay=90))
    makeNodeFaulty(B, partial(delaysPrePrepareProcessing, delay=90))
    A.delaySelfNomination(10)
    B.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #36
0
def setup(startedNodes):
    A = startedNodes.Alpha
    B = startedNodes.Beta
    # Delay processing of PRE-PREPARE messages by Alpha and Beta for 90
    # seconds since the timeout for checking sufficient commits is 60 seconds
    makeNodeFaulty(A, partial(delaysPrePrepareProcessing, delay=90))
    makeNodeFaulty(B, partial(delaysPrePrepareProcessing, delay=90))
    A.delaySelfNomination(10)
    B.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #37
0
def setup(startedNodes):
    # Making nodes faulty such that no primary is chosen
    A = startedNodes.Eta
    B = startedNodes.Gamma
    G = startedNodes.Zeta
    for node in A, B, G:
        makeNodeFaulty(node, changesRequest,
                       partial(delaysPrePrepareProcessing, delay=90))
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(A, B, G))
コード例 #38
0
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    A = txnPoolNodeSet[-3]
    B = txnPoolNodeSet[-2]
    G = txnPoolNodeSet[-1]
    for node in A, B, G:
        makeNodeFaulty(node, changesRequest,
                       partial(delaysPrePrepareProcessing, delay=90))
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(A, B, G))
def setup(txnPoolNodeSet):
    # Making nodes faulty such that no primary is chosen
    E = txnPoolNodeSet[-3]
    G = txnPoolNodeSet[-2]
    Z = txnPoolNodeSet[-1]
    for node in E, G, Z:
        makeNodeFaulty(node,
                       changesRequest, partial(delaysPrePrepareProcessing,
                                               delay=delayPrePrepareSec))
        # Delaying nomination to avoid becoming primary
        # node.delaySelfNomination(10)
    return adict(faulties=(E, G, Z))
コード例 #40
0
def setup(nodeSet, up):
    primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
                                 getNonPrimaryReplicas(nodeSet, 0)

    # A non primary replica sends PREPARE messages with incorrect digest

    faultyRep = nonPrimaryReps[0]
    makeNodeFaulty(faultyRep.node, partial(send3PhaseMsgWithIncorrectDigest,
                                           msgType=Prepare, instId=0))

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps,
                 faultyRep=faultyRep)
コード例 #41
0
def setup(startedNodes):
    # Making nodes faulty such that no primary is chosen
    A = startedNodes.Gamma
    B = startedNodes.Zeta
    # Delay processing of PRE-PREPARE messages by Alpha and Beta for 90
    # seconds since the timeout for checking sufficient commits is 60 seconds
    makeNodeFaulty(A, partial(delaysPrePrepareProcessing, delay=90))
    makeNodeFaulty(B, partial(delaysPrePrepareProcessing, delay=90))
    # Delaying nomination to avoid becoming primary
    # A.delaySelfNomination(10)
    # B.delaySelfNomination(10)
    return adict(faulties=(A, B))
コード例 #42
0
ファイル: test_prepare_digest.py プロジェクト: tomergi/plenum
def setup(nodeSet, up):
    primaryRep, nonPrimaryReps = getPrimaryReplica(nodeSet, 0), \
                                 getNonPrimaryReplicas(nodeSet, 0)

    # A non primary replica sends PREPARE messages with incorrect digest

    faultyRep = nonPrimaryReps[0]
    makeNodeFaulty(faultyRep.node, partial(send3PhaseMsgWithIncorrectDigest,
                                           msgType=Prepare, instId=0))

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

    # The primary replica would send 3 duplicate PRE-PREPARE requests to
    # non primary replicas
    makeNodeFaulty(primaryRep.node, partial(sendDuplicate3PhaseMsg,
                                            msgType=PrePrepare, count=3))

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

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

    # The primary replica would send 3 duplicate PRE-PREPARE requests to
    # non primary replicas
    makeNodeFaulty(primaryRep.node, partial(sendDuplicate3PhaseMsg,
                                            msgType=PrePrepare, count=3))

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

    return adict(primaryRep=primaryRep, nonPrimaryReps=nonPrimaryReps)
コード例 #45
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
コード例 #46
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)
def setup(txnPoolNodeSet):
    A = txnPoolNodeSet[-1]
    makeNodeFaulty(A,
                   partial(delaysPrePrepareProcessing, delay=60))
    # A.delaySelfNomination(10)
    return adict(faulties=A)
コード例 #48
0
def evilAlpha(nodeSet):
    makeNodeFaulty(nodeSet.Alpha, changesRequest)
コード例 #49
0
def evilAlpha(txnPoolNodeSet):
    # Delay processing of PRE-PREPARE messages by Alpha for 90
    # seconds since the timeout for checking sufficient commits is 60 seconds
    makeNodeFaulty(txnPoolNodeSet[0], partial(
        delaysPrePrepareProcessing, delay=90))
コード例 #50
0
def setup(startedNodes):
    A = startedNodes.Alpha
    A.delaySelfNomination(10)
    makeNodeFaulty(A,
                   partial(delaysPrePrepareProcessing, delay=60))
    return adict(faulty=A)
コード例 #51
0
ファイル: tutorial.py プロジェクト: evernym/plenum
        """
        print("Reply: {}\n".format(reply))
        print("Status: {}\n".format(status))

        """
        See the reply details of a request.
        """
        client.showReplyDetails(request.reqId)

        """
        As we are using 4 nodes, we have an f-value of 1, which means that
        consensus can be still achieved with one faulty node. In this example,
        we're going to cause Beta to be malicious, altering a client's request
        before propagating to other nodes.
        """
        makeNodeFaulty(beta, faultyReply)

        """
        Create a new message.
        """
        msg = {"type": "sell", "amount": 101}

        """
        And now sign and submit it to the pool.
        """
        request2 = wallet.signOp(msg, identifier=wallet.defaultId)
        client.submitReqs(request2)

        """
        Allow time for the message to be executed.
        """
コード例 #52
0
def evil_node(txnPoolNodeSet):
    makeNodeFaulty(txnPoolNodeSet[0], changesRequest)