diff --git a/cli/commands/bridge/relays/btp.go b/cli/commands/bridge/relays/btp.go index 106a54e8..824d1672 100644 --- a/cli/commands/bridge/relays/btp.go +++ b/cli/commands/bridge/relays/btp.go @@ -194,7 +194,7 @@ func BtpRelayCmd(diveContext *common.DiveContext) *cobra.Command { func runBtpSetupByRunningNodes(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, params string) { diveContext.SetSpinnerMessage(" Executing BTP Starlark Package") - starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeScript, bridgeMainFunction) + starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeBtpScript, bridgeMainFunction) data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig) if err != nil { @@ -214,7 +214,7 @@ func runBtpSetupByRunningNodes(diveContext *common.DiveContext, enclaveCtx *encl func runBtpSetupForAlreadyRunningNodes(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, mainFunctionName string, srcChain string, dstChain string, srcChainServiceName string, dstChainServiceName string, bridge bool, srcChainServiceResponse string, dstChainServiceResponse string) { params := fmt.Sprintf(`{"src_chain":"%s","dst_chain":"%s", "src_chain_config":%s, "dst_chain_config":%s, "bridge":%s}`, chainA, chainB, srcChainServiceResponse, dstChainServiceResponse, strconv.FormatBool(bridge)) - starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeScript, mainFunctionName) + starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeBtpScript, mainFunctionName) data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig) if err != nil { diff --git a/cli/commands/bridge/relays/common.go b/cli/commands/bridge/relays/common.go index 0d33d7f1..9f97cb69 100644 --- a/cli/commands/bridge/relays/common.go +++ b/cli/commands/bridge/relays/common.go @@ -23,6 +23,7 @@ type Chains struct { func initChains(chainA, chainB, serviceA, serviceB string, bridge bool) *Chains { return &Chains{ + chainA: strings.ToLower(chainA), chainB: strings.ToLower(chainB), chainAServiceName: serviceA, @@ -36,11 +37,11 @@ func (c *Chains) areChainsIcon() bool { } func (chains *Chains) getParams() string { - return fmt.Sprintf(`{"args":{"links": {"src": "%s", "dst": "%s"},"bridge":"%s"}}`, chains.chainA, chains.chainB, chains.bridge) + return fmt.Sprintf(`{"src_chain": "%s", "dst_chain": "%s", "bridge":"%s"}`, chains.chainA, chains.chainB, chains.bridge) } func (chains *Chains) getIbcRelayParams() string { - return fmt.Sprintf(`{"args":{"links": {"src": "%s", "dst": "%s"}, "src_config":{"data":{}}, "dst_config":{"data":{}}}}`, chains.chainA, chains.chainB) + return fmt.Sprintf(`{"src_chain": "%s", "dst_chain": "%s"}`, chains.chainA, chains.chainB) } func (chains *Chains) getServicesResponse() (string, string, error) { diff --git a/cli/commands/bridge/relays/ibc.go b/cli/commands/bridge/relays/ibc.go index d61520ff..9655b3a8 100644 --- a/cli/commands/bridge/relays/ibc.go +++ b/cli/commands/bridge/relays/ibc.go @@ -138,7 +138,7 @@ func setupIbcRelayforAlreadyRunningCosmosChain(diveContext *common.DiveContext, } func runStarlarkPackage(diveContext *common.DiveContext, enclaveContext *enclaves.EnclaveContext, params, functionName string) (string, error) { - starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeScript, functionName) + starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeIbcScript, functionName) executionData, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig) if err != nil { diff --git a/cli/commands/chain/types/icon.go b/cli/commands/chain/types/icon.go index 16e0ec12..9e304a0b 100644 --- a/cli/commands/chain/types/icon.go +++ b/cli/commands/chain/types/icon.go @@ -147,48 +147,24 @@ func RunIconNode(diveContext *common.DiveContext) *common.DiveserviceResponse { diveContext.FatalError("Failed To Get Node Service Config", err.Error()) } - paramData, err := serviceConfig.EncodeToString() - if err != nil { - diveContext.FatalError("Encoding Failed", err.Error()) - } - diveContext.StartSpinner(" Starting Icon Node") kurtosisEnclaveContext, err := diveContext.GetEnclaveContext() if err != nil { diveContext.FatalError("Failed To Retrive Enclave Context", err.Error()) } - starlarkConfig := diveContext.GetStarlarkRunConfig(paramData, common.DiveIconNodeScript, "get_service_config") - data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig) - - if err != nil { - diveContext.FatalError("Starlark Run Failed", err.Error()) - } - - _, services, skippedInstructions, err := diveContext.GetSerializedData(data) - - if err != nil { - diveContext.StopServices(services) - diveContext.FatalError("Starlark Run Failed", err.Error()) - - } genesisHandler, err := genesismanager(kurtosisEnclaveContext) if err != nil { diveContext.FatalError("Failed To Get Genesis", err.Error()) } - diveContext.CheckInstructionSkipped(skippedInstructions, "Instruction Executed Already") - params := fmt.Sprintf(`{"private_port":%d, "public_port":%d, "p2p_listen_address": %s, "p2p_address":%s, "cid": "%s","uploaded_genesis":%s,"genesis_file_path":"%s","genesis_file_name":"%s"}`, serviceConfig.Port, serviceConfig.PublicPort, serviceConfig.P2PListenAddress, serviceConfig.P2PAddress, serviceConfig.Cid, genesisHandler.uploadedFiles, genesisHandler.genesisPath, genesisHandler.genesisFile) - starlarkConfig = diveContext.GetStarlarkRunConfig(params, common.DiveIconNodeScript, "start_icon_node") + starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveIconNodeScript, "start_icon_node") icon_data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig) if err != nil { - - diveContext.StopServices(services) - - diveContext.FatalError("Starlark Run Failed", err.Error()) + diveContext.FatalError("Error while running kurtosis package to run icon node", err.Error()) } diveContext.SetSpinnerMessage(" Finalizing Icon Node") diff --git a/cli/common/constants.go b/cli/common/constants.go index 9ce23a34..6418ffa4 100644 --- a/cli/common/constants.go +++ b/cli/common/constants.go @@ -16,7 +16,8 @@ const ( DiveNeutronNodeScript = "services/cosmvm/neutron/src/node-setup/start_node.star" RelayServiceNameIconToCosmos = "ibc-relayer" DiveNeutronDefaultNodeScript = "services/cosmvm/neutron/neutron.star" - DiveBridgeScript = "main.star" + DiveBridgeBtpScript = "/services/bridges/btp/src/bridge.star" + DiveBridgeIbcScript = "/services/bridges/ibc/src/bridge.star" DiveDryRun = false DiveDefaultParallelism = 4 DiveEthNodeAlreadyRunning = "Eth Node Already Running" diff --git a/main.star b/main.star index 0ad47a1f..1ca527ad 100644 --- a/main.star +++ b/main.star @@ -1,4 +1,5 @@ icon_setup_node = import_module("./services/jvm/icon/src/node-setup/setup_icon_node.star") +icon_node_launcher = import_module("./src/node-setup/start_icon_node.star") eth_contract_service = import_module("./services/evm/eth/src/node-setup/contract-service.star") eth_relay_setup = import_module("./services/evm/eth/src/relay-setup/contract_configuration.star") eth_node = import_module("./services/evm/eth/eth.star") @@ -11,75 +12,297 @@ cosmvm_relay = import_module("./services/bridges/ibc/src/bridge.star") cosmvm_relay_setup = import_module("./services/cosmvm/archway/src/relay-setup/contract-configuration.star") neutron_relay_setup = import_module("./services/cosmvm/neutron/src/relay-setup/contract-configuration.star") btp_relay_setup = import_module("./services/bridges/btp/src/bridge.star") +ibc_relay_setup = import_module("./services/bridges/ibc/src/bridge.star") + + +def run(plan, command, node_name= None, custom_config = None, icon_service_config = None ,decentralize = false, chain_a = None, chain_b = None, service_config_a = None, service_config_b = None, bridge = false): + """ + Parse the input and execute the specified action. + + Parameters: + plan (Plan): The Kurtosis plan. + command (str): The action to perform. + - 'chain': Start a node. + - 'bridge': Start a relay. + - 'decentralize': decentralize already running icon node with given icon_service_config. + + node_name (str, optional): Name of the node to start. + - Currently supported options: 'eth', 'hardhat', 'icon', 'neutron', 'archway'. + + custom_config (dict, optional): Custom configuration for node or relay. If empty, the node will start with default settings. + bridge + For ICON node with custom configuration, the following fields should be provided in custom_config_dict: + - private_port (int): The private port for the node. + - public_port (int): The public port for the node. + - p2p_listen_address (str): The p2p listen address. + - p2p_address (str): The p2p address. + - cid (str): The CID (Chain ID) of the node. + - genesis_file_path (str): The file path to the genesis file. + - genesis_file_name (str): The name of the genesis file. + + For Cosmos (Archway/Neutron) node with custom configuration, the following fields should be provided in the custom config dict: + - chain_id (str): The chain ID. + - key (str): The key. + - password (str): The password. + - public_grpc (str): The public gRPC address. + - public_http (str): The public HTTP address. + - public_tcp (str): The public TCP address. + - public_rpc (str): The public RPC address. + + icon_service_config (dict, optional): ServiceConfig, this field should be provided when wanna decentralize already running icon node + + decentralize (bool, optional): Flag indicating whether to decentralize the ICON node. + relay_type (str, optional): The type of relay. + - 'ibc': Start an IBC relay. + - 'btp': Start a BTP bridge. + + chain_a (str): The source chain for relaying. + chain_b (str): The destination chain for relaying. + service_config_a (dict): Service configuration for chain A (source chain for relaying, Note: fields in dictonary should be same as output return after running node). + service_config_b (dict): Service configuration for chain B (destination chain for relaying, Note: fields in dictonary should be same as output return after running node). + bridge (bool): Flag indicating whether to use a BMV bridge. + + Returns: + service_details (dict): Details about the service started. + """ + return parse_input(plan, command, node_name, custom_config, icon_service_config ,decentralize, chain_a, chain_b, service_config_a, service_config_b, bridge) + + + +def parse_input(plan, action, node_name= None, custom_config = None, icon_service_config = None, decentralize = false, relay_type = None, chain_a = None, chain_b = None, service_config_a = None, service_config_b = None, bridge = false): + if action == "chain": + run_node(plan, node_name, decentralize, custom_config) + + elif action == "bridge": + if relay_type == "btp": + if service_config_a == None and service_config_b == None: + data = btp_relay_setup.run_btp_setup(plan, chain_a, chain_b, bridge) + elif service_config_a != None and service_config_b != None: + if chain_a == "icon" and chain_b == "icon": + data = btp_relay_setup.start_btp_for_already_running_icon_nodes(plan, chain_a, chain_b, service_config_a, service_config_b, bridge) + elif chain_a == "icon" and chain_b in ["eth", "hardhat"]: + data = btp_relay_setup.start_btp_icon_to_eth_for_already_running_nodes(plan, chain_a, chain_b, service_config_a, service_config_b, bridge) + else: + fail("unsupported chain {0} - {1}".format(src_chain, dst_chain)) + else: + fail("Add Service configs for both chain_a and chain_b") -def run(plan, args): - return parse_input(plan, args) + return data -def parse_input(plan, args): - if args["action"] == "start_node": - node_name = args["node_name"] + elif args["relay"]["name"] == "ibc": + if service_config_a == None and service_config_b == None: + data = ibc_relay_setup.run_cosmos_ibc_setup(plan, chain_a, chain_b) + elif service_config_a != None and service_config_b != None: + data = ibc_relay_setup.run_cosmos_ibc_relay_for_already_running_chains(plan, chain_a, chain_b, service_config_a, service_config_b) + else: + fail("Add Service configs for both chain_a and chain_b") - run_node(plan, node_name, args) + return data - if args["action"] == "start_nodes": - nodes = args["nodes"] + else: + fail("More Relay Support will be added soon") + + elif action == "decentralize": + icon_setup_node.configure_node(icon_service_config["service_name"], icon_service_config["enpoint"], icon_service_config["keystore_path"], icon_service_config["keypassword"], icon_service_config["nid"]) + + else: + fail("commands only supports 'chain', 'bridge' and 'decentralize'") - if len(nodes) == 1: - if nodes[0] == "icon": - data = icon_service.start_node_service_icon_to_icon(plan) - return data - else: - fail("Only Icon Supported for MutliRun") - if len(nodes) > 2: - fail("Maximum two nodes are allowed") +def run_node(plan, node_name, decentralize, custom_config = None): + if node_name == "icon": + if custom_config == None: + service_config = icon_service.start_node_service(plan) + else: + service_config = icon_node_launcher.start_icon_node(plan, custom_config["private_port"], custom_config["private_port"], custom_config["p2p_listen_address"], custom_config["p2p_address"], custom_config["cid"], {}, custom_config["genesis_file_path"], custom_config["genesis_file_name"]) - if nodes[0] == "icon" and nodes[1] == "icon": - data = icon_service.start_node_service_icon_to_icon(plan) - return data + if decentralize == true: + icon_setup_node.configure_node(service_config["service_name"], service_config["enpoint"], service_config["keystore_path"], service_config["keypassword"], service_config["nid"]) + + return service_config - else: - node_0 = run_node(plan, nodes[0], args) - node_1 = run_node(plan, nodes[1], args) + elif node_name == "eth" or node_name == "hardhat": + return eth_node.start_eth_node_service(plan, node_name) - return node_0, node_1 + elif node_name == "archway" or node_name == "neutron": + return cosmvm_node.start_cosmvm_chains(plan, node_name, args) - if args["action"] == "setup_relay": - if args["relay"]["name"] == "btp": - data = btp_relay_setup.run_btp_setup(plan, args["relay"]) + else: + fail("Unknown Chain Type. Expected ['icon','eth','hardhat','cosmwasm']") - return data +def run_btp_setup(plan, args): + links = args["links"] + source_chain = links["src"] + destination_chain = links["dst"] + bridge = args["bridge"] - elif args["relay"]["name"] == "ibc": - data = run_cosmos_ibc_setup(plan, args["relay"]) + if source_chain == "icon" and destination_chain == "icon": + data = icon_service.start_node_service_icon_to_icon(plan) + src_chain_service_name = data.src_config["service_name"] + dst_chain_service_name = data.dst_config["service_name"] - return data + config_data = input_parser.generate_new_config_data(links, src_chain_service_name, dst_chain_service_name, bridge) + config_data["chains"][src_chain_service_name] = data.src_config + config_data["chains"][dst_chain_service_name] = data.dst_config + + icon_service.configure_icon_to_icon_node(plan, data.src_config, data.dst_config) + + config = start_btp_for_already_running_icon_nodes(plan, source_chain, destination_chain, config_data, data.src_config["service_name"], data.dst_config["service_name"]) + + return config + else: + if (source_chain == "eth" or source_chain == "hardhat") and destination_chain == "icon": + destination_chain = source_chain + source_chain = "icon" + + if destination_chain == "eth" or destination_chain == "hardhat": + src_chain_config = icon_service.start_node_service(plan) + dst_chain_config = eth_node.start_eth_node_serivce(plan, destination_chain) + + src_chain_service_name = src_chain_config["service_name"] + dst_chain_service_name = dst_chain_config["service_name"] + + config_data = input_parser.generate_new_config_data(links, src_chain_service_name, dst_chain_service_name, bridge) + config_data["chains"][src_chain_service_name] = src_chain_config + config_data["chains"][dst_chain_service_name] = dst_chain_config + + icon_service.configure_icon_node(plan, src_chain_config) + config = start_btp_icon_to_eth_for_already_running_nodes(plan, source_chain, destination_chain, config_data, src_chain_service_name, dst_chain_service_name) + + return config else: - fail("More Relay Support will be added soon") - if args["action"] == "start_relay": - if args["relay"]["name"] == "ibc": - service_name = args["relay"]["service"] - cosmvm_relay.start_relay(plan, service_name) + fail("unsupported chain {0} - {1}".format(source_chain, destination_chain)) -def run_node(plan, node_name, args): - if node_name == "icon": - return icon_service.start_node_service(plan) +def start_btp_for_already_running_icon_nodes(plan, src_chain, dst_chain, config_data, src_service_name, dst_service_name): + src_bmc_address, dst_bmc_address = icon_service.deploy_bmc_icon(plan, src_chain, dst_chain, src_service_name, dst_service_name, config_data) - elif node_name == "eth" or node_name == "hardhat": - return eth_node.start_eth_node_service(plan, node_name) + response = icon_service.deploy_bmv_icon_to_icon(plan, src_service_name, dst_service_name, src_bmc_address, dst_bmc_address, config_data) - elif node_name == "archway" or node_name == "neutron": - return cosmvm_node.start_cosmvm_chains(plan, node_name) + src_xcall_address, dst_xcall_address = icon_service.deploy_xcall_icon(plan, src_chain, dst_chain, src_bmc_address, dst_bmc_address, config_data, src_service_name, dst_service_name) - else: - fail("Unknown Chain Type. Expected ['icon','eth','hardhat','cosmwasm']") + src_dapp_address, dst_dapp_address = icon_service.deploy_dapp_icon(plan, src_chain, dst_chain, src_xcall_address, dst_xcall_address, config_data, src_service_name, dst_service_name) + + src_block_height = icon_setup_node.hex_to_int(plan, src_service_name, response.src_block_height) + dst_block_height = icon_setup_node.hex_to_int(plan, dst_service_name, response.dst_block_height) + + src_contract_addresses = { + "bmc": response.src_bmc, + "bmv": response.src_bmv, + "xcall": src_xcall_address, + "dapp": src_dapp_address, + } + + dst_contract_addresses = { + "bmc": response.dst_bmc, + "bmv": response.dst_bmv, + "xcall": dst_xcall_address, + "dapp": dst_dapp_address, + } + + config_data["chains"][src_service_name]["networkTypeId"] = response.src_network_type_id + config_data["chains"][src_service_name]["networkId"] = response.src_network_id + config_data["chains"][dst_service_name]["networkTypeId"] = response.dst_network_type_id + config_data["chains"][dst_service_name]["networkId"] = response.dst_network_id + config_data["contracts"][src_service_name] = src_contract_addresses + config_data["contracts"][dst_service_name] = dst_contract_addresses + config_data["chains"][src_service_name]["block_number"] = src_block_height + config_data["chains"][dst_service_name]["block_number"] = dst_block_height + config_data = start_btp_relayer(plan, src_chain, dst_chain, config_data, src_service_name, dst_service_name) + config_data["links"]["src"] = src_service_name + config_data["links"]["dst"] = dst_service_name + + return config_data + +def start_btp_icon_to_eth_for_already_running_nodes(plan, src_chain, dst_chain, config_data, src_service_name, dst_service_name): + dst_chain_config = config_data["chains"][dst_service_name] + src_chain_config = config_data["chains"][src_service_name] + + eth_contract_service.start_deploy_service(plan, dst_chain_config["endpoint"]) + + src_bmc_address = icon_service.deploy_bmc_icon(plan, src_chain, dst_chain, src_service_name, dst_service_name, config_data) + + dst_bmc_deploy_response = eth_relay_setup.deploy_bmc(plan, config_data["chains"][dst_service_name]["network"], config_data["chains"][dst_service_name]["network_name"], dst_chain) + + dst_bmc_address = dst_bmc_deploy_response.bmc + + dst_last_block_height_number = eth_contract_service.get_latest_block(plan, dst_chain, "localnet") + + dst_last_block_height_hex = icon_setup_node.int_to_hex(plan, src_service_name, dst_last_block_height_number) + + src_response = icon_service.deploy_bmv_icon(plan, src_service_name, dst_service_name, src_bmc_address, dst_bmc_address, dst_last_block_height_hex, config_data) + + dst_bmv_address = eth_node.deploy_bmv_eth(plan, config_data["bridge"], src_response, config_dataconfig_data["chains"][dst_service_name]["network_name"], config_data["chains"][dst_service_name]["network_name"], dst_chain) + + src_xcall_address = icon_service.deploy_xcall_icon(plan, src_chain, dst_chain, src_bmc_address, dst_bmc_address, config_data, src_service_name, dst_service_name) + + dst_xcall_address = eth_relay_setup.deploy_xcall(plan, config_data["chains"][dst_service_name]["network"], config_data["chains"][dst_service_name]["network_name"], dst_chain) + + src_dapp_address = icon_service.deploy_dapp_icon(plan, src_chain, dst_chain, src_xcall_address, dst_xcall_address, config_data, src_service_name, dst_service_name) + + dst_dapp_address = eth_relay_setup.deploy_dapp(plan, config_data["chains"][dst_service_name]["network"], config_data["chains"][dst_service_name]["network_name"], dst_chain) + + src_block_height = icon_setup_node.hex_to_int(plan, src_service_name, src_response.block_height) + + src_contract_addresses = { + "bmc": src_response.bmc, + "bmv": src_response.bmvbridge, + "xcall": src_xcall_address, + "dapp": src_dapp_address, + } + + dst_contract_addresses = { + "bmc": dst_bmc_address, + "bmcm": dst_bmc_deploy_response.bmcm, + "bmcs": dst_bmc_deploy_response.bmcs, + "bmv": dst_bmv_address, + "xcall": dst_xcall_address, + "dapp": dst_dapp_address, + } + + config_data["contracts"][src_service_name] = src_contract_addresses + config_data["contracts"][dst_service_name] = dst_contract_addresses + config_data["chains"][src_service_name]["networkTypeId"] = src_response.network_type_id + config_data["chains"][src_service_name]["networkId"] = src_response.network_id + config_data["chains"][src_service_name]["block_number"] = src_block_height + config_data["chains"][dst_service_name]["block_number"] = dst_last_block_height_number + + config_data = start_btp_relayer(plan, src_chain, dst_chain, config_data, src_service_name, dst_service_name) + + config_data["links"]["src"] = src_service_name + config_data["links"]["dst"] = dst_service_name + + return config_data + +def start_btp_relayer(plan, src_chain, dst_chain, config_data, src_service_name, dst_service_name): + src_network = config_data["chains"][src_service_name]["network"] + src_bmc = config_data["contracts"][src_service_name]["bmc"] + + dst_network = config_data["chains"][dst_service_name]["network"] + dst_bmc = config_data["contracts"][dst_service_name]["bmc"] + + src_btp_address = "btp://{0}/{1}".format(src_network, src_bmc) + dst_btp_address = "btp://{0}/{1}".format(dst_network, dst_bmc) + + btp_bridge.start_relayer(plan, src_service_name, dst_service_name, config_data, src_btp_address, dst_btp_address, config_data["bridge"]) + + return config_data def run_cosmos_ibc_setup(plan, args): + """ + Start the Cosmos IBC relay setup process between chains. + + Args: + plan (plan): The execution plan. + args (dict): Arguments for configuring the setup. + + Returns: + dict: Configuration response data (will return data for dive.json) + """ links = args["links"] source_chain = links["src"] destination_chain = links["dst"] @@ -87,26 +310,26 @@ def run_cosmos_ibc_setup(plan, args): # Check if source and destination chains are both CosmVM-based chains (archway or neutron) if (source_chain in ["archway", "neutron"]) and (destination_chain in ["archway", "neutron"]): # Start IBC between two CosmVM chains - data = cosmvm_node.start_ibc_between_cosmvm_chains(plan, source_chain, destination_chain) - config_data = run_cosmos_ibc_relay_for_already_running_chains(plan, source_chain, destination_chain ,data.src_config, data.dst_config) + data = cosmvm_node.start_ibc_between_cosmvm_chains(plan, source_chain, destination_chain, args) + config_data = run_cosmos_ibc_relay_for_already_running_chains(plan, data.src_config, data.dst_config, args) return config_data + # Check if the destination chain is CosmVM-based and the source chain is ICON if destination_chain in ["archway", "neutron"] and source_chain == "icon": # Start ICON node service src_chain_config = icon_service.start_node_service(plan) # Start CosmVM node service - dst_chain_config = cosmvm_node.start_cosmvm_chains(plan, destination_chain) + data = {"data": {}} + dst_chain_config = cosmvm_node.start_cosmvm_chains(plan, destination_chain, data) dst_chain_config = input_parser.struct_to_dict(dst_chain_config) # Get service names and new generate configuration data - config_data = run_cosmos_ibc_relay_for_already_running_chains(plan,source_chain, destination_chain ,src_chain_config , dst_chain_config) + config_data = run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain_config , dst_chain_config, args) return config_data - - -def run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain, dst_chain, src_chain_config, dst_chain_config): - source_chain = src_chain - destination_chain = dst_chain - if src_chain in ["archway", "neutron"] and dst_chain in ["archway", "neutron"]: +def run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain_config, dst_chain_config, args): + source_chain = args["links"]["src"] + destination_chain = args["links"]["dst"] + if source_chain in ["archway", "neutron"] and destination_chain in ["archway", "neutron"]: src_chain_service_name = src_chain_config["service_name"] dst_chain_service_name = dst_chain_config["service_name"] src_chain_id = src_chain_config["chain_id"] @@ -114,25 +337,25 @@ def run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain, dst_chain, dst_chain_id = dst_chain_config["chain_id"] dst_chain_key = dst_chain_config["chain_key"] - config_data = input_parser.generate_new_config_data_for_ibc(src_chain, dst_chain, src_chain_service_name, dst_chain_service_name) + config_data = input_parser.generate_new_config_data_cosmvm_cosmvm(args["links"], src_chain_service_name, dst_chain_service_name) config_data["chains"][src_chain_service_name] = src_chain_config config_data["chains"][dst_chain_service_name] = dst_chain_config - cosmvm_relay.start_cosmos_relay(plan, src_chain, dst_chain, src_chain_config, dst_chain_config) + cosmvm_relay.start_cosmos_relay(plan, src_chain_key, src_chain_id, dst_chain_key, dst_chain_id, src_chain_config, dst_chain_config, args["links"]) - elif src_chain == "icon" and dst_chain in ["archway", "neutron"]: + elif source_chain == "icon" and destination_chain in ["archway", "neutron"]: src_chain_service_name = src_chain_config["service_name"] dst_chain_service_name = dst_chain_config["service_name"] - config_data = input_parser.generate_new_config_data_for_ibc(src_chain,dst_chain, src_chain_service_name, dst_chain_service_name) + config_data = input_parser.generate_new_config_data(args["links"], src_chain_service_name, dst_chain_service_name, "") # Add chain configurations to the configuration data config_data["chains"][src_chain_service_name] = src_chain_config config_data["chains"][dst_chain_service_name] = dst_chain_config # Setup ICON contracts for IBC - deploy_icon_contracts = icon_relay_setup.setup_contracts_for_ibc_java(plan, src_chain_config["service_name"], src_chain_config["endpoint"], src_chain_config["keystore_path"], src_chain_config["keypassword"], src_chain_config["nid"], src_chain_config["network"]) + deploy_icon_contracts = icon_relay_setup.setup_contracts_for_ibc_java(plan, src_chain_config) icon_register_client = icon_relay_setup.registerClient(plan, src_chain_service_name, deploy_icon_contracts["light_client"], src_chain_config["keystore_path"], src_chain_config["keypassword"], src_chain_config["nid"], src_chain_config["endpoint"], deploy_icon_contracts["ibc_core"]) # Configure ICON node - icon_setup_node.configure_node(plan, src_chain_config["service_name"], src_chain_config["endpoint"], src_chain_config["keystore_path"], src_chain_config["keypassword"], src_chain_config["nid"]) + icon_setup_node.configure_node(plan, src_chain_config) src_chain_last_block_height = icon_setup_node.get_last_block(plan, src_chain_service_name) @@ -151,12 +374,12 @@ def run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain, dst_chain, icon_bind_port = icon_relay_setup.bindPort(plan, src_chain_service_name, deploy_icon_contracts["xcall_connection"], src_chain_config["keystore_path"], src_chain_config["keypassword"], src_chain_config["nid"], src_chain_config["endpoint"], deploy_icon_contracts["ibc_core"], "xcall") # Depending on the destination chain (archway or neutron), set up Cosmos contracts - if dst_chain == "archway": + if destination_chain == "archway": deploy_cosmos_contracts = cosmvm_relay_setup.setup_contracts_for_ibc_wasm(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], dst_chain_config["chain_id"], "stake", "xcall") cosmvm_relay_setup.registerClient(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["ibc_core"], deploy_cosmos_contracts["light_client"]) plan.wait(service_name = dst_chain_service_name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "sleep 10s && echo 'success'"]), field = "code", assertion = "==", target_value = 0, timeout = "200s") cosmvm_relay_setup.bindPort(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["ibc_core"], deploy_cosmos_contracts["xcall_connection"]) - elif dst_chain == "neutron": + elif destination_chain == "neutron": deploy_cosmos_contracts = neutron_relay_setup.setup_contracts_for_ibc_wasm(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], dst_chain_config["chain_id"], "stake", "xcall") neutron_relay_setup.registerClient(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["ibc_core"], deploy_cosmos_contracts["light_client"]) plan.wait(service_name = dst_chain_service_name, recipe = ExecRecipe(command = ["/bin/sh", "-c", "sleep 10s && echo 'success'"]), field = "code", assertion = "==", target_value = 0, timeout = "200s") @@ -191,18 +414,18 @@ def run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain, dst_chain, } # Start the Cosmos relay for ICON to Cosmos communication - relay_service_response = cosmvm_relay.start_cosmos_relay_for_icon_to_cosmos(plan, src_chain, dst_chain ,src_chain_data, dst_chain_data) + relay_service_response = cosmvm_relay.start_cosmos_relay_for_icon_to_cosmos(plan, src_chain_data, dst_chain_data, args) path_name = cosmvm_relay.setup_relay(plan, src_chain_data, dst_chain_data) relay_data = cosmvm_relay.get_relay_path_data(plan, relay_service_response.service_name, path_name) - dapp_result_java = icon_relay_setup.deploy_and_configure_dapp_java(plan, src_chain_config, deploy_icon_contracts["xcall"], dst_chain_config["chain_id"], deploy_icon_contracts["xcall_connection"], deploy_cosmos_contracts["xcall_connection"]) + dapp_result_java = icon_relay_setup.deploy_and_configure_dapp_java(plan, src_chain_config, deploy_icon_contracts["xcall"], dst_chain_config["chain_id"], deploy_icon_contracts["xcall_connection"], deploy_cosmos_contracts["xcall_connection"], src_chain_service_name, src_chain_config["endpoint"], src_chain_config["keystore_path"], src_chain_config["keypassword"], src_chain_config["nid"]) # Depending on the destination chain (archway or neutron), deploy and configure the DApp for Wasm - if dst_chain == "archway": + if destination_chain == "archway": dapp_result_wasm = cosmvm_relay_setup.deploy_and_configure_xcall_dapp(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall"], deploy_cosmos_contracts["xcall_connection"], deploy_icon_contracts["xcall_connection"], src_chain_config["network"]) cosmvm_relay_setup.configure_connection_for_wasm(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall_connection"], relay_data.dst_connection_id, "xcall", src_chain_config["network"], relay_data.dst_client_id, deploy_cosmos_contracts["xcall"]) - elif dst_chain == "neutron": + elif destination_chain == "neutron": dapp_result_wasm = neutron_relay_setup.deploy_and_configure_xcall_dapp(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall"], deploy_cosmos_contracts["xcall_connection"], deploy_icon_contracts["xcall_connection"], src_chain_config["network"]) neutron_relay_setup.configure_connection_for_wasm(plan, dst_chain_service_name, dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall_connection"], relay_data.dst_connection_id, "xcall", src_chain_config["network"], relay_data.dst_client_id, deploy_cosmos_contracts["xcall"]) @@ -216,3 +439,8 @@ def run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain, dst_chain, return config_data + + + + + diff --git a/services/bridges/btp/src/bridge.star b/services/bridges/btp/src/bridge.star index 502b36c8..3e6eb096 100644 --- a/services/bridges/btp/src/bridge.star +++ b/services/bridges/btp/src/bridge.star @@ -13,50 +13,34 @@ input_parser = import_module("../../../../package_io/input_parser.star") -def run_btp_setup(plan, args): - links = args["links"] - source_chain = links["src"] - destination_chain = links["dst"] - bridge = args["bridge"] - - if source_chain == "icon" and destination_chain == "icon": +def run_btp_setup(plan, src_chain, dst_chain, bridge): + if src_chain == "icon" and dst_chain == "icon": data = icon_service.start_node_service_icon_to_icon(plan) src_chain_service_name = data.src_config["service_name"] dst_chain_service_name = data.dst_config["service_name"] - - config_data = input_parser.generate_new_config_data(links, src_chain_service_name, dst_chain_service_name, bridge) - config_data["chains"][src_chain_service_name] = data.src_config - config_data["chains"][dst_chain_service_name] = data.dst_config - icon_service.configure_icon_to_icon_node(plan, data.src_config, data.dst_config) - - config = start_btp_for_already_running_icon_nodes(plan, source_chain, destination_chain, data.src_config, data.dst_config, bridge) - + config = start_btp_for_already_running_icon_nodes(plan, src_chain, dst_chain, data.src_config, data.dst_config, bridge) return config else: - if (source_chain == "eth" or source_chain == "hardhat") and destination_chain == "icon": - destination_chain = source_chain - source_chain = "icon" + if (src_chain == "eth" or src_chain == "hardhat") and dst_chain == "icon": + dst_chain = src_chain + src_chain = "icon" - if destination_chain == "eth" or destination_chain == "hardhat": + if dst_chain == "eth" or dst_chain == "hardhat": src_chain_config = icon_service.start_node_service(plan) - dst_chain_config = eth_node.start_eth_node_service(plan, destination_chain) + dst_chain_config = eth_node.start_eth_node_service(plan, dst_chain) src_chain_service_name = src_chain_config["service_name"] dst_chain_service_name = dst_chain_config["service_name"] - config_data = input_parser.generate_new_config_data(links, src_chain_service_name, dst_chain_service_name, bridge) - config_data["chains"][src_chain_service_name] = src_chain_config - config_data["chains"][dst_chain_service_name] = dst_chain_config - icon_service.configure_icon_node(plan, src_chain_service_name, src_chain_config["endpoint"], src_chain_config["keystore_path"], src_chain_config["keypassword"], src_chain_config["nid"]) - config = start_btp_icon_to_eth_for_already_running_nodes(plan, source_chain, destination_chain, src_chain_config, dst_chain_config, bridge) + config = start_btp_icon_to_eth_for_already_running_nodes(plan, src_chain, dst_chain, src_chain_config, dst_chain_config, bridge) return config else: - fail("unsupported chain {0} - {1}".format(source_chain, destination_chain)) + fail("unsupported chain {0} - {1}".format(src_chain, dst_chain)) @@ -132,7 +116,8 @@ def start_btp_for_already_running_icon_nodes(plan, src_chain, dst_chain, src_cha # Generate new configuration data for BTP config_data = input_parser.generate_new_config_data_for_btp(src_chain, dst_chain, src_chain_config["service_name"], dst_chain_config["service_name"], bridge) - + config_data["chains"][src_chain_config["service_name"]] = src_chain_config + config_data["chains"][dst_chain_config["service_name"]] = dst_chain_config # Update network and contract information in the configuration data config_data["chains"][src_chain_config["service_name"]]["networkTypeId"] = response.src_network_type_id config_data["chains"][src_chain_config["service_name"]]["networkId"] = response.src_network_id @@ -232,6 +217,9 @@ def start_btp_icon_to_eth_for_already_running_nodes(plan, src_chain, dst_chain, # Generate new configuration data for BTP config_data = input_parser.generate_new_config_data_for_btp(src_chain, dst_chain, src_chain_config["service_name"], dst_chain_config["service_name"], bridge) + config_data["chains"][src_chain_config["service_name"]] = src_chain_config + config_data["chains"][dst_chain_config["service_name"]] = dst_chain_config + config_data["contracts"][src_chain_config["service_name"]] = src_contract_addresses config_data["contracts"][dst_chain_config["service_name"]] = dst_contract_addresses config_data["chains"][src_chain_config["service_name"]]["networkTypeId"] = src_response.network_type_id diff --git a/services/bridges/ibc/src/bridge.star b/services/bridges/ibc/src/bridge.star index eb92aca4..83fd8fe7 100644 --- a/services/bridges/ibc/src/bridge.star +++ b/services/bridges/ibc/src/bridge.star @@ -1,6 +1,146 @@ # Import required modules and constants constants = import_module("../../../../package_io/constants.star") ibc_relay_config = constants.IBC_RELAYER_SERVICE +icon_setup_node = import_module("../../../jvm/icon/src/node-setup/setup_icon_node.star") +icon_relay_setup = import_module("../../../jvm/icon/src/relay-setup/contract_configuration.star") +icon_service = import_module("../../../jvm/icon/icon.star") +input_parser = import_module("../../../../package_io/input_parser.star") +cosmvm_node = import_module("../../../cosmvm/cosmvm.star") +cosmvm_relay_setup = import_module("../../../cosmvm/archway/src/relay-setup/contract-configuration.star") +neutron_relay_setup = import_module("../../../cosmvm/neutron/src/relay-setup/contract-configuration.star") + + + +def run_cosmos_ibc_setup(plan, src_chain, dst_chain): + + # Check if source and destination chains are both CosmVM-based chains (archway or neutron) + if (src_chain in ["archway", "neutron"]) and (dst_chain in ["archway", "neutron"]): + # Start IBC between two CosmVM chains + data = cosmvm_node.start_ibc_between_cosmvm_chains(plan, src_chain, dst_chain) + config_data = run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain, dst_chain ,data.src_config, data.dst_config) + return config_data + + if dst_chain in ["archway", "neutron"] and src_chain == "icon": + # Start ICON node service + src_chain_config = icon_service.start_node_service(plan) + # Start CosmVM node service + dst_chain_config = cosmvm_node.start_cosmvm_chains(plan, dst_chain) + dst_chain_config = input_parser.struct_to_dict(dst_chain_config) + # Get service names and new generate configuration data + config_data = run_cosmos_ibc_relay_for_already_running_chains(plan,src_chain, dst_chain ,src_chain_config , dst_chain_config) + return config_data + + + +def run_cosmos_ibc_relay_for_already_running_chains(plan, src_chain, dst_chain, src_chain_config, dst_chain_config): + + config_data = generate_ibc_config(src_chain, dst_chain, src_chain_config, dst_chain_config) + if src_chain in ["archway", "neutron"] and dst_chain in ["archway", "neutron"]: + start_cosmos_relay(plan, src_chain, dst_chain, src_chain_config, dst_chain_config) + + elif src_chain == "icon" and dst_chain in ["archway", "neutron"]: + config_data = generate_ibc_config(src_chain, dst_chain, src_chain_config, dst_chain_config) + deploy_icon_contracts, src_chain_data = setup_icon_chain(plan, src_chain_config) + deploy_cosmos_contracts, dst_chain_data = setup_cosmos_chain(plan, dst_chain, dst_chain_config) + + relay_service_response = start_cosmos_relay_for_icon_to_cosmos(plan, src_chain, dst_chain ,src_chain_data, dst_chain_data) + path_name = setup_relay(plan, src_chain_data, dst_chain_data) + relay_data = get_relay_path_data(plan, relay_service_response.service_name, path_name) + dapp_result_java = icon_relay_setup.deploy_and_configure_dapp_java(plan, src_chain_config, deploy_icon_contracts["xcall"], dst_chain_config["chain_id"], deploy_icon_contracts["xcall_connection"], deploy_cosmos_contracts["xcall_connection"]) + + # Depending on the destination chain (archway or neutron), deploy and configure the DApp for Wasm + if dst_chain == "archway": + dapp_result_wasm = cosmvm_relay_setup.deploy_and_configure_xcall_dapp(plan, dst_chain_config["service_name"], dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall"], deploy_cosmos_contracts["xcall_connection"], deploy_icon_contracts["xcall_connection"], src_chain_config["network"]) + cosmvm_relay_setup.configure_connection_for_wasm(plan, dst_chain_config["service_name"], dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall_connection"], relay_data.dst_connection_id, "xcall", src_chain_config["network"], relay_data.dst_client_id, deploy_cosmos_contracts["xcall"]) + elif dst_chain == "neutron": + dapp_result_wasm = neutron_relay_setup.deploy_and_configure_xcall_dapp(plan, dst_chain_config["service_name"], dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall"], deploy_cosmos_contracts["xcall_connection"], deploy_icon_contracts["xcall_connection"], src_chain_config["network"]) + neutron_relay_setup.configure_connection_for_wasm(plan, dst_chain_config["service_name"], dst_chain_config["chain_id"], dst_chain_config["chain_key"], deploy_cosmos_contracts["xcall_connection"], relay_data.dst_connection_id, "xcall", src_chain_config["network"], relay_data.dst_client_id, deploy_cosmos_contracts["xcall"]) + + icon_relay_setup.configure_connection_for_java(plan, deploy_icon_contracts["xcall"], deploy_icon_contracts["xcall_connection"], dst_chain_config["chain_id"], relay_data.src_connection_id, "xcall", dst_chain_config["chain_id"], relay_data.src_client_id, src_chain_config["service_name"], src_chain_config["endpoint"], src_chain_config["keystore_path"], src_chain_config["keypassword"], src_chain_config["nid"]) + + config_data["contracts"][src_chain_config["service_name"]] = deploy_icon_contracts + config_data["contracts"][dst_chain_config["service_name"]] = deploy_cosmos_contracts + config_data["contracts"][src_chain_config["service_name"]]["dapp"] = dapp_result_java["xcall_dapp"] + config_data["contracts"][dst_chain_config["service_name"]]["dapp"] = dapp_result_wasm["xcall_dapp"] + + # Start relay channel + start_channel(plan, relay_service_response.service_name, path_name, "xcall", "xcall") + + return config_data + + +def setup_icon_chain(plan, chain_config): + + deploy_icon_contracts = icon_relay_setup.setup_contracts_for_ibc_java(plan, chain_config["service_name"], chain_config["endpoint"], chain_config["keystore_path"], chain_config["keypassword"], chain_config["nid"], chain_config["network"]) + icon_relay_setup.registerClient(plan, chain_config["service_name"], deploy_icon_contracts["light_client"], chain_config["keystore_path"], chain_config["keypassword"], chain_config["nid"], chain_config["endpoint"], deploy_icon_contracts["ibc_core"]) + + # Configure ICON node + icon_setup_node.configure_node(plan, chain_config["service_name"], chain_config["endpoint"], chain_config["keystore_path"], chain_config["keypassword"], chain_config["nid"]) + src_chain_last_block_height = icon_setup_node.get_last_block(plan, chain_config["service_name"]) + + plan.print("source block height %s" % src_chain_last_block_height) + + network_name = "{0}-{1}".format("dst_chain_network_name", src_chain_last_block_height) + + src_data = { + "name": network_name, + "owner": deploy_icon_contracts["ibc_core"], + } + + #Open BTP network on ICON chain + tx_result_open_btp_network = icon_setup_node.open_btp_network(plan, chain_config["service_name"], src_data, chain_config["endpoint"], chain_config["keystore_path"], chain_config["keypassword"], chain_config["nid"]) + + icon_relay_setup.bindPort(plan, chain_config["service_name"], deploy_icon_contracts["xcall_connection"], chain_config["keystore_path"], chain_config["keypassword"], chain_config["nid"], chain_config["endpoint"], deploy_icon_contracts["ibc_core"], "xcall") + + src_chain_id = chain_config["network_name"].split('-', 1)[1] + network_id = icon_setup_node.hex_to_int(plan, chain_config["service_name"], chain_config["nid"]) + btp_network_id = icon_setup_node.hex_to_int(plan, chain_config["service_name"], tx_result_open_btp_network["extract.network_id"]) + btp_network_type_id = icon_setup_node.hex_to_int(plan, chain_config["service_name"], tx_result_open_btp_network["extract.network_type_id"]) + + src_chain_data = { + "chain_id": src_chain_id, + "rpc_address": chain_config["endpoint"], + "ibc_address": deploy_icon_contracts["ibc_core"], + "password": chain_config["keypassword"], + "network_id": network_id, + "btp_network_id": btp_network_id, + "btp_network_type_id": btp_network_type_id + } + + return deploy_icon_contracts, src_chain_data + + +def setup_cosmos_chain(plan, chain ,chain_config): + if chain == "archway": + deploy_cosmos_contracts = cosmvm_relay_setup.setup_contracts_for_ibc_wasm(plan, chain_config["service_name"], chain_config["chain_id"], chain_config["chain_key"], chain_config["chain_id"], "stake", "xcall") + cosmvm_relay_setup.registerClient(plan, chain_config["service_name"], chain_config["chain_id"], chain_config["chain_key"], deploy_cosmos_contracts["ibc_core"], deploy_cosmos_contracts["light_client"]) + plan.wait(service_name = chain_config["service_name"], recipe = ExecRecipe(command = ["/bin/sh", "-c", "sleep 10s && echo 'success'"]), field = "code", assertion = "==", target_value = 0, timeout = "200s") + cosmvm_relay_setup.bindPort(plan, chain_config["service_name"], chain_config["chain_id"], chain_config["chain_key"], deploy_cosmos_contracts["ibc_core"], deploy_cosmos_contracts["xcall_connection"]) + elif chain == "neutron": + deploy_cosmos_contracts = neutron_relay_setup.setup_contracts_for_ibc_wasm(plan, chain_config["service_name"], chain_config["chain_id"], chain_config["chain_key"], chain_config["chain_id"], "stake", "xcall") + neutron_relay_setup.registerClient(plan, chain_config["service_name"], chain_config["chain_id"], chain_config["chain_key"], deploy_cosmos_contracts["ibc_core"], deploy_cosmos_contracts["light_client"]) + plan.wait(service_name = chain_config["service_name"], recipe = ExecRecipe(command = ["/bin/sh", "-c", "sleep 10s && echo 'success'"]), field = "code", assertion = "==", target_value = 0, timeout = "200s") + neutron_relay_setup.bindPort(plan, chain_config["service_name"], chain_config["chain_id"], chain_config["chain_key"], deploy_cosmos_contracts["ibc_core"], deploy_cosmos_contracts["xcall_connection"]) + + dst_chain_data = { + "chain_id": chain_config["chain_id"], + "key": chain_config["chain_key"], + "rpc_address": chain_config["endpoint"], + "ibc_address": deploy_cosmos_contracts["ibc_core"], + "service_name": chain_config["service_name"], + } + + return deploy_cosmos_contracts, dst_chain_data + + + +def generate_ibc_config(src_chain, dst_chain, src_chain_config, dst_chain_config): + config_data = input_parser.generate_new_config_data_for_ibc(src_chain, dst_chain, src_chain_config["service_name"], dst_chain_config["service_name"]) + config_data["chains"][src_chain_config["service_name"]] = src_chain_config + config_data["chains"][dst_chain_config["service_name"]] = dst_chain_config + return config_data + + def start_cosmos_relay(plan, src_chain, dst_chain, src_config, dst_config): """