From 69c8abaff7c00917de250ffdca7aeab30c02a96d Mon Sep 17 00:00:00 2001 From: Dan Kanefsky <56059752+boojamya@users.noreply.github.com> Date: Mon, 5 Feb 2024 08:25:54 -0800 Subject: [PATCH 1/9] Fixes and wires up `CreateClient` (#965) * createClient WIP * use chain id instead of chain name * imp hermes (cherry picked from commit 23a8755d21e5edb6f48ffe850f4eff34d0150272) # Conflicts: # relayer/rly/cosmos_relayer.go --- examples/ibc/client_creation_test.go | 143 +++++++++++++++++++++ ibc/relayer.go | 5 + relayer/docker.go | 7 + relayer/hermes/hermes_commander.go | 4 + relayer/hermes/hermes_relayer.go | 31 +++++ relayer/hyperspace/hyperspace_commander.go | 5 + relayer/rly/cosmos_relayer.go | 13 ++ 7 files changed, 208 insertions(+) create mode 100644 examples/ibc/client_creation_test.go diff --git a/examples/ibc/client_creation_test.go b/examples/ibc/client_creation_test.go new file mode 100644 index 000000000..274788a66 --- /dev/null +++ b/examples/ibc/client_creation_test.go @@ -0,0 +1,143 @@ +package ibc_test + +import ( + "context" + "testing" + + "github.com/strangelove-ventures/interchaintest/v8" + "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" + "github.com/strangelove-ventures/interchaintest/v8/ibc" + "github.com/strangelove-ventures/interchaintest/v8/testreporter" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +var ( + numVals = 1 + numFullNodes = 0 +) + +type relayerImp struct { + name string + relayerImp ibc.RelayerImplementation +} + +func TestCreatClient(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } + + t.Parallel() + + var tests = []relayerImp{ + { + name: "Cosmos Relayer", + relayerImp: ibc.CosmosRly, + }, + { + name: "Hermes", + relayerImp: ibc.Hermes, + }, + } + + for _, tt := range tests { + tt := tt + testname := tt.name + t.Run(testname, func(t *testing.T) { + t.Parallel() + + ctx := context.Background() + + chainSpec := []*interchaintest.ChainSpec{ + { + Name: "ibc-go-simd", + ChainName: "chain1", + Version: "v8.0.0", + + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + { + Name: "ibc-go-simd", + ChainName: "chain2", + Version: "v8.0.0", + + NumValidators: &numVals, + NumFullNodes: &numFullNodes, + }, + } + + chains := interchaintest.CreateChainsWithChainSpecs(t, chainSpec) + + client, network := interchaintest.DockerSetup(t) + + chain, counterpartyChain := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain) + + rf := interchaintest.NewBuiltinRelayerFactory( + tt.relayerImp, + zaptest.NewLogger(t), + ) + + r := rf.Build(t, client, network) + + pathName := "ibc-path" + + ic := interchaintest.NewInterchain(). + AddChain(chain). + AddChain(counterpartyChain). + AddRelayer(r, "relayer"). + AddLink(interchaintest.InterchainLink{ + Chain1: chain, + Chain2: counterpartyChain, + Relayer: r, + Path: pathName, + }) + + rep := testreporter.NewNopReporter() + + require.NoError(t, ic.Build(ctx, rep.RelayerExecReporter(t), interchaintest.InterchainBuildOptions{ + TestName: t.Name(), + Client: client, + NetworkID: network, + SkipPathCreation: true, + })) + t.Cleanup(func() { + _ = ic.Close() + }) + + eRep := rep.RelayerExecReporter(t) + + // Get clients for each chain + srcClientInfoBefore, err := r.GetClients(ctx, eRep, chain.Config().ChainID) + require.NoError(t, err) + destClientInfoBefore, err := r.GetClients(ctx, eRep, counterpartyChain.Config().ChainID) + require.NoError(t, err) + + require.NoError(t, + r.GeneratePath(ctx, eRep, chain.Config().ChainID, counterpartyChain.Config().ChainID, pathName)) + + // create single client + require.NoError(t, + r.CreateClient(ctx, eRep, + chain.Config().ChainID, + counterpartyChain.Config().ChainID, + pathName, ibc.CreateClientOptions{}, + ), + ) + + srcClientInfoAfter, err := r.GetClients(ctx, eRep, chain.Config().ChainID) + require.NoError(t, err) + destClientInfoAfter, err := r.GetClients(ctx, eRep, counterpartyChain.Config().ChainID) + require.NoError(t, err) + + // After creating the single client on the source chain, there should be one more client than before + require.Equal(t, len(srcClientInfoBefore), (len(srcClientInfoAfter) - 1), "there is not exactly 1 more client on the source chain after running createClient") + + // createClients should only create a client on source, NOT destination chain + require.Equal(t, len(destClientInfoBefore), len(destClientInfoAfter), "a client was created on the destination chain") + + }) + + } + +} diff --git a/ibc/relayer.go b/ibc/relayer.go index 3078c7c29..110503c43 100644 --- a/ibc/relayer.go +++ b/ibc/relayer.go @@ -81,6 +81,11 @@ type Relayer interface { // on src that tracks the state of dst, and a light client on dst that tracks the state of src. CreateClients(ctx context.Context, rep RelayerExecReporter, pathName string, opts CreateClientOptions) error + // CreateClient performs the client handshake steps necessary for creating a light client + // on src that tracks the state of dst. + // Unlike CreateClients, this only creates the client on the destination chain + CreateClient(ctx context.Context, rep RelayerExecReporter, srcChainID, dstChainID, pathName string, opts CreateClientOptions) error + // CreateConnections performs the connection handshake steps necessary for creating a connection // between the src and dst chains. CreateConnections(ctx context.Context, rep RelayerExecReporter, pathName string) error diff --git a/relayer/docker.go b/relayer/docker.go index aadd55825..874d05ce1 100644 --- a/relayer/docker.go +++ b/relayer/docker.go @@ -234,6 +234,12 @@ func (r *DockerRelayer) CreateClients(ctx context.Context, rep ibc.RelayerExecRe return res.Err } +func (r *DockerRelayer) CreateClient(ctx context.Context, rep ibc.RelayerExecReporter, srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions) error { + cmd := r.c.CreateClient(srcChainID, dstChainID, pathName, opts, r.HomeDir()) + res := r.Exec(ctx, rep, cmd, nil) + return res.Err +} + func (r *DockerRelayer) CreateConnections(ctx context.Context, rep ibc.RelayerExecReporter, pathName string) error { cmd := r.c.CreateConnections(pathName, r.HomeDir()) res := r.Exec(ctx, rep, cmd, nil) @@ -561,6 +567,7 @@ type RelayerCommander interface { CreateChannel(pathName string, opts ibc.CreateChannelOptions, homeDir string) []string CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string CreateClients(pathName string, opts ibc.CreateClientOptions, homeDir string) []string + CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string CreateConnections(pathName, homeDir string) []string Flush(pathName, channelID, homeDir string) []string GeneratePath(srcChainID, dstChainID, pathName, homeDir string) []string diff --git a/relayer/hermes/hermes_commander.go b/relayer/hermes/hermes_commander.go index e1e2c0b54..3fb1e08b2 100644 --- a/relayer/hermes/hermes_commander.go +++ b/relayer/hermes/hermes_commander.go @@ -189,6 +189,10 @@ func (c commander) CreateClients(pathName string, opts ibc.CreateClientOptions, panic("create clients implemented in hermes relayer not the commander") } +func (c commander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { + panic("create client implemented in hermes relayer not the commander") +} + func (c commander) CreateConnections(pathName string, homeDir string) []string { panic("create connections implemented in hermes relayer not the commander") } diff --git a/relayer/hermes/hermes_relayer.go b/relayer/hermes/hermes_relayer.go index 3b3985e3a..6eea0ec71 100644 --- a/relayer/hermes/hermes_relayer.go +++ b/relayer/hermes/hermes_relayer.go @@ -226,6 +226,37 @@ func (r *Relayer) CreateClients(ctx context.Context, rep ibc.RelayerExecReporter return res.Err } +func (r *Relayer) CreateClient(ctx context.Context, rep ibc.RelayerExecReporter, srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions) error { + pathConfig := r.paths[pathName] + + createClientCmd := []string{hermes, "--json", "create", "client", "--host-chain", srcChainID, "--reference-chain", dstChainID} + if opts.TrustingPeriod != "" { + createClientCmd = append(createClientCmd, "--trusting-period", opts.TrustingPeriod) + } + if opts.MaxClockDrift != "" { + createClientCmd = append(createClientCmd, "--clock-drift", opts.MaxClockDrift) + } + res := r.Exec(ctx, rep, createClientCmd, nil) + if res.Err != nil { + return res.Err + } + + clientId, err := GetClientIdFromStdout(res.Stdout) + if err != nil { + return err + } + + if pathConfig.chainA.chainID == srcChainID { + pathConfig.chainA.chainID = clientId + } else if pathConfig.chainB.chainID == srcChainID { + pathConfig.chainB.chainID = clientId + } else { + return fmt.Errorf("%s not found in path config", srcChainID) + } + + return res.Err +} + // RestoreKey restores a key from a mnemonic. In hermes, you must provide a file containing the mnemonic. We need // to copy the contents of the mnemonic into a file on disk and then reference the newly created file. func (r *Relayer) RestoreKey(ctx context.Context, rep ibc.RelayerExecReporter, cfg ibc.ChainConfig, keyName, mnemonic string) error { diff --git a/relayer/hyperspace/hyperspace_commander.go b/relayer/hyperspace/hyperspace_commander.go index 34f99dc8d..8f469d469 100644 --- a/relayer/hyperspace/hyperspace_commander.go +++ b/relayer/hyperspace/hyperspace_commander.go @@ -109,6 +109,11 @@ func (c *hyperspaceCommander) CreateClients(pathName string, opts ibc.CreateClie } } +// TODO: Implement if available in hyperspace relayer +func (hyperspaceCommander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { + panic("[CreateClient] Not Implemented") +} + func (c *hyperspaceCommander) CreateConnections(pathName, homeDir string) []string { fmt.Println("[hyperspace] CreateConnections", pathName, homeDir) _, ok := c.paths[pathName] diff --git a/relayer/rly/cosmos_relayer.go b/relayer/rly/cosmos_relayer.go index e0e35989f..9ca22c987 100644 --- a/relayer/rly/cosmos_relayer.go +++ b/relayer/rly/cosmos_relayer.go @@ -63,7 +63,11 @@ type CosmosRelayerChainConfig struct { const ( DefaultContainerImage = "ghcr.io/cosmos/relayer" +<<<<<<< HEAD DefaultContainerVersion = "v2.4.2" +======= + DefaultContainerVersion = "v2.5.0" +>>>>>>> 23a8755 (Fixes and wires up `CreateClient` (#965)) ) // Capabilities returns the set of capabilities of the Cosmos relayer. @@ -147,10 +151,19 @@ func (commander) CreateClients(pathName string, opts ibc.CreateClientOptions, ho } func (commander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { +<<<<<<< HEAD return []string{ "rly", "tx", "client", srcChainID, dstChainID, pathName, "--client-tp", opts.TrustingPeriod, "--home", homeDir, } +======= + cmd := []string{"rly", "tx", "client", srcChainID, dstChainID, pathName, "--home", homeDir} + + clientOptions := createClientOptsHelper(opts) + cmd = append(cmd, clientOptions...) + + return cmd +>>>>>>> 23a8755 (Fixes and wires up `CreateClient` (#965)) } func (commander) CreateConnections(pathName string, homeDir string) []string { From 8d85a6c429d2e18bbf1d1d36eb20a8771d4a3c91 Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Tue, 20 Feb 2024 11:48:24 -0800 Subject: [PATCH 2/9] clean up merge --- examples/ibc/client_creation_test.go | 8 ++++---- go.work.sum | 7 +------ ibc/relayer.go | 10 +++------- relayer/docker.go | 7 ------- relayer/hermes/hermes_commander.go | 4 ---- relayer/rly/cosmos_relayer.go | 11 ----------- 6 files changed, 8 insertions(+), 39 deletions(-) diff --git a/examples/ibc/client_creation_test.go b/examples/ibc/client_creation_test.go index 274788a66..02ac4b427 100644 --- a/examples/ibc/client_creation_test.go +++ b/examples/ibc/client_creation_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" - "github.com/strangelove-ventures/interchaintest/v8" - "github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" - "github.com/strangelove-ventures/interchaintest/v8/ibc" - "github.com/strangelove-ventures/interchaintest/v8/testreporter" + "github.com/strangelove-ventures/interchaintest/v7" + "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" + "github.com/strangelove-ventures/interchaintest/v7/ibc" + "github.com/strangelove-ventures/interchaintest/v7/testreporter" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) diff --git a/go.work.sum b/go.work.sum index 7d38743bd..15fab3d72 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,7 +1,2 @@ -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= -github.com/go-playground/validator v9.31.0+incompatible h1:UA72EPEogEnq76ehGdEDp4Mit+3FDh548oRqwVgNsHA= -github.com/go-playground/validator v9.31.0+incompatible/go.mod h1:yrEkQXlcI+PugkyDjY2bRrL/UBU4f3rvrgkN3V8JEig= +github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= -github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= diff --git a/ibc/relayer.go b/ibc/relayer.go index 110503c43..01f7bb0dc 100644 --- a/ibc/relayer.go +++ b/ibc/relayer.go @@ -73,19 +73,15 @@ type Relayer interface { // Flush flushes any outstanding packets and then returns. Flush(ctx context.Context, rep RelayerExecReporter, pathName string, channelID string) error - // CreateClients performs the client handshake steps necessary for creating a light client + // CreateClient performs the client handshake steps necessary for creating a light client // on src that tracks the state of dst. - CreateClient(ctx context.Context, rep RelayerExecReporter, srcChainID string, dstChainID string, pathName string, opts CreateClientOptions) error + // Unlike CreateClients, this only creates the client on the source chain + CreateClient(ctx context.Context, rep RelayerExecReporter, srcChainID, dstChainID, pathName string, opts CreateClientOptions) error // CreateClients performs the client handshake steps necessary for creating a light client // on src that tracks the state of dst, and a light client on dst that tracks the state of src. CreateClients(ctx context.Context, rep RelayerExecReporter, pathName string, opts CreateClientOptions) error - // CreateClient performs the client handshake steps necessary for creating a light client - // on src that tracks the state of dst. - // Unlike CreateClients, this only creates the client on the destination chain - CreateClient(ctx context.Context, rep RelayerExecReporter, srcChainID, dstChainID, pathName string, opts CreateClientOptions) error - // CreateConnections performs the connection handshake steps necessary for creating a connection // between the src and dst chains. CreateConnections(ctx context.Context, rep RelayerExecReporter, pathName string) error diff --git a/relayer/docker.go b/relayer/docker.go index 874d05ce1..648650a06 100644 --- a/relayer/docker.go +++ b/relayer/docker.go @@ -222,12 +222,6 @@ func (r *DockerRelayer) CreateChannel(ctx context.Context, rep ibc.RelayerExecRe return res.Err } -func (r *DockerRelayer) CreateClient(ctx context.Context, rep ibc.RelayerExecReporter, srcChainID string, dstChainID string, pathName string, opts ibc.CreateClientOptions) error { - cmd := r.c.CreateClient(srcChainID, dstChainID, pathName, opts, r.HomeDir()) - res := r.Exec(ctx, rep, cmd, nil) - return res.Err -} - func (r *DockerRelayer) CreateClients(ctx context.Context, rep ibc.RelayerExecReporter, pathName string, opts ibc.CreateClientOptions) error { cmd := r.c.CreateClients(pathName, opts, r.HomeDir()) res := r.Exec(ctx, rep, cmd, nil) @@ -567,7 +561,6 @@ type RelayerCommander interface { CreateChannel(pathName string, opts ibc.CreateChannelOptions, homeDir string) []string CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string CreateClients(pathName string, opts ibc.CreateClientOptions, homeDir string) []string - CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string CreateConnections(pathName, homeDir string) []string Flush(pathName, channelID, homeDir string) []string GeneratePath(srcChainID, dstChainID, pathName, homeDir string) []string diff --git a/relayer/hermes/hermes_commander.go b/relayer/hermes/hermes_commander.go index 3fb1e08b2..e1e2c0b54 100644 --- a/relayer/hermes/hermes_commander.go +++ b/relayer/hermes/hermes_commander.go @@ -189,10 +189,6 @@ func (c commander) CreateClients(pathName string, opts ibc.CreateClientOptions, panic("create clients implemented in hermes relayer not the commander") } -func (c commander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { - panic("create client implemented in hermes relayer not the commander") -} - func (c commander) CreateConnections(pathName string, homeDir string) []string { panic("create connections implemented in hermes relayer not the commander") } diff --git a/relayer/rly/cosmos_relayer.go b/relayer/rly/cosmos_relayer.go index 9ca22c987..ca51bf409 100644 --- a/relayer/rly/cosmos_relayer.go +++ b/relayer/rly/cosmos_relayer.go @@ -63,11 +63,7 @@ type CosmosRelayerChainConfig struct { const ( DefaultContainerImage = "ghcr.io/cosmos/relayer" -<<<<<<< HEAD - DefaultContainerVersion = "v2.4.2" -======= DefaultContainerVersion = "v2.5.0" ->>>>>>> 23a8755 (Fixes and wires up `CreateClient` (#965)) ) // Capabilities returns the set of capabilities of the Cosmos relayer. @@ -151,19 +147,12 @@ func (commander) CreateClients(pathName string, opts ibc.CreateClientOptions, ho } func (commander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { -<<<<<<< HEAD - return []string{ - "rly", "tx", "client", srcChainID, dstChainID, pathName, "--client-tp", opts.TrustingPeriod, - "--home", homeDir, - } -======= cmd := []string{"rly", "tx", "client", srcChainID, dstChainID, pathName, "--home", homeDir} clientOptions := createClientOptsHelper(opts) cmd = append(cmd, clientOptions...) return cmd ->>>>>>> 23a8755 (Fixes and wires up `CreateClient` (#965)) } func (commander) CreateConnections(pathName string, homeDir string) []string { From b94e8fd152326dfb10bf05c67393843d9e0c990c Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Thu, 21 Dec 2023 21:01:50 -0800 Subject: [PATCH 3/9] add create client options --- ibc/relayer.go | 29 +++++++++++++++++++++-------- ibc/relayer_test.go | 28 ++++++++++++++++++++++++++++ relayer/rly/cosmos_relayer.go | 34 +++++++++++++++++++++++++++------- 3 files changed, 76 insertions(+), 15 deletions(-) diff --git a/ibc/relayer.go b/ibc/relayer.go index 01f7bb0dc..ef4e766a2 100644 --- a/ibc/relayer.go +++ b/ibc/relayer.go @@ -273,23 +273,36 @@ func (o Order) Validate() error { } // CreateClientOptions contains the configuration for creating a client. + +// a zero value is the same as not specifying the flag and will use the relayer defauls type CreateClientOptions struct { - TrustingPeriod string + TrustingPeriod string + TrustingPeriodPercentage int64 + MaxClockDrift string } // DefaultClientOpts returns the default settings for creating clients. -// These default options are usually determined by the relayer + +// empty values will use the relayer defaults func DefaultClientOpts() CreateClientOptions { - return CreateClientOptions{ - TrustingPeriod: "0", - } + return CreateClientOptions{} } func (opts CreateClientOptions) Validate() error { - _, err := time.ParseDuration(opts.TrustingPeriod) - if err != nil { - return err + if opts.TrustingPeriod != "" { + _, err := time.ParseDuration(opts.TrustingPeriod) + if err != nil { + return err + } } + + if opts.MaxClockDrift != "" { + _, err := time.ParseDuration(opts.MaxClockDrift) + if err != nil { + return err + } + } + return nil } diff --git a/ibc/relayer_test.go b/ibc/relayer_test.go index 333de7147..4c13b94d2 100644 --- a/ibc/relayer_test.go +++ b/ibc/relayer_test.go @@ -34,3 +34,31 @@ func TestChannelOptsConfigured(t *testing.T) { } require.Error(t, opts.Validate()) } + +func TestClientOptsConfigured(t *testing.T) { + // Test the default client opts + opts := DefaultClientOpts() + require.NoError(t, opts.Validate()) + + // Test empty struct channel opts + opts = CreateClientOptions{} + require.NoError(t, opts.Validate()) + + // Test partial client opts + opts = CreateClientOptions{ + MaxClockDrift: "5m", + } + require.NoError(t, opts.Validate()) + + // Test invalid MaxClockDrift + opts = CreateClientOptions{ + MaxClockDrift: "invalid duration", + } + require.Error(t, opts.Validate()) + + // Test invalid TrustingPeriod + opts = CreateClientOptions{ + TrustingPeriod: "invalid duration", + } + require.Error(t, opts.Validate()) +} diff --git a/relayer/rly/cosmos_relayer.go b/relayer/rly/cosmos_relayer.go index ca51bf409..e09785e65 100644 --- a/relayer/rly/cosmos_relayer.go +++ b/relayer/rly/cosmos_relayer.go @@ -139,11 +139,28 @@ func (commander) CreateChannel(pathName string, opts ibc.CreateChannelOptions, h } } -func (commander) CreateClients(pathName string, opts ibc.CreateClientOptions, homeDir string) []string { - return []string{ - "rly", "tx", "clients", pathName, "--client-tp", opts.TrustingPeriod, - "--home", homeDir, +func createClientOptsHelper(opts ibc.CreateClientOptions) []string { + var clientOptions []string + if opts.TrustingPeriod != "" { + clientOptions = append(clientOptions, "--client-tp", opts.TrustingPeriod) } + if opts.TrustingPeriodPercentage != 0 { + clientOptions = append(clientOptions, "--client-tp-percentage", fmt.Sprint(opts.TrustingPeriodPercentage)) + } + if opts.MaxClockDrift != "" { + clientOptions = append(clientOptions, "--max-clock-drift", opts.MaxClockDrift) + } + + return clientOptions +} + +func (commander) CreateClients(pathName string, opts ibc.CreateClientOptions, homeDir string) []string { + cmd := []string{"rly", "tx", "clients", pathName, "--home", homeDir} + + clientOptions := createClientOptsHelper(opts) + cmd = append(cmd, clientOptions...) + + return cmd } func (commander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { @@ -237,17 +254,20 @@ func (commander) GetClients(chainID, homeDir string) []string { } func (commander) LinkPath(pathName, homeDir string, channelOpts ibc.CreateChannelOptions, clientOpt ibc.CreateClientOptions) []string { - return []string{ + cmd := []string{ "rly", "tx", "link", pathName, "--src-port", channelOpts.SourcePortName, "--dst-port", channelOpts.DestPortName, "--order", channelOpts.Order.String(), "--version", channelOpts.Version, - "--client-tp", clientOpt.TrustingPeriod, "--debug", - "--home", homeDir, } + + clientOptions := createClientOptsHelper(clientOpt) + cmd = append(cmd, clientOptions...) + + return cmd } func (commander) RestoreKey(chainID, keyName, coinType, mnemonic, homeDir string) []string { From 78080e17f7be5f8f678c61b0fefacaf80dadb3c8 Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Thu, 21 Dec 2023 21:56:48 -0800 Subject: [PATCH 4/9] hermes --- ibc/relayer.go | 2 +- relayer/hermes/hermes_relayer.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ibc/relayer.go b/ibc/relayer.go index ef4e766a2..b26333381 100644 --- a/ibc/relayer.go +++ b/ibc/relayer.go @@ -277,7 +277,7 @@ func (o Order) Validate() error { // a zero value is the same as not specifying the flag and will use the relayer defauls type CreateClientOptions struct { TrustingPeriod string - TrustingPeriodPercentage int64 + TrustingPeriodPercentage int64 // only available for Go Relayer MaxClockDrift string } diff --git a/relayer/hermes/hermes_relayer.go b/relayer/hermes/hermes_relayer.go index 6eea0ec71..32c004333 100644 --- a/relayer/hermes/hermes_relayer.go +++ b/relayer/hermes/hermes_relayer.go @@ -194,9 +194,13 @@ func (r *Relayer) UpdateClients(ctx context.Context, rep ibc.RelayerExecReporter func (r *Relayer) CreateClients(ctx context.Context, rep ibc.RelayerExecReporter, pathName string, opts ibc.CreateClientOptions) error { pathConfig := r.paths[pathName] chainACreateClientCmd := []string{hermes, "--json", "create", "client", "--host-chain", pathConfig.chainA.chainID, "--reference-chain", pathConfig.chainB.chainID} - if opts.TrustingPeriod != "0" { + if opts.TrustingPeriod != "" { chainACreateClientCmd = append(chainACreateClientCmd, "--trusting-period", opts.TrustingPeriod) } + if opts.MaxClockDrift != "" { + chainACreateClientCmd = append(chainACreateClientCmd, "--clock-drift", opts.MaxClockDrift) + } + // TODO: add other CreateClientOptions res := r.Exec(ctx, rep, chainACreateClientCmd, nil) if res.Err != nil { return res.Err @@ -209,9 +213,12 @@ func (r *Relayer) CreateClients(ctx context.Context, rep ibc.RelayerExecReporter pathConfig.chainA.clientID = chainAClientId chainBCreateClientCmd := []string{hermes, "--json", "create", "client", "--host-chain", pathConfig.chainB.chainID, "--reference-chain", pathConfig.chainA.chainID} - if opts.TrustingPeriod != "0" { + if opts.TrustingPeriod != "" { chainBCreateClientCmd = append(chainBCreateClientCmd, "--trusting-period", opts.TrustingPeriod) } + if opts.MaxClockDrift != "" { + chainBCreateClientCmd = append(chainBCreateClientCmd, "--clock-drift", opts.MaxClockDrift) + } res = r.Exec(ctx, rep, chainBCreateClientCmd, nil) if res.Err != nil { return res.Err From da75a4d2e01c1866ac388bb8c4ba1b6f3f4e580e Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Thu, 21 Dec 2023 22:10:40 -0800 Subject: [PATCH 5/9] remove comment --- relayer/hermes/hermes_relayer.go | 1 - 1 file changed, 1 deletion(-) diff --git a/relayer/hermes/hermes_relayer.go b/relayer/hermes/hermes_relayer.go index 32c004333..f8f4fb2b2 100644 --- a/relayer/hermes/hermes_relayer.go +++ b/relayer/hermes/hermes_relayer.go @@ -200,7 +200,6 @@ func (r *Relayer) CreateClients(ctx context.Context, rep ibc.RelayerExecReporter if opts.MaxClockDrift != "" { chainACreateClientCmd = append(chainACreateClientCmd, "--clock-drift", opts.MaxClockDrift) } - // TODO: add other CreateClientOptions res := r.Exec(ctx, rep, chainACreateClientCmd, nil) if res.Err != nil { return res.Err From 7117331e00694ba3873c0b6eb9dd8ba84bb39c9b Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Thu, 21 Dec 2023 22:16:18 -0800 Subject: [PATCH 6/9] fix comment --- ibc/relayer_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibc/relayer_test.go b/ibc/relayer_test.go index 4c13b94d2..b1908bea7 100644 --- a/ibc/relayer_test.go +++ b/ibc/relayer_test.go @@ -40,7 +40,7 @@ func TestClientOptsConfigured(t *testing.T) { opts := DefaultClientOpts() require.NoError(t, opts.Validate()) - // Test empty struct channel opts + // Test empty struct client opts opts = CreateClientOptions{} require.NoError(t, opts.Validate()) From db8da12ad0ccabf547037ee2e7161655fd20b163 Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Tue, 20 Feb 2024 11:52:04 -0800 Subject: [PATCH 7/9] clean up hyperspace --- relayer/hyperspace/hyperspace_commander.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/relayer/hyperspace/hyperspace_commander.go b/relayer/hyperspace/hyperspace_commander.go index 8f469d469..12a9fef57 100644 --- a/relayer/hyperspace/hyperspace_commander.go +++ b/relayer/hyperspace/hyperspace_commander.go @@ -81,10 +81,6 @@ func (c *hyperspaceCommander) CreateChannel(pathName string, opts ibc.CreateChan } } -func (c *hyperspaceCommander) CreateClient(srcChainID, dstChainID, pathName string, opts ibc.CreateClientOptions, homeDir string) []string { - panic("[CreateClient] do not call me") -} - func (c *hyperspaceCommander) CreateClients(pathName string, opts ibc.CreateClientOptions, homeDir string) []string { fmt.Println("[hyperspace] CreateClients", pathName, opts, homeDir) _, ok := c.paths[pathName] From bdee086f21477e77b6d7c6945237d5f02c8a3a35 Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Tue, 20 Feb 2024 11:57:37 -0800 Subject: [PATCH 8/9] simd version in test --- examples/ibc/client_creation_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ibc/client_creation_test.go b/examples/ibc/client_creation_test.go index 02ac4b427..d11b44a82 100644 --- a/examples/ibc/client_creation_test.go +++ b/examples/ibc/client_creation_test.go @@ -52,7 +52,7 @@ func TestCreatClient(t *testing.T) { { Name: "ibc-go-simd", ChainName: "chain1", - Version: "v8.0.0", + Version: "v7.2.0", NumValidators: &numVals, NumFullNodes: &numFullNodes, @@ -60,7 +60,7 @@ func TestCreatClient(t *testing.T) { { Name: "ibc-go-simd", ChainName: "chain2", - Version: "v8.0.0", + Version: "v7.2.0", NumValidators: &numVals, NumFullNodes: &numFullNodes, From 4cc1bb80fba2dc0583bfcc3cbb27fecfbc1244fd Mon Sep 17 00:00:00 2001 From: Dan Kanefsky Date: Tue, 20 Feb 2024 12:05:33 -0800 Subject: [PATCH 9/9] mod tidy --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ac89a5ea1..25be96b63 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect - cosmossdk.io/api v0.3.1 // indirect + cosmossdk.io/api v0.3.1 cosmossdk.io/core v0.6.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/errors v1.0.0 // indirect