diff --git a/.github/workflows/interchaintest.yml b/.github/workflows/interchaintest.yml index 4d5725255..e702cc21c 100644 --- a/.github/workflows/interchaintest.yml +++ b/.github/workflows/interchaintest.yml @@ -10,9 +10,10 @@ jobs: runs-on: self-hosted steps: - name: Set up Go 1.20 - uses: actions/setup-go@v4 + uses: actions/setup-go@v1 with: - go-version: '1.20' + go-version: 1.20 + id: go - name: checkout relayer uses: actions/checkout@v2 @@ -31,9 +32,10 @@ jobs: runs-on: self-hosted steps: - name: Set up Go 1.20 - uses: actions/setup-go@v4 + uses: actions/setup-go@v1 with: - go-version: '1.20' + go-version: 1.20 + id: go - name: checkout relayer uses: actions/checkout@v2 @@ -52,9 +54,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.20 - uses: actions/setup-go@v4 + uses: actions/setup-go@v1 with: - go-version: '1.20' + go-version: 1.20 + id: go - name: checkout relayer uses: actions/checkout@v2 @@ -136,9 +139,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.20 - uses: actions/setup-go@v4 + uses: actions/setup-go@v1 with: - go-version: '1.20' + go-version: 1.20 + id: go - name: checkout relayer uses: actions/checkout@v2 @@ -151,4 +155,4 @@ jobs: ${{ runner.os }}-go- - name: interchaintest - run: make interchaintest-scenario \ No newline at end of file + run: make interchaintest-scenario diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97ca73ced..a9464f16b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: 1.20 - run: echo https://github.com/cosmos/relayer/blob/${GITHUB_REF#refs/tags/}/CHANGELOG.md#${GITHUB_REF#refs/tags/} > ../release_notes.md diff --git a/cmd/appstate.go b/cmd/appstate.go index 578ad4bf7..4d739e4ae 100644 --- a/cmd/appstate.go +++ b/cmd/appstate.go @@ -194,19 +194,9 @@ func (a *appState) performConfigLockingOperation(ctx context.Context, operation return fmt.Errorf("failed to initialize config from file: %w", err) } - path, ok := a.Config.Paths[pathName] - - if !ok { - return fmt.Errorf("config does not exist for that path: %s", pathName) - } - if clientSrc != "" { - path.Src.ClientID = clientSrc - } - if clientDst != "" { - path.Dst.ClientID = clientDst - } - if connectionSrc != "" { - path.Src.ConnectionID = connectionSrc + // perform the operation that requires config flock. + if err := operation(); err != nil { + return err } // validate config after changes have been made. @@ -226,12 +216,13 @@ func (a *appState) performConfigLockingOperation(ctx context.Context, operation if err := os.WriteFile(cfgPath, out, 0600); err != nil { return fmt.Errorf("failed to write config file at %s: %w", cfgPath, err) } + return nil } func (a *appState) GetConfigProviderNameFromChainId(chainId string) (string, error) { - chains := a.Config.Chains + chains := a.config.Chains for k, v := range chains { if v.ChainID() == chainId { return k, nil @@ -242,7 +233,7 @@ func (a *appState) GetConfigProviderNameFromChainId(chainId string) (string, err } func (a *appState) CheckIfProviderType(providerName string, providerType string) bool { - providers := a.Config.Wrapped() + providers := a.config.Wrapped() for p, v := range providers.ProviderConfigs { if p == providerName && v.Type == providerType { return true @@ -251,121 +242,154 @@ func (a *appState) CheckIfProviderType(providerName string, providerType string) return false } -func (a *appState) UpdateConfigsIfContainIcon(cmd *cobra.Command, src *relayer.Chain, dst *relayer.Chain) error { +// func (a *appState) UpdateConfigsIfContainIcon(cmd *cobra.Command, src *relayer.Chain, dst *relayer.Chain) error { + +// ctx := context.Background() +// eg, egCtx := errgroup.WithContext(ctx) + +// eg.Go(func() error { +// var err error +// err = a.UpdateProviderIfIcon(cmd, egCtx, src) +// if err != nil { +// return err +// } + +// return nil + +// }) +// eg.Go(func() error { +// var err error +// err = a.UpdateProviderIfIcon(cmd, egCtx, dst) +// if err != nil { +// return err +// } +// return nil + +// }) + +// if err := eg.Wait(); err != nil { +// return err +// } + +// return nil + +// } + +// func (a *appState) UpdateProviderIfIcon(cmd *cobra.Command, ctx context.Context, chain *relayer.Chain) error { + +// providerName, err := a.GetConfigProviderNameFromChainId(chain.ChainID()) +// if err != nil { +// return err +// } + +// if !a.CheckIfProviderType(providerName, "icon") { +// return nil +// } +// // height, err := chain.ChainProvider.QueryLatestHeight(ctx) +// // if err != nil { +// // return errors.New(fmt.Sprintf("Error fetching chain latest height %s ", chain.ChainID())) +// // } + +// // err = a.OverwriteChainConfig(cmd, providerName, "btpHeight", height) +// // if err != nil { +// // return errors.New(fmt.Sprintf("Error updating BTPHeight of config of chain %s ", chain.ChainID())) +// // } +// return nil +// } + +// func (a *appState) OverwriteChainConfig( +// cmd *cobra.Command, +// providerName string, +// fieldName string, +// fieldValue interface{}, +// ) error { + +// // use lock file to guard concurrent access to config.yaml +// lockFilePath := path.Join(a.homePath, "config", "config.lock") +// fileLock := flock.New(lockFilePath) +// err := fileLock.Lock() +// if err != nil { +// return fmt.Errorf("failed to acquire config lock: %w", err) +// } +// defer func() { +// if err := fileLock.Unlock(); err != nil { +// a.Log.Error("error unlocking config file lock, please manually delete", +// zap.String("filepath", lockFilePath), +// ) +// } +// }() + +// if err := initConfig(cmd, a); err != nil { +// return fmt.Errorf("failed to initialize config from file: %w", err) +// } + +// wrappedConfig := a.config.Wrapped() +// err = setProviderConfigField(wrappedConfig, providerName, fieldName, fieldValue) +// if err != nil { +// return err +// } + +// out, err := yaml.Marshal(wrappedConfig) +// if err != nil { +// return err +// } + +// cfgPath := a.viper.ConfigFileUsed() + +// // Overwrite the config file. +// if err := os.WriteFile(cfgPath, out, 0600); err != nil { +// return fmt.Errorf("failed to write config file at %s: %w", cfgPath, err) +// } + +// return nil +// } + +// func setProviderConfigField(cfg *ConfigOutputWrapper, providerName string, fieldToChange string, newValue interface{}) error { +// providerConfigs := cfg.ProviderConfigs +// providerConfigWrapper, ok := providerConfigs[providerName] +// if !ok { +// return fmt.Errorf("ProviderConfigWrapper %s not found", providerName) +// } +// providerConfigValue := providerConfigWrapper.Value +// if err := providerConfigValue.Set(fieldToChange, newValue); err != nil { +// return err +// } +// providerConfigWrapper.Value = providerConfigValue + +// return nil +// } - ctx := context.Background() - eg, egCtx := errgroup.WithContext(ctx) +// updatePathConfig overwrites the config file concurrently, +// locking to read, modify, then write the config. +func (a *appState) updatePathConfig( + ctx context.Context, + pathName string, + clientSrc, clientDst string, + connectionSrc, connectionDst string, +) error { + if pathName == "" { + return errors.New("empty path name not allowed") + } - eg.Go(func() error { - var err error - err = a.UpdateProviderIfIcon(cmd, egCtx, src) - if err != nil { - return err + return a.performConfigLockingOperation(ctx, func() error { + path, ok := a.config.Paths[pathName] + if !ok { + return fmt.Errorf("config does not exist for that path: %s", pathName) } - - return nil - - }) - eg.Go(func() error { - var err error - err = a.UpdateProviderIfIcon(cmd, egCtx, dst) - if err != nil { - return err + if clientSrc != "" { + path.Src.ClientID = clientSrc + } + if clientDst != "" { + path.Dst.ClientID = clientDst + } + if connectionSrc != "" { + path.Src.ConnectionID = connectionSrc + } + if connectionDst != "" { + path.Dst.ConnectionID = connectionDst } return nil - }) - - if err := eg.Wait(); err != nil { - return err - } - - return nil - -} - -func (a *appState) UpdateProviderIfIcon(cmd *cobra.Command, ctx context.Context, chain *relayer.Chain) error { - - providerName, err := a.GetConfigProviderNameFromChainId(chain.ChainID()) - if err != nil { - return err - } - - if !a.CheckIfProviderType(providerName, "icon") { - return nil - } - height, err := chain.ChainProvider.QueryLatestHeight(ctx) - if err != nil { - return errors.New(fmt.Sprintf("Error fetching chain latest height %s ", chain.ChainID())) - } - - err = a.OverwriteChainConfig(cmd, providerName, "btpHeight", height) - if err != nil { - return errors.New(fmt.Sprintf("Error updating BTPHeight of config of chain %s ", chain.ChainID())) - } - return nil -} - -func (a *appState) OverwriteChainConfig( - cmd *cobra.Command, - providerName string, - fieldName string, - fieldValue interface{}, -) error { - - // use lock file to guard concurrent access to config.yaml - lockFilePath := path.Join(a.HomePath, "config", "config.lock") - fileLock := flock.New(lockFilePath) - err := fileLock.Lock() - if err != nil { - return fmt.Errorf("failed to acquire config lock: %w", err) - } - defer func() { - if err := fileLock.Unlock(); err != nil { - a.Log.Error("error unlocking config file lock, please manually delete", - zap.String("filepath", lockFilePath), - ) - } - }() - - if err := initConfig(cmd, a); err != nil { - return fmt.Errorf("failed to initialize config from file: %w", err) - } - - wrappedConfig := a.Config.Wrapped() - err = setProviderConfigField(wrappedConfig, providerName, fieldName, fieldValue) - if err != nil { - return err - } - - out, err := yaml.Marshal(wrappedConfig) - if err != nil { - return err - } - - cfgPath := a.Viper.ConfigFileUsed() - - // Overwrite the config file. - if err := os.WriteFile(cfgPath, out, 0600); err != nil { - return fmt.Errorf("failed to write config file at %s: %w", cfgPath, err) - } - - return nil -} - -func setProviderConfigField(cfg *ConfigOutputWrapper, providerName string, fieldToChange string, newValue interface{}) error { - providerConfigs := cfg.ProviderConfigs - providerConfigWrapper, ok := providerConfigs[providerName] - if !ok { - return fmt.Errorf("ProviderConfigWrapper %s not found", providerName) - } - providerConfigValue := providerConfigWrapper.Value - if err := providerConfigValue.Set(fieldToChange, newValue); err != nil { - return err - } - providerConfigWrapper.Value = providerConfigValue - - return nil } // updatePathConfig overwrites the config file concurrently, diff --git a/cmd/config.go b/cmd/config.go index 0585a9d3b..6582fd7f8 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -443,6 +443,8 @@ func (iw *ProviderConfigYAMLWrapper) UnmarshalYAML(n *yaml.Node) error { iw.Value = new(penumbra.PenumbraProviderConfig) case "archway": iw.Value = new(archway.ArchwayProviderConfig) + case "penumbra": + iw.Value = new(penumbra.PenumbraProviderConfig) default: return fmt.Errorf("%s is an invalid chain type, check your config file", iw.Type) } diff --git a/cmd/tx.go b/cmd/tx.go index a50aa5acf..8aa9e74d1 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -105,7 +105,7 @@ func createClientsCmd(a *appState) *cobra.Command { return fmt.Errorf("key %s not found on dst chain %s", c[dst].ChainProvider.Key(), c[dst].ChainID()) } - clientSrc, clientDst, err := c[src].CreateClients(cmd.Context(), c[dst], allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, override, customClientTrustingPeriod, a.Config.memo(cmd), iconStartHeight) + clientSrc, clientDst, err := c[src].CreateClients(cmd.Context(), c[dst], allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, override, customClientTrustingPeriod, a.config.memo(cmd), iconStartHeight) if err != nil { return err } @@ -124,10 +124,10 @@ func createClientsCmd(a *appState) *cobra.Command { }, } - cmd = clientParameterFlags(a.Viper, cmd) - cmd = overrideFlag(a.Viper, cmd) - cmd = memoFlag(a.Viper, cmd) - cmd = iconStartHeightFlag(a.Viper, cmd) + cmd = clientParameterFlags(a.viper, cmd) + cmd = overrideFlag(a.viper, cmd) + cmd = memoFlag(a.viper, cmd) + cmd = iconStartHeightFlag(a.viper, cmd) return cmd } @@ -236,7 +236,7 @@ func createClientCmd(a *appState) *cobra.Command { return err } - clientID, err := relayer.CreateClient(cmd.Context(), src, dst, srcUpdateHeader, dstUpdateHeader, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, override, customClientTrustingPeriod, a.Config.memo(cmd), iconStartHeight) + clientID, err := relayer.CreateClient(cmd.Context(), src, dst, srcUpdateHeader, dstUpdateHeader, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour, override, customClientTrustingPeriod, a.config.memo(cmd), iconStartHeight) if err != nil { return err } @@ -256,10 +256,10 @@ func createClientCmd(a *appState) *cobra.Command { }, } - cmd = clientParameterFlags(a.Viper, cmd) - cmd = overrideFlag(a.Viper, cmd) - cmd = memoFlag(a.Viper, cmd) - cmd = iconStartHeightFlag(a.Viper, cmd) + cmd = clientParameterFlags(a.viper, cmd) + cmd = overrideFlag(a.viper, cmd) + cmd = memoFlag(a.viper, cmd) + cmd = iconStartHeightFlag(a.viper, cmd) return cmd } @@ -440,13 +440,13 @@ $ %s tx conn demo-path --timeout 5s`, }, } - cmd = timeoutFlag(a.Viper, cmd) - cmd = retryFlag(a.Viper, cmd) - cmd = clientParameterFlags(a.Viper, cmd) - cmd = overrideFlag(a.Viper, cmd) - cmd = memoFlag(a.Viper, cmd) - cmd = initBlockFlag(a.Viper, cmd) - cmd = iconStartHeightFlag(a.Viper, cmd) + cmd = timeoutFlag(a.viper, cmd) + cmd = retryFlag(a.viper, cmd) + cmd = clientParameterFlags(a.viper, cmd) + cmd = overrideFlag(a.viper, cmd) + cmd = memoFlag(a.viper, cmd) + cmd = initBlockFlag(a.viper, cmd) + cmd = iconStartHeightFlag(a.viper, cmd) return cmd } @@ -517,12 +517,7 @@ $ %s tx chan demo-path --timeout 5s --max-retries 10`, } // create channel if it isn't already created - err = c[src].CreateOpenChannels(cmd.Context(), c[dst], retries, to, srcPort, dstPort, order, version, override, a.Config.memo(cmd), pathName) - if err != nil { - return err - } - - return nil + return c[src].CreateOpenChannels(cmd.Context(), c[dst], retries, to, srcPort, dstPort, order, version, override, a.config.memo(cmd), pathName) }, } @@ -723,14 +718,14 @@ $ %s tx connect demo-path --src-port mock --dst-port mock --order unordered --ve return c[src].CreateOpenChannels(cmd.Context(), c[dst], retries, to, srcPort, dstPort, order, version, override, memo, pathName) }, } - cmd = timeoutFlag(a.Viper, cmd) - cmd = retryFlag(a.Viper, cmd) - cmd = clientParameterFlags(a.Viper, cmd) - cmd = channelParameterFlags(a.Viper, cmd) - cmd = overrideFlag(a.Viper, cmd) - cmd = memoFlag(a.Viper, cmd) - cmd = initBlockFlag(a.Viper, cmd) - cmd = iconStartHeightFlag(a.Viper, cmd) + cmd = timeoutFlag(a.viper, cmd) + cmd = retryFlag(a.viper, cmd) + cmd = clientParameterFlags(a.viper, cmd) + cmd = channelParameterFlags(a.viper, cmd) + cmd = overrideFlag(a.viper, cmd) + cmd = memoFlag(a.viper, cmd) + cmd = initBlockFlag(a.viper, cmd) + cmd = iconStartHeightFlag(a.viper, cmd) return cmd } diff --git a/go.mod b/go.mod index 6400167e7..13f8c691f 100644 --- a/go.mod +++ b/go.mod @@ -5,18 +5,19 @@ go 1.19 require ( cosmossdk.io/api v0.3.1 cosmossdk.io/errors v1.0.0-beta.7 - cosmossdk.io/math v1.0.0 - github.com/CosmWasm/wasmd v1.0.0 + cosmossdk.io/math v1.0.1 + github.com/CosmWasm/wasmd v0.0.0-00010101000000-000000000000 github.com/avast/retry-go/v4 v4.3.3 - github.com/btcsuite/btcd v0.22.1 - github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce + github.com/btcsuite/btcd v0.23.4 + github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cometbft/cometbft v0.37.1 github.com/cosmos/cosmos-proto v1.0.0-beta.2 - github.com/cosmos/cosmos-sdk v0.47.1 + github.com/cosmos/cosmos-sdk v0.47.3 github.com/cosmos/go-bip39 v1.0.0 - github.com/cosmos/gogoproto v1.4.8 - github.com/cosmos/ibc-go/v7 v7.0.0 - github.com/ethereum/go-ethereum v1.11.4 + github.com/cosmos/gogoproto v1.4.10 + github.com/cosmos/ibc-go/v7 v7.1.0-rc0 + github.com/cosmos/ics23/go v0.10.0 + github.com/ethereum/go-ethereum v1.10.26 github.com/gofrs/flock v0.8.1 github.com/gogo/protobuf v1.3.3 github.com/google/go-cmp v0.5.9 @@ -38,9 +39,8 @@ require ( golang.org/x/crypto v0.8.0 golang.org/x/mod v0.10.0 golang.org/x/sync v0.1.0 - golang.org/x/term v0.7.0 golang.org/x/text v0.9.0 - google.golang.org/grpc v1.54.0 + google.golang.org/grpc v1.55.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 @@ -54,6 +54,7 @@ require ( cloud.google.com/go/storage v1.29.0 // indirect cosmossdk.io/core v0.5.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.3 // indirect + cosmossdk.io/log v1.1.0 // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -80,8 +81,7 @@ require ( github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v0.20.0 // indirect - github.com/cosmos/ics23/go v0.9.1-0.20221207100636-b1abd8678aab // indirect - github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect + github.com/cosmos/ledger-cosmos-go v0.12.1 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/creachadair/taskgroup v0.4.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -97,7 +97,6 @@ require ( github.com/evalphobia/logrus_fluent v0.5.4 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fluent/fluent-logger-golang v1.4.0 // indirect - github.com/frankban/quicktest v1.14.4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -126,7 +125,7 @@ require ( github.com/gtank/ristretto255 v0.1.2 // indirect github.com/haltingstate/secp256k1-go v0.0.0-20151224084235-572209b26df6 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.0 // indirect + github.com/hashicorp/go-getter v1.7.1 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect @@ -157,16 +156,16 @@ require ( github.com/mtibben/percent v0.2.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.0.7 // indirect - github.com/petermattis/goid v0.0.0-20221215004737-a150e88a970d // indirect - github.com/philhofer/fwd v1.1.1 // indirect + github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect + github.com/philhofer/fwd v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect github.com/rakyll/statik v0.1.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/rivo/uniseg v0.4.4 // indirect github.com/rs/cors v1.8.3 // indirect + github.com/rs/zerolog v1.29.1 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/afero v1.9.3 // indirect @@ -178,8 +177,7 @@ require ( github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect - github.com/tinylib/msgp v1.1.5 // indirect - github.com/tklauser/numcpus v0.4.0 // indirect + github.com/tinylib/msgp v1.1.2 // indirect github.com/ulikunitz/xz v0.5.11 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.1 // indirect @@ -190,14 +188,15 @@ require ( go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/atomic v1.10.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/net v0.9.0 // indirect - golang.org/x/oauth2 v0.5.0 // indirect + golang.org/x/oauth2 v0.6.0 // indirect golang.org/x/sys v0.7.0 // indirect + golang.org/x/term v0.7.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.110.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 // indirect + google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect diff --git a/relayer/chains/archway/helper_debug_msg.go b/relayer/chains/archway/helper_debug_msg.go index 953a8fb12..6b56179de 100644 --- a/relayer/chains/archway/helper_debug_msg.go +++ b/relayer/chains/archway/helper_debug_msg.go @@ -29,7 +29,6 @@ func jsonDumpDataFile(filename string, bufs interface{}) { os.Exit(1) } - fmt.Printf("Successfully created or appended JSON in %s \n", filename) } func readExistingData(filename string, opPointer interface{}) error { diff --git a/relayer/chains/archway/keys.go b/relayer/chains/archway/keys.go index 0bb844d6c..061a6434c 100644 --- a/relayer/chains/archway/keys.go +++ b/relayer/chains/archway/keys.go @@ -58,8 +58,8 @@ func (cc *ArchwayProvider) KeystoreCreated(path string) bool { // AddKey generates a new mnemonic which is then converted to a private key and BIP-39 HD Path and persists it to the keystore. // It fails if there is an existing key with the same address. -func (cc *ArchwayProvider) AddKey(name string, coinType uint32) (output *provider.KeyOutput, err error) { - ko, err := cc.KeyAddOrRestore(name, coinType) +func (cc *ArchwayProvider) AddKey(name string, coinType uint32, signingAlgorithm string) (output *provider.KeyOutput, err error) { + ko, err := cc.KeyAddOrRestore(name, coinType, signingAlgorithm) if err != nil { return nil, err } @@ -68,7 +68,7 @@ func (cc *ArchwayProvider) AddKey(name string, coinType uint32) (output *provide // RestoreKey converts a mnemonic to a private key and BIP-39 HD Path and persists it to the keystore. // It fails if there is an existing key with the same address. -func (cc *ArchwayProvider) RestoreKey(name, mnemonic string, coinType uint32) (address string, err error) { +func (cc *ArchwayProvider) RestoreKey(name, mnemonic string, coinType uint32, signingAlgorithm string) (address string, err error) { ko, err := cc.KeyAddOrRestore(name, coinType, mnemonic) if err != nil { return "", err diff --git a/relayer/chains/archway/provider.go b/relayer/chains/archway/provider.go index d37894f03..c4faf750a 100644 --- a/relayer/chains/archway/provider.go +++ b/relayer/chains/archway/provider.go @@ -191,11 +191,6 @@ func (pp *ArchwayProviderConfig) Validate() error { return nil } -func (pp *ArchwayProviderConfig) Set(field string, value interface{}) error { - // TODO: implement - return nil -} - func (pp *ArchwayProviderConfig) getRPCAddr() string { return pp.RPCAddr } @@ -452,6 +447,10 @@ func (ap *ArchwayProvider) updateNextAccountSequence(seq uint64) { } } +func (app *ArchwayProvider) MsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayeeAddr string) (provider.RelayerMessage, error) { + return nil, fmt.Errorf("Not implemented for Icon") +} + // keysDir returns a string representing the path on the local filesystem where the keystore will be initialized. func keysDir(home, chainID string) string { return path.Join(home, "keys", chainID) diff --git a/relayer/chains/archway/query.go b/relayer/chains/archway/query.go index 9aacf27e4..e6185c103 100644 --- a/relayer/chains/archway/query.go +++ b/relayer/chains/archway/query.go @@ -765,7 +765,7 @@ func (ap *ArchwayProvider) QueryPacketReceipt(ctx context.Context, height int64, } pktReceipt, err := ap.QueryIBCHandlerContract(ctx, pktReceiptParams) - if err != nil && !strings.Contains(err.Error(), "PacketCommitmentNotFound") { + if err != nil && !strings.Contains(err.Error(), "PacketReceiptNotFound") { return nil, err } diff --git a/relayer/chains/archway/tx.go b/relayer/chains/archway/tx.go index 0b1895774..bf09b55d5 100644 --- a/relayer/chains/archway/tx.go +++ b/relayer/chains/archway/tx.go @@ -763,6 +763,9 @@ func (ap *ArchwayProvider) SendMessagesToMempool( ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, false) } + //uncomment for saving msg + SaveMsgToFile(ArchwayDebugMessagePath, msgs) + return nil } @@ -1004,6 +1007,8 @@ func (ap *ArchwayProvider) BroadcastTx( ap.log.Info("Submitted transaction", zap.String("chain_id", ap.PCfg.ChainID), zap.String("txHash", res.TxHash), + zap.Int64("Height", res.Height), + zap.Any("Methods called", msgTypesField(msgs)), ) if shouldWait { @@ -1046,9 +1051,6 @@ func (ap *ArchwayProvider) waitForTx( return } - //uncomment for saving msg - SaveMsgToFile(ArchwayDebugMessagePath, msgs) - rlyResp := &provider.RelayerTxResponse{ Height: res.Height, TxHash: res.TxHash, diff --git a/relayer/chains/cosmos/codec.go b/relayer/chains/cosmos/codec.go index 16cdaa16f..89d849695 100644 --- a/relayer/chains/cosmos/codec.go +++ b/relayer/chains/cosmos/codec.go @@ -47,14 +47,14 @@ var ModuleBasics = []module.AppModuleBasic{ upgradeclient.LegacyCancelProposalHandler, }, ), - crisis.AppModuleBasic{}, + // crisis.AppModuleBasic{}, distribution.AppModuleBasic{}, feegrant.AppModuleBasic{}, mint.AppModuleBasic{}, params.AppModuleBasic{}, slashing.AppModuleBasic{}, staking.AppModuleBasic{}, - upgrade.AppModuleBasic{}, + // upgrade.AppModuleBasic{}, transfer.AppModuleBasic{}, ibc.AppModuleBasic{}, cosmosmodule.AppModuleBasic{}, diff --git a/relayer/chains/cosmos/provider.go b/relayer/chains/cosmos/provider.go index 98547f66d..c33743faf 100644 --- a/relayer/chains/cosmos/provider.go +++ b/relayer/chains/cosmos/provider.go @@ -84,11 +84,6 @@ func (pc CosmosProviderConfig) Validate() error { return nil } -func (pc CosmosProviderConfig) Set(field string, value interface{}) error { - // TODO: - return nil -} - func (pc CosmosProviderConfig) BroadcastMode() provider.BroadcastMode { return pc.Broadcast } diff --git a/relayer/chains/icon/keys.go b/relayer/chains/icon/keys.go index dff67ab1e..9bfda64a6 100644 --- a/relayer/chains/icon/keys.go +++ b/relayer/chains/icon/keys.go @@ -20,11 +20,11 @@ func (cp *IconProvider) KeystoreCreated(path string) bool { return false } -func (cp *IconProvider) AddKey(name string, coinType uint32) (output *provider.KeyOutput, err error) { +func (cp *IconProvider) AddKey(name string, coinType uint32, signingAlgorithm string) (output *provider.KeyOutput, err error) { return nil, fmt.Errorf("Not implemented on icon") } -func (cp *IconProvider) RestoreKey(name, mnemonic string, coinType uint32) (address string, err error) { +func (cp *IconProvider) RestoreKey(name, mnemonic string, coinType uint32, signingAlgorithm string) (address string, err error) { return "", fmt.Errorf("Not implemented on icon") } diff --git a/relayer/chains/icon/provider.go b/relayer/chains/icon/provider.go index 941699388..d1afed8f7 100644 --- a/relayer/chains/icon/provider.go +++ b/relayer/chains/icon/provider.go @@ -77,17 +77,6 @@ func (pp *IconProviderConfig) Validate() error { return nil } -func (pp *IconProviderConfig) Set(field string, value interface{}) error { - switch field { - case "btpHeight": - pp.BTPHeight = value.(int64) - default: - return fmt.Errorf("unknown field or not allowed to set %s", field) - } - return nil - -} - // NewProvider should provide a new Icon provider // NewProvider should provide a new Icon provider func (pp *IconProviderConfig) NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error) { @@ -578,3 +567,7 @@ func (icp *IconProvider) GetCurrentBtpNetworkStartHeight() (int64, error) { } return info.StartHeight.Value() } + +func (icp *IconProvider) MsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayeeAddr string) (provider.RelayerMessage, error) { + return nil, fmt.Errorf("Not implemented for Icon") +} diff --git a/relayer/chains/icon/provider_test.go b/relayer/chains/icon/provider_test.go index d10e7fab1..7bc8d94be 100644 --- a/relayer/chains/icon/provider_test.go +++ b/relayer/chains/icon/provider_test.go @@ -55,6 +55,7 @@ func GetMockIconProvider(network_id int, contractAddress string) *IconProvider { iconProvider, _ := p.(*IconProvider) return iconProvider + } func TestNetworkSectionHashCheck(t *testing.T) { diff --git a/relayer/chains/penumbra/msg.go b/relayer/chains/penumbra/msg.go index 951529b0a..f0b41f416 100644 --- a/relayer/chains/penumbra/msg.go +++ b/relayer/chains/penumbra/msg.go @@ -7,8 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/gogoproto/proto" chantypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - "github.com/cosmos/relayer/v2/relayer/chains/cosmos" - "github.com/cosmos/relayer/v2/relayer/provider" + "github.com/icon-project/ibc-relay/relayer/chains/cosmos" + "github.com/icon-project/ibc-relay/relayer/provider" "go.uber.org/zap/zapcore" ) diff --git a/relayer/chains/penumbra/provider.go b/relayer/chains/penumbra/provider.go index 92918b3d0..1b337dba3 100644 --- a/relayer/chains/penumbra/provider.go +++ b/relayer/chains/penumbra/provider.go @@ -131,6 +131,14 @@ func (h PenumbraIBCHeader) NextValidatorsHash() []byte { return h.SignedHeader.NextValidatorsHash } +func (h PenumbraIBCHeader) IsCompleteBlock() bool { + return true +} + +func (h PenumbraIBCHeader) ShouldUpdateWithZeroMessage() bool { + return false +} + type PenumbraProvider struct { log *zap.Logger diff --git a/relayer/chains/penumbra/query.go b/relayer/chains/penumbra/query.go index ce1f08ed6..0a01f41af 100644 --- a/relayer/chains/penumbra/query.go +++ b/relayer/chains/penumbra/query.go @@ -27,7 +27,7 @@ import ( host "github.com/cosmos/ibc-go/v7/modules/core/24-host" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" tmclient "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - "github.com/cosmos/relayer/v2/relayer/provider" + "github.com/icon-project/ibc-relay/relayer/provider" "go.uber.org/zap" "golang.org/x/sync/errgroup" ) diff --git a/relayer/codecs/ethermint/codec.go b/relayer/codecs/ethermint/codec.go index 65f4df8b9..39984f947 100644 --- a/relayer/codecs/ethermint/codec.go +++ b/relayer/codecs/ethermint/codec.go @@ -3,7 +3,6 @@ package ethermint import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/relayer/v2/relayer/ethermint" ) @@ -21,6 +20,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*authtypes.GenesisAccount)(nil), &EthAccount{}, ) + registry.RegisterImplementations( (*tx.TxExtensionOptionI)(nil), &ExtensionOptionsWeb3Tx{}, diff --git a/relayer/processor/metrics.go b/relayer/processor/metrics.go index 1048eed1e..522c69efe 100644 --- a/relayer/processor/metrics.go +++ b/relayer/processor/metrics.go @@ -14,10 +14,6 @@ type PrometheusMetrics struct { LatestHeightGauge *prometheus.GaugeVec WalletBalance *prometheus.GaugeVec FeesSpent *prometheus.GaugeVec - TxFailureError *prometheus.CounterVec - BlockQueryFailure *prometheus.CounterVec - ClientExpiration *prometheus.GaugeVec - ClientTrustingPeriod *prometheus.GaugeVec } func (m *PrometheusMetrics) AddPacketsObserved(pathName, chain, channel, port, eventType string, count int) { diff --git a/relayer/processor/path_end_runtime.go b/relayer/processor/path_end_runtime.go index bf9be8dd1..7a9c64eed 100644 --- a/relayer/processor/path_end_runtime.go +++ b/relayer/processor/path_end_runtime.go @@ -454,7 +454,7 @@ func (pathEnd *pathEndRuntime) shouldSendPacketMessage(message packetIBCMessage, pathEndForHeight = pathEnd } - if strings.Contains(pathEnd.clientState.ClientID, "tendermint") && message.info.Height >= pathEndForHeight.latestBlock.Height { + if strings.Contains(pathEnd.chainProvider.Type(), common.IconModule) && message.info.Height >= pathEndForHeight.latestBlock.Height { pathEnd.log.Debug("Waiting to relay packet message until counterparty height has incremented", zap.String("event_type", eventType), zap.Uint64("sequence", sequence), @@ -550,10 +550,13 @@ func (pathEnd *pathEndRuntime) removePacketRetention( // It will also determine if the message needs to be given up on entirely and remove retention if so. func (pathEnd *pathEndRuntime) shouldSendConnectionMessage(message connectionIBCMessage, counterparty *pathEndRuntime) bool { eventType := message.eventType - k := connectionInfoConnectionKey(message.info).Counterparty() - pathEndForHeight := counterparty - if strings.Contains(pathEnd.clientState.ClientID, "tendermint") && message.info.Height >= pathEndForHeight.latestBlock.Height { + k := ConnectionInfoConnectionKey(message.info) + if eventType != conntypes.EventTypeConnectionOpenInit { + k = k.Counterparty() + } + + if strings.Contains(pathEnd.chainProvider.Type(), common.IconModule) && message.info.Height >= counterparty.latestBlock.Height { pathEnd.log.Debug("Waiting to relay connection message until counterparty height has incremented", zap.Inline(k), zap.String("event_type", eventType), @@ -624,6 +627,7 @@ func (pathEnd *pathEndRuntime) shouldSendConnectionMessage(message connectionIBC // shouldSendChannelMessage determines if the channel handshake message should be sent now. // It will also determine if the message needs to be given up on entirely and remove retention if so. func (pathEnd *pathEndRuntime) shouldSendChannelMessage(message channelIBCMessage, counterparty *pathEndRuntime) bool { + eventType := message.eventType channelKey := ChannelInfoChannelKey(message.info) if eventType != chantypes.EventTypeChannelOpenInit { diff --git a/relayer/processor/path_processor.go b/relayer/processor/path_processor.go index 86bb2ccb2..142ea73b4 100644 --- a/relayer/processor/path_processor.go +++ b/relayer/processor/path_processor.go @@ -333,7 +333,7 @@ func (pp *PathProcessor) processAvailableSignals(ctx context.Context, cancel fun // No new data to merge in, just retry handling. case <-pp.flushTimer.C: // Periodic flush to clear out any old packets - // pp.flush(ctx) // TODO original not commented + pp.handleFlush(ctx) } return false } @@ -361,8 +361,8 @@ func (pp *PathProcessor) Run(ctx context.Context, cancel func()) { continue } - if !pp.initialFlushComplete { - // pp.flush(ctx) // TODO :: commented by icon-project + if pp.shouldFlush() && !pp.initialFlushComplete { + // pp.handleFlush(ctx) pp.initialFlushComplete = true } else if pp.shouldTerminateForFlushComplete() { cancel() diff --git a/relayer/processor/path_processor_internal.go b/relayer/processor/path_processor_internal.go index bb3219a57..798846e90 100644 --- a/relayer/processor/path_processor_internal.go +++ b/relayer/processor/path_processor_internal.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "fmt" "sort" "sync" @@ -20,8 +21,9 @@ import ( // i.e. a MsgConnectionOpenInit or a MsgChannelOpenInit should be broadcasted to start // the handshake if this key exists in the relevant cache. const ( - preInitKey = "pre_init" - preCloseKey = "pre_close" + preInitKey = "pre_init" + preCloseKey = "pre_close" + maxPacketsPerFlush = 10 ) // getMessagesToSend returns only the lowest sequence message (if it should be sent) for ordered channels, @@ -296,6 +298,17 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages( processRemovals() + for seq, msgTimeoutRequest := range pathEndPacketFlowMessages.DstMsgRequestTimeout { + toDeleteSrc[chantypes.EventTypeSendPacket] = append(toDeleteSrc[chantypes.EventTypeSendPacket], seq) + toDeleteDst[common.EventTimeoutRequest] = append(toDeleteDst[common.EventTimeoutRequest], seq) + timeoutMsg := packetIBCMessage{ + eventType: chantypes.EventTypeTimeoutPacket, + info: msgTimeoutRequest, + } + msgs = append(msgs, timeoutMsg) + } + processRemovals() + for _, info := range pathEndPacketFlowMessages.SrcMsgTransfer { deletePreInitIfMatches(info) @@ -306,11 +319,12 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages( var timeoutOnCloseErr *provider.TimeoutOnCloseError if pathEndPacketFlowMessages.Dst.chainProvider.Type() == common.IconModule { + switch { case errors.As(err, &timeoutHeightErr) || errors.As(err, &timeoutTimestampErr): timeoutRequestMsg := packetIBCMessage{ eventType: common.EventTimeoutRequest, - info: msgTransfer, + info: info, } msgs = append(msgs, timeoutRequestMsg) @@ -320,8 +334,7 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages( zap.Error(err), ) } - continue MsgTransferLoop - + continue } switch { @@ -369,6 +382,13 @@ func (pp *PathProcessor) unrelayedPacketFlowMessages( pathEndPacketFlowMessages.Dst, ) + res.SrcMessages, res.DstMessages = pp.getMessagesToSend( + ctx, + msgs, + pathEndPacketFlowMessages.Src, + pathEndPacketFlowMessages.Dst, + ) + return res } @@ -601,7 +621,6 @@ func (pp *PathProcessor) unrelayedChannelHandshakeMessages( eventType: chantypes.EventTypeChannelOpenTry, info: info, } - if pathEndChannelHandshakeMessages.Dst.shouldSendChannelMessage( msgOpenTry, pathEndChannelHandshakeMessages.Src, ) { @@ -846,7 +865,6 @@ func (pp *PathProcessor) queuePreInitMessages(cancel func()) { pp.pathEnd2.messageCache.PacketFlow[channelKey][eventType][0] = m.Initial.Info } case *ConnectionMessageLifecycle: - pp.sentInitialMsg = true if m.Initial == nil { return diff --git a/relayer/processor/utils.go b/relayer/processor/utils.go index 185510b78..1a004c3f6 100644 --- a/relayer/processor/utils.go +++ b/relayer/processor/utils.go @@ -4,13 +4,12 @@ import ( "math" "strings" + "github.com/cosmos/relayer/v2/relayer/common" "github.com/cosmos/relayer/v2/relayer/provider" ) -const clientName = "iconclient" - func ClientIsIcon(cs provider.ClientState) bool { - if strings.Contains(cs.ClientID, clientName) { + if strings.Contains(cs.ClientID, common.IconLightClient) { return true } return false @@ -54,5 +53,3 @@ func nextIconIBCHeader(heightMap IBCHeaderCache, height uint64) (provider.IBCHea header, ok := heightMap[nextHeight] return header, ok } - -// The next header is { false [] 0} true diff --git a/relayer/provider/provider.go b/relayer/provider/provider.go index f317c8f69..0e429900f 100644 --- a/relayer/provider/provider.go +++ b/relayer/provider/provider.go @@ -31,7 +31,6 @@ type ProviderConfig interface { NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (ChainProvider, error) Validate() error BroadcastMode() BroadcastMode - Set(field string, value interface{}) error } type RelayerMessage interface { @@ -237,7 +236,7 @@ type ChainProvider interface { NewClientState(dstChainID string, dstIBCHeader IBCHeader, dstTrustingPeriod, dstUbdPeriod time.Duration, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool) (ibcexported.ClientState, error) // TODO: Remove later - NewClientStateMock(dstChainID string, dstIBCHeader IBCHeader, dstTrustingPeriod, dstUbdPeriod time.Duration, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool) (ibcexported.ClientState, error) + // NewClientStateMock(dstChainID string, dstIBCHeader IBCHeader, dstTrustingPeriod, dstUbdPeriod time.Duration, allowUpdateAfterExpiry, allowUpdateAfterMisbehaviour bool) (ibcexported.ClientState, error) MsgCreateClient(clientState ibcexported.ClientState, consensusState ibcexported.ConsensusState) (RelayerMessage, error)