From 4478236908b678b84d20cb2ad58f7ee53a3c931a Mon Sep 17 00:00:00 2001 From: Pantani Date: Mon, 8 Apr 2024 14:12:08 +0200 Subject: [PATCH 01/12] remove ts relayer --- ignite/cmd/cmd.go | 2 - ignite/cmd/relayer.go | 33 -- ignite/cmd/relayer_configure.go | 461 ------------------ ignite/cmd/relayer_connect.go | 120 ----- ignite/cmd/tools.go | 68 --- .../nodetime/programs/ts-relayer/tsrelayer.go | 69 --- ignite/pkg/relayer/chain.go | 310 ------------ ignite/pkg/relayer/config/config.go | 99 ---- ignite/pkg/relayer/relayer.go | 288 ----------- 9 files changed, 1450 deletions(-) delete mode 100644 ignite/cmd/relayer.go delete mode 100644 ignite/cmd/relayer_configure.go delete mode 100644 ignite/cmd/relayer_connect.go delete mode 100644 ignite/cmd/tools.go delete mode 100644 ignite/pkg/nodetime/programs/ts-relayer/tsrelayer.go delete mode 100644 ignite/pkg/relayer/chain.go delete mode 100644 ignite/pkg/relayer/config/config.go delete mode 100644 ignite/pkg/relayer/relayer.go diff --git a/ignite/cmd/cmd.go b/ignite/cmd/cmd.go index 622b84a048..4aa8325afe 100644 --- a/ignite/cmd/cmd.go +++ b/ignite/cmd/cmd.go @@ -76,8 +76,6 @@ To get started, create a blockchain: NewGenerate(), NewNode(), NewAccount(), - NewRelayer(), - NewTools(), NewDocs(), NewVersion(), NewApp(), diff --git a/ignite/cmd/relayer.go b/ignite/cmd/relayer.go deleted file mode 100644 index 05087f0080..0000000000 --- a/ignite/cmd/relayer.go +++ /dev/null @@ -1,33 +0,0 @@ -package ignitecmd - -import ( - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/errors" -) - -// NewRelayer returns a new relayer command. -func NewRelayer() *cobra.Command { - c := &cobra.Command{ - Use: "relayer", - Aliases: []string{"r"}, - Short: "Connect blockchains with an IBC relayer", - } - - c.AddCommand( - NewRelayerConfigure(), - NewRelayerConnect(), - ) - - return c -} - -func handleRelayerAccountErr(err error) error { - var accountErr *cosmosaccount.AccountDoesNotExistError - if !errors.As(err, &accountErr) { - return err - } - - return errors.Wrap(accountErr, `make sure to create or import your account through "ignite account" commands`) -} diff --git a/ignite/cmd/relayer_configure.go b/ignite/cmd/relayer_configure.go deleted file mode 100644 index 0babbee9b4..0000000000 --- a/ignite/cmd/relayer_configure.go +++ /dev/null @@ -1,461 +0,0 @@ -package ignitecmd - -import ( - "fmt" - - "github.com/gookit/color" - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cliui" - "github.com/ignite/cli/v29/ignite/pkg/cliui/cliquiz" - "github.com/ignite/cli/v29/ignite/pkg/cliui/entrywriter" - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/errors" - "github.com/ignite/cli/v29/ignite/pkg/relayer" - relayerconfig "github.com/ignite/cli/v29/ignite/pkg/relayer/config" -) - -const ( - flagAdvanced = "advanced" - flagSourceAccount = "source-account" - flagTargetAccount = "target-account" - flagSourceRPC = "source-rpc" - flagTargetRPC = "target-rpc" - flagSourceFaucet = "source-faucet" - flagTargetFaucet = "target-faucet" - flagSourcePort = "source-port" - flagSourceVersion = "source-version" - flagTargetPort = "target-port" - flagTargetVersion = "target-version" - flagSourceGasPrice = "source-gasprice" - flagTargetGasPrice = "target-gasprice" - flagSourceGasLimit = "source-gaslimit" - flagTargetGasLimit = "target-gaslimit" - flagSourceAddressPrefix = "source-prefix" - flagTargetAddressPrefix = "target-prefix" - flagOrdered = "ordered" - flagReset = "reset" - flagSourceClientID = "source-client-id" - flagTargetClientID = "target-client-id" - - RelayerSource = "source" - RelayerTarget = "target" - - defaultSourceRPCAddress = "http://localhost:26657" - defaultTargetRPCAddress = "https://rpc.cosmos.directory:443/cosmoshub" - - defautSourceGasPrice = "0.00025stake" - defautTargetGasPrice = "0.025uatom" - defautSourceGasLimit = 300000 - defautTargetGasLimit = 300000 - defautSourceAddressPrefix = "cosmos" - defautTargetAddressPrefix = "cosmos" -) - -// NewRelayerConfigure returns a new relayer configure command. -// faucet addresses are optional and connect command will try to guess the address -// when not provided. even if auto retrieving coins fails, connect command will complete with success. -func NewRelayerConfigure() *cobra.Command { - c := &cobra.Command{ - Use: "configure", - Short: "Configure source and target chains for relaying", - Aliases: []string{"conf"}, - RunE: relayerConfigureHandler, - } - - c.Flags().BoolP(flagAdvanced, "a", false, "advanced configuration options for custom IBC modules") - c.Flags().String(flagSourceRPC, "", "RPC address of the source chain") - c.Flags().String(flagTargetRPC, "", "RPC address of the target chain") - c.Flags().String(flagSourceFaucet, "", "faucet address of the source chain") - c.Flags().String(flagTargetFaucet, "", "faucet address of the target chain") - c.Flags().String(flagSourcePort, "", "IBC port ID on the source chain") - c.Flags().String(flagSourceVersion, "", "module version on the source chain") - c.Flags().String(flagTargetPort, "", "IBC port ID on the target chain") - c.Flags().String(flagTargetVersion, "", "module version on the target chain") - c.Flags().String(flagSourceGasPrice, "", "gas price used for transactions on source chain") - c.Flags().String(flagTargetGasPrice, "", "gas price used for transactions on target chain") - c.Flags().Int64(flagSourceGasLimit, 0, "gas limit used for transactions on source chain") - c.Flags().Int64(flagTargetGasLimit, 0, "gas limit used for transactions on target chain") - c.Flags().String(flagSourceAddressPrefix, "", "address prefix of the source chain") - c.Flags().String(flagTargetAddressPrefix, "", "address prefix of the target chain") - c.Flags().String(flagSourceAccount, "", "source Account") - c.Flags().String(flagTargetAccount, "", "target Account") - c.Flags().Bool(flagOrdered, false, "set the channel as ordered") - c.Flags().BoolP(flagReset, "r", false, "reset the relayer config") - c.Flags().String(flagSourceClientID, "", "use a custom client id for source") - c.Flags().String(flagTargetClientID, "", "use a custom client id for target") - c.Flags().AddFlagSet(flagSetKeyringBackend()) - c.Flags().AddFlagSet(flagSetKeyringDir()) - - return c -} - -func relayerConfigureHandler(cmd *cobra.Command, _ []string) (err error) { - defer func() { - err = handleRelayerAccountErr(err) - }() - - session := cliui.New() - defer session.End() - - ca, err := cosmosaccount.New( - cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)), - cosmosaccount.WithHome(getKeyringDir(cmd)), - ) - if err != nil { - return err - } - - if err := ca.EnsureDefaultAccount(); err != nil { - return err - } - - if err := printSection(session, "Setting up chains"); err != nil { - return err - } - - // basic configuration - var ( - sourceAccount string - targetAccount string - sourceRPCAddress string - targetRPCAddress string - sourceFaucetAddress string - targetFaucetAddress string - sourceGasPrice string - targetGasPrice string - sourceGasLimit int64 - targetGasLimit int64 - sourceAddressPrefix string - targetAddressPrefix string - ) - - // advanced configuration for the channel - var ( - sourcePort string - sourceVersion string - targetPort string - targetVersion string - ) - - // questions - var ( - questionSourceAccount = cliquiz.NewQuestion( - "Source Account", - &sourceAccount, - cliquiz.DefaultAnswer(cosmosaccount.DefaultAccount), - cliquiz.Required(), - ) - questionTargetAccount = cliquiz.NewQuestion( - "Target Account", - &targetAccount, - cliquiz.DefaultAnswer(cosmosaccount.DefaultAccount), - cliquiz.Required(), - ) - questionSourceRPCAddress = cliquiz.NewQuestion( - "Source RPC", - &sourceRPCAddress, - cliquiz.DefaultAnswer(defaultSourceRPCAddress), - cliquiz.Required(), - ) - questionSourceFaucet = cliquiz.NewQuestion( - "Source Faucet", - &sourceFaucetAddress, - ) - questionTargetRPCAddress = cliquiz.NewQuestion( - "Target RPC", - &targetRPCAddress, - cliquiz.DefaultAnswer(defaultTargetRPCAddress), - cliquiz.Required(), - ) - questionTargetFaucet = cliquiz.NewQuestion( - "Target Faucet", - &targetFaucetAddress, - ) - questionSourcePort = cliquiz.NewQuestion( - "Source Port", - &sourcePort, - cliquiz.DefaultAnswer(relayer.TransferPort), - cliquiz.Required(), - ) - questionSourceVersion = cliquiz.NewQuestion( - "Source Version", - &sourceVersion, - cliquiz.DefaultAnswer(relayer.TransferVersion), - cliquiz.Required(), - ) - questionTargetPort = cliquiz.NewQuestion( - "Target Port", - &targetPort, - cliquiz.DefaultAnswer(relayer.TransferPort), - cliquiz.Required(), - ) - questionTargetVersion = cliquiz.NewQuestion( - "Target Version", - &targetVersion, - cliquiz.DefaultAnswer(relayer.TransferVersion), - cliquiz.Required(), - ) - questionSourceGasPrice = cliquiz.NewQuestion( - "Source Gas Price", - &sourceGasPrice, - cliquiz.DefaultAnswer(defautSourceGasPrice), - cliquiz.Required(), - ) - questionTargetGasPrice = cliquiz.NewQuestion( - "Target Gas Price", - &targetGasPrice, - cliquiz.DefaultAnswer(defautTargetGasPrice), - cliquiz.Required(), - ) - questionSourceGasLimit = cliquiz.NewQuestion( - "Source Gas Limit", - &sourceGasLimit, - cliquiz.DefaultAnswer(defautSourceGasLimit), - cliquiz.Required(), - ) - questionTargetGasLimit = cliquiz.NewQuestion( - "Target Gas Limit", - &targetGasLimit, - cliquiz.DefaultAnswer(defautTargetGasLimit), - cliquiz.Required(), - ) - questionSourceAddressPrefix = cliquiz.NewQuestion( - "Source Address Prefix", - &sourceAddressPrefix, - cliquiz.DefaultAnswer(defautSourceAddressPrefix), - cliquiz.Required(), - ) - questionTargetAddressPrefix = cliquiz.NewQuestion( - "Target Address Prefix", - &targetAddressPrefix, - cliquiz.DefaultAnswer(defautTargetAddressPrefix), - cliquiz.Required(), - ) - ) - - // Get flags - sourceAccount, _ = cmd.Flags().GetString(flagSourceAccount) - targetAccount, _ = cmd.Flags().GetString(flagTargetAccount) - sourceRPCAddress, _ = cmd.Flags().GetString(flagSourceRPC) - sourceFaucetAddress, _ = cmd.Flags().GetString(flagSourceFaucet) - targetRPCAddress, _ = cmd.Flags().GetString(flagTargetRPC) - targetFaucetAddress, _ = cmd.Flags().GetString(flagTargetFaucet) - sourcePort, _ = cmd.Flags().GetString(flagSourcePort) - sourceVersion, _ = cmd.Flags().GetString(flagSourceVersion) - targetPort, _ = cmd.Flags().GetString(flagTargetPort) - targetVersion, _ = cmd.Flags().GetString(flagTargetVersion) - sourceGasPrice, _ = cmd.Flags().GetString(flagSourceGasPrice) - targetGasPrice, _ = cmd.Flags().GetString(flagTargetGasPrice) - sourceGasLimit, _ = cmd.Flags().GetInt64(flagSourceGasLimit) - targetGasLimit, _ = cmd.Flags().GetInt64(flagTargetGasLimit) - sourceAddressPrefix, _ = cmd.Flags().GetString(flagSourceAddressPrefix) - targetAddressPrefix, _ = cmd.Flags().GetString(flagTargetAddressPrefix) - - var ( - advanced, _ = cmd.Flags().GetBool(flagAdvanced) - ordered, _ = cmd.Flags().GetBool(flagOrdered) - sourceClientID, _ = cmd.Flags().GetString(flagSourceClientID) - targetClientID, _ = cmd.Flags().GetString(flagTargetClientID) - reset, _ = cmd.Flags().GetBool(flagReset) - - questions []cliquiz.Question - ) - - // get information from prompt if flag not provided - if sourceAccount == "" { - questions = append(questions, questionSourceAccount) - } - if targetAccount == "" { - questions = append(questions, questionTargetAccount) - } - if sourceRPCAddress == "" { - questions = append(questions, questionSourceRPCAddress) - } - if sourceFaucetAddress == "" { - questions = append(questions, questionSourceFaucet) - } - if targetRPCAddress == "" { - questions = append(questions, questionTargetRPCAddress) - } - if targetFaucetAddress == "" { - questions = append(questions, questionTargetFaucet) - } - if sourceGasPrice == "" { - questions = append(questions, questionSourceGasPrice) - } - if targetGasPrice == "" { - questions = append(questions, questionTargetGasPrice) - } - if sourceGasLimit == 0 { - questions = append(questions, questionSourceGasLimit) - } - if targetGasLimit == 0 { - questions = append(questions, questionTargetGasLimit) - } - if sourceAddressPrefix == "" { - questions = append(questions, questionSourceAddressPrefix) - } - if targetAddressPrefix == "" { - questions = append(questions, questionTargetAddressPrefix) - } - // advanced information - if advanced { - if sourcePort == "" { - questions = append(questions, questionSourcePort) - } - if sourceVersion == "" { - questions = append(questions, questionSourceVersion) - } - if targetPort == "" { - questions = append(questions, questionTargetPort) - } - if targetVersion == "" { - questions = append(questions, questionTargetVersion) - } - } - - session.PauseSpinner() - if len(questions) > 0 { - if err := session.Ask(questions...); err != nil { - return err - } - } - - if reset { - if err := relayerconfig.Delete(); err != nil { - return err - } - } - - session.StartSpinner("Fetching chain info...") - - session.Println() - r := relayer.New(ca) - - // initialize the chains - sourceChain, err := InitChain( - cmd, - r, - session, - RelayerSource, - sourceAccount, - sourceRPCAddress, - sourceFaucetAddress, - sourceGasPrice, - sourceGasLimit, - sourceAddressPrefix, - sourceClientID, - ) - if err != nil { - return err - } - - if err := sourceChain.EnsureChainSetup(cmd.Context()); err != nil { - return err - } - - targetChain, err := InitChain( - cmd, - r, - session, - RelayerTarget, - targetAccount, - targetRPCAddress, - targetFaucetAddress, - targetGasPrice, - targetGasLimit, - targetAddressPrefix, - targetClientID, - ) - if err != nil { - return err - } - - if err := targetChain.EnsureChainSetup(cmd.Context()); err != nil { - return err - } - - session.StartSpinner("Configuring...") - - // sets advanced channel options - var channelOptions []relayer.ChannelOption - if advanced { - channelOptions = append(channelOptions, - relayer.SourcePort(sourcePort), - relayer.SourceVersion(sourceVersion), - relayer.TargetPort(targetPort), - relayer.TargetVersion(targetVersion), - ) - - if ordered { - channelOptions = append(channelOptions, relayer.Ordered()) - } - } - - // create the connection configuration - id, err := sourceChain.Connect(targetChain, channelOptions...) - if err != nil { - return err - } - - return session.Printf("⛓ Configured chains: %s\n\n", color.Green.Sprint(id)) -} - -// InitChain initializes chain information for the relayer connection. -func InitChain( - cmd *cobra.Command, - r relayer.Relayer, - session *cliui.Session, - name, - accountName, - rpcAddr, - faucetAddr, - gasPrice string, - gasLimit int64, - addressPrefix, - clientID string, -) (*relayer.Chain, error) { - defer session.StopSpinner() - session.StartSpinner(fmt.Sprintf("Initializing chain %s...", name)) - - c, account, err := r.NewChain( - accountName, - rpcAddr, - relayer.WithFaucet(faucetAddr), - relayer.WithGasPrice(gasPrice), - relayer.WithGasLimit(gasLimit), - relayer.WithAddressPrefix(addressPrefix), - relayer.WithClientID(clientID), - ) - if err != nil { - return nil, errors.Wrapf(err, "cannot resolve %s", name) - } - - accountAddr, err := account.Address(addressPrefix) - if err != nil { - return nil, err - } - - session.StopSpinner() - session.Printf("🔐 Account on %q is %s(%s)\n \n", name, accountName, accountAddr) - session.StartSpinner(color.Yellow.Sprintf("trying to receive tokens from a faucet...")) - - coins, err := c.TryRetrieve(cmd.Context()) - - session.StopSpinner() - session.Print(" |· ") - if err != nil { - session.Println(color.Yellow.Sprintf(err.Error())) - } else { - session.Println(color.Green.Sprintf("received coins from a faucet")) - } - - balance := coins.String() - if balance == "" { - balance = entrywriter.None - } - session.Printf(" |· (balance: %s)\n\n", balance) - - return c, nil -} diff --git a/ignite/cmd/relayer_connect.go b/ignite/cmd/relayer_connect.go deleted file mode 100644 index 818aebbb20..0000000000 --- a/ignite/cmd/relayer_connect.go +++ /dev/null @@ -1,120 +0,0 @@ -package ignitecmd - -import ( - "bytes" - "fmt" - "text/tabwriter" - - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cliui" - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/relayer" -) - -// NewRelayerConnect returns a new relayer connect command to link all or some relayer paths and start -// relaying txs in between. -// if not paths are specified, all paths are linked. -func NewRelayerConnect() *cobra.Command { - c := &cobra.Command{ - Use: "connect [,...]", - Short: "Link chains associated with paths and start relaying tx packets in between", - RunE: relayerConnectHandler, - } - - c.Flags().AddFlagSet(flagSetKeyringBackend()) - c.Flags().AddFlagSet(flagSetKeyringDir()) - - return c -} - -func relayerConnectHandler(cmd *cobra.Command, args []string) (err error) { - defer func() { - err = handleRelayerAccountErr(err) - }() - - session := cliui.New() - defer session.End() - - ca, err := cosmosaccount.New( - cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)), - cosmosaccount.WithHome(getKeyringDir(cmd)), - ) - if err != nil { - return err - } - - if err := ca.EnsureDefaultAccount(); err != nil { - return err - } - - var ( - use []string - ids = args - r = relayer.New(ca) - ) - - all, err := r.ListPaths(cmd.Context()) - if err != nil { - return err - } - - // if no path ids provided, then we connect all of them otherwise, - // only connect the specified ones. - if len(ids) == 0 { - for _, path := range all { - use = append(use, path.ID) - } - } else { - for _, id := range ids { - for _, path := range all { - if id == path.ID { - use = append(use, path.ID) - break - } - } - } - } - - if len(use) == 0 { - return session.Println("No chains found to connect.") - } - - session.StartSpinner("Creating links between chains...") - - if err := r.LinkPaths(cmd.Context(), use...); err != nil { - return err - } - - session.StopSpinner() - - if err := printSection(session, "Paths"); err != nil { - return err - } - - for _, id := range use { - session.StartSpinner("Loading...") - - path, err := r.GetPath(cmd.Context(), id) - if err != nil { - return err - } - - session.StopSpinner() - - var buf bytes.Buffer - w := tabwriter.NewWriter(&buf, 0, 0, 1, ' ', tabwriter.TabIndent) - fmt.Fprintf(w, "%s:\n", path.ID) - fmt.Fprintf(w, " \t%s\t>\t(port: %s)\t(channel: %s)\n", path.Src.ChainID, path.Src.PortID, path.Src.ChannelID) - fmt.Fprintf(w, " \t%s\t>\t(port: %s)\t(channel: %s)\n", path.Dst.ChainID, path.Dst.PortID, path.Dst.ChannelID) - fmt.Fprintln(w) - w.Flush() - session.Print(buf.String()) - } - - if err := printSection(session, "Listening and relaying packets between chains..."); err != nil { - return err - } - - return r.StartPaths(cmd.Context(), use...) -} diff --git a/ignite/cmd/tools.go b/ignite/cmd/tools.go deleted file mode 100644 index 118c5a81e8..0000000000 --- a/ignite/cmd/tools.go +++ /dev/null @@ -1,68 +0,0 @@ -package ignitecmd - -import ( - "context" - "os" - - "github.com/spf13/cobra" - - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner" - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" - "github.com/ignite/cli/v29/ignite/pkg/nodetime" -) - -// NewTools returns a command where various tools (binaries) are attached as sub commands -// for advanced users. -func NewTools() *cobra.Command { - c := &cobra.Command{ - Use: "tools", - Short: "Tools for advanced users", - } - c.AddCommand( - NewToolsIBCSetup(), - NewToolsIBCRelayer(), - ) - return c -} - -func NewToolsIBCSetup() *cobra.Command { - return &cobra.Command{ - Use: "ibc-setup [--] [...]", - Short: "Collection of commands to quickly setup a relayer", - RunE: toolsNodetimeProxy(nodetime.CommandIBCSetup), - Example: `ignite tools ibc-setup -- -h -ignite tools ibc-setup -- init --src relayer_test_1 --dest relayer_test_2`, - } -} - -func NewToolsIBCRelayer() *cobra.Command { - return &cobra.Command{ - Use: "ibc-relayer [--] [...]", - Short: "TypeScript implementation of an IBC relayer", - RunE: toolsNodetimeProxy(nodetime.CommandIBCRelayer), - Example: `ignite tools ibc-relayer -- -h`, - } -} - -func toolsNodetimeProxy(c nodetime.CommandName) func(cmd *cobra.Command, args []string) error { - return func(cmd *cobra.Command, args []string) error { - command, cleanup, err := nodetime.Command(c) - if err != nil { - return err - } - defer cleanup() - - return toolsProxy(cmd.Context(), append(command, args...)) - } -} - -func toolsProxy(ctx context.Context, command []string) error { - return cmdrunner.New().Run( - ctx, - step.New( - step.Exec(command[0], command[1:]...), - step.Stdout(os.Stdout), - step.Stderr(os.Stderr), - ), - ) -} diff --git a/ignite/pkg/nodetime/programs/ts-relayer/tsrelayer.go b/ignite/pkg/nodetime/programs/ts-relayer/tsrelayer.go deleted file mode 100644 index e1c7b49fb6..0000000000 --- a/ignite/pkg/nodetime/programs/ts-relayer/tsrelayer.go +++ /dev/null @@ -1,69 +0,0 @@ -package tsrelayer - -import ( - "bufio" - "bytes" - "context" - "fmt" - "io" - - "github.com/gorilla/rpc/v2/json2" - "golang.org/x/sync/errgroup" - - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner" - "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" - "github.com/ignite/cli/v29/ignite/pkg/errors" - "github.com/ignite/cli/v29/ignite/pkg/nodetime" -) - -// Call calls a method in the ts relayer wrapper lib with args and fills reply from the returned value. -func Call(ctx context.Context, method string, args, reply interface{}) error { - command, cleanup, err := nodetime.Command(nodetime.CommandXRelayer) - if err != nil { - return err - } - defer cleanup() - - req, err := json2.EncodeClientRequest(method, args) - if err != nil { - return err - } - - r, w := io.Pipe() - - g, ctx := errgroup.WithContext(ctx) - g.Go(func() error { - defer w.Close() - - return cmdrunner.New().Run( - ctx, - step.New( - step.Exec(command[0], command[1:]...), - step.Write(req), - step.Stdout(w), - ), - ) - }) - - // regular logs can be printed to the stdout by the other process before a jsonrpc response is emitted. - // differentiate both kinds and simulate printing regular logs if there are any. - sc := bufio.NewScanner(r) - for sc.Scan() { - err = json2.DecodeClientResponse(bytes.NewReader(sc.Bytes()), reply) - - var e *json2.Error - if errors.As(err, &e) || errors.Is(err, json2.ErrNullResult) { // jsonrpc returned with a server-side error. - return err - } - - if err != nil { // a line printed to the stdout by the other process. - fmt.Println(sc.Text()) - } - } - - if err := sc.Err(); err != nil { - return err - } - - return g.Wait() -} diff --git a/ignite/pkg/relayer/chain.go b/ignite/pkg/relayer/chain.go deleted file mode 100644 index 25e2488f5c..0000000000 --- a/ignite/pkg/relayer/chain.go +++ /dev/null @@ -1,310 +0,0 @@ -package relayer - -import ( - "context" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/imdario/mergo" - - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/cosmosclient" - "github.com/ignite/cli/v29/ignite/pkg/cosmosfaucet" - "github.com/ignite/cli/v29/ignite/pkg/errors" - relayerconfig "github.com/ignite/cli/v29/ignite/pkg/relayer/config" -) - -const ( - TransferPort = "transfer" - TransferVersion = "ics20-1" - OrderingUnordered = "ORDER_UNORDERED" - OrderingOrdered = "ORDER_ORDERED" -) - -var errEndpointExistsWithDifferentChainID = errors.New("rpc endpoint already exists with a different chain id") - -// Chain represents a chain in relayer. -type Chain struct { - // ID is id of the chain. - ID string - - // accountName is account used on the chain. - accountName string - - // rpcAddress is the node address of tm. - rpcAddress string - - // faucetAddress is the faucet address to get tokens for relayer accounts. - faucetAddress string - - // gasPrice is the gas price used when sending transactions to the chain - gasPrice string - - // gasLimit is the gas limit used when sending transactions to the chain - gasLimit int64 - - // addressPrefix is the address prefix of the chain. - addressPrefix string - - // clientID is the client id of the chain for relayer connection. - clientID string - - r Relayer -} - -// Account represents an account in relayer. -type Account struct { - // Address of the account. - Address string `json:"address"` -} - -// Option is used to configure Chain. -type Option func(*Chain) - -// WithFaucet provides a faucet address for chain to get tokens from. -// when it isn't provided. -func WithFaucet(address string) Option { - return func(c *Chain) { - c.faucetAddress = address - } -} - -// WithGasPrice gives the gas price to use to send ibc transactions to the chain. -func WithGasPrice(gasPrice string) Option { - return func(c *Chain) { - c.gasPrice = gasPrice - } -} - -// WithGasLimit gives the gas limit to use to send ibc transactions to the chain. -func WithGasLimit(limit int64) Option { - return func(c *Chain) { - c.gasLimit = limit - } -} - -// WithAddressPrefix configures the account key prefix used on the chain. -func WithAddressPrefix(addressPrefix string) Option { - return func(c *Chain) { - c.addressPrefix = addressPrefix - } -} - -// WithClientID configures the chain client id. -func WithClientID(clientID string) Option { - return func(c *Chain) { - c.clientID = clientID - } -} - -// NewChain creates a new chain on relayer or uses the existing matching chain. -func (r Relayer) NewChain(accountName, rpcAddress string, options ...Option) ( - *Chain, cosmosaccount.Account, error, -) { - c := &Chain{ - accountName: accountName, - rpcAddress: fixRPCAddress(rpcAddress), - r: r, - } - - // apply user options. - for _, o := range options { - o(c) - } - - account, err := r.ca.GetByName(accountName) - if err != nil { - return nil, cosmosaccount.Account{}, err - } - - return c, account, nil -} - -// TryRetrieve tries to receive some coins to the account and returns the total balance. -func (c *Chain) TryRetrieve(ctx context.Context) (sdk.Coins, error) { - acc, err := c.r.ca.GetByName(c.accountName) - if err != nil { - return nil, err - } - - addr, err := acc.Address(c.addressPrefix) - if err != nil { - return nil, err - } - - if err = cosmosfaucet.TryRetrieve(ctx, c.ID, c.rpcAddress, c.faucetAddress, addr); err != nil { - return nil, err - } - return c.r.balance(ctx, c.rpcAddress, c.accountName, c.addressPrefix) -} - -func (c *Chain) Config() relayerconfig.Chain { - return relayerconfig.Chain{ - ID: c.ID, - Account: c.accountName, - AddressPrefix: c.addressPrefix, - RPCAddress: c.rpcAddress, - GasPrice: c.gasPrice, - GasLimit: c.gasLimit, - ClientID: c.clientID, - } -} - -// channelOptions represents options for configuring the IBC channel between two chains. -type channelOptions struct { - sourcePort string - sourceVersion string - targetPort string - targetVersion string - ordering string -} - -// newChannelOptions returns default channel options. -func newChannelOptions() channelOptions { - return channelOptions{ - sourcePort: TransferPort, - sourceVersion: TransferVersion, - targetPort: TransferPort, - targetVersion: TransferVersion, - ordering: OrderingUnordered, - } -} - -// ChannelOption is used to configure relayer IBC connection. -type ChannelOption func(*channelOptions) - -// SourcePort configures the source port of the new channel. -func SourcePort(port string) ChannelOption { - return func(c *channelOptions) { - c.sourcePort = port - } -} - -// TargetPort configures the target port of the new channel. -func TargetPort(port string) ChannelOption { - return func(c *channelOptions) { - c.targetPort = port - } -} - -// SourceVersion configures the source version of the new channel. -func SourceVersion(version string) ChannelOption { - return func(c *channelOptions) { - c.sourceVersion = version - } -} - -// TargetVersion configures the target version of the new channel. -func TargetVersion(version string) ChannelOption { - return func(c *channelOptions) { - c.targetVersion = version - } -} - -// Ordered sets the new channel as ordered. -func Ordered() ChannelOption { - return func(c *channelOptions) { - c.ordering = OrderingOrdered - } -} - -// Connect connects dst chain to c chain and creates a path in between in offline mode. -// it returns the path id on success otherwise, returns with a non-nil error. -func (c *Chain) Connect(dst *Chain, options ...ChannelOption) (id string, err error) { - channelOptions := newChannelOptions() - - for _, apply := range options { - apply(&channelOptions) - } - - conf, err := relayerconfig.Get() - if err != nil { - return "", err - } - - // determine a unique path name from chain ids with incremental numbers. e.g.: - // - src-dst - // - src-dst-2 - pathID := PathID(c.ID, dst.ID) - var suffix string - i := 2 - for { - guess := pathID + suffix - if _, err := conf.PathByID(guess); err != nil { // guess is unique. - pathID = guess - break - } - suffix = fmt.Sprintf("-%d", i) - i++ - } - - confPath := relayerconfig.Path{ - ID: pathID, - Ordering: channelOptions.ordering, - Src: relayerconfig.PathEnd{ - ChainID: c.ID, - PortID: channelOptions.sourcePort, - Version: channelOptions.sourceVersion, - }, - Dst: relayerconfig.PathEnd{ - ChainID: dst.ID, - PortID: channelOptions.targetPort, - Version: channelOptions.targetVersion, - }, - } - - conf.Paths = append(conf.Paths, confPath) - - if err := relayerconfig.Save(conf); err != nil { - return "", err - } - - return pathID, nil -} - -// EnsureChainSetup sets up the new or existing chain. -func (c *Chain) EnsureChainSetup(ctx context.Context) error { - client, err := cosmosclient.New(ctx, cosmosclient.WithNodeAddress(c.rpcAddress)) - if err != nil { - return err - } - status, err := client.RPC.Status(ctx) - if err != nil { - return err - } - c.ID = status.NodeInfo.Network - - confChain := c.Config() - conf, err := relayerconfig.Get() - if err != nil { - return err - } - - var found bool - - for i, chain := range conf.Chains { - if chain.ID == c.ID { - if chain.RPCAddress != c.rpcAddress { - return errEndpointExistsWithDifferentChainID - } - - if err := mergo.Merge(&conf.Chains[i], confChain, mergo.WithOverride); err != nil { - return err - } - - found = true - break - } - } - - if !found { - conf.Chains = append(conf.Chains, confChain) - } - - return relayerconfig.Save(conf) -} - -// PathID creates path name from chain ids. -func PathID(srcChainID, dstChainID string) string { - return fmt.Sprintf("%s-%s", srcChainID, dstChainID) -} diff --git a/ignite/pkg/relayer/config/config.go b/ignite/pkg/relayer/config/config.go deleted file mode 100644 index 017aed50ff..0000000000 --- a/ignite/pkg/relayer/config/config.go +++ /dev/null @@ -1,99 +0,0 @@ -package relayerconf - -import ( - "os" - "reflect" - - "github.com/ignite/cli/v29/ignite/pkg/confile" - "github.com/ignite/cli/v29/ignite/pkg/errors" -) - -const SupportVersion = "2" - -var configPath = os.ExpandEnv("$HOME/.ignite/relayer/config.yml") - -var ( - ErrChainCannotBeFound = errors.New("chain cannot be found") - ErrPathCannotBeFound = errors.New("path cannot be found") -) - -type Config struct { - Version string `json:"version" yaml:"version"` - Chains []Chain `json:"chains" yaml:"chains,omitempty"` - Paths []Path `json:"paths" yaml:"paths,omitempty"` -} - -func (c Config) ChainByID(id string) (Chain, error) { - for _, chain := range c.Chains { - if chain.ID == id { - return chain, nil - } - } - return Chain{}, errors.Wrap(ErrChainCannotBeFound, id) -} - -func (c Config) PathByID(id string) (Path, error) { - for _, path := range c.Paths { - if path.ID == id { - return path, nil - } - } - return Path{}, errors.Wrap(ErrPathCannotBeFound, id) -} - -func (c Config) UpdatePath(path Path) error { - for i, p := range c.Paths { - if p.ID == path.ID { - c.Paths[i] = path - return nil - } - } - return errors.Wrap(ErrPathCannotBeFound, path.ID) -} - -type Chain struct { - ID string `json:"id" yaml:"id"` - Account string `json:"account" yaml:"account"` - AddressPrefix string `json:"address_prefix" yaml:"address_prefix"` - RPCAddress string `json:"rpc_address" yaml:"rpc_address"` - GasPrice string `json:"gas_price" yaml:"gas_price,omitempty"` - GasLimit int64 `json:"gas_limit" yaml:"gas_limit,omitempty"` - ClientID string `json:"client_id" yaml:"client_id,omitempty"` -} - -type Path struct { - ID string `json:"id" yaml:"id"` - Ordering string `json:"ordering" yaml:"ordering,omitempty"` - Src PathEnd `json:"src" yaml:"src"` - Dst PathEnd `json:"dst" yaml:"dst"` -} - -type PathEnd struct { - ChainID string `json:"chain_id" yaml:"chain_id"` - ConnectionID string `json:"connection_id" yaml:"connection_id,omitempty"` - ChannelID string `json:"channel_id" yaml:"channel_id,omitempty"` - PortID string `json:"port_id" yaml:"port_id"` - Version string `json:"version" yaml:"version,omitempty"` - PacketHeight int64 `json:"packet_height" yaml:"packet_height,omitempty"` - AckHeight int64 `json:"ack_height" yaml:"ack_height,omitempty"` -} - -func Get() (Config, error) { - c := Config{} - if err := confile.New(confile.DefaultYAMLEncodingCreator, configPath).Load(&c); err != nil { - return c, err - } - if !reflect.DeepEqual(c, Config{}) && c.Version != SupportVersion { - return c, errors.Errorf("your relayer setup is outdated. run 'rm %s' and configure relayer again", configPath) - } - return c, nil -} - -func Save(c Config) error { - c.Version = SupportVersion - return confile.New(confile.DefaultYAMLEncodingCreator, configPath).Save(c) -} - -func Delete() error { - return os.RemoveAll(configPath) -} diff --git a/ignite/pkg/relayer/relayer.go b/ignite/pkg/relayer/relayer.go deleted file mode 100644 index dc32f98529..0000000000 --- a/ignite/pkg/relayer/relayer.go +++ /dev/null @@ -1,288 +0,0 @@ -package relayer - -import ( - "context" - "encoding/hex" - "strings" - "sync" - "time" - - "github.com/cosmos/cosmos-sdk/crypto" - sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "golang.org/x/sync/errgroup" - - "github.com/ignite/cli/v29/ignite/pkg/cosmosaccount" - "github.com/ignite/cli/v29/ignite/pkg/cosmosclient" - "github.com/ignite/cli/v29/ignite/pkg/ctxticker" - "github.com/ignite/cli/v29/ignite/pkg/errors" - tsrelayer "github.com/ignite/cli/v29/ignite/pkg/nodetime/programs/ts-relayer" - relayerconf "github.com/ignite/cli/v29/ignite/pkg/relayer/config" - "github.com/ignite/cli/v29/ignite/pkg/xurl" -) - -const ( - algoSecp256k1 = "secp256k1" - ibcSetupGas int64 = 2256000 - relayDuration = time.Second * 5 -) - -// ErrLinkedPath indicates that an IBC path is already liked. -var ErrLinkedPath = errors.New("path already linked") - -// Relayer is an IBC relayer. -type Relayer struct { - ca cosmosaccount.Registry -} - -// New creates a new IBC relayer and uses ca to access accounts. -func New(ca cosmosaccount.Registry) Relayer { - return Relayer{ - ca: ca, - } -} - -// LinkPaths links all chains that has a path from config file to each other. -// paths are optional and acts as a filter to only link some chains. -// calling Link multiple times for the same paths does not have any side effects. -func (r Relayer) LinkPaths( - ctx context.Context, - pathIDs ...string, -) error { - conf, err := relayerconf.Get() - if err != nil { - return err - } - - for _, id := range pathIDs { - conf, err = r.Link(ctx, conf, id) - if err != nil { - // Continue with next path when current one is already linked - if errors.Is(err, ErrLinkedPath) { - continue - } - return err - } - if err := relayerconf.Save(conf); err != nil { - return err - } - } - return nil -} - -// Link links chain path to each other. -func (r Relayer) Link( - ctx context.Context, - conf relayerconf.Config, - pathID string, -) (relayerconf.Config, error) { - path, err := conf.PathByID(pathID) - if err != nil { - return conf, err - } - - if path.Src.ChannelID != "" { - return conf, errors.Errorf("%w: %s", ErrLinkedPath, path.ID) - } - - if path, err = r.call(ctx, conf, path, "link"); err != nil { - return conf, err - } - - return conf, conf.UpdatePath(path) -} - -// StartPaths relays packets for linked paths from config file until ctx is canceled. -func (r Relayer) StartPaths(ctx context.Context, pathIDs ...string) error { - conf, err := relayerconf.Get() - if err != nil { - return err - } - - g, ctx := errgroup.WithContext(ctx) - - var m sync.Mutex // protects relayerconf.Path. - for _, id := range pathIDs { - id := id - g.Go(func() error { - return r.Start(ctx, conf, id, func(path relayerconf.Config) error { - m.Lock() - defer m.Unlock() - return relayerconf.Save(conf) - }) - }) - } - return g.Wait() -} - -// Start relays packets for linked path until ctx is canceled. -func (r Relayer) Start( - ctx context.Context, - conf relayerconf.Config, - pathID string, - postExecute func(path relayerconf.Config) error, -) error { - return ctxticker.DoNow(ctx, relayDuration, func() error { - path, err := conf.PathByID(pathID) - if err != nil { - return err - } - path, err = r.call(ctx, conf, path, "start") - if err != nil { - return err - } - if err := conf.UpdatePath(path); err != nil { - return err - } - if postExecute != nil { - return postExecute(conf) - } - return nil - }) -} - -func (r Relayer) call( - ctx context.Context, - conf relayerconf.Config, - path relayerconf.Path, - action string, -) ( - reply relayerconf.Path, err error, -) { - srcChain, srcKey, err := r.prepare(ctx, conf, path.Src.ChainID) - if err != nil { - return relayerconf.Path{}, err - } - - dstChain, dstKey, err := r.prepare(ctx, conf, path.Dst.ChainID) - if err != nil { - return relayerconf.Path{}, err - } - - args := []interface{}{ - path, - srcChain, - dstChain, - srcKey, - dstKey, - } - return reply, tsrelayer.Call(ctx, action, args, &reply) -} - -func (r Relayer) prepare(ctx context.Context, conf relayerconf.Config, chainID string) ( - chain relayerconf.Chain, privKey string, err error, -) { - chain, err = conf.ChainByID(chainID) - if err != nil { - return relayerconf.Chain{}, "", err - } - - coins, err := r.balance(ctx, chain.RPCAddress, chain.Account, chain.AddressPrefix) - if err != nil { - return relayerconf.Chain{}, "", err - } - - gasPrice, err := sdk.ParseCoinNormalized(chain.GasPrice) - if err != nil { - return relayerconf.Chain{}, "", err - } - - account, err := r.ca.GetByName(chain.Account) - if err != nil { - return relayerconf.Chain{}, "", err - } - - addr, err := account.Address(chain.AddressPrefix) - if err != nil { - return relayerconf.Chain{}, "", err - } - - errMissingBalance := errors.Errorf(`account "%s(%s)" on %q chain does not have enough balances`, - addr, - chain.Account, - chain.ID, - ) - - if len(coins) == 0 { - return relayerconf.Chain{}, "", errMissingBalance - } - - for _, coin := range coins { - if gasPrice.Denom != coin.Denom { - continue - } - - if gasPrice.Amount.Int64()*ibcSetupGas > coin.Amount.Int64() { - return relayerconf.Chain{}, "", errMissingBalance - } - } - - // Get the key in ASCII armored format - passphrase := "" - key, err := r.ca.Export(chain.Account, passphrase) - if err != nil { - return relayerconf.Chain{}, "", err - } - - // Unarmor the key to be able to read it as bytes - priv, algo, err := crypto.UnarmorDecryptPrivKey(key, passphrase) - if err != nil { - return relayerconf.Chain{}, "", err - } - - // Check the algorithm because the TS relayer expects a secp256k1 private key - if algo != algoSecp256k1 { - return relayerconf.Chain{}, "", errors.Errorf("private key algorithm must be secp256k1 instead of %s", algo) - } - - return chain, hex.EncodeToString(priv.Bytes()), nil -} - -func (r Relayer) balance(ctx context.Context, rpcAddress, account, addressPrefix string) (sdk.Coins, error) { - client, err := cosmosclient.New(ctx, cosmosclient.WithNodeAddress(rpcAddress)) - if err != nil { - return nil, err - } - - acc, err := r.ca.GetByName(account) - if err != nil { - return nil, err - } - - addr, err := acc.Address(addressPrefix) - if err != nil { - return nil, err - } - - queryClient := banktypes.NewQueryClient(client.Context()) - res, err := queryClient.AllBalances(ctx, &banktypes.QueryAllBalancesRequest{Address: addr}) - if err != nil { - return nil, err - } - - return res.Balances, nil -} - -// GetPath returns a path by its id. -func (r Relayer) GetPath(_ context.Context, id string) (relayerconf.Path, error) { - conf, err := relayerconf.Get() - if err != nil { - return relayerconf.Path{}, err - } - - return conf.PathByID(id) -} - -// ListPaths list all the paths. -func (r Relayer) ListPaths(_ context.Context) ([]relayerconf.Path, error) { - conf, err := relayerconf.Get() - if err != nil { - return nil, err - } - - return conf.Paths, nil -} - -func fixRPCAddress(rpcAddress string) string { - return strings.TrimSuffix(xurl.HTTPEnsurePort(rpcAddress), "/") -} From 610a614ece5e7e357763a5416763ed074fbf9ea0 Mon Sep 17 00:00:00 2001 From: Pantani Date: Mon, 8 Apr 2024 14:13:00 +0200 Subject: [PATCH 02/12] remove unused commands --- ignite/pkg/nodetime/nodetime.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ignite/pkg/nodetime/nodetime.go b/ignite/pkg/nodetime/nodetime.go index 572e7da305..3f77f5b153 100644 --- a/ignite/pkg/nodetime/nodetime.go +++ b/ignite/pkg/nodetime/nodetime.go @@ -25,15 +25,6 @@ const ( // CommandSwaggerCombine is https://www.npmjs.com/package/swagger-combine. CommandSwaggerCombine CommandName = "swagger-combine" - - // CommandIBCSetup is https://github.com/confio/ts-relayer/blob/main/spec/ibc-setup.md. - CommandIBCSetup = "ibc-setup" - - // CommandIBCRelayer is https://github.com/confio/ts-relayer/blob/main/spec/ibc-relayer.md. - CommandIBCRelayer = "ibc-relayer" - - // CommandXRelayer is a relayer wrapper for Ignite CLI made using the confio relayer. - CommandXRelayer = "xrelayer" ) // CommandName represents a high level command under nodetime. From bc511299de06bc24b3905054e0328a0068f67ddc Mon Sep 17 00:00:00 2001 From: Pantani Date: Mon, 8 Apr 2024 19:41:33 +0200 Subject: [PATCH 03/12] remove ts relayer --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index e572d36540..20f6af7801 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ - [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run - [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config - [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg +- [#4076](https://github.com/ignite/cli/pull/4076) Remove ts relayer commands ### Changes From e0463ef622eee221e1fc58412bdb65170cf96aba Mon Sep 17 00:00:00 2001 From: Pantani Date: Tue, 9 Apr 2024 01:21:36 +0200 Subject: [PATCH 04/12] fix hermes relayer cmd for integration tests --- integration/ibc/cmd_relayer_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/integration/ibc/cmd_relayer_test.go b/integration/ibc/cmd_relayer_test.go index 368f22dd90..9a56538cbb 100644 --- a/integration/ibc/cmd_relayer_test.go +++ b/integration/ibc/cmd_relayer_test.go @@ -454,7 +454,6 @@ func TestBlogIBC(t *testing.T) { env.Must(env.Exec("configure the hermes relayer app", step.NewSteps(step.New( step.Exec(envtest.IgniteApp, - "relayer", "hermes", "configure", earthChainID, @@ -474,7 +473,7 @@ func TestBlogIBC(t *testing.T) { go func() { env.Must(env.Exec("run the hermes relayer", step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "relayer", "hermes", "start", earthChainID, marsChainID), + step.Exec(envtest.IgniteApp, "hermes", "start", earthChainID, marsChainID), )), envtest.ExecCtx(ctx), )) @@ -631,5 +630,5 @@ func TestBlogIBC(t *testing.T) { // TODO test ibc using the blog post methods: // step.Exec(app.Binary(), "tx", "blog", "send-ibc-post", "transfer", "channel-0", "Hello", "Hello_Mars-Alice_from_Earth", "--chain-id", earthChainID, "--from", "alice", "--node", earthGRPC, "--output", "json", "--log_format", "json", "--yes") // TODO test ibc using the hermes ft-transfer: - // step.Exec(envtest.IgniteApp, "relayer", "hermes", "exec", "--", "--config", earthConfig, "tx", "ft-transfer", "--timeout-seconds", "1000", "--dst-chain", earthChainID, "--src-chain", marsChainID, "--src-port", "transfer", "--src-channel", "channel-0", "--amount", "100000", "--denom", "stake", "--output", "json", "--log_format", "json", "--yes") + // step.Exec(envtest.IgniteApp, "hermes", "exec", "--", "--config", earthConfig, "tx", "ft-transfer", "--timeout-seconds", "1000", "--dst-chain", earthChainID, "--src-chain", marsChainID, "--src-port", "transfer", "--src-channel", "channel-0", "--amount", "100000", "--denom", "stake", "--output", "json", "--log_format", "json", "--yes") } From d3cb17c6f09bdb1541fa82758f952f6f0d23892c Mon Sep 17 00:00:00 2001 From: Pantani Date: Wed, 17 Apr 2024 13:53:31 +0200 Subject: [PATCH 05/12] add relayer command ad default --- ignite/cmd/plugin_default.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ignite/cmd/plugin_default.go b/ignite/cmd/plugin_default.go index aa69defffa..3e3b97dea8 100644 --- a/ignite/cmd/plugin_default.go +++ b/ignite/cmd/plugin_default.go @@ -18,6 +18,8 @@ type defaultPlugin struct { const ( PluginNetworkVersion = "v0.2.2" PluginNetworkPath = "github.com/ignite/cli-plugin-network@" + PluginNetworkVersion + PluginRelayerVersion = "hermes/v0.2.1" + PluginRelayerPath = "github.com/ignite/apps/hermes@" + PluginRelayerVersion ) // defaultPlugins holds the plugin that are considered trustable and for which @@ -30,9 +32,15 @@ var defaultPlugins = []defaultPlugin{ aliases: []string{"n"}, path: PluginNetworkPath, }, + { + use: "relayer", + short: "Connect blockchains with an IBC relayer", + aliases: []string{"r"}, + path: PluginRelayerPath, + }, } -// ensureDefaultPlugins ensures that all defaultPlugins are wether registered +// ensureDefaultPlugins ensures that all defaultPlugins are whether registered // in cfg OR have an install command added to rootCmd. func ensureDefaultPlugins(rootCmd *cobra.Command, cfg *pluginsconfig.Config) { for _, dp := range defaultPlugins { From 1050480c6efadeb71ae4a140a23441e39c157d3f Mon Sep 17 00:00:00 2001 From: Pantani Date: Wed, 17 Apr 2024 15:07:16 +0200 Subject: [PATCH 06/12] remove unused function --- ignite/cmd/cmd.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ignite/cmd/cmd.go b/ignite/cmd/cmd.go index 4aa8325afe..1b53f52ad1 100644 --- a/ignite/cmd/cmd.go +++ b/ignite/cmd/cmd.go @@ -204,10 +204,6 @@ func checkNewVersion(ctx context.Context) { fmt.Printf("⬆️ Ignite CLI %s is available! To upgrade: https://docs.ignite.com/welcome/install#upgrade", next) } -func printSection(session *cliui.Session, title string) error { - return session.Printf("------\n%s\n------\n\n", title) -} - func newCache(cmd *cobra.Command) (cache.Storage, error) { cacheRootDir, err := config.DirPath() if err != nil { From 2925379f827744f5e73039ba0bf616689884a60d Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Fri, 19 Apr 2024 01:54:16 +0200 Subject: [PATCH 07/12] Update changelog.md --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index e4f8d31adf..d54ae92301 100644 --- a/changelog.md +++ b/changelog.md @@ -10,7 +10,7 @@ - [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run - [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config - [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg -- [#4076](https://github.com/ignite/cli/pull/4076) Remove ts relayer commands +- [#4076](https://github.com/ignite/cli/pull/4076) Remove the ignite `realyer` and `tools` commands with all ts-realyer logic - [#4077](https://github.com/ignite/cli/pull/4077) Merge the swagger files manually instead use nodetime `swagger-combine` ### Changes From bcd89376931feca47c6e0c904959e47371e74041 Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 20 Apr 2024 02:20:31 +0200 Subject: [PATCH 08/12] bump default hermes plugin version --- ignite/cmd/plugin_default.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ignite/cmd/plugin_default.go b/ignite/cmd/plugin_default.go index 3e3b97dea8..798a995610 100644 --- a/ignite/cmd/plugin_default.go +++ b/ignite/cmd/plugin_default.go @@ -18,7 +18,7 @@ type defaultPlugin struct { const ( PluginNetworkVersion = "v0.2.2" PluginNetworkPath = "github.com/ignite/cli-plugin-network@" + PluginNetworkVersion - PluginRelayerVersion = "hermes/v0.2.1" + PluginRelayerVersion = "hermes/v0.2.2" PluginRelayerPath = "github.com/ignite/apps/hermes@" + PluginRelayerVersion ) From a133ffa7bee8f7b0ea7e3744f27494753c26b5bd Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 20 Apr 2024 02:57:25 +0200 Subject: [PATCH 09/12] bump relayer into the tests --- integration/relayer/cmd_relayer_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/relayer/cmd_relayer_test.go b/integration/relayer/cmd_relayer_test.go index 9b06a37772..cd693922c3 100644 --- a/integration/relayer/cmd_relayer_test.go +++ b/integration/relayer/cmd_relayer_test.go @@ -446,7 +446,7 @@ func TestBlogIBC(t *testing.T) { "install", "-g", // filepath.Join(goenv.GoPath(), "src/github.com/ignite/apps/hermes"), // Local path for test proposals - "github.com/ignite/apps/hermes@hermes/v0.2.1", + "github.com/ignite/apps/hermes@hermes/v0.2.2", ), )), )) From f0e77909c783cc6e2f243cee173d7491df2d6c8e Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 20 Apr 2024 02:58:20 +0200 Subject: [PATCH 10/12] run go mod tidy --- go.mod | 3 --- go.sum | 6 ------ 2 files changed, 9 deletions(-) diff --git a/go.mod b/go.mod index 6cbebe2954..19ee30d7eb 100644 --- a/go.mod +++ b/go.mod @@ -51,9 +51,7 @@ require ( github.com/goccy/go-yaml v1.11.3 github.com/golangci/golangci-lint v1.57.2 github.com/google/go-github/v48 v48.2.0 - github.com/gookit/color v1.5.4 github.com/gorilla/mux v1.8.1 - github.com/gorilla/rpc v1.2.1 github.com/hashicorp/go-hclog v1.6.3 github.com/hashicorp/go-plugin v1.6.0 github.com/iancoleman/strcase v0.3.0 @@ -447,7 +445,6 @@ require ( github.com/vbatts/tar-split v0.11.5 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xen0n/gosmopolitan v1.2.2 // indirect - github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.2.0 // indirect github.com/ykadowak/zerologlint v0.1.5 // indirect diff --git a/go.sum b/go.sum index 206b9bb335..7b0f35ed98 100644 --- a/go.sum +++ b/go.sum @@ -792,8 +792,6 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas= github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= -github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= -github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.1.0 h1:y2Gd/9I7MdY1oEIt+n+rowjBNDcLQq3RsH5hwJd0f9s= github.com/gordonklaus/ineffassign v0.1.0/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0= @@ -806,8 +804,6 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/gorilla/rpc v1.2.1 h1:yC+LMV5esttgpVvNORL/xX4jvTTEUE30UZhZ5JF7K9k= -github.com/gorilla/rpc v1.2.1/go.mod h1:uNpOihAlF5xRFLuTYhfR0yfCTm0WTQSQttkMSptRfGk= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -1526,8 +1522,6 @@ github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU= github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= -github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= From 101beaa213eb9087a7cbfb5af19fd7b9bded67b5 Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 20 Apr 2024 03:27:17 +0200 Subject: [PATCH 11/12] rollback relayer command into the integration tests --- integration/relayer/cmd_relayer_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/relayer/cmd_relayer_test.go b/integration/relayer/cmd_relayer_test.go index 0314a51bac..f31321c060 100644 --- a/integration/relayer/cmd_relayer_test.go +++ b/integration/relayer/cmd_relayer_test.go @@ -442,6 +442,7 @@ func TestBlogIBC(t *testing.T) { env.Must(env.Exec("configure the hermes relayer app", step.NewSteps(step.New( step.Exec(envtest.IgniteApp, + "relayer", "hermes", "configure", earthChainID, @@ -461,7 +462,7 @@ func TestBlogIBC(t *testing.T) { go func() { env.Must(env.Exec("run the hermes relayer", step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "hermes", "start", earthChainID, marsChainID), + step.Exec(envtest.IgniteApp, "relayer", "hermes", "start", earthChainID, marsChainID), )), envtest.ExecCtx(ctx), )) From 0182b857ca409b4171d7d10e0beacc1b626e4a37 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Mon, 22 Apr 2024 12:53:33 +0200 Subject: [PATCH 12/12] Update changelog.md --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index b797c2303e..69fcef378a 100644 --- a/changelog.md +++ b/changelog.md @@ -10,7 +10,7 @@ - [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run - [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config - [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg -- [#4076](https://github.com/ignite/cli/pull/4076) Remove the ignite `realyer` and `tools` commands with all ts-realyer logic +- [#4076](https://github.com/ignite/cli/pull/4076) Remove the ignite `relayer` and `tools` commands with all ts-relayer logic - [#4071](https://github.com/ignite/cli/pull/4071) Support custom proto path - [#3718](https://github.com/ignite/cli/pull/3718) Add `gen-mig-diffs` tool app to compare scaffold output of two versions of ignite - [#4077](https://github.com/ignite/cli/pull/4077) Merge the swagger files manually instead use nodetime `swagger-combine`