Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cosmos-sdk Version (backport #9429) #9543

Merged
merged 4 commits into from
Jun 18, 2021
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 @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

* [\#9428](https://github.com/cosmos/cosmos-sdk/pull/9428) Optimize bank InitGenesis. Added `k.initBalances`.
* [\#9429](https://github.com/cosmos/cosmos-sdk/pull/9429) Add `cosmos_sdk_version` to node_info
* [\#9541](https://github.com/cosmos/cosmos-sdk/pull/9541) Bump tendermint dependency to v0.34.11.

### Bug Fixes
Expand Down
202 changes: 127 additions & 75 deletions client/grpc/tmservice/query.pb.go

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions client/grpc/tmservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,14 @@ func (s queryServer) GetNodeInfo(ctx context.Context, req *GetNodeInfoRequest) (
resp := GetNodeInfoResponse{
DefaultNodeInfo: protoNodeInfo,
ApplicationVersion: &VersionInfo{
AppName: nodeInfo.AppName,
Name: nodeInfo.Name,
GitCommit: nodeInfo.GitCommit,
GoVersion: nodeInfo.GoVersion,
Version: nodeInfo.Version,
BuildTags: nodeInfo.BuildTags,
BuildDeps: deps,
AppName: nodeInfo.AppName,
Name: nodeInfo.Name,
GitCommit: nodeInfo.GitCommit,
GoVersion: nodeInfo.GoVersion,
Version: nodeInfo.Version,
BuildTags: nodeInfo.BuildTags,
BuildDeps: deps,
CosmosSdkVersion: nodeInfo.CosmosSdkVersion,
},
}
return &resp, nil
Expand Down
34 changes: 15 additions & 19 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,7 @@ VersionInfo is the type for the GetNodeInfoResponse message.
| `build_tags` | [string](#string) | | |
| `go_version` | [string](#string) | | |
| `build_deps` | [Module](#cosmos.base.tendermint.v1beta1.Module) | repeated | |
| `cosmos_sdk_version` | [string](#string) | | |



Expand Down Expand Up @@ -6527,6 +6528,7 @@ RPC method.
| ----- | ---- | ----- | ----------- |
| `events` | [string](#string) | repeated | events is the list of transaction event type. |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. |
| `order_by` | [OrderBy](#cosmos.tx.v1beta1.OrderBy) | | |



Expand Down Expand Up @@ -6599,6 +6601,19 @@ BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC metho
| BROADCAST_MODE_ASYNC | 3 | BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns immediately. |



<a name="cosmos.tx.v1beta1.OrderBy"></a>

### OrderBy
OrderBy defines the sorting order

| Name | Number | Description |
| ---- | ------ | ----------- |
| ORDER_BY_UNSPECIFIED | 0 | ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. |
| ORDER_BY_ASC | 1 | ORDER_BY_ASC defines ascending order |
| ORDER_BY_DESC | 2 | ORDER_BY_DESC defines descending order |


<!-- end enums -->

<!-- end HasExtensions -->
Expand Down Expand Up @@ -9491,11 +9506,6 @@ GenesisState defines the ibc module's genesis state.

<!-- end services -->

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `events` | [string](#string) | repeated | events is the list of transaction event type. |
| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. |
| `order_by` | [OrderBy](#cosmos.tx.v1beta1.OrderBy) | | |


<a name="ibc/lightclients/localhost/v1/localhost.proto"></a>
Expand Down Expand Up @@ -9571,20 +9581,6 @@ state and if the client is frozen.



<a name="cosmos.tx.v1beta1.OrderBy"></a>

### OrderBy
OrderBy defines the sorting order

| Name | Number | Description |
| ---- | ------ | ----------- |
| ORDER_BY_UNSPECIFIED | 0 | ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. |
| ORDER_BY_ASC | 1 | ORDER_BY_ASC defines ascending order |
| ORDER_BY_DESC | 2 | ORDER_BY_DESC defines descending order |


<!-- end enums -->




Expand Down
15 changes: 8 additions & 7 deletions proto/cosmos/base/tendermint/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ message GetNodeInfoResponse {

// VersionInfo is the type for the GetNodeInfoResponse message.
message VersionInfo {
string name = 1;
string app_name = 2;
string version = 3;
string git_commit = 4;
string build_tags = 5;
string go_version = 6;
repeated Module build_deps = 7;
string name = 1;
string app_name = 2;
string version = 3;
string git_commit = 4;
string build_tags = 5;
string go_version = 6;
repeated Module build_deps = 7;
string cosmos_sdk_version = 8;
}

// Module is the type for VersionInfo
Expand Down
46 changes: 32 additions & 14 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,44 @@ var (
BuildTags = ""
)

func getSDKVersion() string {
deps, ok := debug.ReadBuildInfo()
if !ok {
return "unable to read deps"
}
var sdkVersion string
for _, dep := range deps.Deps {
if dep.Path == "github.com/cosmos/cosmos-sdk" {
sdkVersion = dep.Version
}
}

return sdkVersion
}

// Info defines the application version information.
type Info struct {
Name string `json:"name" yaml:"name"`
AppName string `json:"server_name" yaml:"server_name"`
Version string `json:"version" yaml:"version"`
GitCommit string `json:"commit" yaml:"commit"`
BuildTags string `json:"build_tags" yaml:"build_tags"`
GoVersion string `json:"go" yaml:"go"`
BuildDeps []buildDep `json:"build_deps" yaml:"build_deps"`
Name string `json:"name" yaml:"name"`
AppName string `json:"server_name" yaml:"server_name"`
Version string `json:"version" yaml:"version"`
GitCommit string `json:"commit" yaml:"commit"`
BuildTags string `json:"build_tags" yaml:"build_tags"`
GoVersion string `json:"go" yaml:"go"`
BuildDeps []buildDep `json:"build_deps" yaml:"build_deps"`
CosmosSdkVersion string `json:"cosmos_sdk_version" yaml:"cosmos_sdk_version"`
}

func NewInfo() Info {
sdkVersion := getSDKVersion()
return Info{
Name: Name,
AppName: AppName,
Version: Version,
GitCommit: Commit,
BuildTags: BuildTags,
GoVersion: fmt.Sprintf("go version %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH),
BuildDeps: depsFromBuildInfo(),
Name: Name,
AppName: AppName,
Version: Version,
GitCommit: Commit,
BuildTags: BuildTags,
GoVersion: fmt.Sprintf("go version %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH),
BuildDeps: depsFromBuildInfo(),
CosmosSdkVersion: sdkVersion,
}
}

Expand Down
13 changes: 7 additions & 6 deletions version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ build tags:

func TestInfo_String(t *testing.T) {
info := version.Info{
Name: "testapp",
AppName: "testappd",
Version: "1.0.0",
GitCommit: "1b78457135a4104bc3af97f20654d49e2ea87454",
BuildTags: "netgo,ledger",
GoVersion: "go version go1.14 linux/amd64",
Name: "testapp",
AppName: "testappd",
Version: "1.0.0",
GitCommit: "1b78457135a4104bc3af97f20654d49e2ea87454",
BuildTags: "netgo,ledger",
GoVersion: "go version go1.14 linux/amd64",
CosmosSdkVersion: "0.42.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, will this test fail once we tag 0.42.6?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we dont check sdk version below it should work fine.

}
want := `testapp: 1.0.0
git commit: 1b78457135a4104bc3af97f20654d49e2ea87454
Expand Down