Skip to content

Commit

Permalink
Merge branch 'main' into lucas/distribution-audit
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslopezf authored Aug 16, 2024
2 parents 2756bab + e2ec889 commit 9a1da06
Show file tree
Hide file tree
Showing 16 changed files with 263 additions and 155 deletions.
191 changes: 105 additions & 86 deletions CHANGELOG.md

Large diffs are not rendered by default.

59 changes: 30 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,42 @@ The version matrix below shows which versions of the Cosmos SDK, modules and lib

#### Core Dependencies

Core Dependencies are the core libraries that an application may depend on.
Core dependencies are the core libraries that an application may depend on.
Core dependencies not mentionned here as compatible across all maintained SDK versions.

> Note: the ❌ signals that the version of the Cosmos SDK does not need to import the dependency.
| Cosmos SDK | cosmossdk.io/core | cosmossdk.io/api | cosmossdk.io/math | cosmossdk.io/errors | cosmossdk.io/depinject | cosmossdk.io/log | cosmossdk.io/store |
| ---------- | ----------------- | ---------------- | ----------------- | ------------------- | ---------------------- | ---------------- | ------------------ |
| 0.50.z | 0.11.z | 0.7.z | 1.y.z | 1.y.z | 1.y.z | 1.y.z | 1.y.z |
| 0.47.z | 0.5.z | 0.3.z | 1.y.z | 1.y.z | 1.y.z | 1.y.z ||
| 0.46.z ||| 1.y.z | 1.y.z ||||
| Cosmos SDK | cosmossdk.io/core | cosmossdk.io/api | cosmossdk.io/x/tx |
| ---------- | ----------------- | ---------------- | ----------------- |
| 0.52.z | 1.y.z | 0.8.z | 0.14.z |
| 0.50.z | 0.11.z | 0.7.z | 0.13.z |
| 0.47.z | 0.5.z | 0.3.z | N/A |

#### Module Dependencies

Module Dependencies are the modules that an application may depend on and which version of the Cosmos SDK they are compatible with.

> Note: The version table only goes back to 0.50.x, this is due to the reason that modules were not spun out into their own go.mods until 0.50.z. ❌ signals that the module was not spun out into its own go.mod file.
| Cosmos SDK | 0.50.z | 0.y.z |
| --------------------------- | --------- | ----- |
| cosmossdk.io/x/auth || |
| cosmossdk.io/x/accounts || |
| cosmossdk.io/x/bank || |
| cosmossdk.io/x/circuit | 0.1.z | |
| cosmossdk.io/x/consensus || |
| cosmossdk.io/x/distribution || |
| cosmossdk.io/x/evidence | 0.1.z | |
| cosmossdk.io/x/feegrant | 0.1.z | |
| cosmossdk.io/x/gov || |
| cosmossdk.io/x/group || |
| cosmossdk.io/x/mint || |
| cosmossdk.io/x/nft | 0.1.z | |
| cosmossdk.io/x/protcolpool || |
| cosmossdk.io/x/slashing || |
| cosmossdk.io/x/staking || |
| cosmossdk.io/x/tx | =< 0.13.z | |
| cosmossdk.io/x/upgrade | 0.1.z | |
> Note: The version table only goes back to 0.50.x, as modules started to become modular with 0.50.z.
> X signals that the module was not spun out into its own go.mod file.
> N/A signals that the module was not available in the Cosmos SDK at that time.
| Cosmos SDK | 0.50.z | 0.52.z |
| --------------------------- | ------ | ------ |
| cosmossdk.io/x/auth | X | 0.2.z |
| cosmossdk.io/x/accounts | N/A | 0.2.z |
| cosmossdk.io/x/bank | X | 0.2.z |
| cosmossdk.io/x/circuit | 0.1.z | 0.2.z |
| cosmossdk.io/x/consensus | X | 0.2.z |
| cosmossdk.io/x/distribution | X | 0.2.z |
| cosmossdk.io/x/epochs | N/A | 0.2.z |
| cosmossdk.io/x/evidence | 0.1.z | 0.2.z |
| cosmossdk.io/x/feegrant | 0.1.z | 0.2.z |
| cosmossdk.io/x/gov | X | 0.2.z |
| cosmossdk.io/x/group | X | 0.2.z |
| cosmossdk.io/x/mint | X | 0.2.z |
| cosmossdk.io/x/nft | 0.1.z | 0.2.z |
| cosmossdk.io/x/protocolpool | N/A | 0.2.z |
| cosmossdk.io/x/slashing | X | 0.2.z |
| cosmossdk.io/x/staking | X | 0.2.z |
| cosmossdk.io/x/upgrade | 0.1.z | 0.2.z |

## Disambiguation

Expand Down
24 changes: 21 additions & 3 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ messages, while maintaining the default behavior for other message types.

Here is an example on how `SetIncludeNestedMsgsGas` option could be set to calculate the gas of a gov proposal
nested messages:

```go
baseAppOptions = append(baseAppOptions, baseapp.SetIncludeNestedMsgsGas([]sdk.Message{&gov.MsgSubmitProposal{}}))
// ...
app.App = appBuilder.Build(db, traceStore, baseAppOptions...)
```

## [v0.52.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.52.0-alpha.0)

Documentation to migrate an application from v0.50.x to server/v2 is available elsewhere.
It is additional to the changes described here.

### SimApp

In this section we describe the changes made in Cosmos SDK' SimApp.
Expand Down Expand Up @@ -182,8 +188,7 @@ for more details.
### Depinject `app_config.go` / `app.yml`

With the introduction of [environment in modules](#core-api), depinject automatically creates the environment for all modules.
Learn more about environment [here](https://example.com) <!-- TODO -->. Given the fields of environment, this means runtime creates a kv store service for all modules by default.
It can happen that some modules do not have a store necessary (such as `x/auth/tx` for instance). In this case, the store creation should be skipped in `app_config.go`:
Learn more about environment [here](https://example.com) <!-- TODO -->. Given the fields of environment, this means runtime creates a kv store service for all modules by default. It can happen that some modules do not have a store necessary (such as `x/auth/tx` for instance). In this case, the store creation should be skipped in `app_config.go`:

```diff
InitGenesis: []string{
Expand All @@ -203,7 +208,20 @@ There is no longer a need for the Cosmos SDK to host these protos for itself and
That package containing proto v2 generated code, but the SDK now uses [buf generated go SDK instead](https://buf.build/docs/bsr/generated-sdks/go).
If you were depending on `cosmossdk.io/api/tendermint`, please use the buf generated go SDK instead, or ask CometBFT host the generated proto v2 code.

The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers need to update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location. This change is optional, but recommended, as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK.
The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers need to update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for directly mapping the`Any` type to its new location:

```diff
version: v1
plugins:
- name: gocosmos
out: ..
- opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1/orm.proto=cosmossdk.io/orm
+ opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any,Mcosmos/orm/v1/orm.proto=cosmossdk.io/orm
- name: grpc-gateway
out: ..
opt: logtostderr=true,allow_colon_final_segments=true

```

Also, any usages of the interfaces `AnyUnpacker` and `UnpackInterfacesMessage` must be replaced with the interfaces of the same name in the `github.com/cosmos/gogoproto/types/any` package.

Expand Down
4 changes: 2 additions & 2 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,10 @@ func (app *BaseApp) FinalizeBlock(req *abci.FinalizeBlockRequest) (res *abci.Fin
func (app *BaseApp) checkHalt(height int64, time time.Time) error {
var halt bool
switch {
case app.haltHeight > 0 && uint64(height) > app.haltHeight:
case app.haltHeight > 0 && uint64(height) >= app.haltHeight:
halt = true

case app.haltTime > 0 && time.Unix() > int64(app.haltTime):
case app.haltTime > 0 && time.Unix() >= int64(app.haltTime):
halt = true
}

Expand Down
8 changes: 5 additions & 3 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2257,9 +2257,11 @@ func TestABCI_HaltChain(t *testing.T) {
expHalt bool
}{
{"default", 0, 0, 10, 0, false},
{"halt-height-edge", 10, 0, 10, 0, false},
{"halt-height", 10, 0, 11, 0, true},
{"halt-time-edge", 0, 10, 1, 10, false},
{"halt-height-edge", 11, 0, 10, 0, false},
{"halt-height-equal", 10, 0, 10, 0, true},
{"halt-height", 10, 0, 10, 0, true},
{"halt-time-edge", 0, 11, 1, 10, false},
{"halt-time-equal", 0, 10, 1, 10, true},
{"halt-time", 0, 10, 1, 11, true},
}

Expand Down
43 changes: 43 additions & 0 deletions client/grpc/node/autocli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package node

import (
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
nodev1beta1 "cosmossdk.io/api/cosmos/base/node/v1beta1"
)

var ServiceAutoCLIDescriptor = &autocliv1.ServiceCommandDescriptor{
Service: nodev1beta1.Service_ServiceDesc.ServiceName,
RpcCommandOptions: []*autocliv1.RpcCommandOptions{
{
RpcMethod: "Config",
Use: "config",
Short: "Query the current node config",
},
{
RpcMethod: "Status",
Use: "status",
Short: "Query the current node status",
},
},
}

// NewNodeCommands is a fake `appmodule.Module` to be considered as a module
// and be added in AutoCLI.
func NewNodeCommands() *nodeModule {
return &nodeModule{}
}

type nodeModule struct{}

func (m nodeModule) IsOnePerModuleType() {}
func (m nodeModule) IsAppModule() {}

func (m nodeModule) Name() string {
return "node"
}

func (m nodeModule) AutoCLIOptions() *autocliv1.ModuleOptions {
return &autocliv1.ModuleOptions{
Query: ServiceAutoCLIDescriptor,
}
}
11 changes: 6 additions & 5 deletions collections/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* [#19343](https://github.com/cosmos/cosmos-sdk/pull/19343) Simplify IndexedMap creation by allowing to infer indexes through reflection.
* [#18933](https://github.com/cosmos/cosmos-sdk/pull/18933) Add LookupMap implementation. It is basic wrapping of the standard Map methods but is not iterable.
* [#17656](https://github.com/cosmos/cosmos-sdk/pull/17656) Introduces `Vec`, a collection type that allows to represent a growable array on top of a KVStore.
* [#17656](https://github.com/cosmos/cosmos-sdk/pull/17656) Introduces `Vec`, a collection type that allows to represent a growable array on top of a KVStore.
* [#18933](https://github.com/cosmos/cosmos-sdk/pull/18933) Add LookupMap implementation. It is basic wrapping of the standard Map methods but is not iterable.
* [#19343](https://github.com/cosmos/cosmos-sdk/pull/19343) Simplify IndexedMap creation by allowing to infer indexes through reflection.
* [#19861](https://github.com/cosmos/cosmos-sdk/pull/19861) Add `NewJSONValueCodec` value codec as an alternative for `codec.CollValue` from the SDK for non protobuf types.
* [#21090](https://github.com/cosmos/cosmos-sdk/pull/21090) Introduces `Quad`, a composite key with four keys.

## [v0.4.0](https://github.com/cosmos/cosmos-sdk/releases/tag/collections%2Fv0.4.0)

Expand All @@ -58,8 +59,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

* [#16074](https://github.com/cosmos/cosmos-sdk/pull/16607) Introduces `Clear` method for `Map` and `KeySet`
* [#16773](https://github.com/cosmos/cosmos-sdk/pull/16773)
* Adds `AltValueCodec` which provides a way to decode a value in two ways.
* Adds the possibility to specify an alternative way to decode the values of `KeySet`, `indexes.Multi`, `indexes.ReversePair`.
* Adds `AltValueCodec` which provides a way to decode a value in two ways.
* Adds the possibility to specify an alternative way to decode the values of `KeySet`, `indexes.Multi`, `indexes.ReversePair`.

## [v0.2.0](https://github.com/cosmos/cosmos-sdk/releases/tag/collections%2Fv0.2.0)

Expand Down
12 changes: 5 additions & 7 deletions schema/testing/statesim/app_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,29 @@ func DiffAppStates(expected, actual view.AppState) string {
res += fmt.Sprintf("MODULE COUNT ERROR: expected %d, got %d\n", expectNumModules, actualNumModules)
}

expected.Modules(func(expectedMod view.ModuleState, err error) bool {
for expectedMod, err := range expected.Modules {
if err != nil {
res += fmt.Sprintf("ERROR getting expected module: %s\n", err)
return true
continue
}

moduleName := expectedMod.ModuleName()
actualMod, err := actual.GetModule(moduleName)
if err != nil {
res += fmt.Sprintf("ERROR getting actual module: %s\n", err)
return true
continue
}
if actualMod == nil {
res += fmt.Sprintf("Module %s: actual module NOT FOUND\n", moduleName)
return true
continue
}

diff := DiffModuleStates(expectedMod, actualMod)
if diff != "" {
res += "Module " + moduleName + "\n"
res += indentAllLines(diff)
}

return true
})
}

return res
}
12 changes: 5 additions & 7 deletions schema/testing/statesim/module_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,29 @@ func DiffModuleStates(expected, actual view.ModuleState) string {
res += fmt.Sprintf("OBJECT COLLECTION COUNT ERROR: expected %d, got %d\n", expectedNumObjectCollections, actualNumObjectCollections)
}

expected.ObjectCollections(func(expectedColl view.ObjectCollection, err error) bool {
for expectedColl, err := range expected.ObjectCollections {
if err != nil {
res += fmt.Sprintf("ERROR getting expected object collection: %s\n", err)
return true
continue
}

objTypeName := expectedColl.ObjectType().Name
actualColl, err := actual.GetObjectCollection(objTypeName)
if err != nil {
res += fmt.Sprintf("ERROR getting actual object collection: %s\n", err)
return true
continue
}
if actualColl == nil {
res += fmt.Sprintf("Object Collection %s: actuall collection NOT FOUND\n", objTypeName)
return true
continue
}

diff := DiffObjectCollections(expectedColl, actualColl)
if diff != "" {
res += "Object Collection " + objTypeName + "\n"
res += indentAllLines(diff)
}

return true
})
}

return res
}
15 changes: 6 additions & 9 deletions schema/testing/statesim/object_coll_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"strings"

"cosmossdk.io/schema"
schematesting "cosmossdk.io/schema/testing"
"cosmossdk.io/schema/view"
)
Expand All @@ -30,29 +29,29 @@ func DiffObjectCollections(expected, actual view.ObjectCollection) string {
res += fmt.Sprintf("OBJECT COUNT ERROR: expected %d, got %d\n", expectedNumObjects, actualNumObjects)
}

expected.AllState(func(expectedUpdate schema.ObjectUpdate, err error) bool {
for expectedUpdate, err := range expected.AllState {
if err != nil {
res += fmt.Sprintf("ERROR getting expected object: %s\n", err)
return true
continue
}

keyStr := fmtObjectKey(expected.ObjectType(), expectedUpdate.Key)
actualUpdate, found, err := actual.GetObject(expectedUpdate.Key)
if err != nil {
res += fmt.Sprintf("Object %s: ERROR: %v\n", keyStr, err)
return true
continue
}
if !found {
res += fmt.Sprintf("Object %s: NOT FOUND\n", keyStr)
return true
continue
}

if expectedUpdate.Delete != actualUpdate.Delete {
res += fmt.Sprintf("Object %s: Deleted mismatch, expected %v, got %v\n", keyStr, expectedUpdate.Delete, actualUpdate.Delete)
}

if expectedUpdate.Delete {
return true
continue
}

valueDiff := schematesting.DiffObjectValues(expected.ObjectType().ValueFields, expectedUpdate.Value, actualUpdate.Value)
Expand All @@ -62,9 +61,7 @@ func DiffObjectCollections(expected, actual view.ObjectCollection) string {
res += "\n"
res += indentAllLines(valueDiff)
}

return true
})
}

return res
}
Expand Down
1 change: 0 additions & 1 deletion scripts/validate-gentxs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ if [ "$(ls -A $GENTXS_DIR)" ]; then

GENACC=$(cat $GENTX_FILE | sed -n 's|.*"delegator_address":"\([^"]*\)".*|\1|p')
denomquery=$(jq -r '.body.messages[0].value.denom' $GENTX_FILE)
amountquery=$(jq -r '.body.messages[0].value.amount' $GENTX_FILE)

# only allow $DENOM tokens to be bonded
if [ $denomquery != $DENOM ]; then
Expand Down
4 changes: 4 additions & 0 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/server"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
Expand Down Expand Up @@ -122,6 +123,9 @@ func NewRootCmd() *cobra.Command {
autoCliOpts := tempApp.AutoCliOpts()
autoCliOpts.ClientCtx = initClientCtx

nodeCmds := nodeservice.NewNodeCommands()
autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions()

if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 9a1da06

Please sign in to comment.