Skip to content

Commit

Permalink
chore: bump to SDK v0.46.7 (#293)
Browse files Browse the repository at this point in the history
* chore: bump tendermint to 0.34.24 (cosmos#13972)

* chore: add group and gov/v1 in swagger (backport cosmos#13984) (cosmos#13996)

* chore: add group and gov/v1 in swagger (cosmos#13984)

Co-authored-by: Marko <marbar3778@yahoo.com>
(cherry picked from commit cfa224c)

# Conflicts:
#	client/docs/config.json
#	client/docs/swagger-ui/swagger.yaml

* updates

Co-authored-by: Julien Robert <julien@rbrt.fr>

* fix(baseapp): fix snapshot interval bug (backport cosmos#14049) (cosmos#14053)

* refactor: use viper unmarshal in `config.GetConfig` function (backport cosmos#13651) (cosmos#14082)

* fix(group)!: Don't re-tally proposals after VP end (backport cosmos#14071) (cosmos#14091)

* fix(group)!: Don't re-tally proposals after VP end (cosmos#14071)

(cherry picked from commit 4ebe3aa)

# Conflicts:
#	CHANGELOG.md

* fix changelog and test

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* fix: do not shadow clientCtx in start.go (backport cosmos#14086) (cosmos#14101)

* fix: do not shadow clientCtx in start.go (cosmos#14086)

(cherry picked from commit f96072d)

# Conflicts:
#	server/start.go

* updates

Co-authored-by: Julien Robert <julien@rbrt.fr>

* chore: Test for Server Config Read cosmos#14125 (cosmos#14127)

(cherry picked from commit 9f46665)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* fix: remove duplicate ante events (backport cosmos#13983) (cosmos#14142)

* fix: remove duplicate ante events (cosmos#13983)

## Description

After enabling the post-handler on our chain, we realised something odd with our transaction events. The ordering was `[ANTE, MSGS, ANTE, POST]`. After doing some digging, we realised that the context used inside the post-handler still contains the events from the ante-handler.

This should be backported to v0.46.x and v0.47.x 😄
Happy to make it compatible with cosmos#13940 when that gets merged!

cc @mbreithecker

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

(cherry picked from commit 25449b5)

# Conflicts:
#	CHANGELOG.md

* fix changelog

Co-authored-by: John Letey <john@kyve.network>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* feat: support alternative query multistore (backport cosmos#13529) (cosmos#14169)

* feat: support alternative query multistore (cosmos#13529)

* support customize query multistore

* Update CHANGELOG.md

* fix test

* Update baseapp/abci.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update baseapp/baseapp.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Update baseapp/options.go

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
(cherry picked from commit 15accd7)

# Conflicts:
#	CHANGELOG.md
#	baseapp/baseapp.go
#	baseapp/options.go

* fix conflicts

Co-authored-by: yihuang <huang@crypto.com>

* fix: state listener observe writes at wrong time (backport cosmos#13516) (cosmos#14138)

* fix: state listener observe writes at wrong time (cosmos#13516)

* fix: state listener observe writes at wrong time

Closes: cosmos#13457

Currently state listener is notified when the cache store write, which happens in commit event only, which breaks the current design.
The solution (as discussed in the issue) is to listen state writes on rootmulti store only.

It also changes the file streamer to output single data file for the writes in the whole block, since we can't distinguish writes from different stage of abci events.

It adds new config items for file streamer:
- streamers.file.output-metadata
- streamers.file.stop-node-on-error
- streamers.file.fsync

* synchronous abci call, and format doc

* fix comment

* update file streamer readme and fix typos

* typo

* fix: state listener observe writes at wrong time

Closes: cosmos#13457

Currently state listener is notified when the cache store write, which happens in commit event only, which breaks the current design.
The solution (as discussed in the issue) is to listen state writes on rootmulti store only.

It also changes the file streamer to output single data file for the writes in the whole block, since we can't distinguish writes from different stage of abci events.

It adds new config items for file streamer:
- streamers.file.output-metadata
- streamers.file.stop-node-on-error
- streamers.file.fsync

synchronous abci call, and format doc

fix comment

update file streamer readme and fix typos

typo

* improve UX of file streamer, make it immediately usable after enabled

- set default value to write_dir.
- make write_dir based on home directory by default.
- auto-create the directory if not exists.

* get homePage from opts

Co-authored-by: Marko <marbar3778@yahoo.com>
(cherry picked from commit 1f91ee2)

# Conflicts:
#	CHANGELOG.md
#	api/cosmos/base/store/v1beta1/listening.pulsar.go
#	baseapp/streaming.go
#	docs/architecture/adr-038-state-listening.md
#	server/config/toml.go
#	simapp/app_v2.go
#	store/cachemulti/store.go
#	store/iavl/store.go
#	store/mem/store.go
#	store/streaming/constructor.go
#	store/streaming/file/service.go
#	store/streaming/file/service_test.go
#	store/types/listening.pb.go
#	store/types/store.go

* `make proto-gen`, update changelog, delete uncessary files

* fix conflicts

* fix conflicts

* revert api breaking change

* fix build

* fix unit test

Co-authored-by: yihuang <huang@crypto.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: Marko <marbar3778@yahoo.com>

* refactor: provide a helper for baseapp options (backport cosmos#14175) (cosmos#14178)

* refactor: provide a helper for baseapp options (cosmos#14175)

* provide a helper for baseapp options

* rename

* changelog entry

* fix spelling

(cherry picked from commit 1b6192f)

# Conflicts:
#	CHANGELOG.md
#	server/mock/app_test.go
#	simapp/simd/cmd/root.go

* conflicts

* lint

Co-authored-by: Marko <marbar3778@yahoo.com>

* feat: add --grpc client option (backport cosmos#14051) (cosmos#14192)

Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* refactor: cleanup store/streaming/constructor.go (backport cosmos#14044) (cosmos#14236)

* chore: audit store/streaming/file/service.go (backport cosmos#14234) (cosmos#14241)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

* fix: fix grpc flag conflict (backport cosmos#14244) (cosmos#14248)

* chore: prepare 0.46.7 release (cosmos#14103)

* fix(gov): Fix v3 votes migrations (backport cosmos#14214) (cosmos#14277)

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>

Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: John Letey <john@kyve.network>
Co-authored-by: yihuang <huang@crypto.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Aaron Craelius <aaron@regen.network>
  • Loading branch information
9 people authored Jan 11, 2023
1 parent 0a209fb commit 4591cc5
Show file tree
Hide file tree
Showing 67 changed files with 48,687 additions and 28,515 deletions.
38 changes: 37 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,49 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.46.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.7) - 2022-12-13

### Features

* (client) [#14051](https://github.com/cosmos/cosmos-sdk/pull/14051) Add `--grpc` client option.

### Improvements

* (deps) Bump Tendermint version to [v0.34.24](https://github.com/tendermint/tendermint/releases/tag/v0.34.24).
* [#13651](https://github.com/cosmos/cosmos-sdk/pull/13651) Update `server/config/config.GetConfig` function.
* [#13781](https://github.com/cosmos/cosmos-sdk/pull/13781) Remove `client/keys.KeysCdc`.
* [#14175](https://github.com/cosmos/cosmos-sdk/pull/14175) Add `server.DefaultBaseappOptions(appopts)` function to reduce boiler plate in root.go.

### State Machine Breaking

* (x/gov) [#14214](https://github.com/cosmos/cosmos-sdk/pull/14214) Fix gov v0.46 migration to v1 votes.
* Also provide a helper function `govv046.Migrate_V0466_To_V0467` for migrating a chain already on v0.46 with versions <=v0.46.6 to the latest v0.46.7 correct state.
* (x/group) [#14071](https://github.com/cosmos/cosmos-sdk/pull/14071) Don't re-tally proposal after voting period end if they have been marked as ACCEPTED or REJECTED.

### API Breaking Changes

* (store) [#13516](https://github.com/cosmos/cosmos-sdk/pull/13516) Update State Streaming APIs:
* Add method `ListenCommit` to `ABCIListener`
* Move `ListeningEnabled` and `AddListener` methods to `CommitMultiStore`
* Remove `CacheWrapWithListeners` from `CacheWrap` and `CacheWrapper` interfaces
* Remove listening APIs from the caching layer (it should only listen to the `rootmulti.Store`)
* Add three new options to file streaming service constructor.
* Modify `ABCIListener` such that any error from any method will always halt the app via `panic`
* (store) [#13529](https://github.com/cosmos/cosmos-sdk/pull/13529) Add method `LatestVersion` to `MultiStore` interface, add method `SetQueryMultiStore` to baesapp to support alternative `MultiStore` implementation for query service.

### Bug Fixes

* (baseapp) [#13983](https://github.com/cosmos/cosmos-sdk/pull/13983) Don't emit duplicate ante-handler events when a post-handler is defined.
* (baseapp) [#14049](https://github.com/cosmos/cosmos-sdk/pull/14049) Fix state sync when interval is zero.
* (store) [#13516](https://github.com/cosmos/cosmos-sdk/pull/13516) Fix state listener that was observing writes at wrong time.

## [v0.46.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6) - 2022-11-18

### Improvements

* (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration.

## Bug Fixes
### Bug Fixes

* (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal.

Expand Down
20 changes: 14 additions & 6 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Cosmos SDK v0.46.6 Release Notes
# Cosmos SDK v0.46.7 Release Notes

This release introduces small bug fixes and improvements.
This release introduces bug fixes and improvements. Notably, the upgrade to Tendermint [v0.34.24](https://github.com/tendermint/tendermint/releases/tag/v0.34.24).

Please read the release notes of [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) if you are upgrading from `<=0.46.4`.

Please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md) for an exhaustive list of changes.
A critical vulnerability has been fixed in the group module. For safety, `v0.46.5` and `v0.46.6` are retracted, even though chains not using the group module are not affected. When using the group module, please upgrade immediately to `v0.46.7`.

Full Commit History: https://github.com/cosmos/cosmos-sdk/compare/v0.46.5...v0.46.6
An issue has been discovered in the gov module's votes migration. It does not impact proposals and votes tallying, but the gRPC queries on votes are incorrect. This issue is fixed in `v0.46.7`, however:
- if your chain is already on v0.46 using `<= v0.46.6`, a **coordinated upgrade** to v0.46.7 is required. You can use the helper function `govv046.Migrate_V046_6_To_V046_7` for migrating a chain **already on v0.46 with versions <=v0.46.6** to the latest v0.46.7 correct state.
- if your chain is on a previous version <= v0.45, then simply use v0.46.7 when upgrading to v0.46.

**NOTE**: The changes mentioned in `v0.46.3` are **still** required:
**NOTE**: The changes mentioned in `v0.46.3` are no longer required. The following replace directive can be removed from the chains.

```go
# Chains must add the following to their go.mod for the application:
# Can be deleted from go.mod
replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
```

Instead, `github.com/confio/ics23/go` must be **bumped to `v0.9.0`**.

Please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md) for an exhaustive list of changes.

Full Commit History: https://github.com/cosmos/cosmos-sdk/compare/v0.46.6...v0.46.7
36 changes: 26 additions & 10 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
// call the hooks with the BeginBlock messages
for _, streamingListener := range app.abciListeners {
if err := streamingListener.ListenBeginBlock(app.deliverState.ctx, req, res); err != nil {
app.logger.Error("BeginBlock listening hook failed", "height", req.Header.Height, "err", err)
panic(fmt.Errorf("BeginBlock listening hook failed, height: %d, err: %w", req.Header.Height, err))
}
}

Expand All @@ -214,7 +214,7 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
// call the streaming service hooks with the EndBlock messages
for _, streamingListener := range app.abciListeners {
if err := streamingListener.ListenEndBlock(app.deliverState.ctx, req, res); err != nil {
app.logger.Error("EndBlock listening hook failed", "height", req.Height, "err", err)
panic(fmt.Errorf("EndBlock listening hook failed, height: %d, err: %w", req.Height, err))
}
}

Expand Down Expand Up @@ -268,7 +268,7 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv
defer func() {
for _, streamingListener := range app.abciListeners {
if err := streamingListener.ListenDeliverTx(app.deliverState.ctx, req, res); err != nil {
app.logger.Error("DeliverTx listening hook failed", "err", err)
panic(fmt.Errorf("DeliverTx listening hook failed: %w", err))
}
}
}()
Expand Down Expand Up @@ -321,7 +321,7 @@ func (app *BaseApp) ProcessProposal(req abci.RequestProcessProposal) abci.Respon
// defined in config, Commit will execute a deferred function call to check
// against that height and gracefully halt if it matches the latest committed
// height.
func (app *BaseApp) Commit() (res abci.ResponseCommit) {
func (app *BaseApp) Commit() abci.ResponseCommit {
header := app.deliverState.ctx.BlockHeader()
retainHeight := app.GetBlockRetentionHeight(header.Height)

Expand All @@ -330,6 +330,19 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) {
// MultiStore (app.cms) so when Commit() is called is persists those values.
app.deliverState.ms.Write()
commitID := app.cms.Commit()

res := abci.ResponseCommit{
Data: commitID.Hash,
RetainHeight: retainHeight,
}

// call the hooks with the Commit message
for _, streamingListener := range app.abciListeners {
if err := streamingListener.ListenCommit(app.deliverState.ctx, res); err != nil {
panic(fmt.Errorf("Commit listening hook failed, height: %d, err: %w", header.Height, err))
}
}

app.logger.Info("commit synced", "commit", fmt.Sprintf("%X", commitID))

// Reset the Check state to the latest committed.
Expand Down Expand Up @@ -361,10 +374,7 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) {

go app.snapshotManager.SnapshotIfApplicable(header.Height)

return abci.ResponseCommit{
Data: commitID.Hash,
RetainHeight: retainHeight,
}
return res
}

// halt attempts to gracefully shutdown the node via SIGINT and SIGTERM falling
Expand Down Expand Up @@ -616,7 +626,13 @@ func (app *BaseApp) createQueryContext(height int64, prove bool) (sdk.Context, e
return sdk.Context{}, err
}

lastBlockHeight := app.LastBlockHeight()
// use custom query multistore if provided
qms := app.qms
if qms == nil {
qms = sdk.MultiStore(app.cms)
}

lastBlockHeight := qms.LatestVersion()
if height > lastBlockHeight {
return sdk.Context{},
sdkerrors.Wrap(
Expand All @@ -638,7 +654,7 @@ func (app *BaseApp) createQueryContext(height int64, prove bool) (sdk.Context, e
)
}

cacheMS, err := app.cms.CacheMultiStoreWithVersion(height)
cacheMS, err := qms.CacheMultiStoreWithVersion(height)
if err != nil {
return sdk.Context{},
sdkerrors.Wrapf(
Expand Down
8 changes: 7 additions & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ type BaseApp struct { // nolint: maligned
type appStore struct {
db dbm.DB // common DB backend
cms sdk.CommitMultiStore // Main (uncached) state
qms sdk.MultiStore // Optional alternative state provider for query service
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()

// an inter-block write-through cache provided to the context during deliverState
Expand Down Expand Up @@ -721,7 +722,12 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re
//
// Note: If the postHandler fails, we also revert the runMsgs state.
if app.postHandler != nil {
newCtx, err := app.postHandler(runMsgCtx, tx, mode == runTxModeSimulate)
// The runMsgCtx context currently contains events emitted by the ante handler.
// We clear this to correctly order events without duplicates.
// Note that the state is still preserved.
postCtx := runMsgCtx.WithEventManager(sdk.NewEventManager())

newCtx, err := app.postHandler(postCtx, tx, mode == runTxModeSimulate)
if err != nil {
return gInfo, nil, nil, priority, err
}
Expand Down
12 changes: 11 additions & 1 deletion baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (app *BaseApp) SetSnapshot(snapshotStore *snapshots.Store, opts snapshottyp
if app.sealed {
panic("SetSnapshot() on sealed BaseApp")
}
if snapshotStore == nil || opts.Interval == snapshottypes.SnapshotIntervalOff {
if snapshotStore == nil {
app.snapshotManager = nil
return
}
Expand All @@ -243,3 +243,13 @@ func (app *BaseApp) SetStreamingService(s StreamingService) {
// BaseApp will pass BeginBlock, DeliverTx, and EndBlock requests and responses to the streaming services to update their ABCI context
app.abciListeners = append(app.abciListeners, s)
}

// SetQueryMultiStore set a alternative MultiStore implementation to support grpc query service.
//
// Ref: https://github.com/cosmos/cosmos-sdk/issues/13317
func (app *BaseApp) SetQueryMultiStore(ms sdk.MultiStore) {
if app.sealed {
panic("SetQueryMultiStore() on sealed BaseApp")
}
app.qms = ms
}
14 changes: 9 additions & 5 deletions baseapp/streaming.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package baseapp

import (
"context"
"io"
"sync"

abci "github.com/tendermint/tendermint/abci/types"

store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types"
)

// ABCIListener interface used to hook into the ABCI message processing of the BaseApp
// ABCIListener interface used to hook into the ABCI message processing of the BaseApp.
// the error results are propagated to consensus state machine,
// if you don't want to affect consensus, handle the errors internally and always return `nil` in these APIs.
type ABCIListener interface {
// ListenBeginBlock updates the streaming service with the latest BeginBlock messages
ListenBeginBlock(ctx types.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error
ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error
// ListenEndBlock updates the steaming service with the latest EndBlock messages
ListenEndBlock(ctx types.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error
ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error
// ListenDeliverTx updates the steaming service with the latest DeliverTx messages
ListenDeliverTx(ctx types.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error
ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error
// ListenCommit updates the steaming service with the latest Commit event
ListenCommit(ctx context.Context, res abci.ResponseCommit) error
}

// StreamingService interface for registering WriteListeners with the BaseApp and updating the service with the ABCI messages using the hooks
Expand Down
26 changes: 26 additions & 0 deletions client/cmd.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package client

import (
"crypto/tls"
"fmt"
"strings"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/tendermint/tendermint/libs/cli"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
Expand Down Expand Up @@ -147,6 +151,28 @@ func ReadPersistentCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Cont
}
}

if clientCtx.GRPCClient == nil || flagSet.Changed(flags.FlagGRPC) {
grpcURI, _ := flagSet.GetString(flags.FlagGRPC)
if grpcURI != "" {
var dialOpts []grpc.DialOption

useInsecure, _ := flagSet.GetBool(flags.FlagGRPCInsecure)
if useInsecure {
dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials()))
} else {
dialOpts = append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{
MinVersion: tls.VersionTLS12,
})))
}

grpcClient, err := grpc.Dial(grpcURI, dialOpts...)
if err != nil {
return Context{}, err
}
clientCtx = clientCtx.WithGRPCClient(grpcClient)
}
}

return clientCtx, nil
}

Expand Down
36 changes: 35 additions & 1 deletion client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/gov/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GovV1Params",
"Proposal": "GovV1Proposal",
"Proposals": "GovV1Proposal",
"Vote": "GovV1Vote",
"Votes": "GovV1Votes",
"Deposit": "GovV1Deposit",
"Deposits": "GovV1Deposit",
"TallyResult": "GovV1TallyResult"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/mint/v1beta1/query.swagger.json",
"operationIds": {
Expand Down Expand Up @@ -116,6 +131,25 @@
"Params": "FeegrantParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/nft/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "NftParams",
"Balance": "NftBalance"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/group/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GroupParams",
"Proposal": "GroupProposal",
"TallyResult": "GroupTallyResult"
}
}
}
]
}
}
Loading

0 comments on commit 4591cc5

Please sign in to comment.