Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: icon cosmos integration #146

Merged
merged 30 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fdd3c9e
feat: update icon and wasm contracts for ibc setup
shreyasbhat0 Aug 20, 2023
35693ac
feat: implement methods to deploy wasm contracts
shreyasbhat0 Aug 20, 2023
272d711
feat: implement contract mehtods for icon ibc
shreyasbhat0 Aug 20, 2023
1e6e9b8
feat: update contract deployment for ibc setup
shreyasbhat0 Aug 21, 2023
a540e47
chore: update code
Prathiksha-Nataraja Aug 21, 2023
bdbbeee
feat: update main.star file
shreyasbhat0 Aug 21, 2023
570beaa
chore:update code
Prathiksha-Nataraja Aug 21, 2023
8a9b868
feat: update contract deployment
shreyasbhat0 Aug 21, 2023
6bce84b
chore: add relay service for icon to cosmos
Prathiksha-Nataraja Aug 21, 2023
e9279c1
feat: update comos constants
shreyasbhat0 Aug 21, 2023
2354b21
feat: update cosmos relayer for icon to cosmos
shreyasbhat0 Aug 21, 2023
196baf8
fix: remove typos from code
shreyasbhat0 Aug 21, 2023
2f6162b
feat; update keystore for relay setup
shreyasbhat0 Aug 22, 2023
9854210
chore: update main
Prathiksha-Nataraja Aug 22, 2023
d486303
feat: update relay setup for icon comsos
shreyasbhat0 Aug 22, 2023
d904594
feat: add relay start command
shreyasbhat0 Aug 22, 2023
0bfe028
fix: rly start command
shreyasbhat0 Aug 22, 2023
d38a6e8
chore: update icon-ibc-relay image version
shanithkk Aug 23, 2023
595b200
fix: contract setup archway
shreyasbhat0 Aug 23, 2023
7099527
fix: remove debug print statements
shreyasbhat0 Aug 23, 2023
630d2a7
feat: update relay start command
shreyasbhat0 Aug 25, 2023
00a77ae
Merge branch 'main' into feat/icon-cosmos-integration
shreyasbhat0 Aug 28, 2023
eda3097
fix: error when node already running
shreyasbhat0 Aug 28, 2023
0df55e8
fix: help falg for archway chain command
shreyasbhat0 Aug 28, 2023
9789f52
feat: update bridge
shreyasbhat0 Aug 28, 2023
5fb7950
feat: update cosmos package for icon archway
shreyasbhat0 Aug 28, 2023
b2a45f2
chore: bump versions of dive and kurtosis sdk
shreyasbhat0 Aug 28, 2023
1652cc0
fix: typo in user output
shreyasbhat0 Aug 28, 2023
5eaa7b2
feat: update service file writes
shreyasbhat0 Aug 28, 2023
160e5c0
chore: remove print statemet
shreyasbhat0 Aug 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cli/commands/chain/types/archway.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ func NewArchwayCmd(diveContext *common.DiveContext) *cobra.Command {

common.WriteToServiceFile(runResponse.ServiceName, *runResponse)

diveContext.StopSpinner("Archyway Node Started. Please find service details in current working directory(services.json)")
diveContext.StopSpinner("Archway Node Started. Please find service details in current working directory(services.json)")
},
}
archwayCmd.Flags().StringVarP(&config, "config", "c", "", "provide config to start archway node ")
archwayCmd.Flags().StringVarP(&config, "config", "c", "", "path to custom config json file to start archway node ")

return archwayCmd
}
Expand Down Expand Up @@ -170,12 +170,14 @@ func runArchwayWithDefaultServiceConfig(diveContext *common.DiveContext, enclave

}

nodeServiceResponseData, _, _, err := diveContext.GetSerializedData(nodeServiceResponse)
nodeServiceResponseData, services, skippedInstructions, err := diveContext.GetSerializedData(nodeServiceResponse)
if err != nil {

return "", err
diveContext.StopServices(services)
diveContext.FatalError("Starlark Run Failed", err.Error())

}
diveContext.CheckInstructionSkipped(skippedInstructions, "Archway Node Already Running")

return nodeServiceResponseData, nil
}
2 changes: 1 addition & 1 deletion cli/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package common
var DiveLogs bool

// !!!!!!!!!!! DO NOT UPDATE! WILL BE UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
var DiveVersion = "v0.0.8-beta"
var DiveVersion = "v0.0.9-beta"

const (
DiveEnclave = "dive"
Expand Down
36 changes: 11 additions & 25 deletions cli/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,42 +212,28 @@ func WriteToServiceFile(serviceName string, data DiveserviceResponse) error {
return err
}

if len(jsonDataFromFile) != 0 {
_, ok := jsonDataFromFile[serviceName]
if !ok {
jsonDataFromFile[serviceName] = &data
dataTowrite, err := json.Marshal(jsonDataFromFile)
if err != nil {
return err
}

_, err = file.WriteAt(dataTowrite, 0)

if err != nil {
return err
}

return nil
}

if len(jsonDataFromFile) == 0 {
jsonDataFromFile = Services{}
}
newServices := Services{}

newServices[serviceName] = &data
var dataToWrite []byte

dataTowrite, err := json.Marshal(newServices)
if err != nil {
return err
_, ok := jsonDataFromFile[serviceName]
if !ok {
jsonDataFromFile[serviceName] = &data
dataToWrite, err = json.Marshal(jsonDataFromFile)
if err != nil {
return err
}
}

_, err = file.Write(dataTowrite)
_, err = file.Write(dataToWrite)

if err != nil {
return err
}

return nil

}

func ReadServiceJsonFile() (Services, error) {
Expand Down
2 changes: 1 addition & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/briandowns/spinner v1.23.0
github.com/fatih/color v1.15.0
github.com/google/go-github v17.0.0+incompatible
github.com/kurtosis-tech/kurtosis/api/golang v0.82.5
github.com/kurtosis-tech/kurtosis/api/golang v0.82.6
github.com/kurtosis-tech/stacktrace v0.0.0-20211028211901-1c67a77b5409
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/sirupsen/logrus v1.9.3
Expand Down
92 changes: 91 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ btp_bridge = import_module("github.com/hugobyte/dive/services/bridges/btp/src/br
input_parser = import_module("github.com/hugobyte/dive/package_io/input_parser.star")
cosmvm_node = import_module("github.com/hugobyte/dive/services/cosmvm/cosmvm.star")
cosmvm_relay = import_module("github.com/hugobyte/dive/services/bridges/ibc/src/bridge.star")
cosmvm_relay_setup = import_module("github.com/hugobyte/dive/services/cosmvm/archway/src/relay-setup/contract-configuration.star")

def run(plan, args):
return parse_input(plan, args)
Expand Down Expand Up @@ -48,13 +49,17 @@ def parse_input(plan, args):

return data

elif args["relay"]["name"] == "cosmos":
elif args["relay"]["name"] == "ibc":
data = run_cosmos_ibc_setup(plan, args["relay"])

return data

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)

def run_node(plan, node_name, args):
if node_name == "icon":
Expand Down Expand Up @@ -245,6 +250,90 @@ def run_cosmos_ibc_setup(plan, args):
config_data = run_cosmos_ibc_relay_for_already_running_chains(plan,links,data.src_config,data.dst_config)
return config_data

if destination_chain == "archway":

src_chain_config = icon_service.start_node_service(plan)
data = {"data":{}}
dst_chain_config = cosmvm_node.start_cosmvm_chains(plan, destination_chain,data)

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,"")

config_data["chains"][src_chain_service_name] = src_chain_config
config_data["chains"][dst_chain_service_name] = dst_chain_config

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"])

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)

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"]
}

icon_setup_node.open_btp_network(plan,src_chain_service_name,src_data,src_chain_config["endpoint"],src_chain_config["keystore_path"], src_chain_config["keypassword"],src_chain_config["nid"])

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")

deploy_archway_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_archway_contracts["ibc_core"],deploy_archway_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_archway_contracts["ibc_core"],deploy_archway_contracts["xcall_connection"])


config_data["contracts"][src_chain_service_name] = deploy_icon_contracts
config_data["contracts"][dst_chain_service_name] = deploy_archway_contracts

src_chain_data = {
"chain_id": "0xacbc4e",
"rpc_address": src_chain_config["endpoint"],
"ibc_address": deploy_icon_contracts["ibc_core"],
"password" : src_chain_config["keypassword"]
}
dst_chain_data = {
"chain_id": dst_chain_config.chain_id,
"key": dst_chain_config.chain_key,
"rpc_address": dst_chain_config.endpoint,
"ibc_address": deploy_archway_contracts["ibc_core"],
"service_name": dst_chain_config.service_name
}
relay_service_response = cosmvm_relay.start_cosmos_relay_for_icon_to_cosmos(plan,src_chain_data,dst_chain_data)
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_archway_contracts["xcall_connection"],src_chain_service_name,src_chain_config["endpoint"],src_chain_config["keystore_path"],src_chain_config["keypassword"],src_chain_config["nid"])

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_archway_contracts["xcall"],deploy_archway_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_archway_contracts["xcall_connection"],relay_data.dst_connection_id,"xcall",src_chain_config["network"],relay_data.dst_client_id,deploy_archway_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_service_name,src_chain_config["endpoint"],src_chain_config["keystore_path"],src_chain_config["keypassword"],src_chain_config["nid"])


config_data["contracts"][src_chain_service_name]["dapp"] = dapp_result_java["xcall_dapp"]
config_data["contracts"][dst_chain_service_name]["dapp"] = dapp_result_wasm["xcall_dapp"]

cosmvm_relay.start_channel(plan,relay_service_response.service_name,path_name,"xcall","xcall")


return config_data



def run_cosmos_ibc_relay_for_already_running_chains(plan,links,src_config,dst_config):

src_chain_service_name = src_config["service_name"]
Expand All @@ -260,3 +349,4 @@ def run_cosmos_ibc_relay_for_already_running_chains(plan,links,src_config,dst_co
cosmvm_relay.start_cosmos_relay(plan, src_chain_key, src_chain_id, dst_chain_key, dst_chain_id, src_config, dst_config)

return config_data

15 changes: 11 additions & 4 deletions package_io/constants.star
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ICON_NODE_CLIENT = struct(
node_image = "iconloop/goloop-icon:v1.3.8",
node_image = "iconloop/goloop-icon:v1.3.9",
config_files_directory = "/goloop/config/",
contracts_directory = "/goloop/contracts/",
keystore_directory = "/goloop/keystores/",
Expand Down Expand Up @@ -44,7 +44,7 @@ ARCHWAY_SERVICE_CONFIG = struct(
start_script = "github.com/hugobyte/dive/services/cosmvm/archway/static_files/start.sh",
default_contract_path = "github.com/hugobyte/dive/services/cosmvm/archway/static_files/contracts",
service_name = "node-service",
image = "archwaynetwork/archwayd:constantine",
image = "archwaynetwork/archwayd:v2.0.0",
path = "/start-scripts/",
contract_path = "/root/contracts/",
config_files = "github.com/hugobyte/dive/services/cosmvm/archway/static_files/config/",
Expand All @@ -58,6 +58,13 @@ IBC_RELAYER_SERVICE = struct(
relay_service_image = "hugobyte/ibc-relay:v0.1",
relay_config_files_path = "/script/",
run_file_path = "github.com/hugobyte/dive/services/bridges/ibc/static-files/run.sh",
relay_service_image_icon_to_cosmos = "hugobyte/icon-ibc-relay:v0.1",
relay_service_name_icon_to_cosmos = "ibc-relayer",
config_file_path = "github.com/hugobyte/dive/services/bridges/ibc/static-files/config",
ibc_relay_wasm_file_template = "github.com/hugobyte/dive/services/bridges/ibc/static-files/config/archwayibc.json.tpl",
ibc_relay_java_file_template = "github.com/hugobyte/dive/services/bridges/ibc/static-files/config/icon.json.tpl",
icon_keystore_file = "github.com/hugobyte/dive/services/bridges/btp/static-files/keystores/keystore.json",
relay_keystore_path = "/root/.relayer/keys/"
)

NETWORK_PORT_KEYS_AND_IP_ADDRESS = struct(
Expand All @@ -69,12 +76,12 @@ NETWORK_PORT_KEYS_AND_IP_ADDRESS = struct(
)

ARCHAY_NODE0_CONFIG = struct(
chain_id = "archway-node-0",
chain_id = "constantine-3",
grpc = 9090,
http = 9091,
tcp = 26656,
rpc = 4564,
key = "archway-node-0-key",
key = "constantine-3-key",

)

Expand Down
19 changes: 17 additions & 2 deletions package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def get_args_data(args):
)

def generate_new_config_data(links, srcchain_service_name, dst_chain_service_name, bridge):
config_data = {
config_data = ""
if bridge == "":
config_data = {
"links": links,
"chains": {
"%s" % srcchain_service_name: {},
Expand All @@ -48,8 +50,21 @@ def generate_new_config_data(links, srcchain_service_name, dst_chain_service_nam
"%s" % srcchain_service_name: {},
"%s" % dst_chain_service_name: {},
},
}
else:

config_data = {
"links": links,
"chains": {
"%s" % srcchain_service_name: {},
"%s" % dst_chain_service_name: {},
},
"contracts": {
"%s" % srcchain_service_name: {},
"%s" % dst_chain_service_name: {},
},
"bridge": bridge,
}
}

return config_data

Expand Down
Loading