def _add_token_network_deploy_info(token_network: Dict[str, Any], deployer: ContractDeployer, contracts_version: str) -> None: """Add deploy info dict to the deploy_*.json file""" deployment_file_path = contracts_deployed_path(chain_id=ChainID( deployer.web3.eth.chain_id), version=contracts_version) with deployment_file_path.open() as f: deployed_contracts_info: DeployedContracts = json.load(f) deployed_contracts_info.setdefault("token_networks", []).append(token_network) deployer.store_and_verify_deployment_info_raiden( deployed_contracts_info=deployed_contracts_info)
def _store_deployment_info(self, services: bool, deployment_info: DeployedContracts) -> None: deployment_file_path = contracts_deployed_path( chain_id=ChainID(int(self.web3.version.network)), version=self.contracts_version, services=services, ) with deployment_file_path.open(mode="w") as target_file: target_file.write(json.dumps(deployment_info)) print( f'Deployment information for chain id = {deployment_info["chain_id"]} ' f" has been updated at {deployment_file_path}.")
def test_red_eyes_version() -> None: """contracts_source_path('0.4.0') exists and contains the expected files""" contracts_version = "0.4.0" contract_names = [ "Utils", "EndpointRegistry", "SecretRegistry", "TokenNetworkRegistry", "TokenNetwork", ] manager = ContractManager(contracts_precompiled_path(contracts_version)) assert manager.contracts_version == contracts_version check_precompiled_content(manager, contract_names, PRECOMPILED_DATA_FIELDS) assert contracts_precompiled_path(contracts_version).exists() assert contracts_deployed_path(CHAINNAME_TO_ID["mainnet"], contracts_version).exists() assert contracts_deployed_path(CHAINNAME_TO_ID["rinkeby"], contracts_version).exists() assert contracts_deployed_path(CHAINNAME_TO_ID["ropsten"], contracts_version).exists()
def test_red_eyes_version(): """ contracts_source_path('0.4.0') exists and contains the expected files """ contracts_version = '0.4.0' contract_names = [ 'Utils', 'EndpointRegistry', 'SecretRegistry', 'TokenNetworkRegistry', 'TokenNetwork', ] manager = ContractManager(contracts_precompiled_path(contracts_version)) assert manager.contracts_version == contracts_version check_precompiled_content(manager, contract_names, PRECOMPILED_DATA_FIELDS) assert contracts_precompiled_path(contracts_version).exists() assert contracts_deployed_path(NETWORKNAME_TO_ID['mainnet'], contracts_version).exists() assert contracts_deployed_path(NETWORKNAME_TO_ID['rinkeby'], contracts_version).exists() assert contracts_deployed_path(NETWORKNAME_TO_ID['ropsten'], contracts_version).exists() assert contracts_deployed_path(NETWORKNAME_TO_ID['kovan'], contracts_version).exists()
def verify_deployed_contracts_in_filesystem(self): chain_id = int(self.web3.version.network) deployment_data = get_contracts_deployed( chain_id=chain_id, version=self.contract_manager.contracts_version, ) deployment_file_path = contracts_deployed_path( chain_id=chain_id, version=self.contract_manager.contracts_version, ) assert deployment_data is not None if self._verify_deployment_data(deployment_data): print( f'Deployment info from {deployment_file_path} has been verified' 'and it is CORRECT.')
def verify_deployed_contracts_in_filesystem(self) -> None: chain_id = ChainID(self.web3.eth.chain_id) deployment_data = get_contracts_deployment_info( chain_id=chain_id, version=self.contract_manager.contracts_version, module=DeploymentModule.RAIDEN, ) deployment_file_path = contracts_deployed_path( chain_id=chain_id, version=self.contract_manager.contracts_version) if deployment_data is None: raise RuntimeError( f"Deployment data cannot be found at {deployment_file_path}") if self.verify_deployment_data(deployment_data): print( f"Deployment info from {deployment_file_path} has been verified " "and it is CORRECT.")
def verify_deployed_contracts_in_filesystem( web3: Web3, contract_manager: ContractManager, ): chain_id = int(web3.version.network) deployment_data = get_contracts_deployed( chain_id=chain_id, version=contract_manager.contracts_version, ) deployment_file_path = contracts_deployed_path( chain_id=chain_id, version=contract_manager.contracts_version, ) assert deployment_data is not None if verify_deployment_data(web3, contract_manager, deployment_data): print( f'Deployment info from {deployment_file_path} has been verified and it is CORRECT.' )
def _verify_token_networks(chain_id: ChainID, apikey: str) -> None: deployment_file_path = contracts_deployed_path(chain_id=chain_id) with deployment_file_path.open() as f: deployed_contracts_info = json.load(f) token_networks = deployed_contracts_info.get("token_networks", []) with open(contracts_precompiled_path()) as f: contract_dict = json.load(f)["contracts"][CONTRACT_TOKEN_NETWORK] metadata = json.loads(contract_dict["metadata"]) constructor = [func for func in contract_dict["abi"] if func["type"] == "constructor"][0] arg_types = [arg["type"] for arg in constructor["inputs"]] arg_names = [arg["name"] for arg in constructor["inputs"]] for tn in token_networks: args = [tn["constructor_arguments"][arg_name] for arg_name in arg_names] etherscan_verify_contract( chain_id=chain_id, apikey=apikey, address=tn["token_network_address"], contract_name=CONTRACT_TOKEN_NETWORK, metadata=metadata, constructor_args=encode_abi(arg_types, args).hex(), )
def test_current_development_version(): """ contracts_source_path() exists and contains the expected files """ contracts_version = CONTRACTS_VERSION contract_names = [ 'Utils', 'EndpointRegistry', 'SecretRegistry', 'TokenNetworkRegistry', 'TokenNetwork', 'MonitoringService', 'ServiceRegistry', ] manager = ContractManager(contracts_precompiled_path(contracts_version)) assert manager.contracts_version == contracts_version check_precompiled_content(manager, contract_names, PRECOMPILED_DATA_FIELDS) for _, source_path in contracts_source_path().items(): assert source_path.exists() assert contracts_precompiled_path().exists() # deployment files exist assert contracts_deployed_path(NETWORKNAME_TO_ID['rinkeby']).exists() assert contracts_deployed_path(NETWORKNAME_TO_ID['ropsten']).exists() assert contracts_deployed_path(NETWORKNAME_TO_ID['kovan']).exists() # deployment files for service contracts also exist assert contracts_deployed_path( NETWORKNAME_TO_ID['rinkeby'], services=True, ).exists() assert contracts_deployed_path( NETWORKNAME_TO_ID['ropsten'], services=True, ).exists() assert contracts_deployed_path( NETWORKNAME_TO_ID['kovan'], services=True, ).exists()
def test_deploy_data_file_exists( version: Optional[str], chain_id: ChainID, services: bool ) -> None: """Make sure files exist for deployment data of each chain_id""" assert contracts_deployed_path(chain_id, version, services).exists()
def verify_deployed_contracts(web3: Web3, contract_manager: ContractManager, deployment_data=None): chain_id = int(web3.version.network) deployment_file_path = None if deployment_data is None: deployment_data = get_contracts_deployed( chain_id, contract_manager.contracts_version) deployment_file_path = contracts_deployed_path( chain_id, contract_manager.contracts_version, ) contracts = deployment_data['contracts'] assert contract_manager.contracts_version == deployment_data[ 'contracts_version'] assert chain_id == deployment_data['chain_id'] endpoint_registry_address = contracts[CONTRACT_ENDPOINT_REGISTRY][ 'address'] endpoint_registry_abi = contract_manager.get_contract_abi( CONTRACT_ENDPOINT_REGISTRY) endpoint_registry = web3.eth.contract( abi=endpoint_registry_abi, address=endpoint_registry_address, ) endpoint_registry = PrivateContract(endpoint_registry) # Check that the deployed bytecode matches the precompiled data blockchain_bytecode = web3.eth.getCode(endpoint_registry_address).hex() compiled_bytecode = contract_manager.contracts[CONTRACT_ENDPOINT_REGISTRY][ 'bin'] # Compiled code contains some additional initial data compared to the blockchain bytecode compiled_bytecode = compiled_bytecode[-len(blockchain_bytecode):] compiled_bytecode = hex(int(compiled_bytecode, 16)) assert blockchain_bytecode == compiled_bytecode # Check blockchain transaction hash & block information receipt = web3.eth.getTransactionReceipt( contracts[CONTRACT_ENDPOINT_REGISTRY]['transaction_hash'], ) assert receipt['blockNumber'] == contracts[CONTRACT_ENDPOINT_REGISTRY]['block_number'], \ f"We have block_number {contracts[CONTRACT_ENDPOINT_REGISTRY]['block_number']} " \ f"instead of {receipt['blockNumber']}" assert receipt['gasUsed'] == contracts[CONTRACT_ENDPOINT_REGISTRY]['gas_cost'], \ f"We have gasUsed {contracts[CONTRACT_ENDPOINT_REGISTRY]['gas_cost']} " \ f"instead of {receipt['gasUsed']}" assert receipt['contractAddress'] == contracts[CONTRACT_ENDPOINT_REGISTRY]['address'], \ f"We have contractAddress {contracts[CONTRACT_ENDPOINT_REGISTRY]['address']} " \ f"instead of {receipt['contractAddress']}" # Check the contract version version = endpoint_registry.functions.contract_version().call().decode() assert version == deployment_data['contracts_version'] print( f'{CONTRACT_ENDPOINT_REGISTRY} at {endpoint_registry_address} ' f'matches the compiled data from contracts.json', ) secret_registry_address = contracts[CONTRACT_SECRET_REGISTRY]['address'] secret_registry_abi = contract_manager.get_contract_abi( CONTRACT_SECRET_REGISTRY) secret_registry = web3.eth.contract( abi=secret_registry_abi, address=secret_registry_address, ) secret_registry = PrivateContract(secret_registry) # Check that the deployed bytecode matches the precompiled data blockchain_bytecode = web3.eth.getCode(secret_registry_address).hex() compiled_bytecode = contract_manager.contracts[CONTRACT_SECRET_REGISTRY][ 'bin'] compiled_bytecode = compiled_bytecode[-len(blockchain_bytecode):] compiled_bytecode = hex(int(compiled_bytecode, 16)) assert blockchain_bytecode == compiled_bytecode # Check blockchain transaction hash & block information receipt = web3.eth.getTransactionReceipt( contracts[CONTRACT_SECRET_REGISTRY]['transaction_hash'], ) assert receipt['blockNumber'] == contracts[CONTRACT_SECRET_REGISTRY]['block_number'], \ f"We have block_number {contracts[CONTRACT_SECRET_REGISTRY]['block_number']} " \ f"instead of {receipt['blockNumber']}" assert receipt['gasUsed'] == contracts[CONTRACT_SECRET_REGISTRY]['gas_cost'], \ f"We have gasUsed {contracts[CONTRACT_SECRET_REGISTRY]['gas_cost']} " \ f"instead of {receipt['gasUsed']}" assert receipt['contractAddress'] == contracts[CONTRACT_SECRET_REGISTRY]['address'], \ f"We have contractAddress {contracts[CONTRACT_SECRET_REGISTRY]['address']} " \ f"instead of {receipt['contractAddress']}" # Check the contract version version = secret_registry.functions.contract_version().call().decode() assert version == deployment_data['contracts_version'] print( f'{CONTRACT_SECRET_REGISTRY} at {secret_registry_address} ' f'matches the compiled data from contracts.json', ) token_registry_address = contracts[CONTRACT_TOKEN_NETWORK_REGISTRY][ 'address'] token_registry_abi = contract_manager.get_contract_abi( CONTRACT_TOKEN_NETWORK_REGISTRY, ) token_network_registry = web3.eth.contract( abi=token_registry_abi, address=token_registry_address, ) token_network_registry = PrivateContract(token_network_registry) # Check that the deployed bytecode matches the precompiled data blockchain_bytecode = web3.eth.getCode(token_registry_address).hex() compiled_bytecode = contract_manager.contracts[ CONTRACT_TOKEN_NETWORK_REGISTRY]['bin'] compiled_bytecode = compiled_bytecode[-len(blockchain_bytecode):] compiled_bytecode = hex(int(compiled_bytecode, 16)) assert blockchain_bytecode == compiled_bytecode # Check blockchain transaction hash & block information receipt = web3.eth.getTransactionReceipt( contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['transaction_hash'], ) assert receipt['blockNumber'] == contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['block_number'], \ f"We have block_number {contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['block_number']} " \ f"instead of {receipt['blockNumber']}" assert receipt['gasUsed'] == contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['gas_cost'], \ f"We have gasUsed {contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['gas_cost']} " \ f"instead of {receipt['gasUsed']}" assert receipt['contractAddress'] == contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['address'], \ f"We have contractAddress {contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['address']} " \ f"instead of {receipt['contractAddress']}" # Check the contract version version = token_network_registry.functions.contract_version().call( ).decode() assert version == deployment_data['contracts_version'] # Check constructor parameters constructor_arguments = contracts[CONTRACT_TOKEN_NETWORK_REGISTRY][ 'constructor_arguments'] assert to_checksum_address( token_network_registry.functions.secret_registry_address().call(), ) == secret_registry_address assert secret_registry_address == constructor_arguments[0] chain_id = token_network_registry.functions.chain_id().call() assert chain_id == constructor_arguments[1] settlement_timeout_min = token_network_registry.functions.settlement_timeout_min( ).call() settlement_timeout_max = token_network_registry.functions.settlement_timeout_max( ).call() assert settlement_timeout_min == constructor_arguments[2] assert settlement_timeout_max == constructor_arguments[3] print( f'{CONTRACT_TOKEN_NETWORK_REGISTRY} at {token_registry_address} ' f'matches the compiled data from contracts.json', ) if deployment_file_path is not None: print( f'Deployment info from {deployment_file_path} has been verified and it is CORRECT.' )
def verify_deployed_service_contracts( web3: Web3, contract_manager: ContractManager, token_address: str, deployment_data: dict=None, ): chain_id = int(web3.version.network) deployment_file_path = None if deployment_data is None: deployment_data = get_contracts_deployed( chain_id, contract_manager.contracts_version, services=True, ) deployment_file_path = contracts_deployed_path( chain_id, contract_manager.contracts_version, services=True, ) assert deployment_data is not None assert contract_manager.contracts_version == deployment_data['contracts_version'] assert chain_id == deployment_data['chain_id'] service_bundle = verify_deployed_contract( web3, contract_manager, deployment_data, CONTRACT_RAIDEN_SERVICE_BUNDLE, ) # We need to also check the constructor parameters against the chain constructor_arguments = deployment_data['contracts'][ CONTRACT_RAIDEN_SERVICE_BUNDLE ]['constructor_arguments'] assert to_checksum_address( service_bundle.functions.token().call(), ) == token_address assert token_address == constructor_arguments[0] print( f'{CONTRACT_RAIDEN_SERVICE_BUNDLE} at {service_bundle.address} ' f'matches the compiled data from contracts.json', ) monitoring_service = verify_deployed_contract( web3, contract_manager, deployment_data, CONTRACT_MONITORING_SERVICE, ) # We need to also check the constructor parameters against the chain constructor_arguments = deployment_data['contracts'][ CONTRACT_MONITORING_SERVICE ]['constructor_arguments'] assert to_checksum_address( monitoring_service.functions.token().call(), ) == token_address assert token_address == constructor_arguments[0] assert to_checksum_address( monitoring_service.functions.rsb().call(), ) == service_bundle.address assert service_bundle.address == constructor_arguments[1] print( f'{CONTRACT_MONITORING_SERVICE} at {monitoring_service.address} ' f'matches the compiled data from contracts.json', ) if deployment_file_path is not None: print(f'Deployment info from {deployment_file_path} has been verified and it is CORRECT.')
def verify_deployed_contracts(web3: Web3, contract_manager: ContractManager, deployment_data=None): chain_id = int(web3.version.network) deployment_file_path = None if deployment_data is None: deployment_data = get_contracts_deployed(chain_id, contract_manager.contracts_version) deployment_file_path = contracts_deployed_path( chain_id, contract_manager.contracts_version, ) assert deployment_data is not None assert contract_manager.contracts_version == deployment_data['contracts_version'] assert chain_id == deployment_data['chain_id'] endpoint_registry = verify_deployed_contract( web3, contract_manager, deployment_data, CONTRACT_ENDPOINT_REGISTRY, ) print( f'{CONTRACT_ENDPOINT_REGISTRY} at {endpoint_registry.address} ' f'matches the compiled data from contracts.json', ) secret_registry = verify_deployed_contract( web3, contract_manager, deployment_data, CONTRACT_SECRET_REGISTRY, ) print( f'{CONTRACT_SECRET_REGISTRY} at {secret_registry.address} ' f'matches the compiled data from contracts.json', ) token_network_registry = verify_deployed_contract( web3, contract_manager, deployment_data, CONTRACT_TOKEN_NETWORK_REGISTRY, ) # We need to also check the constructor parameters against the chain constructor_arguments = deployment_data['contracts'][ CONTRACT_TOKEN_NETWORK_REGISTRY ]['constructor_arguments'] assert to_checksum_address( token_network_registry.functions.secret_registry_address().call(), ) == secret_registry.address assert secret_registry.address == constructor_arguments[0] chain_id = token_network_registry.functions.chain_id().call() assert chain_id == constructor_arguments[1] settlement_timeout_min = token_network_registry.functions.settlement_timeout_min().call() settlement_timeout_max = token_network_registry.functions.settlement_timeout_max().call() assert settlement_timeout_min == constructor_arguments[2] assert settlement_timeout_max == constructor_arguments[3] print( f'{CONTRACT_TOKEN_NETWORK_REGISTRY} at {token_network_registry.address} ' f'matches the compiled data from contracts.json', ) if deployment_file_path is not None: print(f'Deployment info from {deployment_file_path} has been verified and it is CORRECT.')
def run_app( address, keystore_path, gas_price, eth_rpc_endpoint, registry_contract_address, secret_registry_contract_address, discovery_contract_address, listen_address, mapped_socket, max_unresponsive_time, api_address, rpc, sync_check, console, password_file, web_ui, datadir, transport, matrix_server, network_id, network_type, config=None, extra_config=None, **kwargs, ): # pylint: disable=too-many-locals,too-many-branches,too-many-statements,unused-argument from raiden.app import App _assert_sql_version() if transport == 'udp' and not mapped_socket: raise RuntimeError('Missing socket') if datadir is None: datadir = os.path.join(os.path.expanduser('~'), '.raiden') address_hex = to_normalized_address(address) if address else None address_hex, privatekey_bin = prompt_account(address_hex, keystore_path, password_file) address = to_canonical_address(address_hex) (listen_host, listen_port) = split_endpoint(listen_address) (api_host, api_port) = split_endpoint(api_address) config['transport']['udp']['host'] = listen_host config['transport']['udp']['port'] = listen_port config['console'] = console config['rpc'] = rpc config['web_ui'] = rpc and web_ui config['api_host'] = api_host config['api_port'] = api_port if mapped_socket: config['socket'] = mapped_socket.socket config['transport']['udp']['external_ip'] = mapped_socket.external_ip config['transport']['udp'][ 'external_port'] = mapped_socket.external_port config['transport_type'] = transport config['transport']['matrix']['server'] = matrix_server config['transport']['udp'][ 'nat_keepalive_retries'] = DEFAULT_NAT_KEEPALIVE_RETRIES timeout = max_unresponsive_time / DEFAULT_NAT_KEEPALIVE_RETRIES config['transport']['udp']['nat_keepalive_timeout'] = timeout privatekey_hex = hexlify(privatekey_bin) config['privatekey_hex'] = privatekey_hex parsed_eth_rpc_endpoint = urlparse(eth_rpc_endpoint) if not parsed_eth_rpc_endpoint.scheme: eth_rpc_endpoint = f'http://{eth_rpc_endpoint}' web3 = _setup_web3(eth_rpc_endpoint) rpc_client = JSONRPCClient( web3, privatekey_bin, gas_price_strategy=gas_price, ) blockchain_service = BlockChainService( privatekey_bin=privatekey_bin, jsonrpc_client=rpc_client, # Not giving the contract manager here, but injecting it later # since we first need blockchain service to calculate the network id ) given_network_id = network_id node_network_id = blockchain_service.network_id known_given_network_id = given_network_id in ID_TO_NETWORKNAME known_node_network_id = node_network_id in ID_TO_NETWORKNAME if node_network_id != given_network_id: if known_given_network_id and known_node_network_id: click.secho( f"The chosen ethereum network '{ID_TO_NETWORKNAME[given_network_id]}' " f"differs from the ethereum client '{ID_TO_NETWORKNAME[node_network_id]}'. " "Please update your settings.", fg='red', ) else: click.secho( f"The chosen ethereum network id '{given_network_id}' differs " f"from the ethereum client '{node_network_id}'. " "Please update your settings.", fg='red', ) sys.exit(1) config['chain_id'] = given_network_id log.debug('Network type', type=network_type) if network_type == 'main': config['network_type'] = NetworkType.MAIN # Forcing private rooms to true for the mainnet config['transport']['matrix']['private_rooms'] = True else: config['network_type'] = NetworkType.TEST network_type = config['network_type'] chain_config = {} contract_addresses_known = False contracts = dict() config['contracts_path'] = contracts_precompiled_path() if node_network_id in ID_TO_NETWORKNAME and ID_TO_NETWORKNAME[ node_network_id] != 'smoketest': contracts_version = 'pre_limit' if network_type == NetworkType.TEST else None deployment_data = get_contracts_deployed(node_network_id, contracts_version) config['contracts_path'] = contracts_deployed_path( node_network_id, contracts_version) not_allowed = ( # for now we only disallow mainnet with test configuration network_id == 1 and network_type == NetworkType.TEST) if not_allowed: click.secho( 'The chosen network {} has no test configuration but a test network type ' 'was given. This is not allowed.'.format( ID_TO_NETWORKNAME[node_network_id], ), fg='red', ) sys.exit(1) contracts = deployment_data['contracts'] contract_addresses_known = True blockchain_service.inject_contract_manager( ContractManager(config['contracts_path'])) if sync_check: check_synced(blockchain_service, known_node_network_id) contract_addresses_given = (registry_contract_address is not None and secret_registry_contract_address is not None and discovery_contract_address is not None) if not contract_addresses_given and not contract_addresses_known: click.secho( f"There are no known contract addresses for network id '{given_network_id}'. " "Please provide them on the command line or in the configuration file.", fg='red', ) sys.exit(1) try: token_network_registry = blockchain_service.token_network_registry( registry_contract_address or contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]['address'], ) except ContractVersionMismatch: handle_contract_version_mismatch('token network registry', registry_contract_address) except AddressWithoutCode: handle_contract_no_code('token network registry', registry_contract_address) except AddressWrongContract: handle_contract_wrong_address('token network registry', registry_contract_address) try: secret_registry = blockchain_service.secret_registry( secret_registry_contract_address or contracts[CONTRACT_SECRET_REGISTRY]['address'], ) except ContractVersionMismatch: handle_contract_version_mismatch('secret registry', secret_registry_contract_address) except AddressWithoutCode: handle_contract_no_code('secret registry', secret_registry_contract_address) except AddressWrongContract: handle_contract_wrong_address('secret registry', secret_registry_contract_address) database_path = os.path.join( datadir, f'node_{pex(address)}', f'netid_{given_network_id}', f'network_{pex(token_network_registry.address)}', f'v{RAIDEN_DB_VERSION}_log.db', ) config['database_path'] = database_path print( '\nYou are connected to the \'{}\' network and the DB path is: {}'. format( ID_TO_NETWORKNAME.get(given_network_id, given_network_id), database_path, ), ) discovery = None if transport == 'udp': transport, discovery = _setup_udp( config, blockchain_service, address, contracts, discovery_contract_address, ) elif transport == 'matrix': transport = _setup_matrix(config) else: raise RuntimeError(f'Unknown transport type "{transport}" given') raiden_event_handler = RaidenEventHandler() message_handler = MessageHandler() try: if 'contracts' in chain_config: start_block = chain_config['contracts']['TokenNetworkRegistry'][ 'block_number'] else: start_block = 0 raiden_app = App( config=config, chain=blockchain_service, query_start_block=start_block, default_registry=token_network_registry, default_secret_registry=secret_registry, transport=transport, raiden_event_handler=raiden_event_handler, message_handler=message_handler, discovery=discovery, ) except RaidenError as e: click.secho(f'FATAL: {e}', fg='red') sys.exit(1) try: raiden_app.start() except RuntimeError as e: click.secho(f'FATAL: {e}', fg='red') sys.exit(1) except filelock.Timeout: name_or_id = ID_TO_NETWORKNAME.get(given_network_id, given_network_id) click.secho( f'FATAL: Another Raiden instance already running for account {address_hex} on ' f'network id {name_or_id}', fg='red', ) sys.exit(1) return raiden_app