Skip to content

Commit

Permalink
fix: breaking change kurtosis update (#189)
Browse files Browse the repository at this point in the history
* fix: update kurtosis api params in dive cli

* fix: relative path in constants and upload file
  • Loading branch information
shreyasbhat0 authored Oct 4, 2023
1 parent 912dbed commit ce12af8
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 31 deletions.
8 changes: 4 additions & 4 deletions cli/commands/bridge/relays/btp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"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"
)
Expand Down Expand Up @@ -195,8 +194,8 @@ func BtpRelayCmd(diveContext *common.DiveContext) *cobra.Command {

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{})
starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeScript, bridgeMainFunction)
data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {
diveContext.FatalError("Starlark Run Failed", err.Error())
Expand All @@ -218,7 +217,8 @@ func runBtpSetupForAlreadyRunningNodes(diveContext *common.DiveContext, enclaveC

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{})
starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeScript, mainFunctionName)
data, _, err := enclaveCtx.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {
diveContext.FatalError("Starlark Run Failed", err.Error())
Expand Down
8 changes: 4 additions & 4 deletions cli/commands/bridge/relays/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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"
)
Expand Down Expand Up @@ -94,8 +93,8 @@ func startIbcRelay(diveContext *common.DiveContext, enclaveContext *enclaves.Enc

func startIbcRelayIconToCosmos(diveContext *common.DiveContext, enclaveContext *enclaves.EnclaveContext, serviceName string) (string, error) {
params := fmt.Sprintf(`{"service_name": "%s"}`, serviceName)

executionData, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, "services/bridges/ibc/src/bridge.star", "start_relay", params, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
starlarkConfig := diveContext.GetStarlarkRunConfig(params, "services/bridges/ibc/src/bridge.star", "start_relay")
executionData, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {
return "", err
Expand Down Expand Up @@ -139,7 +138,8 @@ func setupIbcRelayforAlreadyRunningCosmosChain(diveContext *common.DiveContext,
}

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{})
starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveBridgeScript, functionName)
executionData, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {
return "", err
Expand Down
11 changes: 6 additions & 5 deletions cli/commands/chain/types/archway.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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"
)
Expand Down Expand Up @@ -124,8 +123,8 @@ func RunArchwayNode(diveContext *common.DiveContext) *common.DiveserviceResponse
}

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{})
starlarkConfig := diveContext.GetStarlarkRunConfig(data, common.DiveArchwayNodeScript, constructServiceConfigFunctionName)
serviceExecutionResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {

Expand All @@ -140,8 +139,9 @@ func runArchwayWithCustomServiceConfig(diveContext *common.DiveContext, enclaveC

}
params := fmt.Sprintf(`{"args":%s}`, serviceExecutionResponseData)
starlarkConfig = diveContext.GetStarlarkRunConfig(params, common.DiveArchwayNodeScript, runArchwayNodeWithCustomServiceFunctionName)

nodeExecutionResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveArchwayNodeScript, runArchwayNodeWithCustomServiceFunctionName, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
nodeExecutionResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {

Expand All @@ -162,7 +162,8 @@ func runArchwayWithCustomServiceConfig(diveContext *common.DiveContext, enclaveC
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{})
starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveArchwayDefaultNodeScript, runArchwayNodeWithDefaultConfigFunctionName)
nodeServiceResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {

Expand Down
5 changes: 2 additions & 3 deletions cli/commands/chain/types/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strings"

"github.com/hugobyte/dive/cli/common"
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -45,8 +44,8 @@ func RunEthNode(diveContext *common.DiveContext) *common.DiveserviceResponse {
diveContext.FatalError("Failed To Retrive Enclave Context", err.Error())
}
diveContext.StartSpinner(" Starting ETH Node")

data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveEthHardhatNodeScript, "start_eth_node", `{"args":{}}`, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
starlarkConfig := diveContext.GetStarlarkRunConfig(`{"args":{}}`, common.DiveEthHardhatNodeScript, "start_eth_node")
data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {

Expand Down
4 changes: 2 additions & 2 deletions cli/commands/chain/types/hardhat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package types

import (
"github.com/hugobyte/dive/cli/common"
"github.com/kurtosis-tech/kurtosis/api/golang/core/kurtosis_core_rpc_api_bindings"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -43,7 +42,8 @@ func RunHardhatNode(diveContext *common.DiveContext) *common.DiveserviceResponse
diveContext.FatalError("Failed To Retrive Enclave Context", err.Error())
}
diveContext.StartSpinner(" Starting Hardhat Node")
data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveEthHardhatNodeScript, "start_hardhat_node", "{}", common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
starlarkConfig := diveContext.GetStarlarkRunConfig("{}", common.DiveEthHardhatNodeScript, "start_hardhat_node")
data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {
diveContext.FatalError("Starlark Run Failed", err.Error())
Expand Down
14 changes: 7 additions & 7 deletions cli/commands/chain/types/icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"path/filepath"

"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 DefaultIconGenesisFile = "github.com/hugobyte/dive/services/jvm/icon/static-files/config/genesis-icon-0.zip"
const DefaultIconGenesisFile = "../../static-files/config/genesis-icon-0.zip"

var (
genesis = ""
Expand Down Expand Up @@ -159,8 +158,8 @@ func RunIconNode(diveContext *common.DiveContext) *common.DiveserviceResponse {
if err != nil {
diveContext.FatalError("Failed To Retrive Enclave Context", err.Error())
}

data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveIconNodeScript, "get_service_config", paramData, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
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())
Expand All @@ -182,7 +181,8 @@ func RunIconNode(diveContext *common.DiveContext) *common.DiveserviceResponse {
diveContext.CheckInstructionSkipped(skippedInstructions, "Instruction Executed Already")

params := fmt.Sprintf(`{"service_config":%s,"uploaded_genesis":%s,"genesis_file_path":"%s","genesis_file_name":"%s"}`, responseData, genesisHandler.uploadedFiles, genesisHandler.genesisPath, genesisHandler.genesisFile)
icon_data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveIconNodeScript, "start_icon_node", params, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
starlarkConfig = diveContext.GetStarlarkRunConfig(params, common.DiveIconNodeScript, "start_icon_node")
icon_data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {

Expand Down Expand Up @@ -225,8 +225,8 @@ func Decentralisation(diveContext *common.DiveContext, params string) {
if err != nil {
diveContext.FatalError("Failed To Retrieve Enclave Context", err.Error())
}

data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveIconDecentraliseScript, "configure_node", params, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveIconDecentraliseScript, "configure_node")
data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)

if err != nil {
diveContext.FatalError("Starlark Run Failed", err.Error())
Expand Down
6 changes: 3 additions & 3 deletions cli/commands/chain/types/neutron.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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"
)
Expand All @@ -14,7 +13,7 @@ import (
const (
runNeutronNodeWithDefaultConfigFunctionName = "start_node_service"
runNeutronNodeWithCustomServiceFunctionName = "start_neutron_node"
construcNeutrontServiceConfigFunctionName = "get_service_config"
constructNeutronServiceConfigFunctionName = "get_service_config"
)

// Variable to store the Neutron node configuration file path
Expand Down Expand Up @@ -120,7 +119,8 @@ func RunNeutronNode(diveContext *common.DiveContext) *common.DiveserviceResponse
// RunNeutronWithServiceConfig runs the Neutron service with the provided configuration data.
func RunNeutronWithServiceConfig(diveContext *common.DiveContext, enclaveContext *enclaves.EnclaveContext, data string) (string, error) {
params := fmt.Sprintf(`{"args":{"data":%s}}`, data)
nodeServiceResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveNeutronDefaultNodeScript, runNeutronNodeWithDefaultConfigFunctionName, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
starlarkConfig := diveContext.GetStarlarkRunConfig(params, common.DiveNeutronDefaultNodeScript, runNeutronNodeWithDefaultConfigFunctionName)
nodeServiceResponse, _, err := enclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, starlarkConfig)
if err != nil {
return "", err
}
Expand Down
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.11-beta"
var DiveVersion = "v0.0.12-beta"

const (
DiveEnclave = "dive"
Expand Down
18 changes: 17 additions & 1 deletion cli/common/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/fatih/color"
"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/kurtosis-tech/kurtosis/api/golang/core/lib/starlark_run_config"
"github.com/kurtosis-tech/kurtosis/api/golang/engine/lib/kurtosis_context"

log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -206,7 +207,9 @@ func (diveContext *DiveContext) StopServices(services map[string]string) {

for serviceName, serviceUUID := range services {
params := fmt.Sprintf(`{"service_name": "%s", "uuid": "%s"}`, serviceName, serviceUUID)
_, err := enclaveContext.RunStarlarkScriptBlocking(diveContext.Ctx, "", starlarkScript, params, DiveDryRun, DiveDefaultParallelism, nil)
starlarkConfig := diveContext.GetStarlarkRunConfig(params, "", "")
_, err := enclaveContext.RunStarlarkScriptBlocking(diveContext.Ctx, starlarkScript, starlarkConfig)

if err != nil {
diveContext.Log.Fatal("Failed To Stop Services", err)
}
Expand All @@ -216,3 +219,16 @@ func (diveContext *DiveContext) StopServices(services map[string]string) {
}

}

func (diveContext *DiveContext) GetStarlarkRunConfig(params string, relativePathToMainFile string, mainFunctionName string) *starlark_run_config.StarlarkRunConfig {

starlarkConfig := &starlark_run_config.StarlarkRunConfig{
RelativePathToMainFile: relativePathToMainFile,
MainFunctionName: mainFunctionName,
DryRun: DiveDryRun,
SerializedParams: params,
Parallelism: DiveDefaultParallelism,
ExperimentalFeatureFlags: []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{},
}
return starlarkConfig
}
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.83.16
github.com/kurtosis-tech/kurtosis/api/golang v0.84.0
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

0 comments on commit ce12af8

Please sign in to comment.