def add_cl_node(self, config: DockerConfig, network_with_bootstrap: bool = True) -> None: if self.node_count == 0: raise Exception('Must create bootstrap first') config.bootstrap_address = self.cl_nodes[0].node.address if network_with_bootstrap: config.network = self.cl_nodes[0].node.network self._add_cl_node(config)
def create_cl_network(self, signed_deploy=False): kp = self.get_key() config = DockerConfig(self.docker_client, node_private_key=kp.private_key, node_public_key=kp.public_key, network=self.create_docker_network()) config.node_env[ 'CL_CASPER_IGNORE_DEPLOY_SIGNATURE'] = 'false' if signed_deploy else 'true' self.add_bootstrap(config)
def create_cl_network(self, node_count: int = 3, network_connections: List[List[int]] = None) -> None: """ Allow creation of a network where all nodes are not connected to node-0's network and therefore each other. Ex: Star Network node3 | node1 -- node0 -- node2 create_cl_network(node_count=4, network_connections=[[0, 1], [0, 2], [0, 3]]) :param node_count: Number of nodes to create. :param network_connections: A list of lists of node indexes that should be joined. """ self.network_names = {} kp = self.get_key() config = DockerConfig( self.docker_client, node_private_key=kp.private_key, node_public_key=kp.public_key, network=self.create_docker_network(), node_account=kp, ) self.add_bootstrap(config) for i in range(1, node_count): kp = self.get_key() config = DockerConfig( self.docker_client, node_private_key=kp.private_key, network=self.create_docker_network(), node_account=kp, ) self.add_cl_node(config, network_with_bootstrap=False) for network_members in network_connections: self.connect(network_members) for node_number in range(1, node_count): self.wait_method(wait_for_approved_block_received_handler_state, node_number) # Calculate how many peers should be connected to each node. # Assumes duplicate network connections are not given, else wait_for_peers will time out. peer_counts = [0] * node_count for network in network_connections: for node_num in network: peer_counts[node_num] += len(network) - 1 timeout = self.docker_nodes[0].timeout for node_num, peer_count in enumerate(peer_counts): if peer_count > 0: wait_for_peers_count_at_least(self.docker_nodes[node_num], peer_count, timeout)
def create_cl_network(self): kp = self.get_key() config = DockerConfig(self.docker_client, node_private_key=kp.private_key, node_public_key=kp.public_key, network=self.create_docker_network()) self.add_bootstrap(config) kp = self.get_key() config = DockerConfig(self.docker_client, node_private_key=kp.private_key) self.add_cl_node(config) self.wait_method(wait_for_approved_block_received_handler_state, 1) self.wait_for_peers()
def add_new_node_to_network(self) -> None: kp = self.get_key() config = DockerConfig(self.docker_client, node_private_key=kp.private_key) self.add_cl_node(config) self.wait_method(wait_for_approved_block_received_handler_state, 1) self.wait_for_peers()
def create_cl_network(self, node_count=10): kp = self.get_key() config = DockerConfig(self.docker_client, node_private_key=kp.private_key, node_public_key=kp.public_key, network=self.create_docker_network()) self.add_bootstrap(config) for _ in range(1, node_count): kp = self.get_key() config = DockerConfig(self.docker_client, node_private_key=kp.private_key) self.add_cl_node(config) for node_number in range(1, node_count): self.wait_method(wait_for_approved_block_received_handler_state, node_number) self.wait_for_peers()
def create_cl_network(self): kp = self.get_key() config = DockerConfig(self.docker_client, node_private_key=kp.private_key, node_public_key=kp.public_key, network=self.create_docker_network()) self.add_bootstrap(config)
def add_bootstrap(self, config: DockerConfig) -> None: if self.node_count > 0: raise Exception("There can be only one bootstrap") config.is_bootstrap = True self._add_cl_node(config) self.wait_method(wait_for_node_started, 0) wait_for_genesis_block(self.docker_nodes[0])
def create_cl_network(self): kp = self.get_key() config = DockerConfig( self.docker_client, node_private_key=kp.private_key, node_public_key=kp.public_key, network=self.create_docker_network(), is_payment_code_enabled=self.is_payment_code_enabled, initial_motes=self.initial_motes, ) self.add_bootstrap(config)
def docker_config(self, account): config = DockerConfig( self.docker_client, node_private_key=account.private_key, node_public_key=account.public_key, network=self.create_docker_network(), initial_motes=self.initial_motes, node_account=account, grpc_encryption=self.grpc_encryption, ) return config
def create_cl_network(self): kp = self.get_key() config = DockerConfig( self.docker_client, node_private_key=kp.private_key, node_public_key=kp.public_key, network=self.create_docker_network(), node_account=kp, grpc_encryption=self.grpc_encryption, ) self.add_bootstrap(config) self.add_new_node_to_network() wait_for_genesis_block(self.docker_nodes[1])
def _add_cl_node(self, config: DockerConfig) -> None: with self._lock: config.number = self.node_count cl_node = CasperLabsNode(config) self.cl_nodes.append(cl_node)