Skip to content

Commit 92761bd

Browse files
committed
Merge remote-tracking branch 'origin/release/v0.52.x' into check_header
2 parents aa0d57e + 6b943b2 commit 92761bd

File tree

17 files changed

+631
-47
lines changed

17 files changed

+631
-47
lines changed

docs/architecture/adr-040-storage-and-smt-state-commitments.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ We change the storage layout of the state machine, a storage hard fork and netwo
258258

259259
## Alternative designs
260260

261-
Most of the alternative designs were evaluated in [state commitments and storage report](https://paper.dropbox.com/published/State-commitments-and-storage-review--BDvA1MLwRtOx55KRihJ5xxLbBw-KeEB7eOd11pNrZvVtqUgL3h).
262-
263261
Ethereum research published [Verkle Trie](https://dankradfeist.de/ethereum/2021/06/18/verkle-trie-for-eth1.html) - an idea of combining polynomial commitments with merkle tree in order to reduce the tree height. This concept has a very good potential, but we think it's too early to implement it. The current, SMT based design could be easily updated to the Verkle Trie once other research implement all necessary libraries. The main advantage of the design described in this ADR is the separation of state commitments from the data storage and designing a more powerful interface.
264262

265263
## Further Discussions
@@ -280,7 +278,6 @@ We were discussing use case where modules can use a support database, which is n
280278

281279
* [IAVL What's Next?](https://github.com/cosmos/cosmos-sdk/issues/7100)
282280
* [IAVL overview](https://docs.google.com/document/d/16Z_hW2rSAmoyMENO-RlAhQjAG3mSNKsQueMnKpmcBv0/edit#heading=h.yd2th7x3o1iv) of its state v0.15
283-
* [State commitments and storage report](https://paper.dropbox.com/published/State-commitments-and-storage-review--BDvA1MLwRtOx55KRihJ5xxLbBw-KeEB7eOd11pNrZvVtqUgL3h)
284281
* [Celestia (LazyLedger) SMT](https://github.com/lazyledger/smt)
285282
* Facebook Diem (Libra) SMT [design](https://developers.diem.com/papers/jellyfish-merkle-tree/2021-01-14.pdf)
286283
* [Trillian Revocation Transparency](https://github.com/google/trillian/blob/master/docs/papers/RevocationTransparency.pdf), [Trillian Verifiable Data Structures](https://github.com/google/trillian/blob/master/docs/papers/VerifiableDataStructures.pdf).

docs/build/build.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ sidebar_position: 0
44

55
# Build
66

7-
* [Building Apps](./building-apps/00-app-go.md) - The documentation in this section will guide you through the process of developing your dApp using the Cosmos SDK framework.
8-
* [Modules](./modules/README.md) - Information about the various modules available in the Cosmos SDK: Auth, Authz, Bank, Crisis, Distribution, Evidence, Feegrant, Governance, Mint, Params, Slashing, Staking, Upgrade, NFT, Consensus, Circuit, Genutil.
7+
* [Building Apps](./building-apps/00-runtime.md) - The documentation in this section will guide you through the process of developing your dApp using the Cosmos SDK framework.
8+
* [Modules](./modules/README.md) - Information about the various modules available in the Cosmos SDK: Accounts, Auth, Authz, Bank, Circuit, Consensus, Distribution, Epochs, Evidence, Feegrant, Genutil, Governance, Group, Mint, NFT, Protocolpool, Slashing, Staking, Tx, Upgrade, Validate.
99
* [Migrations](./migrations/01-intro.md) - See what has been updated in each release the process of the transition between versions.
1010
* [Packages](./packages/README.md) - Explore a curated collection of pre-built modules and functionalities, streamlining the development process.
1111
* [Tooling](./tooling/README.md) - A suite of utilities designed to enhance the development workflow, optimizing the efficiency of Cosmos SDK-based projects.

docs/build/building-apps/00-runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ An application only needs to call `AppBuilder.Build` to create a fully configure
134134
https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/runtime/builder.go#L36-L80
135135
```
136136

137-
More information on building applications can be found in the [next section](./02-app-building.md).
137+
More information on building applications can be found in the [next section](./02-app-go-di.md).
138138

139139
## Best Practices
140140

docs/build/building-apps/upgrades/0.52.md

Lines changed: 554 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"label": "Upgrade Tutorials",
3+
"position": 0,
4+
"link": null
5+
}

docs/build/building-modules/06-keeper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/staking/keeper/keeper
4646

4747
Let us go through the different parameters:
4848

49-
* Environment is a struct that holds the necessary references to services available to the modules. This includes the [store services](../../advanced/04-store.md#store-services), the [event manager](../../learn/advanced/06-events.md) and more.
49+
* Environment is a struct that holds the necessary references to services available to the modules. This includes the [kvstore services](../../learn/advanced/02-core.md#kvstore-service), the [event manager](../../learn/advanced/02-core.md#event-service) and more.
5050
* An expected `keeper` is a `keeper` external to a module that is required by the internal `keeper` of said module. External `keeper`s are listed in the internal `keeper`'s type definition as interfaces. These interfaces are themselves defined in an `expected_keepers.go` file in the root of the module's folder. In this context, interfaces are used to reduce the number of dependencies, as well as to facilitate the maintenance of the module itself.
5151
* `cdc` is the [codec](../../learn/advanced/05-encoding.md) used to marshal and unmarshal structs to/from `[]byte`. The `cdc` can be any of `codec.BinaryCodec`, `codec.JSONCodec` or `codec.Codec` based on your requirements. It can be either a proto or amino codec as long as they implement these interfaces.
5252
* The authority listed is a module account or user account that has the right to change module level parameters. Previously this was handled by the param module, which has been deprecated.

docs/build/building-modules/16-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The goal of these integration tests is to test how a component interacts with ot
6161

6262
Integration tests interact with the tested module via the defined `Msg` and `Query` services. The result of the test can be verified by checking the state of the application, by checking the emitted events or the response. It is advised to combine two of these methods to verify the result of the test.
6363

64-
The SDK provides small helpers for quickly setting up an integration tests. These helpers can be found at <https://github.com/cosmos/cosmos-sdk/blob/main/testutil/integration>.
64+
The SDK provides small helpers for quickly setting up an integration tests. These helpers can be found at <https://github.com/cosmos/cosmos-sdk/blob/main/testutil>.
6565

6666
### Example
6767

docs/learn/advanced/00-baseapp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ Unconfirmed transactions are relayed to peers only if they pass `CheckTx`.
309309
`CheckTx()` can perform both _stateful_ and _stateless_ checks, but developers should strive to
310310
make the checks **lightweight** because gas fees are not charged for the resources (CPU, data load...) used during the `CheckTx`.
311311

312-
The [`Context`](../advanced/02-context.md), which includes a `GasMeter` that tracks how much gas is used during the execution of `Tx`, is initialized at the beginning of `CheckTx`. The user-provided amount of gas for `Tx` is referred to as `GasWanted`. If `GasConsumed`, the amount of gas used during execution, exceeds `GasWanted`, the execution is halted and the changes made to the cached copy of the state are not committed. Otherwise, `CheckTx` sets `GasUsed` equal to `GasConsumed` and returns it in the result. After calculating the gas and fee values, validator-nodes ensure that the user-specified `gas-prices` exceed their locally defined `min-gas-prices`.
312+
The [`Core pkg`](../advanced/02-core.md), which includes a `GasService` that tracks how much gas is used during the execution of `Tx`, is initialized at the beginning of `CheckTx`. The user-provided amount of gas for `Tx` is referred to as `GasWanted`. If `GasConsumed`, the amount of gas used during execution, exceeds `GasWanted`, the execution is halted and the changes made to the cached copy of the state are not committed. Otherwise, `CheckTx` sets `GasUsed` equal to `GasConsumed` and returns it in the result. After calculating the gas and fee values, validator-nodes ensure that the user-specified `gas-prices` exceed their locally defined `min-gas-prices`.
313313

314314
In the Cosmos SDK, after [decoding transactions](./05-encoding.md), `CheckTx()` is implemented
315315
to do the following checks:

docs/learn/advanced/04-store.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,6 @@ When methods of the parent `KVStore` are called, `GasKv.Store` automatically con
189189
https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/gas.go#L220-L229
190190
```
191191

192-
By default, all `KVStores` are wrapped in `GasKv.Stores` when retrieved. This is done in the `KVStore()` method of the [`context`](./02-context.md):
193-
194-
```go reference
195-
https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/context.go#L339-L342
196-
```
197-
198192
`KVStores` can be accessed in their corresponding modules by using the [`kvStoreService` and `memStoreService`](./02-core.md#kvstore-service).
199193

200194
### `TraceKv` Store

docs/user/run-node/06-run-production.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ In the past, validators [have had issues](https://github.com/cosmos/cosmos-sdk/i
4848

4949
### Firewall
5050

51-
Nodes should not have all ports open to the public, this is a simple way to get DDOS'd. Secondly it is recommended by [CometBFT](github.com/cometbft/cometbft) to never expose ports that are not required to operate a node.
51+
Nodes should not have all ports open to the public, this is a simple way to get DDOS'd. Secondly it is recommended by [CometBFT](https://github.com/cometbft/cometbft) to never expose ports that are not required to operate a node.
5252

5353
When setting up a firewall there are a few ports that can be open when operating a Cosmos SDK node. There is the CometBFT json-RPC, prometheus, p2p, remote signer and Cosmos SDK GRPC and REST. If the node is being operated as a node that does not offer endpoints to be used for submission or querying then a max of three endpoints are needed.
5454

scripts/build/build.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git
1313
DOCKER := $(shell which docker)
1414
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
1515

16-
rocksdb_version=v9.6.1
17-
1816
ifeq ($(findstring .,$(VERSION)),)
1917
VERSION := 0.0.0
2018
endif

scripts/go-lint-all.bash

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
set -e
44

5-
REPO_ROOT="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )"
5+
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &>/dev/null && pwd)"
66
export REPO_ROOT
77

88
LINT_TAGS="e2e,ledger,test_ledger_mock"
9-
if [[ ! -z "${ROCKSDB:-}" ]]; then
10-
LINT_TAGS+=",rocksdb"
11-
fi
129
export LINT_TAGS
1310

1411
lint_module() {
@@ -58,4 +55,4 @@ else
5855
echo "linting github.com/cosmos/cosmos-sdk [$(date -Iseconds -u)]"
5956
golangci-lint run ./... -c "${REPO_ROOT}/.golangci.yml" "$@" --build-tags=${LINT_TAGS}
6057
fi
61-
fi
58+
fi

x/bank/keeper/grpc_query.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances
6565
func(key collections.Pair[sdk.AccAddress, string], value math.Int) (sdk.Coin, error) {
6666
if req.ResolveDenom {
6767
if metadata, ok := k.GetDenomMetaData(ctx, key.K2()); ok {
68-
return sdk.NewCoin(metadata.Display, value), nil
68+
if err := sdk.ValidateDenom(metadata.Display); err == nil {
69+
return sdk.NewCoin(metadata.Display, value), nil
70+
}
6971
}
7072
}
7173
return sdk.NewCoin(key.K2(), value), nil

x/bank/keeper/grpc_query_test.go

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,13 @@ func (suite *KeeperTestSuite) TestQueryAllBalances() {
119119
suite.Require().NotNil(res)
120120
suite.True(res.Balances.IsZero())
121121

122-
fooCoins := newFooCoin(50)
123122
barCoins := newBarCoin(30)
123+
incompleteCoin := newIncompleteMetadataCoin(40)
124+
fooCoins := newFooCoin(50)
124125
ibcCoins := newIbcCoin(20)
125126

126-
origCoins := sdk.NewCoins(fooCoins, barCoins, ibcCoins)
127+
// NewCoins will sort the Coins, so we prepare in alphabetical order to avoid confusion
128+
origCoins := sdk.NewCoins(barCoins, incompleteCoin, fooCoins, ibcCoins)
127129

128130
suite.mockFundAccount(addr)
129131
suite.Require().NoError(testutil.FundAccount(ctx, suite.bankKeeper, addr, origCoins))
@@ -133,10 +135,28 @@ func (suite *KeeperTestSuite) TestQueryAllBalances() {
133135
res, err = queryClient.AllBalances(gocontext.Background(), req)
134136
suite.Require().NoError(err)
135137
suite.Require().NotNil(res)
136-
suite.Equal(res.Balances.Len(), 1)
138+
suite.Equal(1, res.Balances.Len())
139+
suite.Equal(barCoins.Denom, res.Balances[0].Denom)
140+
suite.NotNil(res.Pagination.NextKey)
141+
142+
addIncompleteMetadata(ctx, suite.bankKeeper)
143+
suite.T().Log("query second page with nextkey and resolve denom with incomplete metadata")
144+
pageReq = &query.PageRequest{
145+
Key: res.Pagination.NextKey,
146+
Limit: 1,
147+
CountTotal: true,
148+
}
149+
req = types.NewQueryAllBalancesRequest(addrStr, pageReq, true)
150+
testFunc := func() {
151+
res, err = queryClient.AllBalances(gocontext.Background(), req)
152+
}
153+
suite.Require().NotPanics(testFunc, "AllBalances with resolve denom + incomplete metadata")
154+
suite.Require().NoError(err)
155+
suite.Equal(1, res.Balances.Len())
156+
suite.Equal(incompleteCoin.Denom, res.Balances[0].Denom)
137157
suite.NotNil(res.Pagination.NextKey)
138158

139-
suite.T().Log("query second page with nextkey")
159+
suite.T().Log("query third page with nextkey")
140160
pageReq = &query.PageRequest{
141161
Key: res.Pagination.NextKey,
142162
Limit: 1,
@@ -145,34 +165,35 @@ func (suite *KeeperTestSuite) TestQueryAllBalances() {
145165
req = types.NewQueryAllBalancesRequest(addrStr, pageReq, false)
146166
res, err = queryClient.AllBalances(gocontext.Background(), req)
147167
suite.Require().NoError(err)
148-
suite.Equal(res.Balances.Len(), 1)
168+
suite.Equal(1, res.Balances.Len())
169+
suite.Equal(fooCoins.Denom, res.Balances[0].Denom)
149170
suite.NotNil(res.Pagination.NextKey)
150171

151-
pageThree := res.Pagination.NextKey
172+
pageFour := res.Pagination.NextKey
152173

153-
suite.T().Log("query third page with nextkey")
174+
suite.T().Log("query fourth page with nextkey")
154175
pageReq = &query.PageRequest{
155-
Key: pageThree,
176+
Key: pageFour,
156177
Limit: 1,
157178
CountTotal: true,
158179
}
159180
req = types.NewQueryAllBalancesRequest(addrStr, pageReq, false)
160181
res, err = queryClient.AllBalances(gocontext.Background(), req)
161182
suite.Require().NoError(err)
162-
suite.Equal(res.Balances.Len(), 1)
163-
suite.Equal(res.Balances[0].Denom, ibcCoins.Denom)
183+
suite.Equal(1, res.Balances.Len())
184+
suite.Equal(ibcCoins.Denom, res.Balances[0].Denom)
164185

165-
suite.T().Log("query third page with nextkey and resolve ibc denom")
186+
suite.T().Log("query fourth page with nextkey and resolve ibc denom")
166187
pageReq = &query.PageRequest{
167-
Key: pageThree,
188+
Key: pageFour,
168189
Limit: 1,
169190
CountTotal: true,
170191
}
171192
req = types.NewQueryAllBalancesRequest(addrStr, pageReq, true)
172193
res, err = queryClient.AllBalances(gocontext.Background(), req)
173194
suite.Require().NoError(err)
174-
suite.Equal(res.Balances.Len(), 1)
175-
suite.Equal(res.Balances[0].Denom, ibcPath+"/"+ibcBaseDenom)
195+
suite.Equal(1, res.Balances.Len())
196+
suite.Equal(ibcPath+"/"+ibcBaseDenom, res.Balances[0].Denom)
176197
suite.Nil(res.Pagination.NextKey)
177198
}
178199

x/bank/keeper/keeper_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const (
4141
barDenom = "bar"
4242
ibcPath = "transfer/channel-0"
4343
ibcBaseDenom = "farboo"
44+
incompleteBaseDenom = "incomplete"
45+
incompletePath = "factory/someaddr"
4446
metaDataDescription = "IBC Token from %s"
4547
initialPower = int64(100)
4648
holder = "holder"
@@ -83,6 +85,10 @@ func newIbcCoin(amt int64) sdk.Coin {
8385
return sdk.NewInt64Coin(getIBCDenom(ibcPath, ibcBaseDenom), amt)
8486
}
8587

88+
func newIncompleteMetadataCoin(amt int64) sdk.Coin {
89+
return sdk.NewInt64Coin(incompletePath+"/"+incompleteBaseDenom, amt)
90+
}
91+
8692
func getIBCDenom(path, baseDenom string) string {
8793
return fmt.Sprintf("%s/%s", "ibc", hex.EncodeToString(getIBCHash(path, baseDenom)))
8894
}
@@ -109,6 +115,21 @@ func addIBCMetadata(ctx context.Context, k keeper.BaseKeeper) {
109115
k.SetDenomMetaData(ctx, metadata)
110116
}
111117

118+
func addIncompleteMetadata(ctx context.Context, k keeper.BaseKeeper) {
119+
metadata := banktypes.Metadata{
120+
Description: "Incomplete metadata without display field",
121+
DenomUnits: []*banktypes.DenomUnit{
122+
{
123+
Denom: incompleteBaseDenom,
124+
Exponent: 0,
125+
},
126+
},
127+
Base: incompletePath + "/" + incompleteBaseDenom,
128+
// Not setting any Display value
129+
}
130+
k.SetDenomMetaData(ctx, metadata)
131+
}
132+
112133
type KeeperTestSuite struct {
113134
suite.Suite
114135

x/staking/simulation/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func getHistEntries(r *rand.Rand) uint32 {
3737

3838
// getKeyRotationFee returns randomized keyRotationFee between 10000-1000000.
3939
func getKeyRotationFee(r *rand.Rand) sdk.Coin {
40-
return sdk.NewInt64Coin(sdk.DefaultBondDenom, r.Int63n(types.DefaultKeyRotationFee.Amount.Int64()-10000)+10000)
40+
return sdk.NewInt64Coin(sdk.DefaultBondDenom, r.Int63n(990000)+10000)
4141
}
4242

4343
// RandomizedGenState generates a random GenesisState for staking

x/staking/types/params.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,8 @@ const (
2727
DefaultMaxEntries uint32 = 7
2828
)
2929

30-
var (
31-
// DefaultMinCommissionRate is set to 0%
32-
DefaultMinCommissionRate = math.LegacyZeroDec()
33-
34-
// DefaultKeyRotationFee is fees used to rotate the ConsPubkey or Operator key
35-
DefaultKeyRotationFee = sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000)
36-
)
30+
// DefaultMinCommissionRate is set to 0%
31+
var DefaultMinCommissionRate = math.LegacyZeroDec()
3732

3833
// NewParams creates a new Params instance
3934
func NewParams(unbondingTime time.Duration,
@@ -60,7 +55,7 @@ func DefaultParams() Params {
6055
DefaultMaxEntries,
6156
sdk.DefaultBondDenom,
6257
DefaultMinCommissionRate,
63-
DefaultKeyRotationFee,
58+
sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000000), // fees used to rotate the ConsPubkey or Operator key
6459
)
6560
}
6661

0 commit comments

Comments
 (0)