Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ tsconfig.tsbuildinfo
# Generated files
.docusaurus
.cache-loader

dist/
45 changes: 45 additions & 0 deletions cli/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
21 changes: 12 additions & 9 deletions cli/commands/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import (

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

const bridgeMainFunction = "run_btp_setup"

var (
chainA string
chainB string
Expand All @@ -38,14 +41,14 @@ func btpBridgeCmd(diveContext *common.DiveContext) *cobra.Command {

var btpbridgeCmd = &cobra.Command{
Use: "btp",
Short: "",
Long: `.`,
Short: "Starts Bridge BTP between ChainA and Chain B",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {

enclaveCtx, err := diveContext.GetEnclaveContext()
if err != nil {
panic(err)

if err != nil {
logrus.Errorln(err)
}

bridge, _ := cmd.Flags().GetBool("bridge")
Expand All @@ -54,7 +57,7 @@ func btpBridgeCmd(diveContext *common.DiveContext) *cobra.Command {

if strings.ToLower(chainA) == "icon" && strings.ToLower(chainB) == "icon" {

data, _, err := enclaveCtx.RunStarlarkPackage(diveContext.Ctx, "../", "main.star", "run_btp_setup", params, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
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 {
fmt.Println(err)
Expand All @@ -63,7 +66,7 @@ func btpBridgeCmd(diveContext *common.DiveContext) *cobra.Command {

common.WriteToFile(response)
} else {
data, _, err := enclaveCtx.RunStarlarkPackage(diveContext.Ctx, "../", "main.star", "run_btp_setup", params, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
data, _, err := enclaveCtx.RunStarlarkPackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveBridgeScript, bridgeMainFunction, params, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})

if err != nil {
fmt.Println(err)
Expand All @@ -75,9 +78,9 @@ func btpBridgeCmd(diveContext *common.DiveContext) *cobra.Command {
},
}

btpbridgeCmd.Flags().StringVar(&chainA, "chainA", "", "specify chain A")
btpbridgeCmd.Flags().StringVar(&chainB, "chainB", "", "specify chain B")
btpbridgeCmd.Flags().Bool("bridge", false, "sepcify bridge falg")
btpbridgeCmd.Flags().StringVar(&chainA, "chainA", "", "Metion Name of Supported Chain")
btpbridgeCmd.Flags().StringVar(&chainB, "chainB", "", "Metion Name of Supported Chain")
btpbridgeCmd.Flags().Bool("bridge", false, "Mention Bridge ENV")

btpbridgeCmd.MarkFlagRequired("chainA")
btpbridgeCmd.MarkFlagRequired("chainB")
Expand Down
16 changes: 5 additions & 11 deletions cli/commands/chain/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,17 @@ func NewChainCmd(diveContext *common.DiveContext) *cobra.Command {
Use: "chain",
Short: "Build, initialize and start a given blockchain node.",
Long: `The command builds, initializes, and starts a specified blockchain node, providing a seamless setup process. It encompasses compiling and configuring the
necessary dependencies and components required for the blockchain network. By executing this command, the node is launched, enabling network participation, transaction
processing, and ledger maintenance within the specified blockchain ecosystem.`,
necessary dependencies and components required for the blockchain network. By executing this command, the node is launched, enabling network participation, transaction
processing, and ledger maintenance within the specified blockchain ecosystem.`,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()

},
}

enclaveCtx, err := diveContext.GetEnclaveContext()
if err != nil {
panic(err)

}

chainCmd.AddCommand(types.NewIconCmd(diveContext.Ctx, enclaveCtx))
chainCmd.AddCommand(types.NewEthCmd(diveContext.Ctx, enclaveCtx))
chainCmd.AddCommand(types.NewHardhatCmd(diveContext.Ctx, enclaveCtx))
chainCmd.AddCommand(types.NewIconCmd(diveContext))
chainCmd.AddCommand(types.NewEthCmd(diveContext))
chainCmd.AddCommand(types.NewHardhatCmd(diveContext))

return chainCmd

Expand Down
29 changes: 18 additions & 11 deletions cli/commands/chain/types/eth.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package types

import (
"context"
"fmt"

"github.com/hugobyte/dive/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 NewEthCmd(ctx context.Context, kurtosisEnclaveContext *enclaves.EnclaveContext) *cobra.Command {
func NewEthCmd(diveContext *common.DiveContext) *cobra.Command {

var ethCmd = &cobra.Command{
Use: "eth",
Expand All @@ -19,20 +15,31 @@ func NewEthCmd(ctx context.Context, kurtosisEnclaveContext *enclaves.EnclaveCont
network and allows the node in executing smart contracts and maintaining the decentralized ledger.`,
Run: func(cmd *cobra.Command, args []string) {

fmt.Println(RunEthNode(ctx, kurtosisEnclaveContext).EncodeToString())
data, err := RunEthNode(diveContext)

if err != nil {
diveContext.FatalError("Fail to Start ETH Node", err.Error())
}
data.WriteDiveResponse(diveContext)
},
}

return ethCmd

}

func RunEthNode(ctx context.Context, kurtosisEnclaveContext *enclaves.EnclaveContext) *common.DiveserviceResponse {
func RunEthNode(diveContext *common.DiveContext) (*common.DiveserviceResponse, error) {

kurtosisEnclaveContext, err := diveContext.GetEnclaveContext()

if err != nil {
return nil, err
}

data, _, err := kurtosisEnclaveContext.RunStarlarkPackage(ctx, "../", "services/evm/eth/eth.star", "start_eth_node_serivce", `{"args":{},"node_type":"eth"}`, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveEthHardhatNodeScript, "start_eth_node", `{"args":{}}`, common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})

if err != nil {
fmt.Println(err)
return nil, err
}

responseData := common.GetSerializedData(data)
Expand All @@ -42,9 +49,9 @@ func RunEthNode(ctx context.Context, kurtosisEnclaveContext *enclaves.EnclaveCon
result, err := ethResponseData.Decode([]byte(responseData))

if err != nil {
fmt.Println(err)
return nil, err
}

return result
return result, nil

}
36 changes: 22 additions & 14 deletions cli/commands/chain/types/hardhat.go
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
package types

import (
"context"
"fmt"

"github.com/hugobyte/dive/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 NewHardhatCmd(ctx context.Context, kurtosisEnclaveContext *enclaves.EnclaveContext) *cobra.Command {
func NewHardhatCmd(diveContext *common.DiveContext) *cobra.Command {

var ethCmd = &cobra.Command{
Use: "hardhat",
Short: "Build, initialize and start a hardhat node.",
Long: `The command starts an hardhat node, initiating the process of setting up and launching a local hardhat network. It establishes a connection to the hardhat
Long: `The command starts an hardhat node, initiating the process of setting up and launching a local hardhat network. It establishes a connection to the hardhat
network and allows the node in executing smart contracts and maintaining the decentralized ledger.`,
Run: func(cmd *cobra.Command, args []string) {

fmt.Println(RunHardhatNode(ctx, kurtosisEnclaveContext).EncodeToString())
data, err := RunHardhatNode(diveContext)

if err != nil {
diveContext.FatalError("Fail to Start Hardhat Node", err.Error())
}

data.WriteDiveResponse(diveContext)
},
}

return ethCmd

}

func RunHardhatNode(ctx context.Context, kurtosisEnclaveContext *enclaves.EnclaveContext) *common.DiveserviceResponse {
func RunHardhatNode(diveContext *common.DiveContext) (*common.DiveserviceResponse, error) {

kurtosisEnclaveContext, err := diveContext.GetEnclaveContext()

if err != nil {
return nil, err
}

data, _, err := kurtosisEnclaveContext.RunStarlarkPackage(ctx, "../", "services/evm/eth/eth.star", "start_eth_node_serivce", `{"args":{},"node_type":"hardhat"}`, false, 4, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})
data, _, err := kurtosisEnclaveContext.RunStarlarkRemotePackage(diveContext.Ctx, common.DiveRemotePackagePath, common.DiveEthHardhatNodeScript, "start_hardhat_node", "{}", common.DiveDryRun, common.DiveDefaultParallelism, []kurtosis_core_rpc_api_bindings.KurtosisFeatureFlag{})

if err != nil {
fmt.Println(err)
return nil, err
}

responseData := common.GetSerializedData(data)

ethResponseData := &common.DiveserviceResponse{}
hardhatResponseData := &common.DiveserviceResponse{}

result, err := ethResponseData.Decode([]byte(responseData))
result, err := hardhatResponseData.Decode([]byte(responseData))

if err != nil {
fmt.Println(err)
return nil, err
}

return result
return result, nil

}
Loading