Skip to content

Commit

Permalink
feat: improve buf rate limit (#4133)
Browse files Browse the repository at this point in the history
* draft improvements

* use --path flag mutilple times

* remove `Build.Proto.ThirdPartyPaths` from the config

* add logic for run buf by folder or by file

* update cosmos-sdk

* fix exclude files for swagger

* fix buf cache

* add changelog

* update buf deps

* fix unit test

* fix wrong proto go path

* clear buf cache

* fix doctor tests and remove `third_party_paths` from the docs

* improve Test_extractRootModulePath test cases

* Update ignite/pkg/cosmosbuf/cache.go

Co-authored-by: Jerónimo Albi <[email protected]>

* fix changelog.md

* improve cache logic

* create a dircache pkg

* add comments

* rename methods `CopyCache` to `CopyTo` and `SaveCache` to `Save`

---------

Co-authored-by: Pantani <Pantani>
Co-authored-by: Jerónimo Albi <[email protected]>
  • Loading branch information
Pantani and jeronimoalbi authored May 21, 2024
1 parent f5a502b commit 0b41262
Show file tree
Hide file tree
Showing 30 changed files with 491 additions and 311 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [#4077](https://github.com/ignite/cli/pull/4077) Merge the swagger files manually instead use nodetime `swagger-combine`
- [#4100](https://github.com/ignite/cli/pull/4100) Set the `proto-dir` flag only for the `scaffold chain` command and use the proto path from the config
- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation
- [#4133](https://github.com/ignite/cli/pull/4133) Improve buf rate limit
- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically
- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands

Expand Down
6 changes: 0 additions & 6 deletions docs/docs/02-guide/06-ibc.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,6 @@ version: 1
build:
proto:
path: proto
third_party_paths:
- third_party/proto
- proto_vendor
accounts:
- name: alice
coins:
Expand Down Expand Up @@ -463,9 +460,6 @@ version: 1
build:
proto:
path: proto
third_party_paths:
- third_party/proto
- proto_vendor
accounts:
- name: alice
coins:
Expand Down
6 changes: 0 additions & 6 deletions docs/docs/02-guide/07-interchange/02-init.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ version: 1
build:
proto:
path: proto
third_party_paths:
- third_party/proto
- proto_vendor
accounts:
- name: alice
coins:
Expand Down Expand Up @@ -164,9 +161,6 @@ version: 1
build:
proto:
path: proto
third_party_paths:
- third_party/proto
- proto_vendor
accounts:
- name: alice
coins:
Expand Down
11 changes: 0 additions & 11 deletions docs/docs/08-references/02-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,6 @@ build:
path: "myproto"
```

Ignite comes with required third-party proto out of the box. Ignite also looks
into `third_party/proto` and `proto_vendor` directories for extra proto files.
If your project keeps third-party proto files in a different directory, you
should tell Ignite about this:

```yml
build:
proto:
third_party_paths: ["my_third_party/proto"]
```

## Faucet

The faucet service sends tokens to addresses.
Expand Down
1 change: 0 additions & 1 deletion docs/versioned_docs/version-v0.25/kb/03-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ build:
| Key | Required | Type | Description |
| ----------------- | -------- | --------------- | ------------------------------------------------------------------------------------------ |
| path | N | String | Path to protocol buffer files. Default: `"proto"`. |
| third_party_paths | N | List of Strings | Path to third-party protocol buffer files. Default: `["third_party/proto", "proto_vendor"]`. |

## client

Expand Down
8 changes: 0 additions & 8 deletions docs/versioned_docs/version-v0.25/kb/06-proto.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,3 @@ Third-party proto files, including those of Cosmos SDK and Tendermint, are bundl
```protobuf
import "cosmos/base/query/v1beta1/pagination.proto";
```

You can also manually add third-party proto files. By default, Ignite CLI imports proto files from these directories: `third_party/proto` and `proto_vendor`. You can define third-party paths of the import directory in `config.yml`:

```yaml
build:
proto:
third_party_paths: ["my_third_party_proto"]
```
4 changes: 4 additions & 0 deletions ignite/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ignite/cli/v29/ignite/pkg/cache"
"github.com/ignite/cli/v29/ignite/pkg/cliui"
uilog "github.com/ignite/cli/v29/ignite/pkg/cliui/log"
"github.com/ignite/cli/v29/ignite/pkg/dircache"
"github.com/ignite/cli/v29/ignite/pkg/errors"
"github.com/ignite/cli/v29/ignite/pkg/gitpod"
"github.com/ignite/cli/v29/ignite/pkg/goenv"
Expand Down Expand Up @@ -275,6 +276,9 @@ func newCache(cmd *cobra.Command) (cache.Storage, error) {
if err := storage.Clear(); err != nil {
return cache.Storage{}, err
}
if err := dircache.ClearCache(); err != nil {
return cache.Storage{}, err
}
}

return storage, nil
Expand Down
7 changes: 1 addition & 6 deletions ignite/config/chain/base/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ type Build struct {
type Proto struct {
// Path is the relative path of where app's proto files are located at.
Path string `yaml:"path" doc:"Relative path where the application's proto files are located."`

// ThirdPartyPath is the relative path of where the third party proto files are
// located that used by the app.
ThirdPartyPaths []string `yaml:"third_party_paths" doc:"Relative paths to third-party proto files used by the application."`
}

// Client configures code generation for clients.
Expand Down Expand Up @@ -174,8 +170,7 @@ func DefaultConfig() Config {
return Config{
Build: Build{
Proto: Proto{
Path: defaults.ProtoDir,
ThirdPartyPaths: []string{"third_party/proto", "proto_vendor"},
Path: defaults.ProtoDir,
},
},
Faucet: Faucet{
Expand Down
3 changes: 1 addition & 2 deletions ignite/config/chain/v1/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func TestConfigDecode(t *testing.T) {
Build: base.Build{
Binary: "evmosd",
Proto: base.Proto{
Path: "proto",
ThirdPartyPaths: []string{"third_party/proto", "proto_vendor"},
Path: "proto",
},
},
Accounts: []base.Account{
Expand Down
3 changes: 0 additions & 3 deletions ignite/config/chain/v1/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ build:
binary: evmosd
proto:
path: proto
third_party_paths:
- third_party/proto
- proto_vendor
accounts:
- name: alice
coins:
Expand Down
3 changes: 0 additions & 3 deletions ignite/config/chain/v1/testdata/config2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ build:
binary: evmosd
proto:
path: proto
third_party_paths:
- third_party/proto
- proto_vendor
accounts:
- name: alice
coins:
Expand Down
9 changes: 5 additions & 4 deletions ignite/internal/analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"

"github.com/ignite/cli/v29/ignite/config"
"github.com/ignite/cli/v29/ignite/pkg/gacli"
"github.com/ignite/cli/v29/ignite/pkg/gitpod"
"github.com/ignite/cli/v29/ignite/pkg/randstr"
Expand All @@ -23,7 +24,6 @@ const (
envDoNotTrack = "DO_NOT_TRACK"
envCI = "CI"
envGitHubActions = "GITHUB_ACTIONS"
igniteDir = ".ignite"
igniteAnonIdentity = "anon_identity.json"
)

Expand Down Expand Up @@ -79,14 +79,15 @@ func checkDNT() (anonIdentity, error) {
return anonIdentity{DoNotTrack: true}, nil
}

home, err := os.UserHomeDir()
globalPath, err := config.DirPath()
if err != nil {
return anonIdentity{}, err
}
if err := os.Mkdir(filepath.Join(home, igniteDir), 0o700); err != nil && !os.IsExist(err) {
if err := os.Mkdir(globalPath, 0o700); err != nil && !os.IsExist(err) {
return anonIdentity{}, err
}
identityPath := filepath.Join(home, igniteDir, igniteAnonIdentity)

identityPath := filepath.Join(globalPath, igniteAnonIdentity)
data, err := os.ReadFile(identityPath)
if err != nil && !os.IsNotExist(err) {
return anonIdentity{}, err
Expand Down
Loading

0 comments on commit 0b41262

Please sign in to comment.