Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        from plenum.common.stacks import nodeStackClass, clientStackClass
        self.NodeStackClass = nodeStackClass
        self.ClientStackClass = clientStackClass

        Node.__init__(self, *args, **kwargs)
        TestNodeCore.__init__(self, *args, **kwargs)
        self.cleanupOnStopping = True
Esempio n. 2
0
def config_state(constraint_serializer):
    state = PruningState(KeyValueStorageInMemory())
    Node.add_auth_rules_to_config_state(state=state,
                                        auth_map=auth_map,
                                        serializer=constraint_serializer)
    Node.add_auth_rules_to_config_state(state=state,
                                        auth_map=anyone_can_write_map,
                                        serializer=constraint_serializer)
    return state
Esempio n. 3
0
    def __init__(self, *args, **kwargs):
        from plenum.common.stacks import nodeStackClass, clientStackClass
        self.NodeStackClass = nodeStackClass
        self.ClientStackClass = clientStackClass
        if kwargs.get('bootstrap_cls', None) is None:
            kwargs['bootstrap_cls'] = TestNodeBootstrap

        Node.__init__(self, *args, **kwargs)
        TestNodeCore.__init__(self, *args, **kwargs)
        self.cleanupOnStopping = True
Esempio n. 4
0
def run_node(config, name, node_port, client_port):
    node_ha = HA("0.0.0.0", node_port)
    client_ha = HA("0.0.0.0", client_port)

    logFileName = os.path.join(config.baseDir, name + ".log")

    Logger(config)
    Logger().enableFileLogging(logFileName)

    logger = getlogger()
    logger.setLevel(config.logLevel)
    logger.debug("You can find logs in {}".format(logFileName))

    vars = [var for var in os.environ.keys() if var.startswith("INDY")]
    logger.debug("Indy related env vars: {}".format(vars))

    from stp_core.loop.looper import Looper
    from indy_node.server.node import Node
    with Looper(debug=config.LOOPER_DEBUG) as looper:
        node = Node(name,
                    nodeRegistry=None,
                    basedirpath=config.baseDir,
                    ha=node_ha,
                    cliha=client_ha)
        looper.add(node)
        looper.run()
Esempio n. 5
0
def run_node(config, name, node_ip, node_port, client_ip, client_port):
    node_ha = HA(node_ip, node_port)
    client_ha = HA(client_ip, client_port)

    node_config_helper = NodeConfigHelper(name, config)

    logFileName = os.path.join(node_config_helper.log_dir, name + ".log")

    logger = getlogger()
    Logger().apply_config(config)
    Logger().enableFileLogging(logFileName)

    logger.setLevel(config.logLevel)
    logger.debug("You can find logs in {}".format(logFileName))

    vars = [var for var in os.environ.keys() if var.startswith("INDY")]
    logger.debug("Indy related env vars: {}".format(vars))

    with Looper(debug=config.LOOPER_DEBUG) as looper:
        node = Node(name,
                    config_helper=node_config_helper,
                    ha=node_ha, cliha=client_ha)
        node = integrate(node_config_helper, node, logger)
        looper.add(node)
        looper.run()
Esempio n. 6
0
def nodeThetaAdded(looper, nodeSet, tdirWithPoolTxns, tconf, steward,
                   stewardWallet, allPluginsPath, testNodeClass,
                   testClientClass, tdir):
    newStewardName = "testClientSteward" + randomString(3)
    newNodeName = "Theta"
    newSteward, newStewardWallet = getClientAddedWithRole(
        nodeSet, tdir, looper, steward, stewardWallet, newStewardName, STEWARD)

    sigseed = randomString(32).encode()
    nodeSigner = DidSigner(seed=sigseed)

    (nodeIp, nodePort), (clientIp, clientPort) = genHa(2)

    data = {
        NODE_IP: nodeIp,
        NODE_PORT: nodePort,
        CLIENT_IP: clientIp,
        CLIENT_PORT: clientPort,
        ALIAS: newNodeName,
        SERVICES: [
            VALIDATOR,
        ]
    }

    node = Node(nodeSigner.identifier, data, newStewardWallet.defaultId)
    newStewardWallet.addNode(node)
    reqs = newStewardWallet.preparePending()
    req = newSteward.submitReqs(*reqs)[0][0]

    waitForSufficientRepliesForRequests(looper, newSteward, requests=[req])

    def chk():
        assert newStewardWallet.getNode(node.id).seqNo is not None

    timeout = waits.expectedTransactionExecutionTime(len(nodeSet))
    looper.run(eventually(chk, retryWait=1, timeout=timeout))

    initLocalKeys(newNodeName, tdirWithPoolTxns, sigseed, override=True)

    newNode = testNodeClass(newNodeName,
                            basedirpath=tdir,
                            base_data_dir=tdir,
                            config=tconf,
                            ha=(nodeIp, nodePort),
                            cliha=(clientIp, clientPort),
                            pluginPaths=allPluginsPath)

    nodeSet.append(newNode)
    looper.add(newNode)
    looper.run(checkNodesConnected(nodeSet))
    ensureClientConnectedToNodesAndPoolLedgerSame(looper, steward, *nodeSet)
    ensureClientConnectedToNodesAndPoolLedgerSame(looper, newSteward, *nodeSet)
    return newSteward, newStewardWallet, newNode
Esempio n. 7
0
def create_local_pool(node_base_dir, cli_base_dir, config=None, node_size=4):
    conf = config or getConfig()

    stewards = []
    node_conf = []
    nodes = []
    genesis_txns = []
    for i in range(node_size):
        w = Wallet("steward")
        s = Steward(wallet=w)
        s.wallet.addIdentifier()

        stewards.append(s)

        node_config_helper = NodeConfigHelper(conf.name,
                                              conf,
                                              chroot=node_base_dir)
        n_config = adict(name='Node' + str(i + 1),
                         basedirpath=node_config_helper.ledger_dir,
                         ha=('127.0.0.1', 9700 + (i * 2)),
                         cliha=('127.0.0.1', 9700 + (i * 2) + 1))

        n_verkey, n_bls_key, n_bls_key_proof = \
            initialize_node_environment(name=n_config.name,
                                        node_config_helper=node_config_helper,
                                        override_keep=True,
                                        sigseed=randomSeed())

        s.set_node(n_config,
                   verkey=n_verkey,
                   blskey=n_bls_key,
                   blsley_proof=n_bls_key_proof)

        node_conf.append(n_config)

        genesis_txns += s.generate_genesis_txns()

    pool = None  # LocalPool(genesis_txns, pool_dir, steward=stewards[0])

    for c in node_conf:
        n = Node(**c)
        pool.add(n)
        nodes.append(n)

    pool.runFor(5)

    return pool
Esempio n. 8
0
def create_local_pool(base_dir, node_size=4):
    conf = getConfig(base_dir)
    pool_dir = os.path.join(base_dir, "pool")

    # TODO: Need to come back to this why we need this cleanup
    shutil.rmtree(pool_dir, ignore_errors=True)

    stewards = []
    node_conf = []
    nodes = []
    genesis_txns = []
    for i in range(node_size):
        w = Wallet("steward")
        s = Steward(wallet=w)
        s.wallet.addIdentifier()

        stewards.append(s)

        n_config = adict(name='Node' + str(i + 1),
                         basedirpath=pool_dir,
                         ha=('127.0.0.1', 9700 + (i * 2)),
                         cliha=('127.0.0.1', 9700 + (i * 2) + 1))

        n_verkey, n_bls_key = initialize_node_environment(
            name=n_config.name,
            base_dir=n_config.basedirpath,
            override_keep=True,
            config=conf,
            sigseed=randomSeed())

        s.set_node(n_config, verkey=n_verkey, blskey=n_bls_key)

        node_conf.append(n_config)

        genesis_txns += s.generate_genesis_txns()

    pool = LocalPool(genesis_txns, pool_dir, steward=stewards[0])

    for c in node_conf:
        n = Node(**c)
        pool.add(n)
        nodes.append(n)

    pool.runFor(5)

    return pool
Esempio n. 9
0
def run_node():

    nodeReg = OrderedDict([('Alpha', ('127.0.0.1', 8001)),
                           ('Beta', ('127.0.0.1', 8003)),
                           ('Gamma', ('127.0.0.1', 8005)),
                           ('Delta', ('127.0.0.1', 8007))])

    genesisTxns = [{
        'txnId': '6b86b273ff34fce19d6b804eff5a3f57'
        '47ada4eaa22f1d49c01e52ddb7875b4b',
        'type': NYM,
        'dest': 'o7z4QmFkNB+mVkFI2BwX0Hdm1BGhnz8psWnKYIXWTaQ=',
        'role': TRUST_ANCHOR
    }]

    # the first argument should be the node name
    try:
        nodeName = sys.argv[1]
    except IndexError:
        names = list(nodeReg.keys())
        print("Please supply a node name (one of {}) as the first argument.".
              format(", ".join(names)))
        print("For example:")
        print("    {} {}".format(sys.argv[0], names[0]))
        return

    with Looper(debug=False) as looper:
        # Nodes persist keys when bootstrapping to other nodes and reconnecting
        # using an ephemeral temporary directory when proving a concept is a
        # nice way to keep things tidy.
        with TemporaryDirectory() as tmpdir:
            node = Node(nodeName, nodeReg, basedirpath=tmpdir)
            node.addGenesisTxns(genesisTxns)
            looper.add(node)
            node.startKeySharing()
            looper.run()
Esempio n. 10
0
 def init_core_authenticator(self):
     return Node.init_core_authenticator(self)
Esempio n. 11
0
 def getDomainReqHandler(self):
     return Node.getDomainReqHandler(self)
Esempio n. 12
0
 def init_domain_req_handler(self):
     return Node.init_domain_req_handler(self)
Esempio n. 13
0
 def __init__(self, *args, **kwargs):
     Node.__init__(self, *args, **kwargs)
     TestNodeCore.__init__(self, *args, **kwargs)
     self.cleanupOnStopping = True
Esempio n. 14
0
 def init_core_authenticator(self):
     return Node.init_core_authenticator(self)
Esempio n. 15
0
 def getDomainReqHandler(self):
     return Node.getDomainReqHandler(self)
Esempio n. 16
0
 def __init__(self, *args, **kwargs):
     Node.__init__(self, *args, **kwargs)
     TestNodeCore.__init__(self, *args, **kwargs)
     self.cleanupOnStopping = True