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 #9429

Merged
merged 11 commits into from
Jun 18, 2021
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ if input key is empty, or input data contains empty key.
* [#9088](https://github.com/cosmos/cosmos-sdk/pull/9088) Added implementation to ADR-28 Derived Addresses.
* [\#9133](https://github.com/cosmos/cosmos-sdk/pull/9133) Added hooks for governance actions.
* (x/staking) [\#9214](https://github.com/cosmos/cosmos-sdk/pull/9214) Added `new_shares` attribute inside `EventTypeDelegate` event.
* [\#9382](https://github.com/cosmos/cosmos-sdk/pull/9382) feat: add Dec.Float64() function.
* [\#9382](https://github.com/cosmos/cosmos-sdk/pull/9382) feat: add Dec.Float64() functio
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
* [\#9429](https://github.com/cosmos/cosmos-sdk/pull/9429) Add `cosmos_sdk_version` to node_info
* [\#9457](https://github.com/cosmos/cosmos-sdk/pull/9457) Add amino support for x/authz and x/feegrant Msgs.
* [\#9498](https://github.com/cosmos/cosmos-sdk/pull/9498) Added `Codec: codec.Codec` attribute to `client/Context` structure.

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ should be targeted against the release candidate branch.
and ensure it's protected against pushing from anyone except the release
manager/coordinator
- **no PRs targeting this branch should be merged unless exceptional circumstances arise**
- Bump defaultCosmosSDKVersion in `version/version.go`
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
- On the `RC` branch, prepare a new version section in the `CHANGELOG.md`
- All links must be link-ified: `$ python ./scripts/linkify_changelog.py CHANGELOG.md`
- Copy the entries into a `RELEASE_CHANGELOG.md`, this is needed so the bot knows which entries to add to the release page on GitHub.
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 @@ -184,13 +184,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
1 change: 1 addition & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3015,6 +3015,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
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()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sdkVersion := getSDKVersion()

Copy link
Member Author

@tac0turtle tac0turtle Jun 18, 2021

Choose a reason for hiding this comment

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

dam, will make the changes

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,
Comment on lines +69 to +76
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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,
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: getSDKVersion(),

}
}

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",
}
want := `testapp: 1.0.0
git commit: 1b78457135a4104bc3af97f20654d49e2ea87454
Expand Down