Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Changes

- [#4689](https://github.com/ignite/cli/pull/4689) Revert `HasGenesis` implementation from retracted `core` v1 to SDK `HasGenesis` interface.
- [#4701](https://github.com/ignite/cli/pull/4701) Improve `ignite doctor` by removing manual migration step. Additionally, remove protoc to buf migrations logic.

### Bug Fixes

Expand Down
25 changes: 24 additions & 1 deletion docs/docs/06-migration/v29.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ description: For chains that were scaffolded with Ignite CLI versions lower than

The changes between v28.0.0 and v29.0.0 are not as significant as the changes between v0.27.0 and v28.0.0.

In v29.0.0, the Cosmos SDK version has been upgraded to 0.53.0 and IBC to v10.
In v29.0.0, the Cosmos SDK version has been upgraded to 0.53.0 and IBC to v10.

Please see the [Changelog](https://github.com/ignite/cli/commit/1b7f19f08d0fa91e3ae71b4b37b8bb4171a9e320#diff-b027e7b11ff55b21dd50b32abcbdd35d95be87a889f0f6562417fbf0995d402a) for more details.

:::tip
If you wish to keep using a chain scaffolded with Ignite v28, simply run the doctor command:

```bash
ignite doctor
```

Note that some scaffolding commands may not work as expected, and you may need to manually adjust your code, unless you follow the migration steps below.
:::

## Upgrade Cosmos SDK to v0.53.0

In order to upgrade, please navigate to the `go.mod` file in your blockchain directory and replace an earlier Cosmos-SDK version with v0.53.0.
Expand All @@ -30,6 +40,7 @@ If you have custom modules, test for deprecated APIs and update as needed.
v29 configures preblockers to include the `auth` module (`authtypes.ModuleName`) for transaction processing. Ensure this is set in your v28 scaffold.

**Edit PreBlockers**:

- Open `mychain/app/app_config.go`.

- Find or add the `preBlockers` slice. Ensure it includes `authtypes.ModuleName`, matching v29’s configuration:
Expand Down Expand Up @@ -84,4 +95,16 @@ Now start your chain.
ignite chain serve
```

:::tip
If Ignite is unable to detect the chain `app.go`, make sure you have the following methods on the `App` struct:

```go
func (app *App) AppCodec() codec.Codec
func (app *App) TxConfig() client.TxConfig
func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig)
```

All recent Ignite v28 scaffolded chains should have these methods.
:::

If you need our help and support, do not hesitate to visit our [Discord](https://discord.com/invite/ignite).
78 changes: 7 additions & 71 deletions ignite/cmd/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,16 @@ import (
"github.com/ignite/cli/v29/ignite/pkg/cosmosgen"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/goanalysis"
"github.com/ignite/cli/v29/ignite/pkg/xgenny"
"github.com/ignite/cli/v29/ignite/services/chain"
)

const (
msgMigration = "Migrating blockchain config file from v%d to v%d..."
msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d."
msgMigrationPrompt = "Would you like to upgrade your config file to v%d"
msgMigrationBuf = "Now ignite supports the `buf.build` (https://buf.build) registry to manage the protobuf dependencies. The embed protoc binary was deprecated and, your blockchain is still using it. Would you like to upgrade and add the `buf.build` config files to `proto/` folder"
msgMigrationBufProtoDir = "Ignite proto directory path from the chain config doesn't match the proto directory path from the chain `buf.work.yaml`. Do you want to add the proto path `%[1]v` to the directories list from the buf work file"
msgMigrationBufProtoDirs = "Chain `buf.work.yaml` file contains directories that don't exist anymore (%[1]v). Do you want to delete them"
msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them"
msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them"
msgMigration = "Migrating blockchain config file from v%d to v%d..."
msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d."
msgMigrationPrompt = "Would you like to upgrade your config file to v%d"
msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them"
msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them"
)

var ErrProtocUnsupported = errors.New("code generation using protoc is only supported by Ignite CLI v0.26.1 or older")

// NewChain returns a command that groups sub commands related to compiling, serving
// blockchains and so on.
func NewChain() *cobra.Command {
Expand Down Expand Up @@ -119,7 +112,7 @@ func preRunHandler(cmd *cobra.Command, _ []string) error {
return err
}

cfg, cfgPath, err := getChainConfig(cmd)
_, cfgPath, err := getChainConfig(cmd)
if err != nil {
return err
}
Expand All @@ -132,7 +125,7 @@ func preRunHandler(cmd *cobra.Command, _ []string) error {
return err
}

return bufMigrationPreRunHandler(cmd, session, appPath, cfg.Build.Proto.Path)
return nil
}

func toolsMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath string) error {
Expand Down Expand Up @@ -189,63 +182,6 @@ func toolsMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, app
return os.WriteFile(goModPath, buf.Bytes(), 0o600)
}

func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath, protoDir string) error {
// check if the buf files exist.
hasFiles, err := chain.CheckBufFiles(appPath, protoDir)
if err != nil {
return err
}

if !hasFiles {
if !getYes(cmd) {
if err := session.AskConfirm(msgMigrationBuf); err != nil {
return ErrProtocUnsupported
}
}

runner := xgenny.NewRunner(cmd.Context(), appPath)
sm, err := chain.BoxBufFiles(runner, appPath, protoDir)
if err != nil {
return err
}

session.Print("\n🎉 buf.build files added: \n\n")
session.Printf("%s\n\n", strings.Join(sm.CreatedFiles(), "\n"))
}

// check if the buf.work.yaml has the same proto path from the config file.
hasProtoPath, missingPaths, err := chain.CheckBufProtoDir(appPath, protoDir)
if err != nil {
return err
}

if !hasProtoPath {
if !getYes(cmd) {
if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoDir, protoDir)); err != nil {
return nil
}
}

if err := chain.AddBufProtoDir(appPath, protoDir); err != nil {
return err
}
}

if len(missingPaths) > 0 {
if !getYes(cmd) {
if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoDirs, strings.Join(missingPaths, ", "))); err != nil {
return nil
}
}

if err := chain.RemoveBufProtoDirs(appPath, missingPaths...); err != nil {
return err
}
}

return nil
}

func configMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath, cfgPath string) error {
rawCfg, err := os.ReadFile(cfgPath)
if err != nil {
Expand Down
9 changes: 0 additions & 9 deletions ignite/cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ func migrationPreRunHandler(cmd *cobra.Command, args []string) error {
session := cliui.New()
defer session.End()

cfg, _, err := getChainConfig(cmd)
if err != nil {
return err
}

appPath, err := goModulePath(cmd)
if err != nil {
return err
Expand All @@ -175,10 +170,6 @@ func migrationPreRunHandler(cmd *cobra.Command, args []string) error {
return err
}

if err := bufMigrationPreRunHandler(cmd, session, appPath, cfg.Build.Proto.Path); err != nil {
return err
}

// we go mod tidy in case new dependencies were added or removed
if err := gocmd.ModTidy(cmd.Context(), appPath); err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion ignite/pkg/cosmosbuf/buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ func (b Buf) Update(ctx context.Context, modDir string) error {

// Migrate runs the buf Migrate command for the files in the app directory.
func (b Buf) Migrate(ctx context.Context, protoDir string) error {
yamlFiles, err := xos.FindFiles(protoDir, xos.WithExtension(xos.YMLFile), xos.WithExtension(xos.YAMLFile), xos.WithPrefix(bufGenPrefix))
yamlFiles, err := xos.FindFiles(protoDir,
xos.WithExtension(xos.YMLFile),
xos.WithExtension(xos.YAMLFile),
xos.WithPrefix(bufGenPrefix),
)
if err != nil {
return err
}
Expand Down
92 changes: 0 additions & 92 deletions ignite/pkg/cosmosbuf/config.go

This file was deleted.

21 changes: 15 additions & 6 deletions ignite/pkg/cosmosgen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
const (
moduleCacheNamespace = "generate.setup.module"
includeProtoCacheNamespace = "generator.includes.proto"
workFilename = "buf.work.yaml"
bufYamlFilename = "buf.yaml"
)

var (
Expand Down Expand Up @@ -223,7 +223,7 @@ func (g *generator) findBufPath(modpath string) (string, error) {
return err
}
base := filepath.Base(path)
if base == "buf.yaml" || base == "buf.yml" {
if base == bufYamlFilename || base == "buf.yml" {
bufPath = path
return filepath.SkipAll
}
Expand Down Expand Up @@ -460,21 +460,30 @@ func (g generator) vendorProtoPackage(pkgName, protoPath string) (err error) {
return err
}

path := filepath.Join(g.appPath, workFilename)
path := filepath.Join(g.appPath, bufYamlFilename)
bz, err := os.ReadFile(path)
if err != nil {
return errors.Errorf("error reading Buf workspace file: %s: %w", path, err)
}

ws := struct {
Version string `yaml:"version"`
Directories []string `yaml:"directories"`
Version string `yaml:"version"`
Modules []struct {
Path string `yaml:"path"`
} `yaml:"modules"`
Deps []string `yaml:"deps"`
Lint any `yaml:"lint"`
Breaking any `yaml:"breaking"`
}{}
if err := yaml.Unmarshal(bz, &ws); err != nil {
return err
}

ws.Directories = append(ws.Directories, vendorRelPath)
ws.Modules = append(ws.Modules, struct {
Path string `yaml:"path"`
}{
Path: vendorRelPath,
})

f, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0o644)
if err != nil {
Expand Down
Loading