Skip to content

Commit

Permalink
Merge branch 'main' into marko/genesis_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Mar 8, 2024
2 parents 4a364a3 + fbff6ff commit c108dd8
Show file tree
Hide file tree
Showing 45 changed files with 826 additions and 482 deletions.
2 changes: 1 addition & 1 deletion baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ func checkNegativeHeight(height int64) error {
return nil
}

// createQueryContext creates a new sdk.Context for a query, taking as args
// CreateQueryContext creates a new sdk.Context for a query, taking as args
// the block height and whether the query needs a proof or not.
func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, error) {
if err := checkNegativeHeight(height); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (app *BaseApp) SetFauxMerkleMode() {
app.fauxMerkleMode = true
}

// SetNotSigverify during simulation testing, transaction signature verification needs to be ignored.
// SetNotSigverifyTx during simulation testing, transaction signature verification needs to be ignored.
func (app *BaseApp) SetNotSigverifyTx() {
app.sigverifyTx = false
}
Expand Down
65 changes: 32 additions & 33 deletions baseapp/params_legacy.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
/*
Deprecated.
// Deprecated:

// Legacy types are defined below to aid in the migration of CometBFT consensus
// parameters from use of the now deprecated x/params modules to a new dedicated
// x/consensus module.
//
// Application developers should ensure that they implement their upgrade handler
// correctly such that app.ConsensusParamsKeeper.Set() is called with the values
// returned by GetConsensusParams().
//
// Example:
//
// baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
//
// app.UpgradeKeeper.SetUpgradeHandler(
// UpgradeName,
// func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// if cp := baseapp.GetConsensusParams(ctx, baseAppLegacySS); cp != nil {
// app.ConsensusParamsKeeper.Set(ctx, cp)
// } else {
// ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration", "upgrade", UpgradeName)
// }
//
// return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
// },
// )
//
// Developers can also bypass the use of the legacy Params subspace and set the
// values to app.ConsensusParamsKeeper.Set() explicitly.
//
// Note, for new chains this is not necessary as CometBFT's consensus parameters
// will automatically be set for you in InitChain.

Legacy types are defined below to aid in the migration of CometBFT consensus
parameters from use of the now deprecated x/params modules to a new dedicated
x/consensus module.
Application developers should ensure that they implement their upgrade handler
correctly such that app.ConsensusParamsKeeper.Set() is called with the values
returned by GetConsensusParams().
Example:
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if cp := baseapp.GetConsensusParams(ctx, baseAppLegacySS); cp != nil {
app.ConsensusParamsKeeper.Set(ctx, cp)
} else {
ctx.Logger().Info("warning: consensus parameters are undefined; skipping migration", "upgrade", UpgradeName)
}
return app.ModuleManager.RunMigrations(ctx, app.Configurator(), fromVM)
},
)
Developers can also bypass the use of the legacy Params subspace and set the
values to app.ConsensusParamsKeeper.Set() explicitly.
Note, for new chains this is not necessary as CometBFT's consensus parameters
will automatically be set for you in InitChain.
*/
package baseapp

import (
Expand Down
2 changes: 1 addition & 1 deletion client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (ctx Context) WithAux(isAux bool) Context {
return ctx
}

// WithLedgerHasProto returns the context with the provided boolean value, indicating
// WithLedgerHasProtobuf returns the context with the provided boolean value, indicating
// whether the target Ledger application can support Protobuf payloads.
func (ctx Context) WithLedgerHasProtobuf(val bool) Context {
ctx.LedgerHasProtobuf = val
Expand Down
2 changes: 1 addition & 1 deletion client/keys/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewAddNewKey(name, password, mnemonic string, account, index int) AddNewKey
}
}

// RecoverKeyBody recovers a key
// RecoverKey recovers a key
type RecoverKey struct {
Password string `json:"password"`
Mnemonic string `json:"mnemonic"`
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func QueryBlocks(clientCtx client.Context, page, limit int, query, orderBy strin
return result, nil
}

// get block by height
// GetBlockByHeight get block by height
func GetBlockByHeight(clientCtx client.Context, height *int64) (*cmt.Block, error) {
// get the node
node, err := clientCtx.GetNode()
Expand Down
2 changes: 1 addition & 1 deletion client/v2/internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// later versions unsupported by the current version can be added
var buildInfo, _ = debug.ReadBuildInfo()

// DescriptorName returns the name of the descriptor in kebab case.
// DescriptorKebabName returns the name of the descriptor in kebab case.
func DescriptorKebabName(descriptor protoreflect.Descriptor) string {
return strcase.ToKebab(string(descriptor.Name()))
}
Expand Down
2 changes: 1 addition & 1 deletion codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type (
// MustUnmarshal calls Unmarshal and panics if error is returned.
MustUnmarshal(bz []byte, ptr proto.Message)

// Unmarshal parses the data encoded with UnmarshalLengthPrefixed method and stores
// UnmarshalLengthPrefixed parses the data encoded with UnmarshalLengthPrefixed method and stores
// the result in the value pointed to by v.
UnmarshalLengthPrefixed(bz []byte, ptr proto.Message) error
// MustUnmarshalLengthPrefixed calls UnmarshalLengthPrefixed and panics if error
Expand Down
6 changes: 3 additions & 3 deletions codec/types/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (a AminoUnpacker) UnpackAny(any *Any, iface interface{}) error {
return nil
}

// AminoUnpacker is an AnyUnpacker provided for backwards compatibility with
// AminoPacker is provided for backwards compatibility with
// amino for the binary marshaling phase
type AminoPacker struct {
Cdc *amino.Codec
Expand All @@ -123,7 +123,7 @@ func (a AminoPacker) UnpackAny(any *Any, _ interface{}) error {
return err
}

// AminoUnpacker is an AnyUnpacker provided for backwards compatibility with
// AminoJSONUnpacker is an AnyUnpacker provided for backwards compatibility with
// amino for the JSON marshaling phase
type AminoJSONUnpacker struct {
Cdc *amino.Codec
Expand Down Expand Up @@ -160,7 +160,7 @@ func (a AminoJSONUnpacker) UnpackAny(any *Any, iface interface{}) error {
return nil
}

// AminoUnpacker is an AnyUnpacker provided for backwards compatibility with
// AminoJSONPacker is an AnyUnpacker provided for backwards compatibility with
// amino for the JSON un-marshaling phase
type AminoJSONPacker struct {
Cdc *amino.Codec
Expand Down
44 changes: 21 additions & 23 deletions codec/unknownproto/doc.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
/*
unknownproto implements functionality to "type check" protobuf serialized byte sequences
against an expected proto.Message to report:
a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor
b) Mismatched wire types for a field -- this is indicative of mismatched services
Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case
if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil {
// Handle the error.
}
and ideally should be added before invoking proto.Unmarshal, if you'd like to enforce the features mentioned above.
By default, for security we report every single field that's unknown, whether a non-critical field or not. To customize
this behavior, please set the boolean parameter allowUnknownNonCriticals to true to RejectUnknownFields:
if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil {
// Handle the error.
}
*/
// Package unknownproto implements functionality to "type check" protobuf serialized byte sequences
// against an expected proto.Message to report:
//
// a) Unknown fields in the stream -- this is indicative of mismatched services, perhaps a malicious actor
//
// b) Mismatched wire types for a field -- this is indicative of mismatched services
//
// Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case
//
// if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil {
// // Handle the error.
// }
//
// and ideally should be added before invoking proto.Unmarshal, if you'd like to enforce the features mentioned above.
//
// By default, for security we report every single field that's unknown, whether a non-critical field or not. To customize
// this behavior, please set the boolean parameter allowUnknownNonCriticals to true to RejectUnknownFields:
//
// if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil {
// // Handle the error.
// }
package unknownproto
4 changes: 2 additions & 2 deletions core/comet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"
)

// BlockInfoService is an interface that can be used to get information specific to Comet
// CometInfoService is an interface that can be used to get information specific to Comet
type CometInfoService interface {
GetCometInfo(context.Context) Info
}
Expand Down Expand Up @@ -50,7 +50,7 @@ type VoteInfo struct {
BlockIDFlag BlockIDFlag
}

// BlockIdFlag indicates which BlockID the signature is for
// BlockIDFlag indicates which BlockID the signature is for
type BlockIDFlag int32

const (
Expand Down
2 changes: 1 addition & 1 deletion core/store/database.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package store

// Database provides access to the underlying database for CRUD operations of non-consensus data.
// DatabaseService provides access to the underlying database for CRUD operations of non-consensus data.
// WARNING: using this api will make your module unprovable for fraud and validity proofs
type DatabaseService interface {
GetDatabase() NonConsensusStore
Expand Down
14 changes: 7 additions & 7 deletions docs/build/building-apps/01-app-go-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_position: 1
---

# Overview of `app_v2.go`
# Overview of `app_di.go`

:::note Synopsis

Expand All @@ -19,7 +19,7 @@ Learn more about the rationale of App Wiring in [ADR-057](../architecture/adr-05

:::

This section is intended to provide an overview of the `SimApp` `app_v2.go` file with App Wiring.
This section is intended to provide an overview of the `SimApp` `app_di.go` file with App Wiring.

## `app_config.go`

Expand Down Expand Up @@ -57,7 +57,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/app_config.go

:::tip
The example above shows how to create an `AppConfig` using Go. However, it is also possible to create an `AppConfig` using YAML, or JSON.
The configuration can then be embed with `go:embed` and read with [`appconfig.LoadYAML`](https://pkg.go.dev/cosmossdk.io/core/appconfig#LoadYAML), or [`appconfig.LoadJSON`](https://pkg.go.dev/cosmossdk.io/core/appconfig#LoadJSON), in `app_v2.go`.
The configuration can then be embed with `go:embed` and read with [`appconfig.LoadYAML`](https://pkg.go.dev/cosmossdk.io/core/appconfig#LoadYAML), or [`appconfig.LoadJSON`](https://pkg.go.dev/cosmossdk.io/core/appconfig#LoadJSON), in `app_di.go`.

```go
//go:embed app_config.yaml
Expand Down Expand Up @@ -95,9 +95,9 @@ modules:

A more complete example of `app.yaml` can be found [here](https://github.com/cosmos/cosmos-sdk/blob/91b1d83f1339e235a1dfa929ecc00084101a19e3/simapp/app.yaml).

## `app_v2.go`
## `app_di.go`

`app_v2.go` is the place where `SimApp` is constructed. `depinject.Inject` facilitates that by automatically wiring the app modules and keepers, provided an application configuration `AppConfig` is provided. `SimApp` is constructed, when calling the injected `*runtime.AppBuilder`, with `appBuilder.Build(...)`.
`app_di.go` is the place where `SimApp` is constructed. `depinject.Inject` facilitates that by automatically wiring the app modules and keepers, provided an application configuration `AppConfig` is provided. `SimApp` is constructed, when calling the injected `*runtime.AppBuilder`, with `appBuilder.Build(...)`.
In short `depinject` and the [`runtime` package](https://pkg.go.dev/github.com/cosmos/cosmos-sdk/runtime) abstract the wiring of the app, and the `AppBuilder` is the place where the app is constructed. [`runtime`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk/runtime) takes care of registering the codecs, KV store, subspaces and instantiating `baseapp`.

```go reference
Expand Down Expand Up @@ -143,10 +143,10 @@ When using AutoCLI and combining app wiring and non app wiring modules. The Auto
Otherwise it will miss the non depinject modules and not register their CLI.
:::

### Complete `app_v2.go`
### Complete `app_di.go`

:::tip
Note that in the complete `SimApp` `app_v2.go` file, testing utilities are also defined, but they could as well be defined in a separate file.
Note that in the complete `SimApp` `app_di.go` file, testing utilities are also defined, but they could as well be defined in a separate file.
:::

```go reference
Expand Down
6 changes: 1 addition & 5 deletions docs/build/building-modules/15-depinject.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,8 @@ All methods, structs and their fields must be public for `depinject`.
https://github.com/cosmos/cosmos-sdk/blob/f4bdec3433373cc4950f4680743e969495763fbb/x/group/module/module.go#L64-L65
```
The module is now ready to be used with `depinject` by a chain developer.
## Integrate in an application
The App Wiring is done in `app_config.go` / `app.yaml` and `app_v2.go` and is explained in detail in the [overview of `app_v2.go`](https://docs.cosmos.network/main/build/building-apps/app-go-v2).
The App Wiring is done in `app_config.go` / `app.yaml` and `app_di.go` and is explained in detail in the [overview of `app_di.go`](https://docs.cosmos.network/main/build/building-apps/app-go-v2).
62 changes: 30 additions & 32 deletions errors/doc.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
/*
Package errors implements custom error interfaces for cosmos-sdk.
Error declarations should be generic and cover broad range of cases. Each
returned error instance can wrap a generic error declaration to provide more
details.
This package provides a broad range of errors declared that fits all common
cases. If an error is very specific for an extension it can be registered outside
of the errors package. If it will be needed my many extensions, please consider
registering it in the errors package. To create a new error instance use Register
function. You must provide a unique, non zero error code and a short description, for example:
var ErrZeroDivision = errors.Register(9241, "zero division")
When returning an error, you can attach to it an additional context
information by using Wrap function, for example:
func safeDiv(val, div int) (int, err) {
if div == 0 {
return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val)
}
return val / div, nil
}
The first time an error instance is wrapped a stacktrace is attached as well.
Stacktrace information can be printed using %+v and %v formats.
%s is just the error message
%+v is the full stack trace
%v appends a compressed [filename:line] where the error was created
*/
// Package errors implements custom error interfaces for cosmos-sdk.
//
// Error declarations should be generic and cover broad range of cases. Each
// returned error instance can wrap a generic error declaration to provide more
// details.
//
// This package provides a broad range of errors declared that fits all common
// cases. If an error is very specific for an extension it can be registered outside
// of the errors package. If it will be needed my many extensions, please consider
// registering it in the errors package. To create a new error instance use Register
// function. You must provide a unique, non zero error code and a short description, for example:
//
// var ErrZeroDivision = errors.Register(9241, "zero division")
//
// When returning an error, you can attach to it an additional context
// information by using Wrap function, for example:
//
// func safeDiv(val, div int) (int, err) {
// if div == 0 {
// return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val)
// }
// return val / div, nil
// }
//
// The first time an error instance is wrapped a stacktrace is attached as well.
// Stacktrace information can be printed using %+v and %v formats.
//
// %s is just the error message
// %+v is the full stack trace
// %v appends a compressed [filename:line] where the error was created
package errors
2 changes: 1 addition & 1 deletion runtime/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (e Events) EmitKV(eventType string, attrs ...event.Attribute) error {
return nil
}

// Emit emits an typed event that is defined in the protobuf file.
// EmitNonConsensus emits an typed event that is defined in the protobuf file.
// In the future these events will be added to consensus.
func (e Events) EmitNonConsensus(event protoiface.MessageV1) error {
return e.EventManagerI.EmitTypedEvent(event)
Expand Down
Loading

0 comments on commit c108dd8

Please sign in to comment.