Exemplo n.º 1
0
def test_add_bls_three_nodes(looper, txnPoolNodeSet, sdk_pool_handle,
                             sdk_wallet_stewards, sdk_wallet_client):
    '''
    Added BLS key for 1st, 2d and 3d Nodes;
    expect that BLS multi-sigs are applied since we have consensus now (3=n-f)
    '''

    # make sure that we have commits from all nodes, and have 3 of 4 (n-f) BLS sigs there is enough
    # otherwise we may have 3 commits, but 1 of them may be without BLS, so we will Order this txn, but without multi-sig

    def patched_set_validators(self, validators):
        ConsensusSharedData.set_validators(self, validators)
        self.quorums.commit = Quorum(nodeCount)

    for node in txnPoolNodeSet:
        for r in node.replicas.values():
            r._consensus_data.quorums.commit = Quorum(nodeCount)
            r._consensus_data.set_validators = functools.partial(
                patched_set_validators, r._consensus_data)
        node.quorums.commit = Quorum(nodeCount)
    check_update_bls_key(node_num=2,
                         saved_multi_sigs_count=4,
                         looper=looper,
                         txnPoolNodeSet=txnPoolNodeSet,
                         sdk_wallet_stewards=sdk_wallet_stewards,
                         sdk_wallet_client=sdk_wallet_client,
                         sdk_pool_handle=sdk_pool_handle)
def test_send_txns_bls_consensus(looper, txnPoolNodeSet, sdk_pool_handle,
                                 sdk_wallet_client):
    # make sure that we have commits from all nodes, and have 5 of 7 (n-f) BLS sigs there is enough
    # otherwise we may have 3 commits, but 1 of them may be without BLS, so we will Order this txn, but without multi-sig
    for node in txnPoolNodeSet:
        node.quorums.commit = Quorum(nodeCount)
        for r in node.replicas.values():
            r._consensus_data.quorums.commit = Quorum(nodeCount)
    # we expect that although not all nodes can sign with BLS (because not all nodes have BLS keys),
    # we get multi-sig on all nodes (since all nodes can verify signatures)
    sdk_check_bls_multi_sig_after_send(looper,
                                       txnPoolNodeSet,
                                       sdk_pool_handle,
                                       sdk_wallet_client,
                                       saved_multi_sigs_count=nodeCount)
def test_deletion_non_forwarded_request(
        looper, chkFreqPatched, reqs_for_checkpoint, txnPoolNodeSet,
        sdk_pool_handle, sdk_wallet_steward, tconf, tdir, allPluginsPath):
    behind_node = txnPoolNodeSet[-1]
    [behind_node.replicas.values()[1].discard_req_key(1, key) for key in behind_node.requests]
    behind_node.requests.clear()

    sdk_send_batches_of_random_and_check(looper, txnPoolNodeSet, sdk_pool_handle,
                                         sdk_wallet_steward, CHK_FREQ, CHK_FREQ)
    behind_node.quorums.propagate = Quorum(len(txnPoolNodeSet) + 1)

    with delay_rules(behind_node.nodeIbStasher,
                     ppDelay(delay=sys.maxsize),
                     pDelay(delay=sys.maxsize),
                     cDelay(delay=sys.maxsize)):
        count = behind_node.spylog.count(behind_node.allLedgersCaughtUp)
        sdk_send_batches_of_random(looper, txnPoolNodeSet, sdk_pool_handle,
                                   sdk_wallet_steward, req_num, req_num)
        looper.run(eventually(node_caughtup, behind_node, count, retryWait=1))

    # We clear caughtup requests
    looper.run(eventually(lambda: assertExp(len(behind_node.requests) == 0)))
    assert all([len(q) == 0 for r in behind_node.replicas.values() for q in r._ordering_service.requestQueues.values()])
    assert len(behind_node.clientAuthNr._verified_reqs) == 0
    assert len(behind_node.requestSender) == 0
def test_send_txns_bls_less_than_consensus(looper, txnPoolNodeSet,
                                           client1, client1Connected, wallet1):
    # make sure that we have commits from all nodes, and have 4 of 7 ( < n-f) BLS sigs there is not enough
    for node in txnPoolNodeSet:
        node.quorums.commit = Quorum(nodeCount)
    check_bls_multi_sig_after_send(looper, txnPoolNodeSet,
                                   client1, wallet1,
                                   saved_multi_sigs_count=0)
Exemplo n.º 5
0
 def req_with_acceptable_quorum(self, quorum: Quorum):
     digests = defaultdict(set)
     # this is workaround because we are getting a propagate from
     # somebody with non-str (byte) name
     for sender, req in filter(lambda x: isinstance(x[0], str),
                               self.propagates.items()):
         digests[req.digest].add(sender)
         if quorum.is_reached(len(digests[req.digest])):
             return req
def setup(txnPoolNodeSet):
    faulty_node = txnPoolNodeSet[-1]
    # Set quorum a bit more, so that faulty_node will request propagates
    faulty_node.quorums.propagate = Quorum(3)

    # do not receive requests and Propagates so that Propagates will be requested
    faulty_node.clientIbStasher.delay(req_delay())
    faulty_node.nodeIbStasher.delay(ppgDelay())
    return faulty_node
def setup(txnPoolNodeSet):
    faulty_node = txnPoolNodeSet[-1]
    # Set quorum a bit more, so that faulty_node will request propagates
    faulty_node.quorums.propagate = Quorum(3)

    # Only Alpha allowed to send propagate to faulty_node
    dont_send_messages_to(txnPoolNodeSet[1:-1], faulty_node.name,
                          dont_send_propagate)
    return faulty_node
Exemplo n.º 8
0
 def req_with_acceptable_quorum(self, quorum: Quorum):
     digests = defaultdict(set)
     # this is workaround because we are getting a propagate from
     # somebody with non-str (byte) name
     for sender, req in filter(lambda x: isinstance(
             x[0], str), self.propagates.items()):
         digests[req.digest].add(sender)
         if quorum.is_reached(len(digests[req.digest])):
             return req
Exemplo n.º 9
0
def test_update_bls_three_nodes(looper, txnPoolNodeSet, tdirWithPoolTxns,
                                poolTxnClientData,
                                stewards_and_wallets):
    '''
    Added BLS key for 1st, 2d and 3d Nodes;
    expect that BLS multi-sigs are applied since we have consensus now (3=n-f)
    '''
    # make sure that we have commits from all nodes, and have 3 of 4 (n-f) BLS sigs there is enough
    # otherwise we may have 3 commits, but 1 of them may be without BLS, so we will Order this txn, but without multi-sig
    for node in txnPoolNodeSet:
        node.quorums.commit = Quorum(nodeCount)
    check_update_bls_key(node_num=2,
                         saved_multi_sigs_count=4,
                         looper=looper, txnPoolNodeSet=txnPoolNodeSet, tdirWithPoolTxns=tdirWithPoolTxns,
                         poolTxnClientData=poolTxnClientData,
                         stewards_and_wallets=stewards_and_wallets)
Exemplo n.º 10
0
def test_add_incorrect_bls_one_node(looper, txnPoolNodeSet, tdirWithPoolTxns,
                                    poolTxnClientData,
                                    stewards_and_wallets):
    '''
    Updated with wrong BLS key for 1st Node;
    Expect that BLS multi-sigs are applied since we have 3 correct signatures
    '''
    # make sure that we have commits from all nodes, and have 3 of 4 (n-f) BLS sigs there is enough
    # otherwise we may have 3 commits, but 1 of them may be without BLS, so we will Order this txn, but without multi-sig
    for node in txnPoolNodeSet:
        node.quorums.commit = Quorum(nodeCount)
    check_update_bls_key(node_num=0,
                         saved_multi_sigs_count=4,
                         looper=looper, txnPoolNodeSet=txnPoolNodeSet, tdirWithPoolTxns=tdirWithPoolTxns,
                         poolTxnClientData=poolTxnClientData,
                         stewards_and_wallets=stewards_and_wallets,
                         add_wrong=True)
Exemplo n.º 11
0
def test_add_incorrect_bls_three_nodes(looper, txnPoolNodeSet, sdk_pool_handle,
                                       sdk_wallet_stewards, sdk_wallet_client):
    '''
    Added wrong BLS key for 1-3 Nodes;
    do not expect that BLS multi-sigs are applied
    '''
    # make sure that we have commits from all nodes, and have 3 of 4 (n-f) BLS sigs there is enough
    # otherwise we may have 3 commits, but 1 of them may be without BLS, so we will Order this txn, but without multi-sig
    for node in txnPoolNodeSet:
        node.quorums.commit = Quorum(nodeCount)
    check_update_bls_key(node_num=2,
                         saved_multi_sigs_count=0,
                         looper=looper,
                         txnPoolNodeSet=txnPoolNodeSet,
                         sdk_wallet_stewards=sdk_wallet_stewards,
                         sdk_wallet_client=sdk_wallet_client,
                         sdk_pool_handle=sdk_pool_handle,
                         add_wrong=True)
Exemplo n.º 12
0
 def patched_set_validators(self, validators):
     ConsensusSharedData.set_validators(self, validators)
     self.quorums.commit = Quorum(nodeCount)