diff --git a/cmd/config/init/relayer.go b/cmd/config/init/relayer.go deleted file mode 100644 index a608a220..00000000 --- a/cmd/config/init/relayer.go +++ /dev/null @@ -1,149 +0,0 @@ -package initconfig - -import ( - "encoding/json" - "os" - "os/exec" - "path/filepath" - - "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/relayer" -) - -type RelayerFileChainConfig struct { - Type string `json:"type"` - Value RelayerFileChainConfigValue `json:"value"` -} - -type RelayerFileChainConfigValue struct { - Key string `json:"key"` - ChainID string `json:"chain-id"` - RpcAddr string `json:"rpc-addr"` - AccountPrefix string `json:"account-prefix"` - KeyringBackend string `json:"keyring-backend"` - GasAdjustment float64 `json:"gas-adjustment"` - GasPrices string `json:"gas-prices"` - Debug bool `json:"debug"` - Timeout string `json:"timeout"` - OutputFormat string `json:"output-format"` - SignMode string `json:"sign-mode"` - ExtraCodecs []string `json:"extra-codecs"` -} - -type RelayerChainConfig struct { - ChainConfig relayer.ChainConfig - GasPrices string - KeyName string -} - -func writeTmpChainConfig(chainConfig RelayerFileChainConfig, fileName string) (string, error) { - file, err := json.Marshal(chainConfig) - if err != nil { - return "", err - } - filePath := filepath.Join(os.TempDir(), fileName) - // nolint:gofumpt - if err := os.WriteFile(filePath, file, 0o644); err != nil { - return "", err - } - return filePath, nil -} - -func getRelayerFileChainConfig(relayerChainConfig RelayerChainConfig) RelayerFileChainConfig { - return RelayerFileChainConfig{ - Type: "cosmos", - Value: RelayerFileChainConfigValue{ - Key: relayerChainConfig.KeyName, - ChainID: relayerChainConfig.ChainConfig.ID, - RpcAddr: relayerChainConfig.ChainConfig.RPC, - AccountPrefix: relayerChainConfig.ChainConfig.AddressPrefix, - KeyringBackend: "test", - GasAdjustment: 1.2, - GasPrices: relayerChainConfig.GasPrices, - Debug: true, - Timeout: "10s", - OutputFormat: "json", - SignMode: "direct", - ExtraCodecs: []string{"ethermint"}, - }, - } -} - -func addChainToRelayer(fileChainConfig RelayerFileChainConfig, relayerHome string) error { - chainFilePath, err := writeTmpChainConfig(fileChainConfig, "chain.json") - if err != nil { - return err - } - addChainCmd := exec.Command( - consts.Executables.Relayer, - "chains", - "add", - fileChainConfig.Value.ChainID, - "--home", - relayerHome, - "--file", - chainFilePath, - ) - if err := addChainCmd.Run(); err != nil { - return err - } - return nil -} - -func initRelayer(relayerHome string) error { - initRelayerConfigCmd := exec.Command( - consts.Executables.Relayer, - "config", - "init", - "--home", - relayerHome, - ) - return initRelayerConfigCmd.Run() -} - -func addChainsConfig( - rollappConfig relayer.ChainConfig, - hubConfig relayer.ChainConfig, - relayerHome string, -) error { - relayerRollappConfig := getRelayerFileChainConfig( - RelayerChainConfig{ - ChainConfig: rollappConfig, - GasPrices: rollappConfig.GasPrices + rollappConfig.Denom, - KeyName: consts.KeysIds.RollappRelayer, - }, - ) - - relayerHubConfig := getRelayerFileChainConfig( - RelayerChainConfig{ - ChainConfig: hubConfig, - GasPrices: hubConfig.GasPrices + hubConfig.Denom, - KeyName: consts.KeysIds.HubRelayer, - }, - ) - - if err := addChainToRelayer(relayerRollappConfig, relayerHome); err != nil { - return err - } - if err := addChainToRelayer(relayerHubConfig, relayerHome); err != nil { - return err - } - return nil -} - -func InitializeRelayerConfig( - rollappConfig relayer.ChainConfig, - hubConfig relayer.ChainConfig, - home string, -) error { - relayerHome := filepath.Join(home, consts.ConfigDirName.Relayer) - - if err := initRelayer(relayerHome); err != nil { - return err - } - if err := addChainsConfig(rollappConfig, hubConfig, relayerHome); err != nil { - return err - } - - return nil -} diff --git a/cmd/consts/consts.go b/cmd/consts/consts.go index 0379a47f..609b1c1f 100644 --- a/cmd/consts/consts.go +++ b/cmd/consts/consts.go @@ -9,7 +9,7 @@ const ( DefaultTokenSupply = "1000000000000000000000000000" DefaultFee = 2000000000000000000 // 2 DefaultTxFee = 10000000000000000 // 0.01 - DefaultAdditionalFunding = "10000000000000000000" // 10, this amount is added to the necessary sequencer balance + DefaultAdditionalFunding = "20000000000000000000" // 20, this amount is added to the necessary sequencer balance ) var InternalBinsDir = fmt.Sprintf("%s/roller_bins", binsDir) diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 04c83996..e5bede44 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -1,26 +1,19 @@ package setup import ( - "context" + "errors" "fmt" "os" - "slices" "strconv" "strings" - "time" - firebase "firebase.google.com/go" "github.com/pterm/pterm" "github.com/spf13/cobra" - "google.golang.org/api/option" initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/relayer" - "github.com/dymensionxyz/roller/sequencer" - "github.com/dymensionxyz/roller/utils/config/yamlconfig" "github.com/dymensionxyz/roller/utils/dependencies" - dymintutils "github.com/dymensionxyz/roller/utils/dymint" "github.com/dymensionxyz/roller/utils/errorhandling" "github.com/dymensionxyz/roller/utils/filesystem" firebaseutils "github.com/dymensionxyz/roller/utils/firebase" @@ -43,57 +36,27 @@ func Cmd() *cobra.Command { cmd.Flag(initconfig.GlobalFlagNames.Home).Value.String(), ) - relayerHome := relayerutils.GetHomeDir(home) - relayerConfigPath := relayerutils.GetConfigFilePath(relayerHome) - - raID, hd, kb, err := relayerutils.GetRollappToRunFor(home) - if err != nil { - pterm.Error.Println("failed to determine what RollApp to run for:", err) - return - } - - _, err = rollapputils.ValidateChainID(hd.ID) + raData, hd, kb, err := getPreRunInfo(home) if err != nil { - pterm.Error.Printf("'%s' is not a valid Hub ID: %v", raID, err) + pterm.Error.Println("failed to run pre-flight checks: ", err) return } - - _, err = rollapputils.ValidateChainID(raID) - if err != nil { - pterm.Error.Printf("'%s' is not a valid RollApp ID: %v", raID, err) - return - } - - ok, err := rollapp.IsRegistered(raID, *hd) - if err != nil { - pterm.Error.Printf("'%s' is not a valid RollApp ID: %v", raID, err) - return - } - - if !ok { - pterm.Error.Printf("%s rollapp not registered on %s", raID, hd.ID) - return - } - - raRpc, err := sequencerutils.GetRpcEndpointFromChain(raID, *hd) - if err != nil { - pterm.Error.Println("failed to retrieve rollapp rpc endpoint: ", err) - return - } - - raData := consts.RollappData{ - ID: raID, - RpcUrl: fmt.Sprintf("%s:%d", raRpc, 443), - } + rly := relayer.NewRelayer( + home, + *raData, + *hd, + ) relayerLogFilePath := logging.GetRelayerLogPath(home) relayerLogger := logging.GetLogger(relayerLogFilePath) + rly.SetLogger(relayerLogger) rollappChainData, err := rollapp.PopulateRollerConfigWithRaMetadataFromChain( home, - raID, + raData.ID, *hd, ) errorhandling.PrettifyErrorIfExists(err) + rollappChainData.KeyringBackend = consts.SupportedKeyringBackend(kb) err = rollappChainData.ValidateConfig() if err != nil { @@ -102,147 +65,52 @@ func Cmd() *cobra.Command { } pterm.Info.Println("rollapp chain data validation passed") - raResp, err := rollapp.GetMetadataFromChain(raID, *hd) + err = installRelayerDependencies(home, rly.Rollapp.ID, *hd) if err != nil { - pterm.Error.Println("failed to fetch rollapp information from hub: ", err) + pterm.Error.Println("failed to install relayer dependencies: ", err) return } - err = genesis.DownloadGenesis(home, raResp.Rollapp.Metadata.GenesisUrl) - if err != nil { - pterm.Error.Println("failed to download genesis file: ", err) - return - } - as, err := genesis.GetGenesisAppState(home) - if err != nil { - pterm.Error.Println("failed to get genesis app state: ", err) - return - } - ctx := context.Background() - conf := &firebase.Config{ProjectID: "drs-metadata"} - app, err := firebase.NewApp(ctx, conf, option.WithoutAuthentication()) - if err != nil { - pterm.Error.Printfln("failed to initialize firebase app: %v", err) - return - } - drsVersion := strconv.Itoa(as.RollappParams.Params.DrsVersion) - - client, err := app.Firestore(ctx) - if err != nil { - pterm.Error.Printfln("failed to create firestore client: %v", err) - return - } - defer client.Close() - - // Fetch DRS version information using the nested collection path - // Path format: versions/{version}/revisions/{revision} - drsInfo, err := firebaseutils.GetLatestDrsVersionCommit(drsVersion) - if err != nil { - pterm.Error.Println("failed to retrieve latest DRS version: ", err) - return - } - - rbi := dependencies.NewRollappBinaryInfo( - raResp.Rollapp.GenesisInfo.Bech32Prefix, - drsInfo.Commit, - strings.ToLower(raResp.Rollapp.VmType), - ) - raDep := dependencies.DefaultRollappDependency(rbi) - err = dependencies.InstallBinaryFromRepo(raDep, raDep.DependencyName) + // things to check: + // 1. relayer folder exists + dirExist, err := filesystem.DirNotEmpty(rly.RelayerHome) if err != nil { - pterm.Error.Printfln("failed to install binary: %s", err) + pterm.Error.Printf("failed to check %s: %v\n", rly.RelayerHome, err) return } - rlyDep := dependencies.DefaultRelayerPrebuiltDependencies() - err = dependencies.InstallBinaryFromRelease(rlyDep["rly"]) - if err != nil { - pterm.Error.Printfln("failed to install binary: %s", err) - return + if !dirExist { + err = os.MkdirAll(rly.RelayerHome, 0o755) + if err != nil { + pterm.Error.Printf("failed to create %s: %v\n", rly.RelayerHome, err) + return + } } - dymdDep := dependencies.DefaultDymdDependency() - err = dependencies.InstallBinaryFromRelease(dymdDep) + pterm.Info.Println("populating relayer config with correct values...") + err = relayerutils.InitializeRelayer(home, *rollappChainData) if err != nil { - pterm.Error.Printfln("failed to install binary: %s", err) + pterm.Error.Printf("failed to initialize relayer config: %v\n", err) return } - // things to check: - // 1. relayer folder exists - isRelayerDirPresent, err := filesystem.DirNotEmpty(relayerHome) + var rlyCfg relayer.Config + err = rlyCfg.Load(rly.ConfigFilePath) if err != nil { - pterm.Error.Printf("failed to check %s: %v\n", relayerHome, err) + pterm.Error.Println("failed to load relayer config: ", err) return } - var ibcPathChains *relayerutils.IbcPathChains - - if isRelayerDirPresent { - ibcPathChains, err = relayerutils.ValidateIbcPathChains( - relayerHome, - raID, - *hd, - ) - if err != nil { - pterm.Error.Printf( - "validate relayer config IBC path %s: %v\n", - relayerHome, - err, - ) - return - } - } else { - err = os.MkdirAll(relayerHome, 0o755) - if err != nil { - pterm.Error.Printf("failed to create %s: %v\n", relayerHome, err) - return - } - } - - if ibcPathChains != nil { - if !ibcPathChains.DefaultPathOk || !ibcPathChains.SrcChainOk || - !ibcPathChains.DstChainOk { - pterm.Warning.Println("relayer config verification failed...") - if ibcPathChains.DefaultPathOk { - pterm.Info.Printfln( - "removing path from config %s", - consts.DefaultRelayerPath, - ) - err := relayer.DeletePath(*rollappChainData) - if err != nil { - pterm.Error.Printf("failed to delete relayer IBC path: %v\n", err) - return - } - } - - pterm.Info.Println("populating relayer config with correct values...") - err = relayerutils.InitializeRelayer(home, *rollappChainData) - if err != nil { - pterm.Error.Printf("failed to initialize relayer config: %v\n", err) - return - } - - if err := relayer.CreatePath(*rollappChainData); err != nil { - pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) - return - } - } - } else { - pterm.Info.Println("populating relayer config with correct values...") - err = relayerutils.InitializeRelayer(home, *rollappChainData) - if err != nil { - pterm.Error.Printf("failed to initialize relayer config: %v\n", err) - return - } - - if err := relayer.CreatePath(*rollappChainData); err != nil { + pterm.Info.Println("verifying path in relayer config") + if rlyCfg.GetPath() == nil { + pterm.Error.Println("no existing path") + if err := rlyCfg.CreatePath(*rollappChainData); err != nil { pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) return } } - if err := relayerutils.UpdateConfigWithDefaultValues(relayerHome, *rollappChainData); err != nil { + if err := rly.UpdateConfigWithDefaultValues(*rollappChainData); err != nil { pterm.Error.Printf("failed to update relayer config file: %v\n", err) return } @@ -257,247 +125,209 @@ func Cmd() *cobra.Command { } // 5. Are there existing channels ( from chain ) - rly := relayer.NewRelayer( - home, - raData.ID, - hd.ID, - ) - rly.SetLogger(relayerLogger) logFileOption := logging.WithLoggerLogging(relayerLogger) - - srcIbcChannel, dstIbcChannel, err := rly.LoadActiveChannel(raData, *hd) + err = rly.LoadActiveChannel(*raData, *hd) if err != nil { - pterm.Error.Printf("failed to load active channel, %v", err) - return - } + if errors.Is(err, relayer.ErrNoOpenChannel) { + + pterm.Warning.Println("No open channel found") + var createIbcChannels bool + if !rly.ChannelReady() { + createIbcChannels, _ = pterm.DefaultInteractiveConfirm.WithDefaultText( + fmt.Sprintf( + "no channel found. would you like to create a new IBC channel for %s?", + pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). + Sprint(rollappChainData.RollappID), + ), + ).Show() + + if !createIbcChannels { + pterm.Warning.Println("you can't run a relayer without an ibc channel") + return + } + } + + pterm.Info.Println("checking whether node is eligible to create ibc connection") + canCreateIbc, err := relayerutils.NewIbcConnenctionCanBeCreatedOnCurrentNode( + home, + rly.Rollapp.ID, + ) + if err != nil { + pterm.Error.Println( + "failed to determine whether connection can be created from this node:", + err, + ) + return + } + if !canCreateIbc { + pterm.Error.Println(err) + return + } - if srcIbcChannel != "" && dstIbcChannel != "" { - pterm.Info.Println("updating application relayer config") + pterm.Info.Println("creating ibc connection") + err = rly.HandleWhitelisting( + relKeys[consts.KeysIds.RollappRelayer].Address, + rollappChainData, + ) + if err != nil { + pterm.Error.Println("failed to handle whitelisting: ", err) + return + } - rollappIbcConnection, hubIbcConnection, err := rly.GetActiveConnections( - raData, - *hd, - ) - if err != nil { - pterm.Error.Printf("failed to retrieve active connections: %v\n", err) + err = rly.HandleIbcChannelCreation(home, *rollappChainData, logFileOption) + if err != nil { + pterm.Error.Println("failed to handle ibc channel creation: ", err) + return + } + } else { + pterm.Error.Printf("failed to load active channel, %v", err) return } + } - updates := map[string]interface{}{ - // hub - fmt.Sprintf("paths.%s.src.client-id", consts.DefaultRelayerPath): hubIbcConnection.ClientID, - fmt.Sprintf("paths.%s.src.connection-id", consts.DefaultRelayerPath): hubIbcConnection.ID, - - // ra - fmt.Sprintf("paths.%s.dst.client-id", consts.DefaultRelayerPath): rollappIbcConnection.ClientID, - fmt.Sprintf("paths.%s.dst.connection-id", consts.DefaultRelayerPath): rollappIbcConnection.ID, - } - err = yamlconfig.UpdateNestedYAML(relayerConfigPath, updates) + if rly.SrcChannel != "" && rly.DstChannel != "" { + err := rly.ConnectionInfoFromRaConnID(*raData, rly.DstConnectionID) if err != nil { - pterm.Error.Printf("Error updating YAML: %v\n", err) + pterm.Error.Println("failed to get hub ibc connection: ", err) return } - pterm.Info.Println("existing IBC channels found ") - pterm.Info.Println("Hub: ", srcIbcChannel) - pterm.Info.Println("RollApp: ", dstIbcChannel) - return - } - - defer func() { - pterm.Info.Println("reverting dymint config to 1h") - err := dymintutils.UpdateDymintConfigForIBC(home, "1h0m0s", true) + err = rly.UpdateDefaultPath() if err != nil { - pterm.Error.Println("failed to update dymint config: ", err) + pterm.Error.Println("failed to update relayer config: ", err) return } - }() - canCreateIbcConnectionOnCurrentNode, err := relayerutils.NewIbcConnenctionCanBeCreatedOnCurrentNode( - home, - raID, - ) - if err != nil { - pterm.Error.Println( - "failed to determine whether connection can be created from this node:", - err, - ) - return + pterm.Info.Println("IBC connection information:") + pterm.Info.Println("Hub chanel: ", rly.SrcChannel) + pterm.Info.Println("Hub connection: ", rly.SrcChannel) + pterm.Info.Println("Hub client: ", rly.SrcClientID) + pterm.Info.Println("RollApp chanel: ", rly.DstChannel) + pterm.Info.Println("RollApp connection: ", rly.DstConnectionID) + pterm.Info.Println("RollApp client: ", rly.DstClientID) } - if !canCreateIbcConnectionOnCurrentNode { - pterm.Error.Println(err) - return - } - - err = relayerutils.InitializeRelayer(home, *rollappChainData) - if err != nil { - pterm.Error.Println("failed to initialize relayer:", err) - return - } - - pterm.Info.Println("let's create that IBC connection, shall we?") - seq := sequencer.GetInstance(*rollappChainData) - - dymintutils.WaitForHealthyRollApp("http://localhost:26657/health") - err = relayer.WaitForValidRollappHeight(seq) - if err != nil { - pterm.Error.Printf("rollapp did not reach valid height: %v\n", err) - return - } + defer func() { + pterm.Info.Println("next steps:") + pterm.Info.Printf( + "run %s load the necessary systemd services\n", + pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). + Sprintf("roller relayer services load"), + ) + }() + }, + } - // add whitelisted relayers - seqAddr, err := sequencerutils.GetSequencerAccountAddress(*rollappChainData) - if err != nil { - pterm.Error.Printf("failed to get sequencer address: %v\n", err) - return - } + return relayerStartCmd +} - isRlyKeyWhitelisted, err := relayerutils.IsRelayerRollappKeyWhitelisted( - seqAddr, - relKeys[consts.KeysIds.RollappRelayer].Address, - *hd, - ) - if err != nil { - pterm.Error.Printf("failed to check if relayer key is whitelisted: %v\n", err) - return - } +func getPreRunInfo(home string) (*consts.RollappData, *consts.HubData, string, error) { + raID, hd, kb, err := relayerutils.GetRollappToRunFor(home) + if err != nil { + pterm.Error.Println("failed to determine what RollApp to run for:", err) + return nil, nil, "", err + } - if !isRlyKeyWhitelisted { - pterm.Warning.Printfln( - "relayer key (%s) is not whitelisted, updating whitelisted relayers", - relKeys[consts.KeysIds.RollappRelayer].Address, - ) + _, err = rollapputils.ValidateChainID(hd.ID) + if err != nil { + pterm.Error.Printf("'%s' is not a valid Hub ID: %v", raID, err) + return nil, nil, "", err + } - err := sequencerutils.UpdateWhitelistedRelayers( - home, - relKeys[consts.KeysIds.RollappRelayer].Address, - kb, - *hd, - ) - if err != nil { - pterm.Error.Println("failed to update whitelisted relayers:", err) - return - } - } + _, err = rollapputils.ValidateChainID(raID) + if err != nil { + pterm.Error.Printf("'%s' is not a valid RollApp ID: %v", raID, err) + return nil, nil, "", err + } - raOpAddr, err := sequencerutils.GetSequencerOperatorAddress(home, kb) - if err != nil { - pterm.Error.Println("failed to get RollApp's operator address:", err) - return - } + ok, err := rollapp.IsRegistered(raID, *hd) + if err != nil { + pterm.Error.Printf("'%s' is not a valid RollApp ID: %v", raID, err) + return nil, nil, "", err + } - wrSpinner, _ := pterm.DefaultSpinner.Start( - "waiting for the whitelisted relayer to propagate to RollApp (this might take a while)", - ) - for { - r, err := sequencerutils.GetWhitelistedRelayersOnRa(raOpAddr) - if err != nil { - pterm.Error.Println("failed to get whitelisted relayers:", err) - return - } + if !ok { + pterm.Error.Printf("%s rollapp not registered on %s", raID, hd.ID) + return nil, nil, "", err + } - if len(r) == 0 && - slices.Contains(r, relKeys[consts.KeysIds.RollappRelayer].Address) { - wrSpinner.UpdateText( - "waiting for the whitelisted relayer to propagate to RollApp...", - ) - time.Sleep(time.Second * 5) - continue - } else { - // nolint: errcheck - wrSpinner.Success("relayer whitelisted and propagated to rollapp") - break - } - } + raRpc, err := sequencerutils.GetRpcEndpointFromChain(raID, *hd) + if err != nil { + pterm.Error.Println("failed to retrieve rollapp rpc endpoint: ", err) + return nil, nil, "", err + } - pterm.Info.Println("setting block time to 5s for esstablishing IBC connection") - err = dymintutils.UpdateDymintConfigForIBC(home, "5s", true) - if err != nil { - pterm.Error.Println("failed to update dymint config: ", err) - return - } + raData := consts.RollappData{ + ID: raID, + RpcUrl: fmt.Sprintf("%s:%d", raRpc, 443), + } + return &raData, hd, kb, nil +} - if rly.ChannelReady() { - pterm.DefaultSection.WithIndentCharacter("💈"). - Println("IBC transfer channel is already established!") +func getDrsVersionFromGenesis( + home string, + raResp *rollapputils.ShowRollappResponse, +) (string, error) { + err := genesis.DownloadGenesis(home, raResp.Rollapp.Metadata.GenesisUrl) + if err != nil { + return "", err + } - status := fmt.Sprintf( - "Active\nrollapp: %s\n<->\nhub: %s", - rly.SrcChannel, - rly.DstChannel, - ) - err := rly.WriteRelayerStatus(status) - if err != nil { - fmt.Println(err) - return - } + as, err := genesis.GetGenesisAppState(home) + if err != nil { + pterm.Error.Println("failed to get genesis app state: ", err) + return "", err + } + drsVersion := strconv.Itoa(as.RollappParams.Params.DrsVersion) - pterm.Info.Println(status) - return - } + return drsVersion, nil +} - var createIbcChannels bool - if !rly.ChannelReady() { - createIbcChannels, _ = pterm.DefaultInteractiveConfirm.WithDefaultText( - fmt.Sprintf( - "no channel found. would you like to create a new IBC channel for %s?", - pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). - Sprint(rollappChainData.RollappID), - ), - ).Show() - - if !createIbcChannels { - pterm.Warning.Println("you can't run a relayer without an ibc channel") - return - } - } +func installRelayerDependencies( + home string, + raID string, + hd consts.HubData, +) error { + raResp, err := rollapp.GetMetadataFromChain(raID, hd) + if err != nil { + return err + } - if createIbcChannels { - err = relayerutils.VerifyRelayerBalances(*hd) - if err != nil { - pterm.Error.Printf("failed to verify relayer balances: %v\n", err) - return - } + drsVersion, err := getDrsVersionFromGenesis(home, raResp) + if err != nil { + pterm.Error.Println("failed to get drs version from genesis: ", err) + return err + } - pterm.Info.Println("establishing IBC transfer channel") - channels, err := rly.CreateIBCChannel( - logFileOption, - raData, - *hd, - ) - if err != nil { - pterm.Error.Printf("failed to create IBC channel: %v\n", err) - return - } + drsInfo, err := firebaseutils.GetLatestDrsVersionCommit(drsVersion) + if err != nil { + pterm.Error.Println("failed to retrieve latest DRS version: ", err) + return err + } - srcIbcChannel = channels.Src - dstIbcChannel = channels.Dst + rbi := dependencies.NewRollappBinaryInfo( + raResp.Rollapp.GenesisInfo.Bech32Prefix, + drsInfo.Commit, + strings.ToLower(raResp.Rollapp.VmType), + ) - status := fmt.Sprintf( - "Active\nrollapp: %s\n<->\nhub: %s", - srcIbcChannel, - dstIbcChannel, - ) + raDep := dependencies.DefaultRollappDependency(rbi) + err = dependencies.InstallBinaryFromRepo(raDep, raDep.DependencyName) + if err != nil { + return err + } - pterm.Info.Println(status) - err = rly.WriteRelayerStatus(status) - if err != nil { - fmt.Println(err) - return - } - } + rlyDep := dependencies.DefaultRelayerPrebuiltDependencies() + err = dependencies.InstallBinaryFromRelease(rlyDep["rly"]) + if err != nil { + return err + } - defer func() { - pterm.Info.Println("next steps:") - pterm.Info.Printf( - "run %s load the necessary systemd services\n", - pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()). - Sprintf("roller relayer services load"), - ) - }() - }, + dymdDep := dependencies.DefaultDymdDependency() + err = dependencies.InstallBinaryFromRelease(dymdDep) + if err != nil { + return err } - return relayerStartCmd + return nil } diff --git a/cmd/relayer/start/start.go b/cmd/relayer/start/start.go index 41adb835..776bccf6 100644 --- a/cmd/relayer/start/start.go +++ b/cmd/relayer/start/start.go @@ -3,24 +3,18 @@ package start import ( "context" "fmt" - "os" "path/filepath" "github.com/pterm/pterm" "github.com/spf13/cobra" - "gopkg.in/yaml.v3" initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/relayer" "github.com/dymensionxyz/roller/utils/bash" - "github.com/dymensionxyz/roller/utils/config" "github.com/dymensionxyz/roller/utils/errorhandling" "github.com/dymensionxyz/roller/utils/logging" - relayerutils "github.com/dymensionxyz/roller/utils/relayer" "github.com/dymensionxyz/roller/utils/rollapp" - "github.com/dymensionxyz/roller/utils/roller" - sequencerutils "github.com/dymensionxyz/roller/utils/sequencer" ) const ( @@ -44,83 +38,24 @@ Consider using 'services' if you want to run a 'systemd' service instead. "config.yaml", ) - data, err := os.ReadFile(rlyConfigPath) + var rlyCfg relayer.Config + err := rlyCfg.Load(rlyConfigPath) if err != nil { - fmt.Printf("Error reading YAML file: %v\n", err) + pterm.Error.Println("failed to load relayer config: ", err) return } - var rlyConfig relayerutils.Config - err = yaml.Unmarshal(data, &rlyConfig) - if err != nil { - fmt.Printf("Error unmarshaling YAML: %v\n", err) - return - } - - var hd consts.HubData - var raChainID string - var hubChainID string - - rollerConfig, err := roller.LoadConfig(home) - if err != nil { - // src is Hub, dst is RollApp - raChainID = rlyConfig.Paths.HubRollapp.Dst.ChainID - hubChainID = rlyConfig.Paths.HubRollapp.Src.ChainID - - var found bool - _, hd, found = roller.FindHubDataByID(consts.Hubs, hubChainID) - if !found { - pterm.Error.Println("Hub Data not found for ", hubChainID) - runCustomHub, _ := pterm.DefaultInteractiveConfirm.WithDefaultText("would you like to provide custom hub?"). - WithDefaultValue(false). - Show() - - if !runCustomHub { - pterm.Error.Println("cancelled by user") - return - } - - chd, err := config.CreateCustomHubData() - if err != nil { - pterm.Error.Println("failed to create custom hub data:", err) - return - } - hd = consts.HubData{ - ApiUrl: chd.ApiUrl, - ID: chd.ID, - RpcUrl: chd.RpcUrl, - ArchiveRpcUrl: chd.RpcUrl, - GasPrice: chd.GasPrice, - DaNetwork: consts.CelestiaTestnet, - } - } - } else { - hd = rollerConfig.HubData - raChainID = rlyConfig.Paths.HubRollapp.Dst.ChainID - hubChainID = rollerConfig.HubData.ID - } + raData := rlyCfg.RaDataFromRelayerConfig() + hd := rlyCfg.HubDataFromRelayerConfig() - raResponse, err := rollapp.GetMetadataFromChain(raChainID, hd) + raResponse, err := rollapp.GetMetadataFromChain(raData.ID, *hd) if err != nil { pterm.Error.Println("failed to fetch rollapp information from hub: ", err) return } + raData.Denom = raResponse.Rollapp.GenesisInfo.NativeDenom.Base - // errorhandling.RequireMigrateIfNeeded(rollappConfig) - raRpc, err := sequencerutils.GetRpcEndpointFromChain( - raChainID, - hd, - ) - if err != nil { - return - } - raData := consts.RollappData{ - ID: raChainID, - RpcUrl: fmt.Sprintf("%s:%d", raRpc, 443), - Denom: raResponse.Rollapp.GenesisInfo.NativeDenom.Base, - } - - err = relayerutils.VerifyRelayerBalances(hd) + err = relayer.VerifyRelayerBalances(*hd) if err != nil { pterm.Error.Println("failed to check balances", err) return @@ -130,14 +65,12 @@ Consider using 'services' if you want to run a 'systemd' service instead. logFileOption := logging.WithLoggerLogging(logger) rly := relayer.NewRelayer( home, - raChainID, - hubChainID, + *raData, + *hd, ) rly.SetLogger(logger) - // TODO: relayer is initialized with both chains at this point and it should be possible - // to construct the hub data from relayer config - _, _, err = rly.LoadActiveChannel(raData, hd) + err = rly.LoadActiveChannel(*raData, *hd) errorhandling.PrettifyErrorIfExists(err) // override := cmd.Flag(flagOverride).Changed @@ -147,7 +80,7 @@ Consider using 'services' if you want to run a 'systemd' service instead. // } if rly.ChannelReady() { - fmt.Println("💈 IBC transfer channel is already established!") + fmt.Println("💈 IBC transfer channel is established!") status := fmt.Sprintf( "Active\nrollapp: %s\n<->\nhub: %s\n", rly.DstChannel, rly.SrcChannel, @@ -171,9 +104,13 @@ Consider using 'services' if you want to run a 'systemd' service instead. ) fmt.Printf( - "💈 The relayer is running successfully on you local machine!\nChannels:\nrollapp: %s\n<->\nhub: %s\n", - rly.SrcChannel, + `💈 The relayer is running successfully on you local machine! +Channels: +RollApp: %s + <-> +Hub: %s`, rly.DstChannel, + rly.SrcChannel, ) fmt.Println("💈 Log file path: ", relayerLogFilePath) diff --git a/cmd/relayer/status/status.go b/cmd/relayer/status/status.go index 0106297a..adfc5abe 100644 --- a/cmd/relayer/status/status.go +++ b/cmd/relayer/status/status.go @@ -4,14 +4,16 @@ import ( "errors" "fmt" "os" + "path/filepath" + "github.com/pterm/pterm" "github.com/spf13/cobra" initconfig "github.com/dymensionxyz/roller/cmd/config/init" + "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/relayer" "github.com/dymensionxyz/roller/utils/errorhandling" "github.com/dymensionxyz/roller/utils/logging" - "github.com/dymensionxyz/roller/utils/roller" ) func Cmd() *cobra.Command { @@ -20,14 +22,28 @@ func Cmd() *cobra.Command { Short: "Show the status of the relayer on the local machine.", Run: func(cmd *cobra.Command, args []string) { home := cmd.Flag(initconfig.GlobalFlagNames.Home).Value.String() - rollappConfig, err := roller.LoadConfig(home) - + rlyConfigPath := filepath.Join( + home, + consts.ConfigDirName.Relayer, + "config", + "config.yaml", + ) relayerLogFilePath := logging.GetRelayerLogPath(home) - errorhandling.PrettifyErrorIfExists(err) + + var rlyCfg relayer.Config + err := rlyCfg.Load(rlyConfigPath) + if err != nil { + pterm.Error.Println("failed to load relayer config: ", err) + return + } + + raData := rlyCfg.RaDataFromRelayerConfig() + hd := rlyCfg.HubDataFromRelayerConfig() + rly := relayer.NewRelayer( - rollappConfig.Home, - rollappConfig.RollappID, - rollappConfig.HubData.ID, + home, + *raData, + *hd, ) bytes, err := os.ReadFile(rly.StatusFilePath()) diff --git a/cmd/rollapp/init/init.go b/cmd/rollapp/init/init.go index c77ddfad..b97056b6 100644 --- a/cmd/rollapp/init/init.go +++ b/cmd/rollapp/init/init.go @@ -2,7 +2,6 @@ package initrollapp import ( "fmt" - "os/exec" "strings" "time" @@ -16,7 +15,6 @@ import ( "github.com/dymensionxyz/roller/utils/config/scripts" "github.com/dymensionxyz/roller/utils/config/tomlconfig" "github.com/dymensionxyz/roller/utils/dependencies" - "github.com/dymensionxyz/roller/utils/dependencies/types" "github.com/dymensionxyz/roller/utils/filesystem" "github.com/dymensionxyz/roller/utils/keys" "github.com/dymensionxyz/roller/utils/rollapp" @@ -130,21 +128,7 @@ func Cmd() *cobra.Command { // TODO: move to consts // TODO(v2): move to roller config if !shouldUseMockBackend && env != "custom" { - dymdBinaryOptions := types.Dependency{ - DependencyName: "dymension", - RepositoryOwner: "dymensionxyz", - RepositoryName: "dymension", - RepositoryUrl: "https://github.com/artemijspavlovs/dymension", - Release: "v3.1.0-pg10", - Binaries: []types.BinaryPathPair{ - { - Binary: "dymd", - BinaryDestination: consts.Executables.Dymension, - BuildCommand: exec.Command("make", "build"), - }, - }, - PersistFiles: []types.PersistFile{}, - } + dymdBinaryOptions := dependencies.DefaultDymdDependency() pterm.Info.Println("installing dependencies") err = dependencies.InstallBinaryFromRelease(dymdBinaryOptions) if err != nil { diff --git a/cmd/rollapp/setup/setup.go b/cmd/rollapp/setup/setup.go index 5f955fcf..6f71a7d9 100644 --- a/cmd/rollapp/setup/setup.go +++ b/cmd/rollapp/setup/setup.go @@ -18,7 +18,7 @@ import ( dymensionseqtypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" "github.com/pterm/pterm" "github.com/spf13/cobra" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" diff --git a/d14.json b/d14.json new file mode 100644 index 00000000..004f3b6d --- /dev/null +++ b/d14.json @@ -0,0 +1,7 @@ +{ + "id": "dymension_1405-1", + "rpcUrl": "https://rpc-dym-migration-test-2.mzonder.com:443", + "apiUrl": "https://api-dym-migration-test-2.mzonder.com:443", + "commit": "1c428229", + "gasPrice": "2000000000" +} diff --git a/data_layer/celestia/lightclient/lightclient.go b/data_layer/celestia/lightclient/lightclient.go index e18407e4..29de066a 100644 --- a/data_layer/celestia/lightclient/lightclient.go +++ b/data_layer/celestia/lightclient/lightclient.go @@ -9,7 +9,7 @@ import ( "github.com/pelletier/go-toml/v2" "github.com/pterm/pterm" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "github.com/dymensionxyz/roller/cmd/consts" datalayer "github.com/dymensionxyz/roller/data_layer" diff --git a/go.mod b/go.mod index 21d876fd..d071ead2 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,10 @@ require ( ) require ( + cloud.google.com/go/firestore v1.17.0 cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 + firebase.google.com/go v3.13.0+incompatible github.com/BurntSushi/toml v1.4.0 github.com/briandowns/spinner v1.23.0 github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.0-00010101000000-000000000000 @@ -35,8 +37,8 @@ require ( github.com/tidwall/sjson v1.2.5 golang.org/x/exp v0.0.0-20231006140011-7918f672742d golang.org/x/text v0.20.0 + google.golang.org/api v0.206.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 - gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -48,7 +50,6 @@ require ( cloud.google.com/go/auth v0.10.2 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.5 // indirect cloud.google.com/go/compute/metadata v0.5.2 // indirect - cloud.google.com/go/firestore v1.17.0 // indirect cloud.google.com/go/iam v1.2.0 // indirect cloud.google.com/go/longrunning v0.6.0 // indirect cloud.google.com/go/storage v1.43.0 // indirect @@ -58,7 +59,6 @@ require ( cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect - firebase.google.com/go v3.13.0+incompatible // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect @@ -95,7 +95,6 @@ require ( github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/creachadair/taskgroup v0.4.2 // indirect - github.com/creack/pty v1.1.24 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/danwt/gerr v1.0.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -220,7 +219,6 @@ require ( go.opentelemetry.io/otel v1.29.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect go.opentelemetry.io/otel/metric v1.29.0 // indirect - go.opentelemetry.io/otel/sdk v1.29.0 // indirect go.opentelemetry.io/otel/trace v1.29.0 // indirect go.uber.org/multierr v1.10.0 // indirect golang.org/x/crypto v0.29.0 // indirect @@ -232,7 +230,6 @@ require ( golang.org/x/term v0.26.0 // indirect golang.org/x/time v0.8.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - google.golang.org/api v0.206.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect @@ -242,6 +239,7 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect nhooyr.io/websocket v1.8.7 // indirect pgregory.net/rapid v1.1.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect diff --git a/go.sum b/go.sum index 86002d83..5cd6029e 100644 --- a/go.sum +++ b/go.sum @@ -50,7 +50,6 @@ cloud.google.com/go v0.110.8/go.mod h1:Iz8AkXJf1qmxC3Oxoep8R1T36w8B92yU29PcBhHO5 cloud.google.com/go v0.112.0/go.mod h1:3jEEVwZ/MHU4djK5t5RHuKOA/GbLddgTdVubX1qnPD4= cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= cloud.google.com/go v0.112.2/go.mod h1:iEqjp//KquGIJV/m+Pk3xecgKNhV+ry+vVTsy4TbDms= -cloud.google.com/go v0.113.0 h1:g3C70mn3lWfckKBiCVsAshabrDg01pQ0pnX1MNtnMkA= cloud.google.com/go v0.113.0/go.mod h1:glEqlogERKYeePz6ZdkcLJ28Q2I6aERgDDErBg9GzO8= cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE= cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U= @@ -69,12 +68,10 @@ cloud.google.com/go/asset v1.19.1/go.mod h1:kGOS8DiCXv6wU/JWmHWCgaErtSZ6uN5noCy0 cloud.google.com/go/assuredworkloads v1.11.7/go.mod h1:CqXcRH9N0KCDtHhFisv7kk+cl//lyV+pYXGi1h8rCEU= cloud.google.com/go/auth v0.2.1/go.mod h1:khQRBNrvNoHiHhV1iu2x8fSnlNbCaVHilznW5MAI5GY= cloud.google.com/go/auth v0.2.2/go.mod h1:2bDNJWtWziDT3Pu1URxHHbkHE/BbOCuyUiKIGcNvafo= -cloud.google.com/go/auth v0.3.0 h1:PRyzEpGfx/Z9e8+lHsbkoUVXD0gnu4MNmm7Gp8TQNIs= cloud.google.com/go/auth v0.3.0/go.mod h1:lBv6NKTWp8E3LPzmO1TbiiRKc4drLOfHsgmlH9ogv5w= cloud.google.com/go/auth v0.10.2 h1:oKF7rgBfSHdp/kuhXtqU/tNDr0mZqhYbEh+6SiqzkKo= cloud.google.com/go/auth v0.10.2/go.mod h1:xxA5AqpDrvS+Gkmo9RqrGGRh6WSNKKOXhY3zNOr38tI= cloud.google.com/go/auth/oauth2adapt v0.2.1/go.mod h1:tOdK/k+D2e4GEwfBRA48dKNQiDsqIXxLh7VU319eV0g= -cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= cloud.google.com/go/auth/oauth2adapt v0.2.5 h1:2p29+dePqsCHPP1bqDJcKj4qxRyYCcbzKpFyKGt3MTk= cloud.google.com/go/auth/oauth2adapt v0.2.5/go.mod h1:AlmsELtlEBnaNTL7jCj8VQFLy6mbZv0s4Q7NGBeQ5E8= @@ -119,13 +116,11 @@ cloud.google.com/go/compute v1.23.1/go.mod h1:CqB3xpmPKKt3OJpW2ndFIXnA9A4xAy/F3X cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzcFZeQ+h8CI= cloud.google.com/go/compute v1.23.4/go.mod h1:/EJMj55asU6kAFnuZET8zqgwgJ9FvXWXOkkfQZa4ioI= cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40= -cloud.google.com/go/compute v1.26.0 h1:uHf0NN2nvxl1Gh4QO83yRCOdMK4zivtMS5gv0dEX0hg= cloud.google.com/go/compute v1.26.0/go.mod h1:T9RIRap4pVHCGUkVFRJ9hygT3KCXjip41X1GgWtBBII= cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.5.2 h1:UxK4uu/Tn+I3p2dYWTfiX4wva7aYlKixAHn3fyqngqo= cloud.google.com/go/compute/metadata v0.5.2/go.mod h1:C66sj2AluDcIqakBq/M8lw8/ybHgOZqin2obFxa/E5k= @@ -175,7 +170,6 @@ cloud.google.com/go/iam v1.1.3/go.mod h1:3khUlaBXfPKKe7huYgEpDn6FtgRyMEqbkvBxrQy cloud.google.com/go/iam v1.1.5/go.mod h1:rB6P/Ic3mykPbFio+vo7403drjlgvoWfYpJhMXEbzv8= cloud.google.com/go/iam v1.1.6/go.mod h1:O0zxdPeGBoFdWW3HWmBxJsk0pfvNM/p/qa82rWOGTwI= cloud.google.com/go/iam v1.1.7/go.mod h1:J4PMPg8TtyurAUvSmPj8FF3EDgY1SPRZxcUGrn7WXGA= -cloud.google.com/go/iam v1.1.8 h1:r7umDwhj+BQyz0ScZMp4QrGXjSTI3ZINnpgU2nlB/K0= cloud.google.com/go/iam v1.1.8/go.mod h1:GvE6lyMmfxXauzNq8NbgJbeVQNspG+tcdL/W8QO1+zE= cloud.google.com/go/iam v1.2.0 h1:kZKMKVNk/IsSSc/udOb83K0hL/Yh/Gcqpz+oAkoIFN8= cloud.google.com/go/iam v1.2.0/go.mod h1:zITGuWgsLZxd8OwAlX+eMFgZDXzBm7icj1PVTYG766Q= @@ -257,7 +251,6 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk cloud.google.com/go/storage v1.36.0/go.mod h1:M6M/3V/D3KpzMTJyPOR/HU6n2Si5QdaXYEsng2xgOs8= cloud.google.com/go/storage v1.38.0/go.mod h1:tlUADB0mAb9BgYls9lq+8MGkfzOXuLrnHXlpHmvFJoY= cloud.google.com/go/storage v1.39.1/go.mod h1:xK6xZmxZmo+fyP7+DEF6FhNc24/JAe95OLyOHCXFH1o= -cloud.google.com/go/storage v1.40.0 h1:VEpDQV5CJxFmJ6ueWNsKxcr1QAYOXEgxDa+sBbJahPw= cloud.google.com/go/storage v1.40.0/go.mod h1:Rrj7/hKlG87BLqDJYtwR0fbPld8uJPbQ2ucUMY7Ir0g= cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs= cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0= @@ -572,8 +565,6 @@ github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJF github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= -github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= @@ -797,8 +788,6 @@ github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0L github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= -github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= -github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -874,11 +863,13 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc= github.com/google/martian/v3 v3.3.3/go.mod h1:iEPrYcgCF7jA9OtScMFQyAlZZ4YXTKEtJ1E6RWzmBA0= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= @@ -902,7 +893,6 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/s2a-go v0.1.0/go.mod h1:OJpEgntRZo8ugHpF9hkoLJbS5dSI20XZeXJ9JVywLlM= github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= -github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM= github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA= @@ -922,7 +912,6 @@ github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/ github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/enterprise-certificate-proxy v0.2.4/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gTgghdIA6Stxb52D5RnLI1SLyw= github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA= @@ -944,7 +933,6 @@ github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qK github.com/googleapis/gax-go/v2 v2.12.1/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= github.com/googleapis/gax-go/v2 v2.12.2/go.mod h1:61M8vcyyXR2kqKFxKrfA22jaA8JGF7Dc8App1U3H6jc= github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBHwWRvkNFJUQcS4= -github.com/googleapis/gax-go/v2 v2.12.4 h1:9gWcmF85Wvq4ryPFvGFaOgPIs1AQX0d0bcbGw4Z96qg= github.com/googleapis/gax-go/v2 v2.12.4/go.mod h1:KYEYLorsnIGDi/rPC8b5TdlB9kbKoFubselGIoBMCwI= github.com/googleapis/gax-go/v2 v2.14.0 h1:f+jMrjBPl+DL9nI4IQzLUxMq7XrAqFYB7hBPqMNIe8o= github.com/googleapis/gax-go/v2 v2.14.0/go.mod h1:lhBCnjdLrWRaPvLWhmc8IS24m9mr07qSYnHncrgo+zk= @@ -1587,7 +1575,6 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1/go.mod h1:4UoMYEZOC0yN/sPGH76KPkkU7zgiEWYWL9vwmbnTJPE= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0/go.mod h1:r9vWsPS/3AQItv3OSlEJ/E4mbrhUbbw18meOjArPtKQ= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.48.0/go.mod h1:tIKj3DbO8N9Y2xo52og3irLsPI4GW02DSMtrVgNMgxg= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 h1:r6I7RJCN86bpD/FQwedZ0vSixDpwuWREjW9oRMsmqDc= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0/go.mod h1:B9yO6b04uB80CzjedvewuqDhxJxi11s7/GtiGa8bAjI= @@ -1595,16 +1582,12 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1: go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0/go.mod h1:SK2UL73Zy1quvRPonmOmRDiWk1KBV3LyIeeIxcEApWw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0/go.mod h1:rdENBZMT2OE6Ne/KLwpiXudnAsbdrdBaqBvTN8M8BgA= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= go.opentelemetry.io/otel v1.23.0/go.mod h1:YCycw9ZeKhcJFrb34iVSkyT0iczq/zYDtZYFufObyB0= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= @@ -1615,23 +1598,17 @@ go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzu go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= go.opentelemetry.io/otel/metric v1.23.0/go.mod h1:MqUW2X2a6Q8RN96E2/nqNoT+z9BSms20Jb7Bbp+HiTo= go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= -go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk v1.29.0 h1:vkqKjk7gwhS8VaWb0POZKmIEDimRCMsopNYnriHyryo= go.opentelemetry.io/otel/sdk v1.29.0/go.mod h1:pM8Dx5WKnvxLCb+8lG1PRNIDxu9g9b9g59Qr7hfAAok= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= go.opentelemetry.io/otel/trace v1.23.0/go.mod h1:GSGTbIClEsuZrGIzoEHqsVfxgn5UkggkflQwDScNUsk= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1692,8 +1669,6 @@ golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1m golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us= @@ -1828,8 +1803,6 @@ golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1872,8 +1845,6 @@ golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5H golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1896,7 +1867,6 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= @@ -2026,7 +1996,6 @@ golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -2055,7 +2024,6 @@ golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= @@ -2080,8 +2048,6 @@ golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2091,7 +2057,6 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= @@ -2261,7 +2226,6 @@ google.golang.org/api v0.172.0/go.mod h1:+fJZq6QXWfa9pXhnIzsjx4yI22d4aI9ZpLb58gv google.golang.org/api v0.175.0/go.mod h1:Rra+ltKu14pps/4xTycZfobMgLpbosoaaL7c+SEMrO8= google.golang.org/api v0.176.1/go.mod h1:j2MaSDYcvYV1lkZ1+SMW4IeF90SrEyFA+tluDYWRrFg= google.golang.org/api v0.177.0/go.mod h1:srbhue4MLjkjbkux5p3dw/ocYOSZTaIEvf7bCOnFQDw= -google.golang.org/api v0.178.0 h1:yoW/QMI4bRVCHF+NWOTa4cL8MoWL3Jnuc7FlcFF91Ok= google.golang.org/api v0.178.0/go.mod h1:84/k2v8DFpDRebpGcooklv/lais3MEfqpaBLA12gl2U= google.golang.org/api v0.206.0 h1:A27GClesCSheW5P2BymVHjpEeQ2XHH8DI8Srs2HI2L8= google.golang.org/api v0.206.0/go.mod h1:BtB8bfjTYIrai3d8UyvPmV9REGgox7coh+ZRwm0b+W8= @@ -2301,8 +2265,6 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go. google.golang.org/genproto/googleapis/api v0.0.0-20240429193739-8cf5692501f6/go.mod h1:10yRODfgim2/T8csjQsMPgZOMvtytXKTDRzH6HRGzRw= google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y= google.golang.org/genproto/googleapis/api v0.0.0-20240509183442-62759503f434/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y= -google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 h1:0+ozOGcrp+Y8Aq8TLNN2Aliibms5LEzsq99ZZmAGYm0= -google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094/go.mod h1:fJ/e3If/Q67Mj99hin0hMhiNyCRmt6BQ2aWIJshUSJw= google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 h1:M0KvPgPmDZHPlbRbaNU1APr28TvwvvdUPlSv7PUvy8g= google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:dguCy7UOdZhTvLzDyt15+rOrawrpM4q7DD9dQ1P11P4= google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:ylj+BE99M198VPbBh6A8d9n3w8fChvyLK3wwBOjXBFA= @@ -2353,8 +2315,6 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go. google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= google.golang.org/genproto/googleapis/rpc v0.0.0-20240509183442-62759503f434/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 h1:XVhgTWWV3kGQlwJHR3upFWZeTsei6Oks1apkZSeonIE= google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -2419,8 +2379,6 @@ google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJai google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= -google.golang.org/grpc v1.66.1 h1:hO5qAXR19+/Z44hmvIM4dQFMSYX9XcWsByfoxutBpAM= -google.golang.org/grpc v1.66.1/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2444,8 +2402,6 @@ google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/relayer/channels.go b/relayer/channels.go index f33022c1..6839c559 100644 --- a/relayer/channels.go +++ b/relayer/channels.go @@ -2,102 +2,183 @@ package relayer import ( "encoding/json" + "fmt" "os/exec" "slices" "github.com/pterm/pterm" "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/utils" + "github.com/dymensionxyz/roller/sequencer" "github.com/dymensionxyz/roller/utils/bash" + dymintutils "github.com/dymensionxyz/roller/utils/dymint" + "github.com/dymensionxyz/roller/utils/roller" ) // TODO: Change to use the connection for fetching relevant channel using connection-channels rly command func (r *Relayer) LoadActiveChannel( raData consts.RollappData, hd consts.HubData, -) (string, string, error) { +) error { spinner, _ := pterm.DefaultSpinner.Start("loading active IBC channels") defer spinner.Stop() - var activeRaConnectionID string - var activeHubConnectionID string - activeRaConnectionID, activeHubConnectionID, err := r.GetActiveConnectionIDs(raData, hd) - if err != nil { - if keyErr, ok := err.(*utils.KeyNotFoundError); ok { - r.logger.Printf("No active connection found. Key not found: %v", keyErr) - return "", "", nil - } else { - r.logger.Println("something bad happened", err) - return "", "", err - } - } - if activeRaConnectionID == "" { - r.logger.Println("no active connection found") - return "", "", nil - } - - pterm.Info.Println("active connection found on the hub side: ", activeHubConnectionID) - pterm.Info.Println("active connection found on the rollapp side: ", activeRaConnectionID) + gacCmd := r.getQueryChannelsRollappCmd(raData) - var raChannelResponse QueryChannelsResponse - rollappChannels, err := bash.ExecCommandWithStdout(r.queryChannelsRollappCmd(raData)) + gacOut, err := bash.ExecCommandWithStdout(gacCmd) if err != nil { - return "", "", err + return err } - err = json.Unmarshal(rollappChannels.Bytes(), &raChannelResponse) + var gacResponse QueryChannelsResponse + err = json.Unmarshal(gacOut.Bytes(), &gacResponse) if err != nil { - return "", "", err + return err } - if len(raChannelResponse.Channels) == 0 { - return "", "", nil - } - - var hubChannelResponse QueryChannelsResponse - hubChannels, err := bash.ExecCommandWithStdout(r.queryChannelsHubCmd(hd)) - if err != nil { - return "", "", err - } - - err = json.Unmarshal(hubChannels.Bytes(), &hubChannelResponse) - if err != nil { - return "", "", err + if len(gacResponse.Channels) == 0 { + return ErrNoOpenChannel } - if len(hubChannelResponse.Channels) == 0 { - return "", "", nil - } - - raChanIndex := slices.IndexFunc( - raChannelResponse.Channels, func(ibcChan Channel) bool { - return ibcChan.ConnectionHops[0] == activeRaConnectionID && - ibcChan.State == "STATE_OPEN" - }, - ) - raChan := raChannelResponse.Channels[raChanIndex] - - hubChanIndex := slices.IndexFunc( - hubChannelResponse.Channels, func(ibcChan Channel) bool { - return ibcChan.ConnectionHops[0] == activeHubConnectionID && - ibcChan.State == "STATE_OPEN" + raIbcChanIndex := slices.IndexFunc( + gacResponse.Channels, func(ibcChan Channel) bool { + return ibcChan.State == "STATE_OPEN" }, ) - hubChan := hubChannelResponse.Channels[hubChanIndex] - pterm.Info.Println("active channel found on the hub side: ", hubChan.ChannelID) - pterm.Info.Println("active channel found on the rollapp side: ", raChan.ChannelID) + fmt.Println(raIbcChanIndex) - spinner.Success("IBC channels loaded successfully") + if raIbcChanIndex == -1 { + return ErrNoOpenChannel + } - r.SrcChannel = hubChan.ChannelID + raChan := gacResponse.Channels[raIbcChanIndex] + r.SrcChannel = raChan.Counterparty.ChannelID r.DstChannel = raChan.ChannelID + r.DstConnectionID = raChan.ConnectionHops[0] - return r.SrcChannel, r.DstChannel, nil + return nil } -func (r *Relayer) queryChannelsRollappCmd(raData consts.RollappData) *exec.Cmd { +// func (r *Relayer) GetActiveConnections( +// raData consts.RollappData, +// hd consts.HubData, +// ) (string, string, error) { +// var gacResponse QueryChannelsResponse +// +// pterm.Info.Println("querying connections") +// cmd := r.queryConnectionRollappCmd(raData) +// rollappConnectionOutput, err := bash.ExecCommandWithStdout(cmd) +// if err != nil { +// pterm.Error.Printfln( +// "failed to find connection on the rollapp side for %s: %v", +// r.RollappID, +// err, +// ) +// return "", "", err +// } +// var raIbcConnections ConnectionsQueryResult +// err = json.Unmarshal(rollappConnectionOutput.Bytes(), &raIbcConnections) +// if err != nil { +// return "", "", err +// } +// +// activeIbcConnectionID := gacResponse.Channels[0].ConnectionHops[0] +// raIbcConnInx := slices.IndexFunc( +// raIbcConnections.Connections, func(conn ConnectionInfo) bool { +// return conn.ID == activeIbcConnectionID +// }, +// ) +// +// raIbcConn := raIbcConnections.Connections[raIbcConnInx] +// j, _ := json.Marshal(raIbcConn) +// fmt.Printf("\tRA IBC Connection:\n%s", string(j)) +// // END QUERY CONNECTIONS +// +// return "", "", errors.New("debugging") +// +// var activeRaConnectionID string +// var activeHubConnectionID string +// activeRaConnectionID, activeHubConnectionID, err = r.GetActiveConnectionIDs(raData, hd) +// if err != nil { +// if keyErr, ok := err.(*utils.KeyNotFoundError); ok { +// r.logger.Printf("No active connection found. Key not found: %v", keyErr) +// return "", "", nil +// } else { +// r.logger.Println("something bad happened", err) +// return "", "", err +// } +// } +// if activeRaConnectionID == "" { +// r.logger.Println("no active connection found") +// return "", "", nil +// } +// +// pterm.Info.Println("active connection found on the hub side: ", activeHubConnectionID) +// pterm.Info.Println("active connection found on the rollapp side: ", activeRaConnectionID) +// +// var raChannelResponse QueryChannelsResponse +// rollappChannels, err := bash.ExecCommandWithStdout(r.queryChannelsRollappCmd(raData)) +// if err != nil { +// return "", "", err +// } +// +// err = json.Unmarshal(rollappChannels.Bytes(), &raChannelResponse) +// if err != nil { +// return "", "", err +// } +// +// if len(raChannelResponse.Channels) == 0 { +// return "", "", nil +// } +// +// for _, v := range raChannelResponse.Channels { +// fmt.Printf("%s: %s\n", v.ChannelID, v.State) +// } +// +// raChanIndex := slices.IndexFunc( +// raChannelResponse.Channels, func(ibcChan Channel) bool { +// return ibcChan.ConnectionHops[0] == activeRaConnectionID && +// ibcChan.State == "STATE_OPEN" +// }, +// ) +// raChan := raChannelResponse.Channels[raChanIndex] +// +// var hubChannelResponse QueryChannelsResponse +// hubChannels, err := bash.ExecCommandWithStdout(r.queryChannelsHubCmd(hd)) +// if err != nil { +// return "", "", err +// } +// +// err = json.Unmarshal(hubChannels.Bytes(), &hubChannelResponse) +// if err != nil { +// return "", "", err +// } +// +// if len(hubChannelResponse.Channels) == 0 { +// return "", "", nil +// } +// +// hubChanIndex := slices.IndexFunc( +// hubChannelResponse.Channels, func(ibcChan Channel) bool { +// return ibcChan.ConnectionHops[0] == activeHubConnectionID && +// ibcChan.State == "STATE_OPEN" +// }, +// ) +// hubChan := hubChannelResponse.Channels[hubChanIndex] +// +// pterm.Info.Println("active channel found on the hub side: ", hubChan.ChannelID) +// pterm.Info.Println("active channel found on the rollapp side: ", raChan.ChannelID) +// +// spinner.Success("IBC channels loaded successfully") +// +// r.SrcChannel = hubChan.ChannelID +// r.DstChannel = raChan.ChannelID +// +// return r.SrcChannel, r.DstChannel, nil +// } + +func (r *Relayer) getQueryChannelsRollappCmd(raData consts.RollappData) *exec.Cmd { args := []string{"q", "ibc", "channel", "channels"} args = append(args, "--node", raData.RpcUrl, "--chain-id", raData.ID, "-o", "json") @@ -201,3 +282,71 @@ type RlyRollappQueryResult struct { PortID string `json:"port_id"` ChannelID string `json:"channel_id"` } + +func (r *Relayer) HandleIbcChannelCreation( + home string, + rollappChainData roller.RollappConfig, + logFileOption bash.CommandOption, +) error { + defer func() { + pterm.Info.Println("reverting dymint config to 1h") + err := dymintutils.UpdateDymintConfigForIBC(home, "1h0m0s", true) + if err != nil { + pterm.Error.Println("failed to update dymint config: ", err) + return + } + + dymintutils.WaitForHealthyRollApp("http://localhost:26657/health") + }() + + seq := sequencer.GetInstance(rollappChainData) + + pterm.Info.Println("setting block time to 5s for esstablishing IBC connection") + err := dymintutils.UpdateDymintConfigForIBC(home, "5s", true) + if err != nil { + pterm.Error.Println("failed to update dymint config: ", err) + return err + } + + dymintutils.WaitForHealthyRollApp("http://localhost:26657/health") + err = WaitForValidRollappHeight(seq) + if err != nil { + pterm.Error.Printf("rollapp did not reach valid height: %v\n", err) + return err + } + + err = VerifyRelayerBalances(r.Hub) + if err != nil { + pterm.Error.Printf("failed to verify relayer balances: %v\n", err) + return err + } + + pterm.Info.Println("establishing IBC transfer channel") + channels, err := r.CreateIBCChannel( + logFileOption, + r.Rollapp, + r.Hub, + ) + if err != nil { + pterm.Error.Printf("failed to create IBC channel: %v\n", err) + return err + } + + r.SrcChannel = channels.Src + r.DstChannel = channels.Dst + + status := fmt.Sprintf( + "Active\nRollApp: %s\n<->Hub: %s", + r.DstChannel, + r.SrcChannel, + ) + + pterm.Info.Println(status) + err = r.WriteRelayerStatus(status) + if err != nil { + fmt.Println(err) + return err + } + + return nil +} diff --git a/relayer/clients.go b/relayer/clients.go index a52ecc84..b4cb2637 100644 --- a/relayer/clients.go +++ b/relayer/clients.go @@ -1,39 +1,34 @@ package relayer -import ( - "github.com/dymensionxyz/roller/cmd/consts" - roller_utils "github.com/dymensionxyz/roller/utils" -) - -func (r *Relayer) CheckClientsExist() (bool, error) { - rlyCfg, err := ReadRlyConfig(r.Home) - if err != nil { - return false, err - } - clientIDRollapp_raw, err := roller_utils.GetNestedValue( - rlyCfg, - []string{"paths", consts.DefaultRelayerPath, "dst", "client-id"}, - ) - if err != nil { - return false, err - } - - clientIDHub_raw, err := roller_utils.GetNestedValue( - rlyCfg, - []string{"paths", consts.DefaultRelayerPath, "src", "client-id"}, - ) - if err != nil { - return false, err - } - - //nolint:errcheck - clientIDRollapp := clientIDRollapp_raw.(string) - //nolint:errcheck - clientIDHub := clientIDHub_raw.(string) - - if clientIDRollapp == "" || clientIDHub == "" { - r.logger.Printf("can't find clients in the config for both rollapp and hub") - return false, nil - } - return true, nil -} +// func (r *Relayer) CheckClientsExist() (bool, error) { +// rlyCfg, err := ReadRlyConfig(r.RollerHome) +// if err != nil { +// return false, err +// } +// clientIDRollapp_raw, err := roller_utils.GetNestedValue( +// rlyCfg, +// []string{"paths", consts.DefaultRelayerPath, "dst", "client-id"}, +// ) +// if err != nil { +// return false, err +// } +// +// clientIDHub_raw, err := roller_utils.GetNestedValue( +// rlyCfg, +// []string{"paths", consts.DefaultRelayerPath, "src", "client-id"}, +// ) +// if err != nil { +// return false, err +// } +// +// //nolint:errcheck +// clientIDRollapp := clientIDRollapp_raw.(string) +// //nolint:errcheck +// clientIDHub := clientIDHub_raw.(string) +// +// if clientIDRollapp == "" || clientIDHub == "" { +// r.logger.Printf("can't find clients in the config for both rollapp and hub") +// return false, nil +// } +// return true, nil +// } diff --git a/relayer/commands.go b/relayer/commands.go index 8e8e2336..0bc109a6 100644 --- a/relayer/commands.go +++ b/relayer/commands.go @@ -47,6 +47,6 @@ func (r *Relayer) getArgsWithSrcChannel() []string { consts.DefaultRelayerPath, r.DstChannel, "--home", - filepath.Join(r.Home, consts.ConfigDirName.Relayer), + filepath.Join(r.RollerHome, consts.ConfigDirName.Relayer), } } diff --git a/relayer/config.go b/relayer/config.go index 76ba97f3..b0650fbf 100644 --- a/relayer/config.go +++ b/relayer/config.go @@ -1,20 +1,98 @@ package relayer import ( + "encoding/json" "fmt" "os" "os/exec" "path/filepath" "github.com/pterm/pterm" - yaml "gopkg.in/yaml.v2" + yaml "gopkg.in/yaml.v3" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/utils" + "github.com/dymensionxyz/roller/utils/config/yamlconfig" "github.com/dymensionxyz/roller/utils/roller" ) -func CreatePath(rlpCfg roller.RollappConfig) error { +type RelayerFileChainConfig struct { + Type string `json:"type"` + Value RelayerFileChainConfigValue `json:"value"` +} + +type RelayerFileChainConfigValue struct { + Key string `json:"key"` + ChainID string `json:"chain-id"` + RpcAddr string `json:"rpc-addr"` + ApiAddr string `json:"http-addr"` + AccountPrefix string `json:"account-prefix"` + KeyringBackend string `json:"keyring-backend"` + GasAdjustment float64 `json:"gas-adjustment"` + GasPrices string `json:"gas-prices"` + Debug bool `json:"debug"` + Timeout string `json:"timeout"` + OutputFormat string `json:"output-format"` + SignMode string `json:"sign-mode"` + ExtraCodecs []string `json:"extra-codecs"` +} + +type RelayerChainConfig struct { + ChainConfig ChainConfig + GasPrices string + KeyName string +} + +// Config struct represents the paths section inside the relayer +// configuration file +type Config struct { + Chains map[string]RelayerFileChainConfig `yaml:"chains"` + Paths *Paths `yaml:"paths"` +} + +type Paths struct { + HubRollapp *struct { + Dst *struct { + ChainID string `yaml:"chain-id"` + ClientID string `yaml:"client-id"` + ConnectionID string `yaml:"connection-id"` + } `yaml:"dst"` + Src *struct { + ChainID string `yaml:"chain-id"` + ClientID string `yaml:"client-id"` + ConnectionID string `yaml:"connection-id"` + } `yaml:"src"` + SrcChannelFilter *struct { + ChannelList []string `yaml:"channel-list"` + Rule string `yaml:"rule"` + } `yaml:"src-channel-filter"` + } `yaml:"hub-rollapp"` +} + +func (c *Config) Load(rlyConfigPath string) error { + fmt.Println("loading config from", rlyConfigPath) + data, err := os.ReadFile(rlyConfigPath) + if err != nil { + return err + } + + err = yaml.Unmarshal(data, c) + if err != nil { + return err + } + + return nil +} + +func (c *Config) GetPath() *Paths { + if c.Paths == nil || c.Paths.HubRollapp == nil { + return nil + } + + return c.Paths +} + +func (c *Config) CreatePath(rlpCfg roller.RollappConfig) error { relayerHome := filepath.Join(rlpCfg.Home, consts.ConfigDirName.Relayer) pterm.Info.Printf("creating new ibc path from %s to %s\n", rlpCfg.HubData.ID, rlpCfg.RollappID) @@ -116,3 +194,161 @@ func WriteRlyConfig(homeDir string, rlyCfg map[interface{}]interface{}) error { // nolint:gofumpt return os.WriteFile(rlyConfigPath, data, 0o644) } + +func writeTmpChainConfig(chainConfig RelayerFileChainConfig, fileName string) (string, error) { + file, err := json.Marshal(chainConfig) + if err != nil { + return "", err + } + filePath := filepath.Join(os.TempDir(), fileName) + // nolint:gofumpt + if err := os.WriteFile(filePath, file, 0o644); err != nil { + return "", err + } + return filePath, nil +} + +func getRelayerFileChainConfig(relayerChainConfig RelayerChainConfig) RelayerFileChainConfig { + return RelayerFileChainConfig{ + Type: "cosmos", + Value: RelayerFileChainConfigValue{ + Key: relayerChainConfig.KeyName, + ChainID: relayerChainConfig.ChainConfig.ID, + RpcAddr: relayerChainConfig.ChainConfig.RPC, + AccountPrefix: relayerChainConfig.ChainConfig.AddressPrefix, + KeyringBackend: "test", + GasAdjustment: 1.2, + GasPrices: relayerChainConfig.GasPrices, + Debug: true, + Timeout: "10s", + OutputFormat: "json", + SignMode: "direct", + ExtraCodecs: []string{"ethermint"}, + }, + } +} + +func addChainToRelayer(fileChainConfig RelayerFileChainConfig, relayerHome string) error { + chainFilePath, err := writeTmpChainConfig(fileChainConfig, "chain.json") + if err != nil { + return err + } + addChainCmd := exec.Command( + consts.Executables.Relayer, + "chains", + "add", + fileChainConfig.Value.ChainID, + "--home", + relayerHome, + "--file", + chainFilePath, + ) + if err := addChainCmd.Run(); err != nil { + return err + } + return nil +} + +func initRelayer(relayerHome string) error { + initRelayerConfigCmd := exec.Command( + consts.Executables.Relayer, + "config", + "init", + "--home", + relayerHome, + ) + return initRelayerConfigCmd.Run() +} + +func addChainsConfig( + rollappConfig ChainConfig, + hubConfig ChainConfig, + relayerHome string, +) error { + relayerRollappConfig := getRelayerFileChainConfig( + RelayerChainConfig{ + ChainConfig: rollappConfig, + GasPrices: rollappConfig.GasPrices + rollappConfig.Denom, + KeyName: consts.KeysIds.RollappRelayer, + }, + ) + + relayerHubConfig := getRelayerFileChainConfig( + RelayerChainConfig{ + ChainConfig: hubConfig, + GasPrices: hubConfig.GasPrices + hubConfig.Denom, + KeyName: consts.KeysIds.HubRelayer, + }, + ) + + if err := addChainToRelayer(relayerRollappConfig, relayerHome); err != nil { + return err + } + if err := addChainToRelayer(relayerHubConfig, relayerHome); err != nil { + return err + } + return nil +} + +func InitializeConfig( + rollappConfig ChainConfig, + hubConfig ChainConfig, + home string, +) error { + relayerHome := filepath.Join(home, consts.ConfigDirName.Relayer) + + if err := initRelayer(relayerHome); err != nil { + return err + } + if err := addChainsConfig(rollappConfig, hubConfig, relayerHome); err != nil { + return err + } + + return nil +} + +func (c *Config) HubDataFromRelayerConfig() *consts.HubData { + hd := consts.HubData{ + ID: c.Paths.HubRollapp.Src.ChainID, + RpcUrl: c.Chains[c.Paths.HubRollapp.Src.ChainID].Value.RpcAddr, + ApiUrl: c.Chains[c.Paths.HubRollapp.Src.ChainID].Value.ApiAddr, + } + + return &hd +} + +func (c *Config) RaDataFromRelayerConfig() *consts.RollappData { + raData := consts.RollappData{ + ID: c.Paths.HubRollapp.Dst.ChainID, + RpcUrl: c.Chains[c.Paths.HubRollapp.Dst.ChainID].Value.RpcAddr, + } + + return &raData +} + +func (r *Relayer) UpdateConfigWithDefaultValues(rollerData roller.RollappConfig) error { + updates := map[string]interface{}{ + fmt.Sprintf("chains.%s.value.gas-adjustment", rollerData.HubData.ID): 1.5, + fmt.Sprintf("chains.%s.value.gas-prices", rollerData.HubData.ID): fmt.Sprintf( + "20000000000%s", + consts.Denoms.Hub, + ), + fmt.Sprintf("chains.%s.value.gas-adjustment", rollerData.RollappID): 1.3, + fmt.Sprintf("chains.%s.value.is-dym-hub", rollerData.HubData.ID): true, + fmt.Sprintf( + "chains.%s.value.http-addr", + rollerData.HubData.ID, + ): rollerData.HubData.ApiUrl, + fmt.Sprintf("chains.%s.value.is-dym-rollapp", rollerData.RollappID): true, + "extra-codecs": []string{ + "ethermint", + }, + } + err := yamlconfig.UpdateNestedYAML(r.ConfigFilePath, updates) + if err != nil { + pterm.Error.Printf("Error updating YAML: %v\n", err) + return err + } + + return nil +} diff --git a/relayer/connections.go b/relayer/connections.go index b465ece7..4471b6d5 100644 --- a/relayer/connections.go +++ b/relayer/connections.go @@ -2,126 +2,148 @@ package relayer import ( "encoding/json" + "fmt" "os/exec" "path/filepath" "slices" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/utils/bash" + "github.com/dymensionxyz/roller/utils/config/yamlconfig" ) -type ConnectionsQueryResult struct { - Connections []ConnectionInfo `json:"connections"` - Height ProofHeightInfo `json:"height"` - Pagination PaginationInfo `json:"pagination"` -} +func (r *Relayer) HubIbcConnections(hd consts.HubData) (*ConnectionsQueryResult, error) { + cmd := r.queryConnectionHubCmd(hd) -type RlyConnectionsQueryResult struct { - ID string `json:"id"` - ClientID string `json:"client_id"` - Versions []VersionInfo `json:"versions"` - State string `json:"state"` - Counterparty CounterpartyInfo `json:"counterparty"` - DelayPeriod string `json:"delay_period"` -} + hubIbcConnectionsOut, err := bash.ExecCommandWithStdout(cmd) + if err != nil { + return nil, err + } -type RlyConnectionQueryResult struct { - Connection ConnectionInfo `json:"connection"` - Proof string `json:"proof"` - ProofHeight ProofHeightInfo `json:"proof_height"` + var hubIbcConnections ConnectionsQueryResult + err = json.Unmarshal(hubIbcConnectionsOut.Bytes(), &hubIbcConnections) + if err != nil { + return nil, err + } + return &hubIbcConnections, nil } -type ConnectionInfo struct { - ClientID string `json:"client_id"` - Versions []VersionInfo `json:"versions"` - State string `json:"state"` - ID string `json:"id"` - Counterparty CounterpartyInfo `json:"counterparty"` - DelayPeriod string `json:"delay_period"` -} +func (r *Relayer) RaIbcConnections( + raData consts.RollappData, +) (*ConnectionsQueryResult, error) { + cmd := r.getQueryRaIbcConnectionsCmd(raData) -type ProofHeightInfo struct { - RevisionNumber string `json:"revision_number"` - RevisionHeight string `json:"revision_height"` -} + raConnectionsOut, err := bash.ExecCommandWithStdout(cmd) + if err != nil { + r.logger.Printf( + "failed to find connection on the rollapp side for %s: %v", + r.Rollapp.ID, + err, + ) + return nil, err + } -type PaginationInfo struct { - NextKey string `json:"next_key"` - Total string `json:"total"` + var raIbcConnections ConnectionsQueryResult + err = json.Unmarshal(raConnectionsOut.Bytes(), &raIbcConnections) + if err != nil { + return nil, err + } + return &raIbcConnections, nil } -type VersionInfo struct { - Identifier string `json:"identifier"` - Features []string `json:"features"` -} +func (r *Relayer) UpdateDefaultPath() error { + updates := map[string]interface{}{ + // hub + fmt.Sprintf("paths.%s.src.client-id", consts.DefaultRelayerPath): r.SrcClientID, + fmt.Sprintf("paths.%s.src.connection-id", consts.DefaultRelayerPath): r.SrcConnectionID, + + // ra + fmt.Sprintf("paths.%s.dst.client-id", consts.DefaultRelayerPath): r.DstClientID, + fmt.Sprintf("paths.%s.dst.connection-id", consts.DefaultRelayerPath): r.DstConnectionID, + } + err := yamlconfig.UpdateNestedYAML(r.ConfigFilePath, updates) + if err != nil { + return err + } -type CounterpartyInfo struct { - ClientID string `json:"client_id"` - ConnectionID string `json:"connection_id"` - Prefix PrefixInfo `json:"prefix"` + return nil } -type PrefixInfo struct { - KeyPrefix string `json:"key_prefix"` +func (r *Relayer) ConnectionInfoFromRaConnID( + raData consts.RollappData, + raIbcConnectionID string, +) error { + raIbcConnections, err := r.RaIbcConnections(raData) + if err != nil { + return err + } + + if len(raIbcConnections.Connections) == 0 { + return fmt.Errorf("no connections found on the rollapp side for %s", r.Rollapp.ID) + } + + raIbcConnIndex := slices.IndexFunc( + raIbcConnections.Connections, func(ibcConn ConnectionInfo) bool { + return ibcConn.ID == raIbcConnectionID && ibcConn.State == "STATE_OPEN" + }, + ) + + if raIbcConnIndex == -1 { + return fmt.Errorf("no open channel found for %s", r.Rollapp.ID) + } + + conn := raIbcConnections.Connections[raIbcConnIndex] + r.SrcConnectionID = conn.Counterparty.ConnectionID + r.SrcClientID = conn.Counterparty.ClientID + r.DstClientID = conn.ClientID + + return nil } func (r *Relayer) GetActiveConnectionIDs( raData consts.RollappData, hd consts.HubData, ) (string, string, error) { - cmd := r.queryConnectionRollappCmd(raData) - - rollappConnectionOutput, err := bash.ExecCommandWithStdout(cmd) - if err != nil { - r.logger.Printf( - "failed to find connection on the rollapp side for %s: %v", - r.RollappID, - err, - ) - return "", "", err - } - // While there are JSON objects in the stream... - var rollappIbcConnection ConnectionsQueryResult - err = json.Unmarshal(rollappConnectionOutput.Bytes(), &rollappIbcConnection) + raIbcConnections, err := r.RaIbcConnections( + raData, + ) if err != nil { - r.logger.Printf("error while decoding JSON: %v", err) + return "", "", err } - if len(rollappIbcConnection.Connections) == 0 { - r.logger.Printf("no connections found on the rollapp side for %s", r.RollappID) + if len(raIbcConnections.Connections) == 0 { + r.logger.Printf("no connections found on the rollapp side for %s", r.Rollapp.ID) return "", "", nil } - // TODO: review, why return nil error? - if rollappIbcConnection.Connections[0].State != "STATE_OPEN" { + var raActiveConnectionInfo *ConnectionInfo + + for _, conn := range raIbcConnections.Connections { + if conn.State == "STATE_OPEN" { + raActiveConnectionInfo = &conn + } + } + if raActiveConnectionInfo == nil { return "", "", nil } - hubConnectionID := rollappIbcConnection.Connections[0].Counterparty.ConnectionID + hubConnectionID := raActiveConnectionInfo.Counterparty.ConnectionID // Check if the connection is open on the hub - var hubIbcConnection ConnectionsQueryResult - outputHub, err := bash.ExecCommandWithStdout( - r.queryConnectionHubCmd(hd), - ) - if err != nil { - return "", "", err - } - - err = json.Unmarshal(outputHub.Bytes(), &hubIbcConnection) + hubIbcConnections, err := r.HubIbcConnections(hd) if err != nil { return "", "", err } hubConnIndex := slices.IndexFunc( - hubIbcConnection.Connections, func(conn ConnectionInfo) bool { + hubIbcConnections.Connections, func(conn ConnectionInfo) bool { return conn.ID == hubConnectionID }, ) - hubConnection := hubIbcConnection.Connections[hubConnIndex] + hubConnection := hubIbcConnections.Connections[hubConnIndex] - return rollappIbcConnection.Connections[0].ID, hubConnection.ID, nil + return raActiveConnectionInfo.ID, hubConnection.ID, nil } func (r *Relayer) GetActiveConnections(raData consts.RollappData, hd consts.HubData) ( @@ -130,14 +152,14 @@ func (r *Relayer) GetActiveConnections(raData consts.RollappData, hd consts.HubD error, ) { rollappConnectionOutput, err := bash.ExecCommandWithStdout( - r.queryConnectionRollappCmd( + r.getQueryRaIbcConnectionsCmd( raData, ), ) if err != nil { r.logger.Printf( "failed to find connection on the rollapp side for %s: %v", - r.RollappID, + r.Rollapp.ID, err, ) return nil, nil, err @@ -151,7 +173,7 @@ func (r *Relayer) GetActiveConnections(raData consts.RollappData, hd consts.HubD } if len(rollappIbcConnection.Connections) == 0 { - r.logger.Printf("no connections found on the rollapp side for %s", r.RollappID) + r.logger.Printf("no connections found on the rollapp side for %s", r.Rollapp.ID) return nil, nil, nil } @@ -162,31 +184,23 @@ func (r *Relayer) GetActiveConnections(raData consts.RollappData, hd consts.HubD hubConnectionID := rollappIbcConnection.Connections[0].Counterparty.ConnectionID // Check if the connection is open on the hub - var hubIbcConnection ConnectionsQueryResult - outputHub, err := bash.ExecCommandWithStdout( - r.queryConnectionHubCmd(hd), - ) - if err != nil { - return nil, nil, err - } - - err = json.Unmarshal(outputHub.Bytes(), &hubIbcConnection) + hubIbcConnections, err := r.HubIbcConnections(hd) if err != nil { return nil, nil, err } hubConnIndex := slices.IndexFunc( - hubIbcConnection.Connections, func(conn ConnectionInfo) bool { + hubIbcConnections.Connections, func(conn ConnectionInfo) bool { return conn.ID == hubConnectionID }, ) - hubConnection := hubIbcConnection.Connections[hubConnIndex] + hubConnection := hubIbcConnections.Connections[hubConnIndex] return &rollappIbcConnection.Connections[0], &hubConnection, nil } -func (r *Relayer) queryConnectionRollappCmd( +func (r *Relayer) getQueryRaIbcConnectionsCmd( raData consts.RollappData, ) *exec.Cmd { args := []string{ @@ -226,7 +240,7 @@ func (r *Relayer) queryConnectionHubCmd(hd consts.HubData) *exec.Cmd { } func (r *Relayer) queryConnectionsHubCmd() *exec.Cmd { - args := []string{"q", "connections", r.HubID} - args = append(args, "--home", filepath.Join(r.Home, consts.ConfigDirName.Relayer)) + args := []string{"q", "connections", r.Hub.ID} + args = append(args, "--home", filepath.Join(r.RollerHome, consts.ConfigDirName.Relayer)) return exec.Command(consts.Executables.Relayer, args...) } diff --git a/relayer/connections_types.go b/relayer/connections_types.go new file mode 100644 index 00000000..58f9cc44 --- /dev/null +++ b/relayer/connections_types.go @@ -0,0 +1,56 @@ +package relayer + +type ConnectionsQueryResult struct { + Connections []ConnectionInfo `json:"connections"` + Height ProofHeightInfo `json:"height"` + Pagination PaginationInfo `json:"pagination"` +} + +type RlyConnectionsQueryResult struct { + ID string `json:"id"` + ClientID string `json:"client_id"` + Versions []VersionInfo `json:"versions"` + State string `json:"state"` + Counterparty CounterpartyInfo `json:"counterparty"` + DelayPeriod string `json:"delay_period"` +} + +type RlyConnectionQueryResult struct { + Connection ConnectionInfo `json:"connection"` + Proof string `json:"proof"` + ProofHeight ProofHeightInfo `json:"proof_height"` +} + +type ConnectionInfo struct { + ClientID string `json:"client_id"` + Versions []VersionInfo `json:"versions"` + State string `json:"state"` + ID string `json:"id"` + Counterparty CounterpartyInfo `json:"counterparty"` + DelayPeriod string `json:"delay_period"` +} + +type ProofHeightInfo struct { + RevisionNumber string `json:"revision_number"` + RevisionHeight string `json:"revision_height"` +} + +type PaginationInfo struct { + NextKey string `json:"next_key"` + Total string `json:"total"` +} + +type VersionInfo struct { + Identifier string `json:"identifier"` + Features []string `json:"features"` +} + +type CounterpartyInfo struct { + ClientID string `json:"client_id"` + ConnectionID string `json:"connection_id"` + Prefix PrefixInfo `json:"prefix"` +} + +type PrefixInfo struct { + KeyPrefix string `json:"key_prefix"` +} diff --git a/relayer/create_ibc_channel.go b/relayer/create_ibc_channel.go index 27b3e1b6..f664b74b 100644 --- a/relayer/create_ibc_channel.go +++ b/relayer/create_ibc_channel.go @@ -1,6 +1,7 @@ package relayer import ( + "encoding/json" "fmt" "os/exec" "path/filepath" @@ -15,9 +16,6 @@ import ( "github.com/dymensionxyz/roller/utils/logging" ) -// TODO: the relayer whitelisted address has to be the rollapp's relayer address -// not the hub - // CreateIBCChannel Creates an IBC channel between the hub and the client, // and return the source channel ID. func (r *Relayer) CreateIBCChannel( @@ -45,7 +43,12 @@ func (r *Relayer) CreateIBCChannel( return ConnectionChannels{}, err } - createConnectionCmd := r.getCreateConnectionCmd() + sp, err := getHubStakingParams(r.Hub) + if err != nil { + return ConnectionChannels{}, err + } + + createConnectionCmd := r.getCreateConnectionCmd(sp.UnbondingTime) if err := bash.ExecCmd(createConnectionCmd, logFileOption); err != nil { return ConnectionChannels{}, err } @@ -54,9 +57,8 @@ func (r *Relayer) CreateIBCChannel( // Sleep for a few seconds to make sure the connection is created time.Sleep(15 * time.Second) // we ran create channel with override, as it not recovarable anyway - createChannelCmd := r.getCreateChannelCmd(true) + createChannelCmd := r.getCreateChannelCmd(false) - // TODO: switch to spinned pterm.Info.Println("💈 Creating channel (this may take a while)...") if err := r.WriteRelayerStatus(status); err != nil { return ConnectionChannels{}, err @@ -70,7 +72,7 @@ func (r *Relayer) CreateIBCChannel( return ConnectionChannels{}, err } - _, _, err = r.LoadActiveChannel(raData, hd) + err = r.LoadActiveChannel(raData, hd) if err != nil { return ConnectionChannels{}, err } @@ -78,11 +80,6 @@ func (r *Relayer) CreateIBCChannel( return ConnectionChannels{}, fmt.Errorf("could not load channels") } - fmt.Printf( - "💈 The relayer is running successfully on you local machine!\nChannels:\nrollapp: %s\n<->\nhub: %s\n", - r.DstChannel, - r.SrcChannel, - ) if err := r.WriteRelayerStatus(status); err != nil { return ConnectionChannels{}, err } @@ -127,44 +124,75 @@ func WaitForValidRollappHeight(seq *sequencer.Sequencer) error { } } -func (r *Relayer) getCreateClientsCmd(override bool) *exec.Cmd { - args := []string{"tx", "clients"} - args = append(args, r.getRelayerDefaultArgs()...) - args = append(args, "--log-level", "debug") - if override { - args = append(args, "--override") - } - cmd := exec.Command(consts.Executables.Relayer, args...) - return cmd -} - -func (r *Relayer) getCreateConnectionCmd() *exec.Cmd { +func (r *Relayer) getCreateConnectionCmd(unbondingTime string) *exec.Cmd { args := []string{"tx", "connection", "--max-clock-drift", "70m"} args = append(args, r.getRelayerDefaultArgs()...) return exec.Command(consts.Executables.Relayer, args...) } -func (r *Relayer) getTxLinkCmd(override bool) *exec.Cmd { - args := []string{ - "tx", - "link", - consts.DefaultRelayerPath, - "--src-port", - "transfer", - "--dst-port", - "transfer", - "--version", - "ics20-1", - "--max-clock-drift", - "70m", +type StakingParamsResponse struct { + BondDenom string `json:"bond_denom"` + HistoricalEntries uint32 `json:"historical_entries"` + MaxEntries uint32 `json:"max_entries"` + MaxValidators uint32 `json:"max_validators"` + MinCommissionRate string `json:"min_commission_rate"` + UnbondingTime string `json:"unbonding_time"` +} + +func getHubStakingParams(hd consts.HubData) (*StakingParamsResponse, error) { + cmd := exec.Command( + consts.Executables.Dymension, + "q", + "staking", + "params", + "--node", + hd.RpcUrl, + "--chain-id", + hd.ID, + "--output", + "json", + ) + + out, err := bash.ExecCommandWithStdout(cmd) + if err != nil { + return nil, err } - if override { - args = append(args, "--override") + + var stakingParams StakingParamsResponse + err = json.Unmarshal(out.Bytes(), &stakingParams) + if err != nil { + return nil, err } - args = append(args, r.getRelayerDefaultArgs()...) - return exec.Command(consts.Executables.Relayer, args...) + + return &stakingParams, nil } +// func (r *Relayer) getTxLinkCmd(override bool, unbondingTime time.Duration) *exec.Cmd { +// args := []string{ +// "tx", +// "link", +// consts.DefaultRelayerPath, +// "--src-port", +// "transfer", +// "--dst-port", +// "transfer", +// "--version", +// "ics20-1", +// "--max-clock-drift", +// "70m", +// "--client-tp", +// unbondingTime.String(), +// } +// if override { +// args = append(args, "--override") +// } +// args = append(args, r.getRelayerDefaultArgs()...) +// cmd := exec.Command(consts.Executables.Relayer, args...) +// fmt.Println(cmd.String()) +// +// return cmd +// } + func (r *Relayer) getCreateChannelCmd(override bool) *exec.Cmd { args := []string{"tx", "channel", "--timeout", "60s", "--debug"} if override { @@ -178,6 +206,6 @@ func (r *Relayer) getRelayerDefaultArgs() []string { return []string{ consts.DefaultRelayerPath, "--home", - filepath.Join(r.Home, consts.ConfigDirName.Relayer), + filepath.Join(r.RollerHome, consts.ConfigDirName.Relayer), } } diff --git a/relayer/errors.go b/relayer/errors.go new file mode 100644 index 00000000..999040ed --- /dev/null +++ b/relayer/errors.go @@ -0,0 +1,5 @@ +package relayer + +import "errors" + +var ErrNoOpenChannel = errors.New("no open channel") diff --git a/relayer/keys.go b/relayer/keys.go new file mode 100644 index 00000000..3d96584a --- /dev/null +++ b/relayer/keys.go @@ -0,0 +1,130 @@ +package relayer + +import ( + cosmossdkmath "cosmossdk.io/math" + + "github.com/dymensionxyz/roller/cmd/consts" + "github.com/dymensionxyz/roller/sequencer" + "github.com/dymensionxyz/roller/utils/keys" + "github.com/dymensionxyz/roller/utils/roller" +) + +var oneDayRelayPrice, _ = cosmossdkmath.NewIntFromString( + "2000000000000000000", +) // 2000000000000000000 = 2dym + +func VerifyRelayerBalances(hd consts.HubData) error { + insufficientBalances, err := getRelayerInsufficientBalances(hd) + if err != nil { + return err + } + + if len(insufficientBalances) != 0 { + err = keys.PrintInsufficientBalancesIfAny(insufficientBalances) + if err != nil { + return err + } + } + + return nil +} + +func getRelayerInsufficientBalances( + hd consts.HubData, +) ([]keys.NotFundedAddressData, error) { + var insufficientBalances []keys.NotFundedAddressData + home := roller.GetRootDir() + + accData, err := GetRelayerAccountsData(home, hd) + if err != nil { + return nil, err + } + + // consts.Denoms.Hub is used here because as of @202409 we no longer require rollapp + // relayer account funding to establish IBC connection. + for _, acc := range accData { + if acc.Balance.Amount.IsNegative() { + insufficientBalances = append( + insufficientBalances, keys.NotFundedAddressData{ + KeyName: consts.KeysIds.HubRelayer, + Address: acc.Address, + CurrentBalance: acc.Balance.Amount.BigInt(), + RequiredBalance: oneDayRelayPrice.BigInt(), + Denom: consts.Denoms.Hub, + Network: hd.ID, + }, + ) + } + } + + return insufficientBalances, nil +} + +func GetRelayerAccountsData( + home string, + hd consts.HubData, +) ([]keys.AccountData, error) { + var data []keys.AccountData + + // rollappRlyAcc, err := getRolRlyAccData(cfg) + // if err != nil { + // return nil, err + // } + // data = append(data, *rollappRlyAcc) + + hubRlyAcc, err := getHubRlyAccData(home, hd) + if err != nil { + return nil, err + } + + data = append(data, *hubRlyAcc) + return data, nil +} + +func getHubRlyAccData(home string, hd consts.HubData) (*keys.AccountData, error) { + HubRlyAddr, err := keys.GetRelayerAddress(home, hd.ID) + if err != nil { + return nil, err + } + + HubRlyBalance, err := keys.QueryBalance( + keys.ChainQueryConfig{ + RPC: hd.RpcUrl, + Denom: consts.Denoms.Hub, + Binary: consts.Executables.Dymension, + }, HubRlyAddr, + ) + if err != nil { + return nil, err + } + + return &keys.AccountData{ + Address: HubRlyAddr, + Balance: *HubRlyBalance, + }, nil +} + +// nolint: unused +func getRolRlyAccData(home string, raData roller.RollappConfig) (*keys.AccountData, error) { + RollappRlyAddr, err := keys.GetRelayerAddress(home, raData.RollappID) + seq := sequencer.GetInstance(raData) + if err != nil { + return nil, err + } + + RollappRlyBalance, err := keys.QueryBalance( + keys.ChainQueryConfig{ + RPC: seq.GetRPCEndpoint(), + Denom: raData.Denom, + Binary: consts.Executables.RollappEVM, + }, RollappRlyAddr, + ) + if err != nil { + return nil, err + } + + return &keys.AccountData{ + Address: RollappRlyAddr, + Balance: *RollappRlyBalance, + }, nil +} diff --git a/relayer/relayer_manager.go b/relayer/relayer_manager.go index 506a2012..051a1df1 100644 --- a/relayer/relayer_manager.go +++ b/relayer/relayer_manager.go @@ -13,20 +13,37 @@ import ( ) type Relayer struct { - Home string - RollappID string - HubID string + RollerHome string + RelayerHome string + ConfigFilePath string + + Rollapp consts.RollappData + Hub consts.HubData + // channels SrcChannel string DstChannel string - logger *log.Logger + // connections + SrcConnectionID string + DstConnectionID string + // clients + SrcClientID string + DstClientID string + + logger *log.Logger } -func NewRelayer(home, rollappID, hubID string) *Relayer { +func NewRelayer(home string, raData consts.RollappData, hd consts.HubData) *Relayer { + relayerHome := GetHomeDir(home) + relayerConfigPath := GetConfigFilePath(relayerHome) return &Relayer{ - Home: home, - RollappID: rollappID, - HubID: hubID, - logger: log.New(io.Discard, "", 0), + RollerHome: home, + RelayerHome: relayerHome, + ConfigFilePath: relayerConfigPath, + + Rollapp: raData, + Hub: hd, + + logger: log.New(io.Discard, "", 0), } } @@ -58,7 +75,7 @@ func (r *Relayer) WriteRelayerStatus(status string) error { } func (r *Relayer) StatusFilePath() string { - return filepath.Join(r.Home, consts.ConfigDirName.Relayer, "relayer_status.txt") + return filepath.Join(r.RollerHome, consts.ConfigDirName.Relayer, "relayer_status.txt") } type ConnectionChannels struct { diff --git a/relayer/utils.go b/relayer/utils.go new file mode 100644 index 00000000..dcdc7742 --- /dev/null +++ b/relayer/utils.go @@ -0,0 +1,15 @@ +package relayer + +import ( + "path/filepath" + + "github.com/dymensionxyz/roller/cmd/consts" +) + +func GetHomeDir(home string) string { + return filepath.Join(home, consts.ConfigDirName.Relayer) +} + +func GetConfigFilePath(relayerHome string) string { + return filepath.Join(relayerHome, "config", "config.yaml") +} diff --git a/relayer/whitelisting.go b/relayer/whitelisting.go new file mode 100644 index 00000000..5dd19529 --- /dev/null +++ b/relayer/whitelisting.go @@ -0,0 +1,95 @@ +package relayer + +import ( + "slices" + "time" + + "github.com/pterm/pterm" + + "github.com/dymensionxyz/roller/cmd/consts" + "github.com/dymensionxyz/roller/utils/roller" + sequencerutils "github.com/dymensionxyz/roller/utils/sequencer" +) + +func (r *Relayer) HandleWhitelisting( + addr string, + rollappChainData *roller.RollappConfig, +) error { + kb := rollappChainData.KeyringBackend + + seqAddr, err := sequencerutils.GetSequencerAccountAddress(*rollappChainData) + if err != nil { + return err + } + + isRlyKeyWhitelisted, err := isRelayerRollappKeyWhitelisted( + seqAddr, + addr, + r.Hub, + ) + if err != nil { + return err + } + + if !isRlyKeyWhitelisted { + pterm.Warning.Printfln( + "relayer key (%s) is not whitelisted, updating whitelisted relayers", + addr, + ) + + err := sequencerutils.UpdateWhitelistedRelayers( + r.RollerHome, + addr, + string(kb), + r.Hub, + ) + if err != nil { + pterm.Error.Println("failed to update whitelisted relayers:", err) + return err + } + } + + raOpAddr, err := sequencerutils.GetSequencerOperatorAddress( + r.RollerHome, + string(kb), + ) + if err != nil { + pterm.Error.Println("failed to get RollApp's operator address:", err) + return err + } + + wrSpinner, _ := pterm.DefaultSpinner.Start( + "waiting for the whitelisted relayer to propagate to RollApp (this might take a while)", + ) + for { + wra, err := sequencerutils.GetWhitelistedRelayersOnRa(raOpAddr) + if err != nil { + pterm.Error.Println("failed to get whitelisted relayers:", err) + return err + } + + if len(wra) == 0 && + slices.Contains(wra, addr) { + wrSpinner.UpdateText( + "waiting for the whitelisted relayer to propagate to RollApp...", + ) + time.Sleep(time.Second * 5) + continue + } else { + // nolint: errcheck + wrSpinner.Success("relayer whitelisted and propagated to rollapp") + break + } + } + + return nil +} + +func isRelayerRollappKeyWhitelisted(seqAddr, relAddr string, hd consts.HubData) (bool, error) { + relayers, err := sequencerutils.GetWhitelistedRelayersOnHub(seqAddr, hd) + if err != nil { + return false, err + } + + return slices.Contains(relayers, relAddr), nil +} diff --git a/utils/dependencies/celestia.go b/utils/dependencies/celestia.go index 08780d24..e450a990 100644 --- a/utils/dependencies/celestia.go +++ b/utils/dependencies/celestia.go @@ -8,7 +8,7 @@ import ( ) const ( - DefaultCelestiaNodeVersion = "v0.20.2-mocha" + DefaultCelestiaNodeVersion = "v0.20.4-mocha" DefaultCelestiaAppVersion = "v2.3.1" ) diff --git a/utils/dependencies/relayer.go b/utils/dependencies/relayer.go index 62bdb98b..da39a382 100644 --- a/utils/dependencies/relayer.go +++ b/utils/dependencies/relayer.go @@ -5,6 +5,10 @@ import ( "github.com/dymensionxyz/roller/utils/dependencies/types" ) +const ( + DefaultRelayerVersion = "v0.4.2-v2.5.2-roller" +) + func DefaultRelayerPrebuiltDependencies() map[string]types.Dependency { return map[string]types.Dependency{ "rly": { @@ -12,7 +16,7 @@ func DefaultRelayerPrebuiltDependencies() map[string]types.Dependency { RepositoryOwner: "artemijspavlovs", RepositoryName: "go-relayer", RepositoryUrl: "https://github.com/artemijspavlovs/go-relayer", - Release: "v0.4.0-v2.5.2-relayer-pg-roller", + Release: DefaultRelayerVersion, Binaries: []types.BinaryPathPair{ { Binary: "rly", diff --git a/utils/firebase/firebase.go b/utils/firebase/firebase.go index 162e8f13..1361b129 100644 --- a/utils/firebase/firebase.go +++ b/utils/firebase/firebase.go @@ -16,6 +16,9 @@ type DrsVersionInfo struct { Commit string `firestore:"commit"` } +// GetLatestDrsVersionCommit +// Fetch DRS version information using the nested collection path +// Path format: versions/{version}/revisions/{revision} func GetLatestDrsVersionCommit(drsVersion string) (*DrsVersionInfo, error) { ctx := context.Background() conf := &firebase.Config{ProjectID: "drs-metadata"} diff --git a/utils/relayer/config.go b/utils/relayer/config.go deleted file mode 100644 index bbfe1171..00000000 --- a/utils/relayer/config.go +++ /dev/null @@ -1,100 +0,0 @@ -package relayer - -import ( - "fmt" - "path/filepath" - - "github.com/pterm/pterm" - - "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/utils/config/yamlconfig" - "github.com/dymensionxyz/roller/utils/filesystem" - "github.com/dymensionxyz/roller/utils/roller" -) - -func UpdateConfigWithDefaultValues(relayerHome string, rollerData roller.RollappConfig) error { - pterm.Info.Println("updating application relayer config") - relayerConfigPath := filepath.Join(relayerHome, "config", "config.yaml") - updates := map[string]interface{}{ - fmt.Sprintf("chains.%s.value.gas-adjustment", rollerData.HubData.ID): 1.5, - fmt.Sprintf("chains.%s.value.gas-prices", rollerData.HubData.ID): fmt.Sprintf( - "20000000000%s", - consts.Denoms.Hub, - ), - fmt.Sprintf("chains.%s.value.gas-adjustment", rollerData.RollappID): 1.3, - fmt.Sprintf("chains.%s.value.is-dym-hub", rollerData.HubData.ID): true, - fmt.Sprintf( - "chains.%s.value.http-addr", - rollerData.HubData.ID, - ): rollerData.HubData.ApiUrl, - fmt.Sprintf("chains.%s.value.is-dym-rollapp", rollerData.RollappID): true, - "extra-codecs": []string{ - "ethermint", - }, - } - err := yamlconfig.UpdateNestedYAML(relayerConfigPath, updates) - if err != nil { - pterm.Error.Printf("Error updating YAML: %v\n", err) - return err - } - - return nil -} - -type IbcPathChains struct { - SrcChainOk bool - DstChainOk bool - DefaultPathOk bool - RelayerConfigExists bool -} - -func ValidateIbcPathChains(relayerHome, raID string, hd consts.HubData) (*IbcPathChains, error) { - var err error - ibcPathChains := IbcPathChains{} - - relayerConfigPath := GetConfigFilePath(relayerHome) - - // 2. config file exists - relayerConfigExists, err := filesystem.DoesFileExist(relayerConfigPath) - if err != nil { - return nil, err - } - ibcPathChains.RelayerConfigExists = relayerConfigExists - - if relayerConfigExists { - // 2.1. path exist - defaultPathOk, err := VerifyDefaultPath(relayerHome) - if err != nil { - pterm.Error.Printf( - "failed to verify relayer path %s: %v\n", - consts.DefaultRelayerPath, - err, - ) - } - ibcPathChains.DefaultPathOk = defaultPathOk - - if defaultPathOk { - // 2.2. isHubChainPresent - srcChainOk, err := VerifyPathSrcChain(relayerHome, hd) - if err != nil { - pterm.Error.Printf( - "failed to verify source chain in relayer path: %v\n", - err, - ) - } - ibcPathChains.SrcChainOk = srcChainOk - - // 2.3. isRollappChainPresent - dstChainOk, err := VerifyPathDstChain(relayerHome, raID) - if err != nil { - return &ibcPathChains, err - } - ibcPathChains.DstChainOk = dstChainOk - } else { - pterm.Error.Println("default path not found in relayer config") - } - } - - pterm.Info.Println("ibc path validation passed") - return &ibcPathChains, nil -} diff --git a/utils/relayer/connection.go b/utils/relayer/connection.go deleted file mode 100644 index 8bc30dda..00000000 --- a/utils/relayer/connection.go +++ /dev/null @@ -1,80 +0,0 @@ -package relayer - -import ( - "os" - - "github.com/pterm/pterm" - "gopkg.in/yaml.v3" - - "github.com/dymensionxyz/roller/cmd/consts" -) - -func VerifyDefaultPath(relayerHome string) (bool, error) { - cfp := GetConfigFilePath(relayerHome) - - data, err := os.ReadFile(cfp) - if err != nil { - pterm.Error.Println("failed to read config file:", err) - return false, err - } - - var config Config - err = yaml.Unmarshal(data, &config) - if err != nil { - pterm.Error.Println("failed to unmarshal config file:", err) - return false, err - } - - if config.Paths == nil || config.Paths.HubRollapp == nil { - pterm.Error.Println("hub-rollapp not found in the YAML configuration.") - return false, nil - } - - return true, nil -} - -func VerifyPathSrcChain(relayerHome string, hd consts.HubData) (bool, error) { - cfp := GetConfigFilePath(relayerHome) - - data, err := os.ReadFile(cfp) - if err != nil { - return false, err - } - - // Unmarshal the YAML into the Config struct - var config Config - err = yaml.Unmarshal(data, &config) - if err != nil { - return false, err - } - - // Check if src.chain-id has a specific value - if config.Paths.HubRollapp.Src.ChainID == hd.ID { - return true, nil - } - - return false, nil -} - -func VerifyPathDstChain(relayerHome, raID string) (bool, error) { - cfp := GetConfigFilePath(relayerHome) - - data, err := os.ReadFile(cfp) - if err != nil { - return false, err - } - - // Unmarshal the YAML into the Config struct - var config Config - err = yaml.Unmarshal(data, &config) - if err != nil { - return false, err - } - - // Check if src.chain-id has a specific value - if config.Paths.HubRollapp.Dst.ChainID == raID { - return true, nil - } - - return false, nil -} diff --git a/utils/relayer/newibc.go b/utils/relayer/newibc.go index e29da8ed..44cb7434 100644 --- a/utils/relayer/newibc.go +++ b/utils/relayer/newibc.go @@ -6,7 +6,6 @@ import ( "github.com/pterm/pterm" - initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/relayer" "github.com/dymensionxyz/roller/utils/filesystem" @@ -26,30 +25,32 @@ func InitializeRelayer(home string, rollerData roller.RollappConfig) error { return err } - if !isRelayerInitialized { - pterm.Info.Println("initializing relayer config") - err = initconfig.InitializeRelayerConfig( - relayer.ChainConfig{ - ID: rollerData.RollappID, - RPC: consts.DefaultRollappRPC, - Denom: rollerData.BaseDenom, - AddressPrefix: rollerData.Bech32Prefix, - GasPrices: "2000000000", - }, relayer.ChainConfig{ - ID: rollerData.HubData.ID, - RPC: rollerData.HubData.RpcUrl, - Denom: consts.Denoms.Hub, - AddressPrefix: consts.AddressPrefixes.Hub, - GasPrices: rollerData.HubData.GasPrice, - }, home, + if isRelayerInitialized { + return nil + } + + pterm.Info.Println("initializing relayer config") + err = relayer.InitializeConfig( + relayer.ChainConfig{ + ID: rollerData.RollappID, + RPC: consts.DefaultRollappRPC, + Denom: rollerData.BaseDenom, + AddressPrefix: rollerData.Bech32Prefix, + GasPrices: "2000000000", + }, relayer.ChainConfig{ + ID: rollerData.HubData.ID, + RPC: rollerData.HubData.RpcUrl, + Denom: consts.Denoms.Hub, + AddressPrefix: consts.AddressPrefixes.Hub, + GasPrices: rollerData.HubData.GasPrice, + }, home, + ) + if err != nil { + pterm.Error.Printf( + "failed to initialize relayer config: %v\n", + err, ) - if err != nil { - pterm.Error.Printf( - "failed to initialize relayer config: %v\n", - err, - ) - return err - } + return err } return nil @@ -78,7 +79,7 @@ func EnsureKeysArePresentAndFunded( return nil, fmt.Errorf("cancelled by user") } - err = VerifyRelayerBalances(rollerData.HubData) + err = relayer.VerifyRelayerBalances(rollerData.HubData) if err != nil { return nil, err } diff --git a/utils/relayer/relayer.go b/utils/relayer/relayer.go index 677c1234..40a24a16 100644 --- a/utils/relayer/relayer.go +++ b/utils/relayer/relayer.go @@ -2,19 +2,14 @@ package relayer import ( "fmt" - "path/filepath" - "slices" "github.com/pterm/pterm" "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/sequencer" "github.com/dymensionxyz/roller/utils/config" "github.com/dymensionxyz/roller/utils/dependencies" "github.com/dymensionxyz/roller/utils/filesystem" - "github.com/dymensionxyz/roller/utils/keys" "github.com/dymensionxyz/roller/utils/roller" - sequencerutils "github.com/dymensionxyz/roller/utils/sequencer" ) // GetRollappToRunFor function retrieves the RollApp ID and Hub Data from the roller @@ -117,136 +112,3 @@ func promptForRaAndHd() (string, *consts.HubData, string, error) { return raID, &hd, "test", nil } - -func VerifyRelayerBalances(hd consts.HubData) error { - insufficientBalances, err := getRelayerInsufficientBalances(hd) - if err != nil { - return err - } - - if len(insufficientBalances) != 0 { - err = keys.PrintInsufficientBalancesIfAny(insufficientBalances) - if err != nil { - return err - } - } - - return nil -} - -func getRelayerInsufficientBalances( - hd consts.HubData, -) ([]keys.NotFundedAddressData, error) { - var insufficientBalances []keys.NotFundedAddressData - home := roller.GetRootDir() - - accData, err := GetRelayerAccountsData(home, hd) - if err != nil { - return nil, err - } - - // consts.Denoms.Hub is used here because as of @202409 we no longer require rollapp - // relayer account funding to establish IBC connection. - for _, acc := range accData { - if acc.Balance.Amount.IsNegative() { - insufficientBalances = append( - insufficientBalances, keys.NotFundedAddressData{ - KeyName: consts.KeysIds.HubRelayer, - Address: acc.Address, - CurrentBalance: acc.Balance.Amount.BigInt(), - RequiredBalance: oneDayRelayPrice.BigInt(), - Denom: consts.Denoms.Hub, - Network: hd.ID, - }, - ) - } - } - - return insufficientBalances, nil -} - -func GetRelayerAccountsData( - home string, - hd consts.HubData, -) ([]keys.AccountData, error) { - var data []keys.AccountData - - // rollappRlyAcc, err := getRolRlyAccData(cfg) - // if err != nil { - // return nil, err - // } - // data = append(data, *rollappRlyAcc) - - hubRlyAcc, err := getHubRlyAccData(home, hd) - if err != nil { - return nil, err - } - - data = append(data, *hubRlyAcc) - return data, nil -} - -// nolint: unused -func getRolRlyAccData(home string, raData roller.RollappConfig) (*keys.AccountData, error) { - RollappRlyAddr, err := keys.GetRelayerAddress(home, raData.RollappID) - seq := sequencer.GetInstance(raData) - if err != nil { - return nil, err - } - - RollappRlyBalance, err := keys.QueryBalance( - keys.ChainQueryConfig{ - RPC: seq.GetRPCEndpoint(), - Denom: raData.Denom, - Binary: consts.Executables.RollappEVM, - }, RollappRlyAddr, - ) - if err != nil { - return nil, err - } - - return &keys.AccountData{ - Address: RollappRlyAddr, - Balance: *RollappRlyBalance, - }, nil -} - -func getHubRlyAccData(home string, hd consts.HubData) (*keys.AccountData, error) { - HubRlyAddr, err := keys.GetRelayerAddress(home, hd.ID) - if err != nil { - return nil, err - } - - HubRlyBalance, err := keys.QueryBalance( - keys.ChainQueryConfig{ - RPC: hd.RpcUrl, - Denom: consts.Denoms.Hub, - Binary: consts.Executables.Dymension, - }, HubRlyAddr, - ) - if err != nil { - return nil, err - } - - return &keys.AccountData{ - Address: HubRlyAddr, - Balance: *HubRlyBalance, - }, nil -} - -func GetHomeDir(home string) string { - return filepath.Join(home, consts.ConfigDirName.Relayer) -} - -func GetConfigFilePath(relayerHome string) string { - return filepath.Join(relayerHome, "config", "config.yaml") -} - -func IsRelayerRollappKeyWhitelisted(seqAddr, relAddr string, hd consts.HubData) (bool, error) { - relayers, err := sequencerutils.GetWhitelistedRelayersOnHub(seqAddr, hd) - if err != nil { - return false, err - } - - return slices.Contains(relayers, relAddr), nil -} diff --git a/utils/relayer/types.go b/utils/relayer/types.go deleted file mode 100644 index c880bb7f..00000000 --- a/utils/relayer/types.go +++ /dev/null @@ -1,53 +0,0 @@ -package relayer - -import cosmossdkmath "cosmossdk.io/math" - -var oneDayRelayPrice, _ = cosmossdkmath.NewIntFromString( - "2000000000000000000", -) // 2000000000000000000 = 2dym - -type Channels struct { - Channels []struct { - State string `json:"state"` - Ordering string `json:"ordering"` - Counterparty struct { - PortId string `json:"port_id"` - ChannelId string `json:"channel_id"` - } `json:"counterparty"` - ConnectionHops []string `json:"connection_hops"` - Version string `json:"version"` - PortId string `json:"port_id"` - ChannelId string `json:"channel_id"` - } `json:"channels"` - Pagination struct { - NextKey interface{} `json:"next_key"` - Total string `json:"total"` - } `json:"pagination"` - Height struct { - RevisionNumber string `json:"revision_number"` - RevisionHeight string `json:"revision_height"` - } `json:"height"` -} - -// Config struct represents the paths section inside the relayer -// configuration file -type Config struct { - Paths *struct { - HubRollapp *struct { - Dst *struct { - ChainID string `yaml:"chain-id"` - ClientID string `yaml:"client-id"` - ConnectionID string `yaml:"connection-id"` - } `yaml:"dst"` - Src *struct { - ChainID string `yaml:"chain-id"` - ClientID string `yaml:"client-id"` - ConnectionID string `yaml:"connection-id"` - } `yaml:"src"` - SrcChannelFilter *struct { - ChannelList []string `yaml:"channel-list"` - Rule string `yaml:"rule"` - } `yaml:"src-channel-filter"` - } `yaml:"hub-rollapp"` - } `yaml:"paths"` -}