diff --git a/cli/commands/bridge/bridge.go b/cli/commands/bridge/bridge.go index a2407644..f30e0740 100644 --- a/cli/commands/bridge/bridge.go +++ b/cli/commands/bridge/bridge.go @@ -4,72 +4,11 @@ Copyright © 2023 Hugobyte AI Labs package bridge import ( - "fmt" - "strconv" - "strings" - - "github.com/kurtosis-tech/kurtosis/api/golang/core/lib/enclaves" - - "github.com/hugobyte/dive/commands/chain/types" - "github.com/hugobyte/dive/common" - "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" + "github.com/hugobyte/dive/cli/commands/bridge/relyas" + "github.com/hugobyte/dive/cli/common" "github.com/spf13/cobra" ) -const bridgeMainFunction = "run_btp_setup" -const runbridgeicon2icon = "start_btp_for_already_running_icon_nodes" -const runbridgeicon2ethhardhat = "start_btp_icon_to_eth_for_already_running_nodes" - -var ( - chainA string - chainB string - serviceA string - serviceB string -) - -var runChain = map[string]func(diveContext *common.DiveContext) *common.DiveserviceResponse{ - "icon": func(diveContext *common.DiveContext) *common.DiveserviceResponse { - nodeResponse := types.RunIconNode(diveContext) - params := types.GetDecentralizeParms(nodeResponse.ServiceName, nodeResponse.PrivateEndpoint, nodeResponse.KeystorePath, nodeResponse.KeyPassword, nodeResponse.NetworkId) - - diveContext.SetSpinnerMessage("Starting Decentralisation") - types.Decentralisation(diveContext, params) - - return nodeResponse - - }, - "eth": func(diveContext *common.DiveContext) *common.DiveserviceResponse { - return types.RunEthNode(diveContext) - - }, - "hardhat": func(diveContext *common.DiveContext) *common.DiveserviceResponse { - - return types.RunHardhatNode(diveContext) - }, -} - -type Chains struct { - chainA string - chainB string - chainAServiceName string - chainBServiceName string - bridge string -} - -func initChains(chainA, chainB, serviceA, serviceB string, bridge bool) *Chains { - return &Chains{ - chainA: strings.ToLower(chainA), - chainB: strings.ToLower(chainB), - chainAServiceName: serviceA, - chainBServiceName: serviceB, - bridge: strconv.FormatBool(bridge), - } -} - -func (c *Chains) areChainsIcon() bool { - return (c.chainA == "icon" && c.chainB == "icon") -} - func NewBridgeCmd(diveContext *common.DiveContext) *cobra.Command { var bridgeCmd = &cobra.Command{ @@ -83,229 +22,9 @@ This will create an relay to connect two different chains and pass any messages }, } - bridgeCmd.AddCommand(btpBridgeCmd(diveContext)) - - return bridgeCmd -} - -func btpBridgeCmd(diveContext *common.DiveContext) *cobra.Command { - - var btpbridgeCmd = &cobra.Command{ - Use: "btp", - Short: "Starts BTP Bridge between ChainA and ChainB", - Long: ``, - Run: func(cmd *cobra.Command, args []string) { - common.ValidateCmdArgs(args, cmd.UsageString()) - - diveContext.InitKurtosisContext() - enclaveCtx, err := diveContext.GetEnclaveContext() - - if err != nil { - diveContext.Error(err.Error()) - } - - bridge, _ := cmd.Flags().GetBool("bmvbridge") // To Specify Which Type of BMV to be used in btp setup(if true BMV bridge is used else BMV-BTP Block is used) - - chains := initChains(chainA, chainB, serviceA, serviceB, bridge) - diveContext.StartSpinner(fmt.Sprintf(" Starting BTP Bridge for %s,%s", chains.chainA, chains.chainB)) - - if chains.areChainsIcon() { - - if chains.chainAServiceName != "" && chains.chainBServiceName != "" { - - srcChainServiceResponse, dstChainServiceResponse, err := chains.getServicesResponse() - - if err != nil { - diveContext.FatalError("Failed To read ServiceFile", err.Error()) - } - - runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2icon, chains.chainA, chains.chainB, chains.chainAServiceName, chains.chainBServiceName, bridge, srcChainServiceResponse, dstChainServiceResponse) - - } else { - - params := chains.getParams() - - runBtpSetupByRunningNodes(diveContext, enclaveCtx, params) - - } - - } else { - if chains.chainAServiceName != "" && chains.chainBServiceName != "" { - - srcChainServiceResponse, dstChainServiceResponse, err := chains.getServicesResponse() - - if err != nil { - diveContext.FatalError("failed to get service data", err.Error()) - } - - if chains.chainB == "icon" { - runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainB, chains.chainA, chains.chainBServiceName, chains.chainAServiceName, bridge, dstChainServiceResponse, srcChainServiceResponse) - } else { - - runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainA, chains.chainB, chains.chainAServiceName, chains.chainBServiceName, bridge, srcChainServiceResponse, dstChainServiceResponse) - - } - } else if (chains.chainAServiceName == "" && chains.chainBServiceName != "") || (chains.chainAServiceName != "" && chains.chainBServiceName == "") { - - var chainAServiceResponse string - var chainBServiceResponse string - var chainAServiceName string - var chainBServiceName string - - serviceConfig, err := common.ReadServiceJsonFile() - if err != nil { - diveContext.FatalError("failed to get service data", err.Error()) - } - - if chains.chainAServiceName == "" { - - chainBserviceresponse, OK := serviceConfig[chains.chainBServiceName] - if !OK { - diveContext.FatalError("failed to get service data", fmt.Sprint("service name not found:", chains.chainBServiceName)) - } - chainBServiceName = chainBserviceresponse.ServiceName - - chainBServiceResponse, err = chainBserviceresponse.EncodeToString() - - if err != nil { - diveContext.FatalError("failed to get service data", err.Error()) - } - - response := runChain[chains.chainA](diveContext) - chainAServiceName = response.ServiceName - chainAServiceResponse, err = response.EncodeToString() - if err != nil { - diveContext.FatalError("failed to get service data", err.Error()) - } - - } else if chains.chainBServiceName == "" { + bridgeCmd.AddCommand(relyas.BtpRelayCmd(diveContext)) - chainAserviceresponse, OK := serviceConfig[chains.chainAServiceName] - if !OK { - diveContext.FatalError("failed to get service data", fmt.Sprint("service name not found:", chains.chainAServiceName)) - } + bridgeCmd.AddCommand(relyas.IbcRelayCmd(diveContext)) - chainAServiceName = chainAserviceresponse.ServiceName - - chainAServiceResponse, err = chainAserviceresponse.EncodeToString() - - if err != nil { - diveContext.FatalError("failed to get service data", err.Error()) - } - - response := runChain[chains.chainB](diveContext) - chainBServiceName = response.ServiceName - chainBServiceResponse, err = response.EncodeToString() - if err != nil { - diveContext.FatalError("failed to get service data", err.Error()) - - } - } - if chains.chainB == "icon" { - runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainB, chains.chainA, chainBServiceName, chainAServiceName, bridge, chainBServiceResponse, chainAServiceResponse) - } else { - - runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainA, chains.chainB, chainAServiceName, chainBServiceName, bridge, chainAServiceResponse, chainBServiceResponse) - - } - - } else { - params := chains.getParams() - - runBtpSetupByRunningNodes(diveContext, enclaveCtx, params) - } - - } - - diveContext.StopSpinner(fmt.Sprintf("BTP Bridge Setup Completed between %s and %s. Please find service details in current working directory(dive.json)", chainA, chainB)) - }, - } - - btpbridgeCmd.Flags().StringVar(&chainA, "chainA", "", "Mention Name of Supported Chain") - btpbridgeCmd.Flags().StringVar(&chainB, "chainB", "", "Mention Name of Supported Chain") - btpbridgeCmd.Flags().BoolP("bmvbridge", "b", false, "To Specify Which Type of BMV to be used in btp setup(if true BMV bridge is used else BMV-BTP Block is used)") - - btpbridgeCmd.Flags().StringVar(&serviceA, "chainAServiceName", "", "Service Name of Chain A from services.json") - btpbridgeCmd.Flags().StringVar(&serviceB, "chainBServiceName", "", "Service Name of Chain B from services.json") - btpbridgeCmd.MarkFlagRequired("chainA") - btpbridgeCmd.MarkFlagRequired("chainB") - - return btpbridgeCmd -} - -func runBtpSetupByRunningNodes(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, params string) { - diveContext.SetSpinnerMessage(" Executing BTP Starlark Package") - - data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, bridgeMainFunction, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) - - if err != nil { - diveContext.FatalError("Starlark Run Failed", err.Error()) - } - response, services, skippedInstructions, err := diveContext.GetSerializedData(data) - if err != nil { - diveContext.StopServices(services) - diveContext.FatalError("Starlark Run Failed", err.Error()) - - } - diveContext.CheckInstructionSkipped(skippedInstructions, "Bridge Already Running") - common.WriteToFile(response) - -} - -func runBtpSetupForAlreadyRunningNodes(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, mainFunctionName string, srcChain string, dstChain string, srcChainServiceName string, dstChainServiceName string, bridge bool, srcChainServiceResponse string, dstChainServiceResponse string) { - - configData := fmt.Sprintf(`{"links": {"src":"%s","dst":"%s"},"chains" : { "%s" : %s,"%s" : %s},"contracts" : {"%s" : {},"%s" : {}},"bridge" : "%s"}`, srcChain, dstChain, srcChainServiceName, srcChainServiceResponse, dstChainServiceName, dstChainServiceResponse, srcChainServiceName, dstChainServiceName, strconv.FormatBool(bridge)) - - params := fmt.Sprintf(`{"src_chain":"%s", "dst_chain":"%s", "config_data":%s, "src_service_name":"%s", "dst_service_name":"%s"}`, srcChain, dstChain, configData, srcChainServiceName, dstChainServiceName) - - data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, mainFunctionName, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) - - if err != nil { - diveContext.FatalError("Starlark Run Failed", err.Error()) - } - response, services, skippedInstructions, err := diveContext.GetSerializedData(data) - if err != nil { - diveContext.StopServices(services) - diveContext.FatalError("Starlark Run Failed", err.Error()) - - } - - diveContext.CheckInstructionSkipped(skippedInstructions, "Bridge Already Running") - - common.WriteToFile(response) - -} - -func (chains *Chains) getParams() string { - return fmt.Sprintf(`{"args":{"links": {"src": "%s", "dst": "%s"},"bridge":"%s"}}`, chains.chainA, chains.chainB, chains.bridge) -} - -func (chains *Chains) getServicesResponse() (string, string, error) { - - serviceConfig, err := common.ReadServiceJsonFile() - - if err != nil { - return "", "", err - } - - chainAServiceResponse, OK := serviceConfig[chains.chainAServiceName] - if !OK { - return "", "", fmt.Errorf("service name not found") - } - chainBServiceResponse, OK := serviceConfig[chains.chainBServiceName] - if !OK { - return "", "", fmt.Errorf("service name not found") - } - - srcChainServiceResponse, err := chainAServiceResponse.EncodeToString() - if err != nil { - return "", "", err - } - dstChainServiceResponse, err := chainBServiceResponse.EncodeToString() - - if err != nil { - return "", "", err - } - - return srcChainServiceResponse, dstChainServiceResponse, nil + return bridgeCmd } diff --git a/cli/commands/bridge/relyas/btp.go b/cli/commands/bridge/relyas/btp.go new file mode 100644 index 00000000..6aa25245 --- /dev/null +++ b/cli/commands/bridge/relyas/btp.go @@ -0,0 +1,232 @@ +package relyas + +import ( + "fmt" + "strconv" + + "github.com/hugobyte/dive/cli/commands/chain/types" + "github.com/hugobyte/dive/cli/common" + "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" + "github.com/kurtosis-tech/kurtosis/api/golang/core/lib/enclaves" + "github.com/spf13/cobra" +) + +const bridgeMainFunction = "run_btp_setup" +const runbridgeicon2icon = "start_btp_for_already_running_icon_nodes" +const runbridgeicon2ethhardhat = "start_btp_icon_to_eth_for_already_running_nodes" + +var ( + chainA string + chainB string + serviceA string + serviceB string +) + +var runChain = map[string]func(diveContext *common.DiveContext) *common.DiveserviceResponse{ + "icon": func(diveContext *common.DiveContext) *common.DiveserviceResponse { + nodeResponse := types.RunIconNode(diveContext) + params := types.GetDecentralizeParms(nodeResponse.ServiceName, nodeResponse.PrivateEndpoint, nodeResponse.KeystorePath, nodeResponse.KeyPassword, nodeResponse.NetworkId) + + diveContext.SetSpinnerMessage("Starting Decentralisation") + types.Decentralisation(diveContext, params) + + return nodeResponse + + }, + "eth": func(diveContext *common.DiveContext) *common.DiveserviceResponse { + return types.RunEthNode(diveContext) + + }, + "hardhat": func(diveContext *common.DiveContext) *common.DiveserviceResponse { + + return types.RunHardhatNode(diveContext) + }, +} + +func BtpRelayCmd(diveContext *common.DiveContext) *cobra.Command { + + var btpbridgeCmd = &cobra.Command{ + Use: "btp", + Short: "Starts BTP Bridge between ChainA and ChainB", + Long: ``, + Run: func(cmd *cobra.Command, args []string) { + common.ValidateCmdArgs(args, cmd.UsageString()) + + diveContext.InitKurtosisContext() + enclaveCtx, err := diveContext.GetEnclaveContext() + + if err != nil { + diveContext.Error(err.Error()) + } + + bridge, _ := cmd.Flags().GetBool("bmvbridge") // To Specify Which Type of BMV to be used in btp setup(if true BMV bridge is used else BMV-BTP Block is used) + + chains := initChains(chainA, chainB, serviceA, serviceB, bridge) + diveContext.StartSpinner(fmt.Sprintf(" Starting BTP Bridge for %s,%s", chains.chainA, chains.chainB)) + + if chains.areChainsIcon() { + + if chains.chainAServiceName != "" && chains.chainBServiceName != "" { + + srcChainServiceResponse, dstChainServiceResponse, err := chains.getServicesResponse() + + if err != nil { + diveContext.FatalError("Failed To read ServiceFile", err.Error()) + } + + runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2icon, chains.chainA, chains.chainB, chains.chainAServiceName, chains.chainBServiceName, bridge, srcChainServiceResponse, dstChainServiceResponse) + + } else { + + params := chains.getParams() + + runBtpSetupByRunningNodes(diveContext, enclaveCtx, params) + + } + + } else { + if chains.chainAServiceName != "" && chains.chainBServiceName != "" { + + srcChainServiceResponse, dstChainServiceResponse, err := chains.getServicesResponse() + + if err != nil { + diveContext.FatalError("failed to get service data", err.Error()) + } + + if chains.chainB == "icon" { + runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainB, chains.chainA, chains.chainBServiceName, chains.chainAServiceName, bridge, dstChainServiceResponse, srcChainServiceResponse) + } else { + + runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainA, chains.chainB, chains.chainAServiceName, chains.chainBServiceName, bridge, srcChainServiceResponse, dstChainServiceResponse) + + } + } else if (chains.chainAServiceName == "" && chains.chainBServiceName != "") || (chains.chainAServiceName != "" && chains.chainBServiceName == "") { + + var chainAServiceResponse string + var chainBServiceResponse string + var chainAServiceName string + var chainBServiceName string + + serviceConfig, err := common.ReadServiceJsonFile() + if err != nil { + diveContext.FatalError("failed to get service data", err.Error()) + } + + if chains.chainAServiceName == "" { + + chainBserviceresponse, OK := serviceConfig[chains.chainBServiceName] + if !OK { + diveContext.FatalError("failed to get service data", fmt.Sprint("service name not found:", chains.chainBServiceName)) + } + chainBServiceName = chainBserviceresponse.ServiceName + + chainBServiceResponse, err = chainBserviceresponse.EncodeToString() + + if err != nil { + diveContext.FatalError("failed to get service data", err.Error()) + } + + response := runChain[chains.chainA](diveContext) + chainAServiceName = response.ServiceName + chainAServiceResponse, err = response.EncodeToString() + if err != nil { + diveContext.FatalError("failed to get service data", err.Error()) + } + + } else if chains.chainBServiceName == "" { + + chainAserviceresponse, OK := serviceConfig[chains.chainAServiceName] + if !OK { + diveContext.FatalError("failed to get service data", fmt.Sprint("service name not found:", chains.chainAServiceName)) + } + + chainAServiceName = chainAserviceresponse.ServiceName + + chainAServiceResponse, err = chainAserviceresponse.EncodeToString() + + if err != nil { + diveContext.FatalError("failed to get service data", err.Error()) + } + + response := runChain[chains.chainB](diveContext) + chainBServiceName = response.ServiceName + chainBServiceResponse, err = response.EncodeToString() + if err != nil { + diveContext.FatalError("failed to get service data", err.Error()) + + } + } + if chains.chainB == "icon" { + runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainB, chains.chainA, chainBServiceName, chainAServiceName, bridge, chainBServiceResponse, chainAServiceResponse) + } else { + + runBtpSetupForAlreadyRunningNodes(diveContext, enclaveCtx, runbridgeicon2ethhardhat, chains.chainA, chains.chainB, chainAServiceName, chainBServiceName, bridge, chainAServiceResponse, chainBServiceResponse) + + } + + } else { + params := chains.getParams() + + runBtpSetupByRunningNodes(diveContext, enclaveCtx, params) + } + + } + + diveContext.StopSpinner(fmt.Sprintf("BTP Bridge Setup Completed between %s and %s. Please find service details in current working directory(dive.json)", chainA, chainB)) + }, + } + + btpbridgeCmd.Flags().StringVar(&chainA, "chainA", "", "Mention Name of Supported Chain") + btpbridgeCmd.Flags().StringVar(&chainB, "chainB", "", "Mention Name of Supported Chain") + btpbridgeCmd.Flags().BoolP("bmvbridge", "b", false, "To Specify Which Type of BMV to be used in btp setup(if true BMV bridge is used else BMV-BTP Block is used)") + + btpbridgeCmd.Flags().StringVar(&serviceA, "chainAServiceName", "", "Service Name of Chain A from services.json") + btpbridgeCmd.Flags().StringVar(&serviceB, "chainBServiceName", "", "Service Name of Chain B from services.json") + btpbridgeCmd.MarkFlagRequired("chainA") + btpbridgeCmd.MarkFlagRequired("chainB") + + return btpbridgeCmd +} + +func runBtpSetupByRunningNodes(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, params string) { + diveContext.SetSpinnerMessage(" Executing BTP Starlark Package") + + data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, bridgeMainFunction, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) + + if err != nil { + diveContext.FatalError("Starlark Run Failed", err.Error()) + } + response, services, skippedInstructions, err := diveContext.GetSerializedData(data) + if err != nil { + diveContext.StopServices(services) + diveContext.FatalError("Starlark Run Failed", err.Error()) + + } + diveContext.CheckInstructionSkipped(skippedInstructions, "Bridge Already Running") + common.WriteToFile(response) + +} + +func runBtpSetupForAlreadyRunningNodes(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, mainFunctionName string, srcChain string, dstChain string, srcChainServiceName string, dstChainServiceName string, bridge bool, srcChainServiceResponse string, dstChainServiceResponse string) { + + configData := fmt.Sprintf(`{"links": {"src":"%s","dst":"%s"},"chains" : { "%s" : %s,"%s" : %s},"contracts" : {"%s" : {},"%s" : {}},"bridge" : "%s"}`, srcChain, dstChain, srcChainServiceName, srcChainServiceResponse, dstChainServiceName, dstChainServiceResponse, srcChainServiceName, dstChainServiceName, strconv.FormatBool(bridge)) + + params := fmt.Sprintf(`{"src_chain":"%s", "dst_chain":"%s", "config_data":%s, "src_service_name":"%s", "dst_service_name":"%s"}`, srcChain, dstChain, configData, srcChainServiceName, dstChainServiceName) + + data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, mainFunctionName, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) + + if err != nil { + diveContext.FatalError("Starlark Run Failed", err.Error()) + } + response, services, skippedInstructions, err := diveContext.GetSerializedData(data) + if err != nil { + diveContext.StopServices(services) + diveContext.FatalError("Starlark Run Failed", err.Error()) + + } + + diveContext.CheckInstructionSkipped(skippedInstructions, "Bridge Already Running") + + common.WriteToFile(response) + +} diff --git a/cli/commands/bridge/relyas/common.go b/cli/commands/bridge/relyas/common.go new file mode 100644 index 00000000..2c5adfbf --- /dev/null +++ b/cli/commands/bridge/relyas/common.go @@ -0,0 +1,69 @@ +package relyas + +import ( + "fmt" + "strconv" + "strings" + + "github.com/hugobyte/dive/cli/common" +) + +type Chains struct { + chainA string + chainB string + chainAServiceName string + chainBServiceName string + bridge string +} + +func initChains(chainA, chainB, serviceA, serviceB string, bridge bool) *Chains { + return &Chains{ + chainA: strings.ToLower(chainA), + chainB: strings.ToLower(chainB), + chainAServiceName: serviceA, + chainBServiceName: serviceB, + bridge: strconv.FormatBool(bridge), + } +} + +func (c *Chains) areChainsIcon() bool { + return (c.chainA == "icon" && c.chainB == "icon") +} + +func (chains *Chains) getParams() string { + return fmt.Sprintf(`{"args":{"links": {"src": "%s", "dst": "%s"},"bridge":"%s"}}`, chains.chainA, chains.chainB, chains.bridge) +} +func (chains *Chains) getIbcRelayParams() string { + + return fmt.Sprintf(`{"args":{"links": {"src": "%s", "dst": "%s"}}}`, chains.chainA, chains.chainB) +} + +func (chains *Chains) getServicesResponse() (string, string, error) { + + serviceConfig, err := common.ReadServiceJsonFile() + + if err != nil { + return "", "", err + } + + chainAServiceResponse, OK := serviceConfig[chains.chainAServiceName] + if !OK { + return "", "", fmt.Errorf("service name not found") + } + chainBServiceResponse, OK := serviceConfig[chains.chainBServiceName] + if !OK { + return "", "", fmt.Errorf("service name not found") + } + + srcChainServiceResponse, err := chainAServiceResponse.EncodeToString() + if err != nil { + return "", "", err + } + dstChainServiceResponse, err := chainBServiceResponse.EncodeToString() + + if err != nil { + return "", "", err + } + + return srcChainServiceResponse, dstChainServiceResponse, nil +} diff --git a/cli/commands/bridge/relyas/ibc.go b/cli/commands/bridge/relyas/ibc.go new file mode 100644 index 00000000..e753c723 --- /dev/null +++ b/cli/commands/bridge/relyas/ibc.go @@ -0,0 +1,124 @@ +package relyas + +import ( + "fmt" + + "github.com/hugobyte/dive/cli/common" + "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" + "github.com/kurtosis-tech/kurtosis/api/golang/core/lib/enclaves" + "github.com/spf13/cobra" +) + +func IbcRelayCmd(diveContext *common.DiveContext) *cobra.Command { + + ibcRelayCommand := &cobra.Command{ + Use: "ibc", + Short: "Start connection between Cosmos based chainA and ChainB and initiate communication between them", + Long: "", + Run: func(cmd *cobra.Command, args []string) { + diveContext.InitKurtosisContext() + + enclaveCtx, err := diveContext.GetEnclaveContext() + + if err != nil { + diveContext.Error(err.Error()) + } + + result := stratIbcRelay(diveContext, enclaveCtx) + + err = common.WriteToFile(result) + + if err != nil { + diveContext.Error(err.Error()) + } + + diveContext.StopSpinner(fmt.Sprintf("IBC Setup Completed between %s and %s. Please find service details in current working directory(dive.json)", chainA, chainB)) + }, + } + + ibcRelayCommand.Flags().StringVar(&chainA, "chainA", "", "Mention Name of Supported Chain") + ibcRelayCommand.Flags().StringVar(&chainB, "chainB", "", "Mention Name of Supported Chain") + + ibcRelayCommand.Flags().StringVar(&serviceA, "chainAServiceName", "", "Service Name of Chain A from services.json") + ibcRelayCommand.Flags().StringVar(&serviceB, "chainBServiceName", "", "Service Name of Chain B from services.json") + ibcRelayCommand.MarkFlagRequired("chainA") + ibcRelayCommand.MarkFlagRequired("chainB") + + return ibcRelayCommand +} + +func stratIbcRelay(diveContext *common.DiveContext, enclaveContext *enclaves.EnclaveContext) string { + diveContext.StartSpinner(" Starting IBC Setup") + chains := initChains(chainA, chainB, serviceA, serviceB, false) + var starlarkExecutionResponse string + var err error + + if chains.chainAServiceName != "" && chains.chainBServiceName != "" { + + srcChainServiceResponse, dstChainServiceResponse, err := chains.getServicesResponse() + + if err != nil { + diveContext.FatalError("Failed To read ServiceFile", err.Error()) + } + starlarkExecutionResponse, err = setupIbcRelayforAlreadyRunningCosmosChain(diveContext, enclaveContext, chains.chainA, chains.chainB, srcChainServiceResponse, dstChainServiceResponse) + + if err != nil { + diveContext.FatalError("Starlark Run Failed", err.Error()) + } + + } else { + starlarkExecutionResponse, err = startCosmosChainsAndSetupIbcRelay(diveContext, enclaveContext, chains) + + if err != nil { + diveContext.FatalError("Starlark Run Failed", err.Error()) + } + + } + return starlarkExecutionResponse +} + +func startCosmosChainsAndSetupIbcRelay(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, chains *Chains) (string, error) { + + params := chains.getIbcRelayParams() + + executionResult, err := runStarlarkPackage(diveContext, enclaveCtx, params, "run_cosmos_ibc_setup") + + if err != nil { + return "", err + } + + return executionResult, nil +} + +func setupIbcRelayforAlreadyRunningCosmosChain(diveContext *common.DiveContext, enclaveCtx *enclaves.EnclaveContext, chainA, chainB, chainAServiceResponse, chainBServiceResponse string) (string, error) { + + params := fmt.Sprintf(`{"links":{"src":"%s","dst":"%s"},"src_config":%s,"dst_config":%s}`, chainA, chainB, chainAServiceResponse, chainBServiceResponse) + + executionResult, err := runStarlarkPackage(diveContext, enclaveCtx, params, "run_cosmos_ibc_relay_for_already_running_chains") + + if err != nil { + return "", err + } + + return executionResult, nil +} + +func runStarlarkPackage(diveContext *common.DiveContext, enclaveContext *enclaves.EnclaveContext, params, functionName string) (string, error) { + executionData, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, functionName, params, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) + + if err != nil { + return "", err + } + + executionSerializedData, services, skippedInstructions, err := diveContext.GetSerializedData(executionData) + + if err != nil { + diveContext.StopServices(services) + return "", err + + } + + diveContext.CheckInstructionSkipped(skippedInstructions, "Instruction Executed Already") + + return executionSerializedData, nil +} diff --git a/cli/commands/chain/chains.go b/cli/commands/chain/chains.go index 3b42a638..123a2794 100644 --- a/cli/commands/chain/chains.go +++ b/cli/commands/chain/chains.go @@ -4,8 +4,8 @@ Copyright © 2023 Hugobyte AI Labs package chain import ( - "github.com/hugobyte/dive/commands/chain/types" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/commands/chain/types" + "github.com/hugobyte/dive/cli/common" "github.com/spf13/cobra" ) @@ -29,7 +29,7 @@ maintenance within the specified blockchain ecosystem.`, chainCmd.AddCommand(types.NewIconCmd(diveContext)) chainCmd.AddCommand(types.NewEthCmd(diveContext)) chainCmd.AddCommand(types.NewHardhatCmd(diveContext)) - chainCmd.AddCommand(types.NewCosmosCmd(diveContext)) + chainCmd.AddCommand(types.NewArchwayCmd(diveContext)) return chainCmd diff --git a/cli/commands/chain/types/archway.go b/cli/commands/chain/types/archway.go new file mode 100644 index 00000000..f9d37840 --- /dev/null +++ b/cli/commands/chain/types/archway.go @@ -0,0 +1,181 @@ +package types + +import ( + "encoding/json" + "fmt" + + "github.com/hugobyte/dive/cli/common" + "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" + "github.com/kurtosis-tech/kurtosis/api/golang/core/lib/enclaves" + "github.com/spf13/cobra" +) + +const ( + constructServiceConfigFunctionName = "get_service_config" + runArchwayNodeWithCustomServiceFunctionName = "start_cosmos_node" + runArchwayNodeWithDefaultConfigFunctionName = "start_node_service" +) + +var ( + config string +) + +type ArchwayServiceConfig struct { + Cid string `json:"cid"` + Key string `json:"key"` + PrivateGrpcPort int `json:"private_grpc"` + PrivateHttpPort int `json:"private_http"` + PrivateTcpPort int `json:"private_tcp"` + PrivateRpcPort int `json:"private_rpc"` + PublicGrpcPort int `json:"public_grpc"` + PublicHttpPort int `json:"public_http"` + PublicTcpPort int `json:"public_tcp"` + PublicRpcPort int `json:"public_rpc"` + Password string `json:"password"` +} + +func (as *ArchwayServiceConfig) EncodeToString() (string, error) { + + data, err := json.Marshal(as) + if err != nil { + return "", err + } + + return string(data), nil +} +func (as *ArchwayServiceConfig) ReadServiceConfig(path string) error { + configData, err := common.ReadConfigFile(config) + if err != nil { + return err + } + + err = json.Unmarshal(configData, as) + + if err != nil { + return err + } + return nil +} + +func NewArchwayCmd(diveContext *common.DiveContext) *cobra.Command { + + archwayCmd := &cobra.Command{ + Use: "archway", + Short: "Build, initialize and start a archway node", + Long: "The command starts the archway network and allows node in executing contracts", + Run: func(cmd *cobra.Command, args []string) { + + runResponse := RunArchwayNode(diveContext) + + common.WriteToServiceFile(runResponse.ServiceName, *runResponse) + + diveContext.StopSpinner("Archyway Node Started. Please find service details in current working directory(services.json)") + }, + } + archwayCmd.Flags().StringVarP(&config, "config", "c", "", "provide config to start archway node ") + + return archwayCmd +} + +func RunArchwayNode(diveContext *common.DiveContext) *common.DiveserviceResponse { + diveContext.InitKurtosisContext() + kurtosisEnclaveContext, err := diveContext.GetEnclaveContext() + + if err != nil { + diveContext.FatalError("Failed To Retrive Enclave Context", err.Error()) + } + + diveContext.StartSpinner(" Starting Archway Node") + var serviceConfig = &ArchwayServiceConfig{} + var archwayResponse = &common.DiveserviceResponse{} + var starlarkExecutionData = "" + + if config != "" { + + err := serviceConfig.ReadServiceConfig(config) + + if err != nil { + diveContext.FatalError("Failed read service config", err.Error()) + } + encodedServiceConfigDataString, err := serviceConfig.EncodeToString() + + if err != nil { + diveContext.FatalError("Failed encode service config", err.Error()) + } + + starlarkExecutionData, err = runArchwayWithCustomServiceConfig(diveContext, kurtosisEnclaveContext, encodedServiceConfigDataString) + if err != nil { + diveContext.FatalError("Starlark Run Failed", err.Error()) + } + + } else { + starlarkExecutionData, err = runArchwayWithDefaultServiceConfig(diveContext, kurtosisEnclaveContext) + if err != nil { + diveContext.FatalError("Starlark Run Failed", err.Error()) + } + } + + err = json.Unmarshal([]byte(starlarkExecutionData), archwayResponse) + if err != nil { + diveContext.FatalError("Failed to Unmarshall Service Response", err.Error()) + } + + return archwayResponse +} + +func runArchwayWithCustomServiceConfig(diveContext *common.DiveContext, enclaveContext *enclaves.EnclaveContext, data string) (string, error) { + + serviceExecutionResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveArchwayNodeScript, constructServiceConfigFunctionName, data, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) + + if err != nil { + + return "", err + + } + + serviceExecutionResponseData, _, _, err := diveContext.GetSerializedData(serviceExecutionResponse) + if err != nil { + + return "", err + + } + params := fmt.Sprintf(`{"args":%s}`, serviceExecutionResponseData) + + nodeExecutionResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveArchwayNodeScript, runArchwayNodeWithCustomServiceFunctionName, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) + + if err != nil { + + return "", err + + } + + nodeExecutionResponseData, _, _, err := diveContext.GetSerializedData(nodeExecutionResponse) + if err != nil { + + return "", err + + } + + return nodeExecutionResponseData, nil +} + +func runArchwayWithDefaultServiceConfig(diveContext *common.DiveContext, enclaveContext *enclaves.EnclaveContext) (string, error) { + + params := `{"args":{"data":{}}}` + nodeServiceResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveArchwayDefaultNodeScript, runArchwayNodeWithDefaultConfigFunctionName, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{}) + + if err != nil { + + return "", err + + } + + nodeServiceResponseData, _, _, err := diveContext.GetSerializedData(nodeServiceResponse) + if err != nil { + + return "", err + + } + + return nodeServiceResponseData, nil +} diff --git a/cli/commands/chain/types/cosmos.go b/cli/commands/chain/types/cosmos.go deleted file mode 100644 index 07dccd78..00000000 --- a/cli/commands/chain/types/cosmos.go +++ /dev/null @@ -1,23 +0,0 @@ -package types - -import ( - "github.com/hugobyte/dive/common" - "github.com/spf13/cobra" -) - -func NewCosmosCmd(diveContext *common.DiveContext) *cobra.Command { - - cosmosCmd := &cobra.Command{ - Use: "cosmos", - Short: "Build, initialize and start a cosmos node.", - Long: `The command starts an Cosmos node, initiating the process of setting up and launching a local cosmos network. -It establishes a connection to the Cosmos network and allows the node in executing smart contracts and maintaining the decentralized ledger.`, - Run: func(cmd *cobra.Command, args []string) { - - }, - } - - return cosmosCmd -} - -func RunCosmosNode() {} diff --git a/cli/commands/chain/types/eth.go b/cli/commands/chain/types/eth.go index 59007d5d..962953a8 100644 --- a/cli/commands/chain/types/eth.go +++ b/cli/commands/chain/types/eth.go @@ -4,7 +4,7 @@ import ( "os" "strings" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" "github.com/spf13/cobra" ) diff --git a/cli/commands/chain/types/hardhat.go b/cli/commands/chain/types/hardhat.go index 56f46b3b..66492d3a 100644 --- a/cli/commands/chain/types/hardhat.go +++ b/cli/commands/chain/types/hardhat.go @@ -1,7 +1,7 @@ package types import ( - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" "github.com/spf13/cobra" ) diff --git a/cli/commands/chain/types/icon.go b/cli/commands/chain/types/icon.go index 25f9e360..75f900f9 100644 --- a/cli/commands/chain/types/icon.go +++ b/cli/commands/chain/types/icon.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings" "github.com/kurtosis-tech/kurtosis/api/golang/core/lib/enclaves" "github.com/spf13/cobra" diff --git a/cli/commands/clean/clean.go b/cli/commands/clean/clean.go index 8644fe36..2f2c0a64 100644 --- a/cli/commands/clean/clean.go +++ b/cli/commands/clean/clean.go @@ -7,7 +7,7 @@ import ( "fmt" "os" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/spf13/cobra" ) diff --git a/cli/commands/discord/discord.go b/cli/commands/discord/discord.go index 2912d4ec..e9698d4f 100644 --- a/cli/commands/discord/discord.go +++ b/cli/commands/discord/discord.go @@ -6,7 +6,7 @@ package discord import ( "os" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/spf13/cobra" ) diff --git a/cli/commands/root.go b/cli/commands/root.go index 9386be61..c740bc8f 100644 --- a/cli/commands/root.go +++ b/cli/commands/root.go @@ -6,16 +6,16 @@ package commands import ( "os" - "github.com/hugobyte/dive/commands/bridge" - "github.com/hugobyte/dive/commands/chain" - "github.com/hugobyte/dive/commands/clean" - "github.com/hugobyte/dive/commands/discord" - "github.com/hugobyte/dive/commands/tutorial" - "github.com/hugobyte/dive/commands/twitter" - "github.com/hugobyte/dive/commands/version" - "github.com/hugobyte/dive/common" - - "github.com/hugobyte/dive/styles" + "github.com/hugobyte/dive/cli/commands/bridge" + "github.com/hugobyte/dive/cli/commands/chain" + "github.com/hugobyte/dive/cli/commands/clean" + "github.com/hugobyte/dive/cli/commands/discord" + "github.com/hugobyte/dive/cli/commands/tutorial" + "github.com/hugobyte/dive/cli/commands/twitter" + "github.com/hugobyte/dive/cli/commands/version" + "github.com/hugobyte/dive/cli/common" + + "github.com/hugobyte/dive/cli/styles" "github.com/spf13/cobra" ) diff --git a/cli/commands/tutorial/tutorial.go b/cli/commands/tutorial/tutorial.go index 7585d477..f2d710f7 100644 --- a/cli/commands/tutorial/tutorial.go +++ b/cli/commands/tutorial/tutorial.go @@ -6,7 +6,7 @@ package tutorial import ( "os" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/spf13/cobra" ) diff --git a/cli/commands/twitter/twitter.go b/cli/commands/twitter/twitter.go index 822e7016..43e0e1a1 100644 --- a/cli/commands/twitter/twitter.go +++ b/cli/commands/twitter/twitter.go @@ -6,7 +6,7 @@ package twitter import ( "os" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/spf13/cobra" ) diff --git a/cli/commands/version/version.go b/cli/commands/version/version.go index 5a0b7092..974d0d0c 100644 --- a/cli/commands/version/version.go +++ b/cli/commands/version/version.go @@ -8,7 +8,7 @@ import ( "os" "github.com/fatih/color" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/spf13/cobra" ) diff --git a/cli/common/constants.go b/cli/common/constants.go index f7f341f7..6c2d0b9f 100644 --- a/cli/common/constants.go +++ b/cli/common/constants.go @@ -11,6 +11,8 @@ const ( DiveIconNodeScript = "services/jvm/icon/src/node-setup/start_icon_node.star" DiveIconDecentraliseScript = "services/jvm/icon/src/node-setup/setup_icon_node.star" DiveEthHardhatNodeScript = "services/evm/eth/src/node-setup/start-eth-node.star" + DiveArchwayNodeScript = "services/cosmvm/archway/src/node-setup/start_node.star" + DiveArchwayDefaultNodeScript = "services/cosmvm/archway/archway.star" DiveBridgeScript = "main.star" DiveDryRun = false DiveDefaultParallelism = 4 diff --git a/cli/common/types.go b/cli/common/types.go index eebafa5c..b906345c 100644 --- a/cli/common/types.go +++ b/cli/common/types.go @@ -19,14 +19,16 @@ import ( ) type DiveserviceResponse struct { - ServiceName string `json:"service_name"` - PublicEndpoint string `json:"endpoint_public"` - PrivateEndpoint string `json:"endpoint"` - KeyPassword string `json:"keypassword"` - KeystorePath string `json:"keystore_path"` - Network string `json:"network"` - NetworkName string `json:"network_name"` - NetworkId string `json:"nid"` + ServiceName string `json:"service_name,omitempty"` + PublicEndpoint string `json:"endpoint_public,omitempty"` + PrivateEndpoint string `json:"endpoint,omitempty"` + KeyPassword string `json:"keypassword,omitempty"` + KeystorePath string `json:"keystore_path,omitempty"` + Network string `json:"network,omitempty"` + NetworkName string `json:"network_name,omitempty"` + NetworkId string `json:"nid,omitempty"` + ChainId string `json:"chain_id,omitempty"` + ChainKey string `json:"chain_key,omitempty"` } func (dive *DiveserviceResponse) Decode(responseData []byte) (*DiveserviceResponse, error) { @@ -255,7 +257,7 @@ func ReadServiceJsonFile() (Services, error) { return nil, err } serviceFile := fmt.Sprintf("%s/%s", pwd, ServiceFilePath) - + jsonFile, _ := os.ReadFile(serviceFile) if len(jsonFile) == 0 { diff --git a/cli/go.mod b/cli/go.mod index 9a18012f..5f777aab 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -1,12 +1,12 @@ -module github.com/hugobyte/dive +module github.com/hugobyte/dive/cli -go 1.20 +go 1.21 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.81.5 + github.com/kurtosis-tech/kurtosis/api/golang v0.81.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 diff --git a/cli/go.sum b/cli/go.sum index de5068fc..425e461e 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -28,6 +28,7 @@ github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -43,7 +44,9 @@ github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgo github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kurtosis-tech/kurtosis-portal/api/golang v0.0.0-20230712110324-ce92904bb514 h1:FBM2wGL9BTzj+qVs+Jd8l1mYAGd2uaKJdL7Ccei2DGU= github.com/kurtosis-tech/kurtosis-portal/api/golang v0.0.0-20230712110324-ce92904bb514/go.mod h1:pHSIQlUtd+zPdILuvu3uCydjypzJk/wLex9bePmuqWA= github.com/kurtosis-tech/kurtosis/api/golang v0.81.5 h1:CKGQS0snOui/+cud7fx13b7Cu0zrZ7yO4Xzc8NH4V3c= @@ -73,6 +76,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo= github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -122,9 +126,11 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/cli/main.go b/cli/main.go index 849ba1e3..9ae545e9 100644 --- a/cli/main.go +++ b/cli/main.go @@ -4,7 +4,7 @@ Copyright © 2023 Hugobyte AI Labs package main import ( - "github.com/hugobyte/dive/commands" + "github.com/hugobyte/dive/cli/commands" ) func main() { diff --git a/test/functional/dive_test.go b/test/functional/dive_test.go index 00eb525e..4eda5970 100644 --- a/test/functional/dive_test.go +++ b/test/functional/dive_test.go @@ -8,7 +8,7 @@ import ( "path/filepath" "testing" - "github.com/hugobyte/dive/common" + "github.com/hugobyte/dive/cli/common" "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" )