Skip to content

Commit

Permalink
Merge branch 'main' into technicallyty/22715-grpc-auto-registration
Browse files Browse the repository at this point in the history
  • Loading branch information
technicallyty committed Dec 20, 2024
2 parents f0c3e47 + 6ed9452 commit 176726b
Show file tree
Hide file tree
Showing 19 changed files with 239 additions and 89 deletions.
50 changes: 50 additions & 0 deletions UPGRADING_v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Upgrading Cosmos SDK v2 [DRAFT, see #22531](https://github.com/cosmos/cosmos-sdk/issues/22531)

This guide provides instructions for upgrading to specific versions of Cosmos SDK.
Note, always read the **SimApp** section for more information on application wiring updates.

## Upgrading from v0.52.x to v2.

First and foremost, v2 uses [depinject](./depinject/README.md) to wire the module and application dependencies.
This guide assumes that you have already made your modules depinject compatible, and that you made use of depinject in your application.

### Modules

### Server


### SimApp

With the migration to server/v2 and runtime/v2 some changes are required in the `root.go` and `app.go` of your application.

#### `app.go`


#### `root.go`

Thanks to the more modular design of v2, the application developer is free to pick which server to use in their application:

```go
// wire server commands
return serverv2.AddCommands[T](
rootCmd,
logger,
simApp,
deps.GlobalConfig,
initServerConfig(),
deps.ConsensusServer,
grpcServer,
storeComponent,
telemetryServer,
restServer,
grpcgatewayServer,
)
```

## Upgrading from v0.50.x to v2

Upgrading directly from v0.50.x to v2 is supported.
Modules should be updated to support all the latest changes in the SDK.

Read the module section from the v0.52 [UPGRADING.md](UPGRADING.md) file for more information.
Then simply follow the instructions from the [v0.52 section](#upgrading-from-v052x-to-v200) from this file.
2 changes: 1 addition & 1 deletion docs/architecture/adr-023-protobuf-naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Further guidelines to be described below.
Names should be descriptive enough to convey their meaning and distinguish
them from other names.

Given that we are using fully-qualifed names within
Given that we are using fully-qualified names within
`google.protobuf.Any` as well as within gRPC query routes, we should aim to
keep names concise, without going overboard. The general rule of thumb should
be if a shorter name would convey more or else the same thing, pick the shorter
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/adr-063-core-module-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ type HasServices interface {

```

Because of the `cosmos.msg.v1.service` protobuf option, required for `Msg` services, the same `ServiceRegitrar` can be
Because of the `cosmos.msg.v1.service` protobuf option, required for `Msg` services, the same `ServiceRegistrar` can be
used to register both `Msg` and query services.

#### Genesis
Expand Down
2 changes: 1 addition & 1 deletion docs/user/run-node/01-run-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Local state sync work similar to normal state sync except that it works off a lo

1. As mentioned in https://docs.cometbft.com/v0.37/core/state-sync, one must set a height and hash in the config.toml along with a few rpc servers (the afromentioned link has instructions on how to do this).
2. Run `<appd snapshot restore <height> <format>` to restore a local snapshot (note: first load it from a file with the *load* command).
3. Bootsrapping Comet state in order to start the node after the snapshot has been ingested. This can be done with the bootstrap command `<app> comet bootstrap-state`
3. Bootstrapping Comet state in order to start the node after the snapshot has been ingested. This can be done with the bootstrap command `<app> comet bootstrap-state`

### Snapshots Commands

Expand Down
18 changes: 9 additions & 9 deletions runtime/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ module cosmossdk.io/runtime/v2

go 1.23

// server v2 integration
replace (
cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager
cosmossdk.io/server/v2/stf => ../../server/v2/stf
cosmossdk.io/store/v2 => ../../store/v2
)
// server v2 integration (uncomment during development, but comment before release)
// replace (
// cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager
// cosmossdk.io/server/v2/stf => ../../server/v2/stf
// cosmossdk.io/store/v2 => ../../store/v2
// )

require (
cosmossdk.io/api v0.8.0-rc.1
cosmossdk.io/core v1.0.0-alpha.6
cosmossdk.io/depinject v1.1.0
cosmossdk.io/log v1.5.0
cosmossdk.io/schema v1.0.0
cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000
cosmossdk.io/server/v2/stf v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1
cosmossdk.io/server/v2/stf v1.0.0-beta.1
cosmossdk.io/store/v2 v2.0.0-beta.1
cosmossdk.io/x/tx v1.0.0-alpha.3
github.com/cosmos/gogoproto v1.7.0
github.com/stretchr/testify v1.10.0
Expand Down
6 changes: 6 additions & 0 deletions runtime/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ cosmossdk.io/log v1.5.0 h1:dVdzPJW9kMrnAYyMf1duqacoidB9uZIl+7c6z0mnq0g=
cosmossdk.io/log v1.5.0/go.mod h1:Tr46PUJjiUthlwQ+hxYtUtPn4D/oCZXAkYevBeh5+FI=
cosmossdk.io/schema v1.0.0 h1:/diH4XJjpV1JQwuIozwr+A4uFuuwanFdnw2kKeiXwwQ=
cosmossdk.io/schema v1.0.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1 h1:EISWki+z9SDAt3OJnUl2y5Ow4qjOb+epYjLb1C7CN/E=
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1/go.mod h1:RVYxIaEdIT10nWSRqbwKDLFWfvCVx+cwAorCyPAQg9A=
cosmossdk.io/server/v2/stf v1.0.0-beta.1 h1:s+nRgjhKVC08/qpr51eFVodLhyyQ9ASvJBanLBfQVNI=
cosmossdk.io/server/v2/stf v1.0.0-beta.1/go.mod h1:nfjihbofEF2GGadkYSFmgy5tqrAnSrmGcXUDZmmWyi8=
cosmossdk.io/store/v2 v2.0.0-beta.1 h1:p1fdZ9uNijhpXZXdqs0QS6NmXNDVPNyT4DHV4yQnF64=
cosmossdk.io/store/v2 v2.0.0-beta.1/go.mod h1:qHQmf/9mnsXwo/Ypp2u2Zs6BmkYcx1R/Jrpyn9Ro13A=
cosmossdk.io/x/tx v1.0.0-alpha.3 h1:+55/JFH5QRqnFhOI2heH3DKsaNL0RpXcJOQNzUvHiaQ=
cosmossdk.io/x/tx v1.0.0-alpha.3/go.mod h1:h4pQ/j6Gfu8goB1R3Jbl4qY4RjYVNAsoylcleTXdSRg=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down
36 changes: 7 additions & 29 deletions server/v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,21 @@ Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section under the
appropriate stanza (see below). Each entry is required to include a tag and
the Github issue reference in the following format:
* (<tag>) \#<issue-number> message
The tag should consist of where the change is being made ex. (x/staking), (store)
The issue numbers will later be link-ified during the release process so you do
not have to worry about including a link manually, but you can if you wish.
Types of changes (Stanzas):
"Features" for new features.
"Improvements" for changes in existing functionality.
"Deprecated" for soon-to-be removed features.
"Bug Fixes" for any bug fixes.
"Client Breaking" for breaking Protobuf, gRPC and REST routes used by end-users.
"CLI Breaking" for breaking CLI commands.
"API Breaking" for breaking exported APIs used by developers building on SDK.
"State Machine Breaking" for any changes that result in a different AppState given same genesisState and txList.
Ref: https://keepachangelog.com/en/1.0.0/
Change log entries are to be added to the Unreleased section from newest to oldest.
Each entry must include the Github issue reference in the following format:
* [#<issue-number>] Changelog message.
-->

# Changelog

## [Unreleased]

Every module contains its own CHANGELOG.md. Please refer to the module you are interested in.

### Features

* [#22715](https://github.com/cosmos/cosmos-sdk/pull/22941) Add custom HTTP handler for grpc-gateway that removes the need to manually register grpc-gateway services.

### Improvements

### Bug Fixes

### API Breaking Changes
## [v2.0.0-beta.1](https://github.com/cosmos/cosmos-sdk/releases/tag/server/v2.0.0-beta.1)

### Deprecated
Initial tag of `cosmossdk.io/server/v2`.
17 changes: 17 additions & 0 deletions server/v2/api/telemetry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@ type Config struct {
// Datadog. Only utilized if MetricsSink is set to "dogstatsd".
DatadogHostname string `mapstructure:"datadog-hostname" toml:"data-dog-hostname" comment:"DatadogHostname defines the hostname to use when emitting metrics to Datadog. Only utilized if MetricsSink is set to \"dogstatsd\"."`
}

// CfgOption is a function that allows to overwrite the default server configuration.
type CfgOption func(*Config)

// OverwriteDefaultConfig overwrites the default config with the new config.
func OverwriteDefaultConfig(newCfg *Config) CfgOption {
return func(cfg *Config) {
*cfg = *newCfg
}
}

// Disable the telemetry server by default (default enabled).
func Disable() CfgOption {
return func(cfg *Config) {
cfg.Enable = false
}
}
29 changes: 23 additions & 6 deletions server/v2/api/telemetry/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ var (
const ServerName = "telemetry"

type Server[T transaction.Tx] struct {
logger log.Logger
config *Config
server *http.Server
metrics *Metrics
logger log.Logger
config *Config
cfgOptions []CfgOption
server *http.Server
metrics *Metrics
}

// New creates a new telemetry server.
func New[T transaction.Tx](cfg server.ConfigMap, logger log.Logger, enableTelemetry func()) (*Server[T], error) {
func New[T transaction.Tx](cfg server.ConfigMap, logger log.Logger, enableTelemetry func(), cfgOptions ...CfgOption) (*Server[T], error) {
srv := &Server[T]{}
serverCfg := srv.Config().(*Config)
if len(cfg) > 0 {
Expand All @@ -37,6 +38,7 @@ func New[T transaction.Tx](cfg server.ConfigMap, logger log.Logger, enableTeleme
}
}
srv.config = serverCfg
srv.cfgOptions = cfgOptions
srv.logger = logger.With(log.ModuleKey, srv.Name())

if enableTelemetry == nil {
Expand Down Expand Up @@ -66,14 +68,29 @@ func New[T transaction.Tx](cfg server.ConfigMap, logger log.Logger, enableTeleme
return srv, nil
}

// NewWithConfigOptions creates a new telemetry server with the provided config options.
// It is *not* a fully functional server (since it has been created without dependencies)
// The returned server should only be used to get and set configuration.
func NewWithConfigOptions[T transaction.Tx](opts ...CfgOption) *Server[T] {
return &Server[T]{
cfgOptions: opts,
}
}

// Name returns the server name.
func (s *Server[T]) Name() string {
return ServerName
}

func (s *Server[T]) Config() any {
if s.config == nil || s.config.Address == "" {
return DefaultConfig()
cfg := DefaultConfig()
// overwrite the default config with the provided options
for _, opt := range s.cfgOptions {
opt(cfg)
}

return cfg
}

return s.config
Expand Down
27 changes: 27 additions & 0 deletions server/v2/appmanager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section from newest to oldest.
Each entry must include the Github issue reference in the following format:
* [#<issue-number>] Changelog message.
-->

# Changelog

## [Unreleased]

## [v1.0.0-beta.1](https://github.com/cosmos/cosmos-sdk/releases/tag/server/v2/appmanager%2Fv1.0.0-beta.1)

Initial tag of `cosmossdk.io/server/v2/appmanager`.
27 changes: 27 additions & 0 deletions server/v2/cometbft/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section from newest to oldest.
Each entry must include the Github issue reference in the following format:
* [#<issue-number>] Changelog message.
-->

# Changelog

## [Unreleased]

## [v1.0.0-beta.1](https://github.com/cosmos/cosmos-sdk/releases/tag/server/v2/cometbft%2Fv1.0.0-beta.1)

Initial tag of `cosmossdk.io/server/v2/cometbft`.
8 changes: 4 additions & 4 deletions server/v2/cometbft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ require (
cosmossdk.io/errors/v2 v2.0.0
cosmossdk.io/log v1.5.0
cosmossdk.io/schema v1.0.0
cosmossdk.io/server/v2 v2.0.0-00010101000000-000000000000
cosmossdk.io/server/v2/appmanager v0.0.0-20240802110823-cffeedff643d
cosmossdk.io/server/v2/stf v0.0.0-20240708142107-25e99c54bac1
cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000
cosmossdk.io/server/v2 v2.0.0-beta.1
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1
cosmossdk.io/server/v2/stf v1.0.0-beta.1
cosmossdk.io/store/v2 v2.0.0-beta.1
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
github.com/cometbft/cometbft v1.0.0
github.com/cometbft/cometbft/api v1.0.0
Expand Down
15 changes: 7 additions & 8 deletions server/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ module cosmossdk.io/server/v2

go 1.23

replace (
cosmossdk.io/server/v2/appmanager => ./appmanager
cosmossdk.io/server/v2/stf => ./stf
cosmossdk.io/store/v2 => ../../store/v2
cosmossdk.io/store/v2/db => ../../store/v2/db
)
// server v2 integration (uncomment during development, but comment before release)
// replace (
// cosmossdk.io/server/v2/appmanager => ./appmanager
// cosmossdk.io/store/v2 => ../../store/v2
// )

require (
cosmossdk.io/api v0.8.0-rc.1
cosmossdk.io/core v1.0.0-alpha.6
cosmossdk.io/core/testing v0.0.1
cosmossdk.io/log v1.5.0
cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1
cosmossdk.io/store/v2 v2.0.0-beta.1
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/gogogateway v1.2.0
github.com/cosmos/gogoproto v1.7.0
Expand Down
4 changes: 4 additions & 0 deletions server/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ cosmossdk.io/log v1.5.0 h1:dVdzPJW9kMrnAYyMf1duqacoidB9uZIl+7c6z0mnq0g=
cosmossdk.io/log v1.5.0/go.mod h1:Tr46PUJjiUthlwQ+hxYtUtPn4D/oCZXAkYevBeh5+FI=
cosmossdk.io/schema v1.0.0 h1:/diH4XJjpV1JQwuIozwr+A4uFuuwanFdnw2kKeiXwwQ=
cosmossdk.io/schema v1.0.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1 h1:EISWki+z9SDAt3OJnUl2y5Ow4qjOb+epYjLb1C7CN/E=
cosmossdk.io/server/v2/appmanager v1.0.0-beta.1/go.mod h1:RVYxIaEdIT10nWSRqbwKDLFWfvCVx+cwAorCyPAQg9A=
cosmossdk.io/store/v2 v2.0.0-beta.1 h1:p1fdZ9uNijhpXZXdqs0QS6NmXNDVPNyT4DHV4yQnF64=
cosmossdk.io/store/v2 v2.0.0-beta.1/go.mod h1:qHQmf/9mnsXwo/Ypp2u2Zs6BmkYcx1R/Jrpyn9Ro13A=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
Expand Down
27 changes: 27 additions & 0 deletions server/v2/stf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Usage:
Change log entries are to be added to the Unreleased section from newest to oldest.
Each entry must include the Github issue reference in the following format:
* [#<issue-number>] Changelog message.
-->

# Changelog

## [Unreleased]

## [v1.0.0-beta.1](https://github.com/cosmos/cosmos-sdk/releases/tag/server/v2/stf%2Fv1.0.0-beta.1)

Initial tag of `cosmossdk.io/server/v2/stf`.
Loading

0 comments on commit 176726b

Please sign in to comment.