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))
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))
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))
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))
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)
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)
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)
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))
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))
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))
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,)
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))
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))
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))
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, )
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))
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))
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))
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))
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))
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))
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)
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))
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))
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))
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))
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))
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))
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))
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)
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))
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)
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
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)
def evilAlpha(nodeSet): makeNodeFaulty(nodeSet.Alpha, changesRequest)
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))
def setup(startedNodes): A = startedNodes.Alpha A.delaySelfNomination(10) makeNodeFaulty(A, partial(delaysPrePrepareProcessing, delay=60)) return adict(faulty=A)
""" 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. """
def evil_node(txnPoolNodeSet): makeNodeFaulty(txnPoolNodeSet[0], changesRequest)