diff --git a/.github/workflows/cache-rocksdb.yml b/.github/workflows/cache-rocksdb.yml
index d85965181312..5db3dff15d28 100644
--- a/.github/workflows/cache-rocksdb.yml
+++ b/.github/workflows/cache-rocksdb.yml
@@ -4,7 +4,7 @@ on:
paths:
- build.mk
schedule:
- - cron: "*/15 * * * *" # Every 15 minutes
+ - cron: "15 */2 * * *" # Every two hours at xx:15 minutes
workflow_dispatch:
permissions:
@@ -59,4 +59,4 @@ jobs:
path: |
/usr/local/lib/librocksdb.*
/usr/local/include/rocksdb
- key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64
\ No newline at end of file
+ key: ${{ runner.os }}-rocksdb-${{ env.ROCKSDB_VERSION }}-amd64
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index f6493a9c8d7d..a22b16c54bdf 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -9,8 +9,9 @@ on:
branches:
- main
tags:
- - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- - "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5
+ - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0.0, v20.15.10
+ - "v[0-9]+.[0-9]+.[0-9]+-rc.*" # Push events to matching v*, i.e. v1.0.0-rc.1, v20.15.10-rc.5
+ - "v[0-9]+.[0-9]+.[0-9]+-beta.*" # Push events to matching v*, i.e. v1.0.0-beta.1, v20.15.10-beta.5
workflow_dispatch:
inputs:
tags:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f86a2748fdce..e2670454a86a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -44,30 +44,17 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (baseapp) [#20291](https://github.com/cosmos/cosmos-sdk/pull/20291) Simulate nested messages.
* (crypto/keyring) [#21653](https://github.com/cosmos/cosmos-sdk/pull/21653) New Linux-only backend that adds Linux kernel's `keyctl` support.
-* (runtime) [#21704](https://github.com/cosmos/cosmos-sdk/pull/21704) Add StoreLoader in simappv2.
* (client/keys) [#21829](https://github.com/cosmos/cosmos-sdk/pull/21829) Add support for importing hex key using standard input.
-* (x/validate) [#21822](https://github.com/cosmos/cosmos-sdk/pull/21822) New module solely responsible for providing ante/post handlers and tx validators for v2. It can be extended by the app developer to provide extra tx validators.
- * In comparison to x/auth/tx/config, there is no app config to skip ante/post handlers, as overwriting them in baseapp or not injecting the x/validate module has the same effect.
-* (baeapp) [#21979](https://github.com/cosmos/cosmos-sdk/pull/21979) Create CheckTxHandler to allow extending the logic of CheckTx.
### Improvements
-* (crypto/ledger) [#22116](https://github.com/cosmos/cosmos-sdk/pull/22116) Improve error message when deriving paths using index >100
-* (sims) [#21613](https://github.com/cosmos/cosmos-sdk/pull/21613) Add sims2 framework and factory methods for simpler message factories in modules
-* (modules) [#21963](https://github.com/cosmos/cosmos-sdk/pull/21963) Duplicatable metrics are no more collected in modules. They were unecessary overhead.
-
### Bug Fixes
-* (sims) [#21952](https://github.com/cosmos/cosmos-sdk/pull/21952) Use liveness matrix for validator sign status in sims
* (sims) [#21906](https://github.com/cosmos/cosmos-sdk/pull/21906) Skip sims test when running dry on validators
* (cli) [#21919](https://github.com/cosmos/cosmos-sdk/pull/21919) Query address-by-acc-num by account_id instead of id.
### API Breaking Changes
-* (types/mempool) [#21744](https://github.com/cosmos/cosmos-sdk/pull/21744) Update types/mempool.Mempool interface to take decoded transactions. This avoid to decode the transaction twice.
-* (x/auth/tx/config) [#21822](https://github.com/cosmos/cosmos-sdk/pull/21822) Sign mode textual is no more automatically added to tx config when using runtime. Should be added manually on the server side.
-* (x/auth/tx/config) [#21822](https://github.com/cosmos/cosmos-sdk/pull/21822) This depinject module now only provide txconfig and tx config options. `x/validate` now handles the providing of ante/post handlers, alongside tx validators for v2. The corresponding app config options have been removed from the depinject module config.
-
### Deprecated
## [v0.52.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.52.0) - 2024-XX-XX
@@ -99,6 +86,9 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (crypto/keyring) [#20212](https://github.com/cosmos/cosmos-sdk/pull/20212) Expose the db keyring used in the keystore.
* (client/tx) [#20870](https://github.com/cosmos/cosmos-sdk/pull/20870) Add `timeout-timestamp` field for tx body defines time based timeout.Add `WithTimeoutTimestamp` to tx factory. Increased gas cost for processing newly added timeout timestamp field in tx body.
* (client) [#21074](https://github.com/cosmos/cosmos-sdk/pull/21074) Add auto cli for node service
+* (x/validate) [#21822](https://github.com/cosmos/cosmos-sdk/pull/21822) New module solely responsible for providing ante/post handlers and tx validators for v2. It can be extended by the app developer to provide extra tx validators.
+ * In comparison to x/auth/tx/config, there is no app config to skip ante/post handlers, as overwriting them in baseapp or not injecting the x/validate module has the same effect.
+* (baseapp) [#21979](https://github.com/cosmos/cosmos-sdk/pull/21979) Create CheckTxHandler to allow extending the logic of CheckTx.
### Improvements
@@ -143,7 +133,11 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (internal) [#21412](https://github.com/cosmos/cosmos-sdk/pull/21412) Using unsafe.String and unsafe.SliceData.
* (client) [#21436](https://github.com/cosmos/cosmos-sdk/pull/21436) Use `address.Codec` from client.Context in `tx.Sign`.
* (x/genutil) [#21249](https://github.com/cosmos/cosmos-sdk/pull/21249) Incremental JSON parsing for AppGenesis where possible.
-* (testnet) [#21941](https://github.com/cosmos/cosmos-sdk/pull/21941) Regenerate addrbook.json for in place testnet.
+* (genutil) [#21701](https://github.com/cosmos/cosmos-sdk/pull/21701) Improved error messages for genesis validation.
+* (runtime) [#21704](https://github.com/cosmos/cosmos-sdk/pull/21704) Move `upgradetypes.StoreLoader` to runtime and alias it in upgrade for backward compatibility.
+* (sims)[#21613](https://github.com/cosmos/cosmos-sdk/pull/21613) Add sims2 framework and factory methods for simpler message factories in modules
+* (modules) [#21963](https://github.com/cosmos/cosmos-sdk/pull/21963) Duplicatable metrics are no more collected in modules. They were unecessary overhead.
+* (crypto/ledger) [#22116](https://github.com/cosmos/cosmos-sdk/pull/22116) Improve error message when deriving paths using index >100
### Bug Fixes
@@ -156,6 +150,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (server) [#18994](https://github.com/cosmos/cosmos-sdk/pull/18994) Update server context directly rather than a reference to a sub-object
* [#19833](https://github.com/cosmos/cosmos-sdk/pull/19833) Fix some places in which we call Remove inside a Walk.
* [#19851](https://github.com/cosmos/cosmos-sdk/pull/19851) Fix some places in which we call Remove inside a Walk (x/staking and x/gov).
+* (sims) [#21952](https://github.com/cosmos/cosmos-sdk/pull/21952) Use liveness matrix for validator sign status in sims
+* (baseapp) [#21003](https://github.com/cosmos/cosmos-sdk/pull/21003) Align block header when query with latest height.
### API Breaking Changes
@@ -229,6 +225,9 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (sims) [#21039](https://github.com/cosmos/cosmos-sdk/pull/21039): Remove Baseapp from sims by a new interface `simtypes.AppEntrypoint`.
* (x/genutil) [#21372](https://github.com/cosmos/cosmos-sdk/pull/21372) Remove `AddGenesisAccount` for `AddGenesisAccounts`.
* (baseapp) [#21413](https://github.com/cosmos/cosmos-sdk/pull/21413) Add `SelectBy` method to `Mempool` interface, which is thread-safe to use.
+* (types/mempool) [#21744](https://github.com/cosmos/cosmos-sdk/pull/21744) Update types/mempool.Mempool interface to take decoded transactions. This avoid to decode the transaction twice.
+* (x/auth/tx/config) [#21822](https://github.com/cosmos/cosmos-sdk/pull/21822) Sign mode textual is no more automatically added to tx config when using runtime. Should be added manually on the server side.
+* (x/auth/tx/config) [#21822](https://github.com/cosmos/cosmos-sdk/pull/21822) This depinject module now only provide txconfig and tx config options. `x/validate` now handles the providing of ante/post handlers, alongside tx validators for v2. The corresponding app config options have been removed from the depinject module config.
### Client Breaking Changes
diff --git a/Dockerfile b/Dockerfile
index 9c563258c48d..9998f34c02b4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -35,7 +35,6 @@ COPY x/gov/go.mod x/gov/go.sum ./x/gov/
COPY x/distribution/go.mod x/distribution/go.sum ./x/distribution/
COPY x/slashing/go.mod x/slashing/go.sum ./x/slashing/
COPY x/staking/go.mod x/staking/go.sum ./x/staking/
-COPY x/auth/go.mod x/auth/go.sum ./x/auth/
COPY x/authz/go.mod x/authz/go.sum ./x/authz/
COPY x/bank/go.mod x/bank/go.sum ./x/bank/
COPY x/mint/go.mod x/mint/go.sum ./x/mint/
diff --git a/api/go.mod b/api/go.mod
index c6e040103a8b..723f4fdab37d 100644
--- a/api/go.mod
+++ b/api/go.mod
@@ -3,16 +3,16 @@ module cosmossdk.io/api
go 1.21
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/gogoproto v1.7.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
diff --git a/api/go.sum b/api/go.sum
index d1fd43b81060..c31e3013c9b7 100644
--- a/api/go.sum
+++ b/api/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro=
@@ -22,5 +22,5 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
diff --git a/baseapp/abci.go b/baseapp/abci.go
index dd091294d563..15646e438ab6 100644
--- a/baseapp/abci.go
+++ b/baseapp/abci.go
@@ -143,7 +143,7 @@ func (app *BaseApp) Info(_ *abci.InfoRequest) (*abci.InfoResponse, error) {
lastCommitID := app.cms.LastCommitID()
appVersion := InitialAppVersion
if lastCommitID.Version > 0 {
- ctx, err := app.CreateQueryContext(lastCommitID.Version, false)
+ ctx, err := app.CreateQueryContextWithCheckHeader(lastCommitID.Version, false, false)
if err != nil {
return nil, fmt.Errorf("failed creating query context: %w", err)
}
@@ -1222,6 +1222,12 @@ func checkNegativeHeight(height int64) error {
// 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) {
+ return app.CreateQueryContextWithCheckHeader(height, prove, true)
+}
+
+// CreateQueryContextWithCheckHeader creates a new sdk.Context for a query, taking as args
+// the block height, whether the query needs a proof or not, and whether to check the header or not.
+func (app *BaseApp) CreateQueryContextWithCheckHeader(height int64, prove, checkHeader bool) (sdk.Context, error) {
if err := checkNegativeHeight(height); err != nil {
return sdk.Context{}, err
}
@@ -1245,12 +1251,7 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
)
}
- // when a client did not provide a query height, manually inject the latest
- if height == 0 {
- height = lastBlockHeight
- }
-
- if height <= 1 && prove {
+ if height > 0 && height <= 1 && prove {
return sdk.Context{},
errorsmod.Wrap(
sdkerrors.ErrInvalidRequest,
@@ -1258,6 +1259,38 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
)
}
+ var header *cmtproto.Header
+ isLatest := height == 0
+ for _, state := range []*state{
+ app.checkState,
+ app.finalizeBlockState,
+ } {
+ if state != nil {
+ // branch the commit multi-store for safety
+ h := state.Context().BlockHeader()
+ if isLatest {
+ lastBlockHeight = qms.LatestVersion()
+ }
+ if !checkHeader || !isLatest || isLatest && h.Height == lastBlockHeight {
+ header = &h
+ break
+ }
+ }
+ }
+
+ if header == nil {
+ return sdk.Context{},
+ errorsmod.Wrapf(
+ sdkerrors.ErrInvalidHeight,
+ "header height in all state context is not latest height (%d)", lastBlockHeight,
+ )
+ }
+
+ // when a client did not provide a query height, manually inject the latest
+ if isLatest {
+ height = lastBlockHeight
+ }
+
cacheMS, err := qms.CacheMultiStoreWithVersion(height)
if err != nil {
return sdk.Context{},
@@ -1275,10 +1308,10 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
ChainID: app.chainID,
Height: height,
}).
- WithBlockHeader(app.checkState.Context().BlockHeader()).
+ WithBlockHeader(*header).
WithBlockHeight(height)
- if height != lastBlockHeight {
+ if !isLatest {
rms, ok := app.cms.(*rootmulti.Store)
if ok {
cInfo, err := rms.GetCommitInfo(height)
@@ -1287,7 +1320,6 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
}
}
}
-
return ctx, nil
}
diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go
index 60e474b851e4..9ca9669b6224 100644
--- a/baseapp/baseapp_test.go
+++ b/baseapp/baseapp_test.go
@@ -696,26 +696,26 @@ func TestBaseAppPostHandler(t *testing.T) {
require.NotContains(t, suite.logBuffer.String(), "panic recovered in runTx")
}
+type mockABCIListener struct {
+ ListenCommitFn func(context.Context, abci.CommitResponse, []*storetypes.StoreKVPair) error
+}
+
+func (m mockABCIListener) ListenFinalizeBlock(_ context.Context, _ abci.FinalizeBlockRequest, _ abci.FinalizeBlockResponse) error {
+ return nil
+}
+
+func (m *mockABCIListener) ListenCommit(ctx context.Context, commit abci.CommitResponse, pairs []*storetypes.StoreKVPair) error {
+ return m.ListenCommitFn(ctx, commit, pairs)
+}
+
// Test and ensure that invalid block heights always cause errors.
// See issues:
// - https://github.com/cosmos/cosmos-sdk/issues/11220
// - https://github.com/cosmos/cosmos-sdk/issues/7662
func TestABCI_CreateQueryContext(t *testing.T) {
t.Parallel()
+ app := getQueryBaseapp(t)
- db := coretesting.NewMemDB()
- name := t.Name()
- app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil)
-
- _, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
- require.NoError(t, err)
- _, err = app.Commit()
- require.NoError(t, err)
-
- _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2})
- require.NoError(t, err)
- _, err = app.Commit()
- require.NoError(t, err)
testCases := []struct {
name string
height int64
@@ -724,7 +724,7 @@ func TestABCI_CreateQueryContext(t *testing.T) {
expErr bool
}{
{"valid height", 2, 2, true, false},
- {"valid height with different initial height", 2, 1, true, false},
+ {"valid height with different initial height", 2, 1, true, true},
{"future height", 10, 10, true, true},
{"negative height, prove=true", -1, -1, true, true},
{"negative height, prove=false", -1, -1, false, true},
@@ -738,7 +738,11 @@ func TestABCI_CreateQueryContext(t *testing.T) {
})
require.NoError(t, err)
}
- ctx, err := app.CreateQueryContext(tc.height, tc.prove)
+ height := tc.height
+ if tc.height > tc.headerHeight {
+ height = 0
+ }
+ ctx, err := app.CreateQueryContext(height, tc.prove)
if tc.expErr {
require.Error(t, err)
} else {
@@ -749,6 +753,81 @@ func TestABCI_CreateQueryContext(t *testing.T) {
}
}
+func TestABCI_CreateQueryContextWithCheckHeader(t *testing.T) {
+ t.Parallel()
+ app := getQueryBaseapp(t)
+ var height int64 = 2
+ var headerHeight int64 = 1
+
+ testCases := []struct {
+ checkHeader bool
+ expErr bool
+ }{
+ {true, true},
+ {false, false},
+ }
+
+ for _, tc := range testCases {
+ t.Run("valid height with different initial height", func(t *testing.T) {
+ _, err := app.InitChain(&abci.InitChainRequest{
+ InitialHeight: headerHeight,
+ })
+ require.NoError(t, err)
+ ctx, err := app.CreateQueryContextWithCheckHeader(0, true, tc.checkHeader)
+ if tc.expErr {
+ require.Error(t, err)
+ } else {
+ require.NoError(t, err)
+ require.Equal(t, height, ctx.BlockHeight())
+ }
+ })
+ }
+}
+
+func TestABCI_CreateQueryContext_Before_Set_CheckState(t *testing.T) {
+ t.Parallel()
+
+ db := coretesting.NewMemDB()
+ name := t.Name()
+ var height int64 = 2
+ var headerHeight int64 = 1
+
+ t.Run("valid height with different initial height", func(t *testing.T) {
+ app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil)
+
+ _, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
+ require.NoError(t, err)
+ _, err = app.Commit()
+ require.NoError(t, err)
+
+ _, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 2})
+ require.NoError(t, err)
+
+ var queryCtx *sdk.Context
+ var queryCtxErr error
+ app.SetStreamingManager(storetypes.StreamingManager{
+ ABCIListeners: []storetypes.ABCIListener{
+ &mockABCIListener{
+ ListenCommitFn: func(context.Context, abci.CommitResponse, []*storetypes.StoreKVPair) error {
+ qCtx, qErr := app.CreateQueryContext(0, true)
+ queryCtx = &qCtx
+ queryCtxErr = qErr
+ return nil
+ },
+ },
+ },
+ })
+ _, err = app.Commit()
+ require.NoError(t, err)
+ require.NoError(t, queryCtxErr)
+ require.Equal(t, height, queryCtx.BlockHeight())
+ _, err = app.InitChain(&abci.InitChainRequest{
+ InitialHeight: headerHeight,
+ })
+ require.NoError(t, err)
+ })
+}
+
func TestSetMinGasPrices(t *testing.T) {
minGasPrices := sdk.DecCoins{sdk.NewInt64DecCoin("stake", 5000)}
suite := NewBaseAppSuite(t, baseapp.SetMinGasPrices(minGasPrices.String()))
diff --git a/client/account_retriever.go b/client/account_retriever.go
index 63ff674dfd1e..7ffcc0e17f42 100644
--- a/client/account_retriever.go
+++ b/client/account_retriever.go
@@ -13,6 +13,26 @@ type Account interface {
GetSequence() uint64
}
+type mockAccount struct {
+ addr []byte
+}
+
+func (m mockAccount) GetAddress() sdk.AccAddress {
+ return m.addr
+}
+
+func (m mockAccount) GetPubKey() cryptotypes.PubKey {
+ return nil
+}
+
+func (m mockAccount) GetAccountNumber() uint64 {
+ return 0
+}
+
+func (m mockAccount) GetSequence() uint64 {
+ return 0
+}
+
// AccountRetriever defines the interfaces required by transactions to
// ensure an account exists and to be able to query for account fields necessary
// for signing.
@@ -32,8 +52,8 @@ type MockAccountRetriever struct {
ReturnAccNum, ReturnAccSeq uint64
}
-func (mar MockAccountRetriever) GetAccount(_ Context, _ sdk.AccAddress) (Account, error) {
- return nil, nil
+func (mar MockAccountRetriever) GetAccount(_ Context, address sdk.AccAddress) (Account, error) {
+ return mockAccount{addr: address}, nil
}
func (mar MockAccountRetriever) GetAccountWithHeight(_ Context, _ sdk.AccAddress) (Account, int64, error) {
diff --git a/client/v2/CHANGELOG.md b/client/v2/CHANGELOG.md
index a3702845c575..8bd7877b448a 100644
--- a/client/v2/CHANGELOG.md
+++ b/client/v2/CHANGELOG.md
@@ -53,6 +53,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#17709](https://github.com/cosmos/cosmos-sdk/pull/17709) Address codecs have been removed from `autocli.AppOptions` and `flag.Builder`. Instead client/v2 uses the address codecs present in the context (introduced in [#17503](https://github.com/cosmos/cosmos-sdk/pull/17503)).
+### Bug Fixes
+
+* [#21853](https://github.com/cosmos/cosmos-sdk/pull/21853) Fix `*big.Int` unmarshalling in txs.
+
## [v2.0.0-beta.5] - 2024-09-18
### Improvements
diff --git a/client/v2/autocli/flag/builder.go b/client/v2/autocli/flag/builder.go
index 6ff325c53bdb..bdd42634dd35 100644
--- a/client/v2/autocli/flag/builder.go
+++ b/client/v2/autocli/flag/builder.go
@@ -26,6 +26,7 @@ const (
ValidatorAddressStringScalarType = "cosmos.ValidatorAddressString"
ConsensusAddressStringScalarType = "cosmos.ConsensusAddressString"
PubkeyScalarType = "cosmos.Pubkey"
+ DecScalarType = "cosmos.Dec"
)
// Builder manages options for building pflag flags for protobuf messages.
@@ -67,6 +68,7 @@ func (b *Builder) init() {
b.scalarFlagTypes[ValidatorAddressStringScalarType] = validatorAddressStringType{}
b.scalarFlagTypes[ConsensusAddressStringScalarType] = consensusAddressStringType{}
b.scalarFlagTypes[PubkeyScalarType] = pubkeyType{}
+ b.scalarFlagTypes[DecScalarType] = decType{}
}
}
diff --git a/client/v2/autocli/flag/legacy_dec.go b/client/v2/autocli/flag/legacy_dec.go
new file mode 100644
index 000000000000..073afa94f1f5
--- /dev/null
+++ b/client/v2/autocli/flag/legacy_dec.go
@@ -0,0 +1,48 @@
+package flag
+
+import (
+ "context"
+
+ "google.golang.org/protobuf/reflect/protoreflect"
+
+ "cosmossdk.io/math"
+)
+
+type decType struct{}
+
+func (a decType) NewValue(_ *context.Context, _ *Builder) Value {
+ return &decValue{}
+}
+
+func (a decType) DefaultValue() string {
+ return "0"
+}
+
+type decValue struct {
+ value string
+}
+
+func (a decValue) Get(protoreflect.Value) (protoreflect.Value, error) {
+ return protoreflect.ValueOf(a.value), nil
+}
+
+func (a decValue) String() string {
+ return a.value
+}
+
+func (a *decValue) Set(s string) error {
+ dec, err := math.LegacyNewDecFromStr(s)
+ if err != nil {
+ return err
+ }
+
+ // we need to convert from float representation to non-float representation using default precision
+ // 0.5 -> 500000000000000000
+ a.value = dec.BigInt().String()
+
+ return nil
+}
+
+func (a decValue) Type() string {
+ return "cosmos.Dec"
+}
diff --git a/client/v2/go.mod b/client/v2/go.mod
index b999f9c15ba5..0b4f281d7021 100644
--- a/client/v2/go.mod
+++ b/client/v2/go.mod
@@ -14,14 +14,14 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
sigs.k8s.io/yaml v1.4.0
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/errors v1.0.1 // indirect
@@ -125,7 +125,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -153,14 +153,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
diff --git a/client/v2/go.sum b/client/v2/go.sum
index 1a32ea6bc6f2..236f4ac476a9 100644
--- a/client/v2/go.sum
+++ b/client/v2/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -414,8 +414,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -523,8 +523,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -607,19 +607,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -679,8 +679,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/codec/unknownproto/unknown_fields.go b/codec/unknownproto/unknown_fields.go
index 5fa80001c0fe..07759456e296 100644
--- a/codec/unknownproto/unknown_fields.go
+++ b/codec/unknownproto/unknown_fields.go
@@ -222,7 +222,7 @@ var checks = [...]map[descriptorpb.FieldDescriptorProto_Type]bool{
descriptorpb.FieldDescriptorProto_TYPE_MESSAGE: true,
// The following types can be packed repeated.
// ref: "Only repeated fields of primitive numeric types (types which use the varint, 32-bit, or 64-bit wire types) can be declared "packed"."
- // ref: https://developers.google.com/protocol-buffers/docs/encoding#packed
+ // ref: https://protobuf.dev/programming-guides/encoding/#packed
descriptorpb.FieldDescriptorProto_TYPE_INT32: true,
descriptorpb.FieldDescriptorProto_TYPE_INT64: true,
descriptorpb.FieldDescriptorProto_TYPE_UINT32: true,
@@ -255,7 +255,7 @@ var checks = [...]map[descriptorpb.FieldDescriptorProto_Type]bool{
}
// canEncodeType returns true if the wireType is suitable for encoding the descriptor type.
-// See https://developers.google.com/protocol-buffers/docs/encoding#structure.
+// See https://protobuf.dev/programming-guides/encoding/#structure.
func canEncodeType(wireType protowire.Type, descType descriptorpb.FieldDescriptorProto_Type) bool {
if iwt := int(wireType); iwt < 0 || iwt >= len(checks) {
return false
diff --git a/collections/quad.go b/collections/quad.go
index a5dfc2929b01..cf17cc32eaba 100644
--- a/collections/quad.go
+++ b/collections/quad.go
@@ -106,6 +106,7 @@ type quadKeyCodec[K1, K2, K3, K4 any] struct {
type jsonQuadKey [4]json.RawMessage
+// EncodeJSON encodes Quads to json
func (t quadKeyCodec[K1, K2, K3, K4]) EncodeJSON(value Quad[K1, K2, K3, K4]) ([]byte, error) {
json1, err := t.keyCodec1.EncodeJSON(*value.k1)
if err != nil {
@@ -130,6 +131,7 @@ func (t quadKeyCodec[K1, K2, K3, K4]) EncodeJSON(value Quad[K1, K2, K3, K4]) ([]
return json.Marshal(jsonQuadKey{json1, json2, json3, json4})
}
+// DecodeJSON decodes json to Quads
func (t quadKeyCodec[K1, K2, K3, K4]) DecodeJSON(b []byte) (Quad[K1, K2, K3, K4], error) {
var jsonKey jsonQuadKey
err := json.Unmarshal(b, &jsonKey)
@@ -160,6 +162,7 @@ func (t quadKeyCodec[K1, K2, K3, K4]) DecodeJSON(b []byte) (Quad[K1, K2, K3, K4]
return Join4(key1, key2, key3, key4), nil
}
+// Stringify converts Quads to string
func (t quadKeyCodec[K1, K2, K3, K4]) Stringify(key Quad[K1, K2, K3, K4]) string {
b := new(strings.Builder)
b.WriteByte('(')
diff --git a/collections/triple.go b/collections/triple.go
index e4a07970945c..17f519d54d6d 100644
--- a/collections/triple.go
+++ b/collections/triple.go
@@ -85,6 +85,7 @@ type tripleKeyCodec[K1, K2, K3 any] struct {
type jsonTripleKey [3]json.RawMessage
+// EncodeJSON convert triple keys to json
func (t tripleKeyCodec[K1, K2, K3]) EncodeJSON(value Triple[K1, K2, K3]) ([]byte, error) {
json1, err := t.keyCodec1.EncodeJSON(*value.k1)
if err != nil {
@@ -104,6 +105,7 @@ func (t tripleKeyCodec[K1, K2, K3]) EncodeJSON(value Triple[K1, K2, K3]) ([]byte
return json.Marshal(jsonTripleKey{json1, json2, json3})
}
+// DecodeJSON convert json to triple keys
func (t tripleKeyCodec[K1, K2, K3]) DecodeJSON(b []byte) (Triple[K1, K2, K3], error) {
var jsonKey jsonTripleKey
err := json.Unmarshal(b, &jsonKey)
@@ -129,6 +131,7 @@ func (t tripleKeyCodec[K1, K2, K3]) DecodeJSON(b []byte) (Triple[K1, K2, K3], er
return Join3(key1, key2, key3), nil
}
+// Stringify convert triple keys to string
func (t tripleKeyCodec[K1, K2, K3]) Stringify(key Triple[K1, K2, K3]) string {
b := new(strings.Builder)
b.WriteByte('(')
diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile
index 8ff6675b0379..9839c032e3b2 100644
--- a/contrib/images/simd-env/Dockerfile
+++ b/contrib/images/simd-env/Dockerfile
@@ -17,7 +17,6 @@ COPY x/gov/go.mod x/gov/go.sum /work/x/gov/
COPY x/distribution/go.mod x/distribution/go.sum /work/x/distribution/
COPY x/slashing/go.mod x/slashing/go.sum /work/x/slashing/
COPY x/staking/go.mod x/staking/go.sum /work/x/staking/
-COPY x/auth/go.mod x/auth/go.sum /work/x/auth/
COPY x/authz/go.mod x/authz/go.sum /work/x/authz/
COPY x/bank/go.mod x/bank/go.sum /work/x/bank/
COPY x/mint/go.mod x/mint/go.sum /work/x/mint/
diff --git a/core/store/store.go b/core/store/store.go
index 164bcca6112e..5c50855e2b7b 100644
--- a/core/store/store.go
+++ b/core/store/store.go
@@ -1,7 +1,7 @@
package store
// KVStore describes the basic interface for interacting with key-value stores.
-type KVStore interface {
+type KVStore = interface {
// Get returns nil iff key doesn't exist. Errors on nil key.
Get(key []byte) ([]byte, error)
diff --git a/crypto/codec/pubkey.go b/crypto/codec/pubkey.go
new file mode 100644
index 000000000000..7710e9275abc
--- /dev/null
+++ b/crypto/codec/pubkey.go
@@ -0,0 +1,69 @@
+package codec
+
+import (
+ "cosmossdk.io/errors"
+
+ cryptokeys "github.com/cosmos/cosmos-sdk/crypto/keys"
+ bls12_381 "github.com/cosmos/cosmos-sdk/crypto/keys/bls12_381"
+ "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
+ "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
+ cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
+ sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
+)
+
+// PubKeyToProto converts a JSON public key (in `cryptokeys.JSONPubkey` format) to its corresponding protobuf public key type.
+//
+// Parameters:
+// - pk: A `cryptokeys.JSONPubkey` containing the public key and its type.
+//
+// Returns:
+// - cryptotypes.PubKey: The protobuf public key corresponding to the provided JSON public key.
+// - error: An error if the key type is invalid or unsupported.
+func PubKeyToProto(pk cryptokeys.JSONPubkey) (cryptotypes.PubKey, error) {
+ switch pk.KeyType {
+ case ed25519.PubKeyName:
+ return &ed25519.PubKey{
+ Key: pk.Value,
+ }, nil
+ case secp256k1.PubKeyName:
+ return &secp256k1.PubKey{
+ Key: pk.Value,
+ }, nil
+ case bls12_381.PubKeyName:
+ return &bls12_381.PubKey{
+ Key: pk.Value,
+ }, nil
+ default:
+ return nil, errors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v to proto public key", pk)
+ }
+}
+
+// PubKeyFromProto converts a protobuf public key (in `cryptotypes.PubKey` format) to a JSON public key format (`cryptokeys.JSONPubkey`).
+//
+// Parameters:
+// - pk: A `cryptotypes.PubKey` which is the protobuf representation of a public key.
+//
+// Returns:
+// - cryptokeys.JSONPubkey: The JSON-formatted public key corresponding to the provided protobuf public key.
+// - error: An error if the key type is invalid or unsupported.
+func PubKeyFromProto(pk cryptotypes.PubKey) (cryptokeys.JSONPubkey, error) {
+ switch pk := pk.(type) {
+ case *ed25519.PubKey:
+ return cryptokeys.JSONPubkey{
+ KeyType: ed25519.PubKeyName,
+ Value: pk.Bytes(),
+ }, nil
+ case *secp256k1.PubKey:
+ return cryptokeys.JSONPubkey{
+ KeyType: secp256k1.PubKeyName,
+ Value: pk.Bytes(),
+ }, nil
+ case *bls12_381.PubKey:
+ return cryptokeys.JSONPubkey{
+ KeyType: bls12_381.PubKeyName,
+ Value: pk.Bytes(),
+ }, nil
+ default:
+ return cryptokeys.JSONPubkey{}, errors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v from proto public key", pk)
+ }
+}
diff --git a/crypto/hd/hdpath.go b/crypto/hd/hdpath.go
index 9ef9961d1213..7e3107dfba77 100644
--- a/crypto/hd/hdpath.go
+++ b/crypto/hd/hdpath.go
@@ -230,11 +230,11 @@ func derivePrivateKey(privKeyBytes, chainCode [32]byte, index uint32, harden boo
pubkeyBytes := ecPub.SerializeCompressed()
data = pubkeyBytes
- /* By using btcec, we can remove the dependency on tendermint/crypto/secp256k1
- pubkey := secp256k1.PrivKeySecp256k1(privKeyBytes).PubKey()
- public := pubkey.(secp256k1.PubKeySecp256k1)
- data = public[:]
- */
+ // By using btcec, we can remove the dependency on tendermint/crypto/secp256k1
+ // pubkey := secp256k1.PrivKeySecp256k1(privKeyBytes).PubKey()
+ // public := pubkey.(secp256k1.PubKeySecp256k1)
+ // data = public[:]
+
}
data = append(data, uint32ToBytes(index)...)
diff --git a/crypto/keyring/autocli.go b/crypto/keyring/autocli.go
index 26f39b3e4362..9af9f1528729 100644
--- a/crypto/keyring/autocli.go
+++ b/crypto/keyring/autocli.go
@@ -30,7 +30,7 @@ type autoCLIKeyring interface {
KeyInfo(name string) (string, string, uint, error)
}
-// NewAutoCLIKeyring wraps the SDK keyring and make it compatible with the AutoCLI keyring interfaces.
+// NewAutoCLIKeyring wraps the SDK keyring and makes it compatible with the AutoCLI keyring interfaces.
func NewAutoCLIKeyring(kr Keyring, ac address.Codec) (autoCLIKeyring, error) {
return &autoCLIKeyringAdapter{kr, ac}, nil
}
@@ -40,6 +40,7 @@ type autoCLIKeyringAdapter struct {
ac address.Codec
}
+// List returns the names of all keys stored in the keyring.
func (a *autoCLIKeyringAdapter) List() ([]string, error) {
list, err := a.Keyring.List()
if err != nil {
@@ -69,6 +70,7 @@ func (a *autoCLIKeyringAdapter) LookupAddressByKeyName(name string) ([]byte, err
return addr, nil
}
+// GetPubKey returns the public key of the key with the given name.
func (a *autoCLIKeyringAdapter) GetPubKey(name string) (cryptotypes.PubKey, error) {
record, err := a.Keyring.Key(name)
if err != nil {
@@ -78,6 +80,7 @@ func (a *autoCLIKeyringAdapter) GetPubKey(name string) (cryptotypes.PubKey, erro
return record.GetPubKey()
}
+// Sign signs the given bytes with the key with the given name.
func (a *autoCLIKeyringAdapter) Sign(name string, msg []byte, signMode signingv1beta1.SignMode) ([]byte, error) {
record, err := a.Keyring.Key(name)
if err != nil {
@@ -93,6 +96,7 @@ func (a *autoCLIKeyringAdapter) Sign(name string, msg []byte, signMode signingv1
return signBytes, err
}
+// KeyType returns the type of the key with the given name.
func (a *autoCLIKeyringAdapter) KeyType(name string) (uint, error) {
record, err := a.Keyring.Key(name)
if err != nil {
@@ -102,6 +106,7 @@ func (a *autoCLIKeyringAdapter) KeyType(name string) (uint, error) {
return uint(record.GetType()), nil
}
+// KeyInfo returns key name, key address, and key type given a key name or address.
func (a *autoCLIKeyringAdapter) KeyInfo(nameOrAddr string) (string, string, uint, error) {
addr, err := a.ac.StringToBytes(nameOrAddr)
if err != nil {
diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go
index ef3b0a16df08..950ecbab440f 100644
--- a/crypto/keyring/keyring.go
+++ b/crypto/keyring/keyring.go
@@ -376,6 +376,17 @@ func (ks keystore) ImportPubKey(uid, armor string) error {
return nil
}
+// Sign signs a message using the private key associated with the provided UID.
+//
+// Parameters:
+// - uid: The unique identifier of the account/key to use for signing.
+// - msg: The message or data to be signed.
+// - signMode: The signing mode that specifies how the message should be signed.
+//
+// Returns:
+// - []byte: The generated signature.
+// - types.PubKey: The public key corresponding to the private key used for signing.
+// - error: Any error encountered during the signing process.
func (ks keystore) Sign(uid string, msg []byte, signMode signing.SignMode) ([]byte, types.PubKey, error) {
k, err := ks.Key(uid)
if err != nil {
@@ -536,6 +547,19 @@ func (ks keystore) List() ([]*Record, error) {
return ks.MigrateAll()
}
+// NewMnemonic generates a new mnemonic and derives a new account from it.
+//
+// Parameters:
+// - uid: A unique identifier for the account.
+// - language: The language for the mnemonic (only English is supported).
+// - hdPath: The hierarchical deterministic (HD) path for key derivation.
+// - bip39Passphrase: The passphrase used in conjunction with the mnemonic for BIP-39.
+// - algo: The signature algorithm used for signing keys.
+//
+// Returns:
+// - *Record: A new key record that contains the private and public key information.
+// - string: The generated mnemonic phrase.
+// - error: Any error encountered during the process.
func (ks keystore) NewMnemonic(uid string, language Language, hdPath, bip39Passphrase string, algo SignatureAlgo) (*Record, string, error) {
if language != English {
return nil, "", ErrUnsupportedLanguage
@@ -707,6 +731,15 @@ func newFileBackendKeyringConfig(name, dir string, buf io.Reader) keyring.Config
}
}
+// newRealPrompt creates a password prompt function to retrieve or create a passphrase
+// for the keyring system.
+//
+// Parameters:
+// - dir: The directory where the keyhash file is stored.
+// - buf: An io.Reader input, typically used for reading user input (e.g., the passphrase).
+//
+// Returns:
+// - A function that accepts a prompt string and returns the passphrase or an error.
func newRealPrompt(dir string, buf io.Reader) func(string) (string, error) {
return func(prompt string) (string, error) {
keyhashStored := false
@@ -896,6 +929,7 @@ func (ks keystore) writeMultisigKey(name string, pk types.PubKey) (*Record, erro
return k, ks.writeRecord(k)
}
+// MigrateAll migrates all legacy key information stored in the keystore to the new Record format.
func (ks keystore) MigrateAll() ([]*Record, error) {
keys, err := ks.db.Keys()
if err != nil {
@@ -1008,6 +1042,16 @@ func (ks keystore) SetItem(item keyring.Item) error {
return ks.db.Set(item)
}
+// convertFromLegacyInfo converts a legacy account info (LegacyInfo) into a new Record format.
+// It handles different types of legacy info and creates the corresponding Record based on the type.
+//
+// Parameters:
+// - info: The legacy account information (LegacyInfo) that needs to be converted.
+// It provides the name, public key, and other data depending on the type of account.
+
+// Returns:
+// - *Record: A pointer to the newly created Record that corresponds to the legacy account info.
+// - error: An error if the conversion fails due to invalid info or an unsupported account type.
func (ks keystore) convertFromLegacyInfo(info LegacyInfo) (*Record, error) {
if info == nil {
return nil, errorsmod.Wrap(ErrLegacyToRecord, "info is nil")
diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go
index 2e19c5b91576..009a89ebda35 100644
--- a/crypto/keyring/record.go
+++ b/crypto/keyring/record.go
@@ -128,6 +128,13 @@ func extractPrivKeyFromRecord(k *Record) (cryptotypes.PrivKey, error) {
return extractPrivKeyFromLocal(rl)
}
+// extractPrivKeyFromLocal extracts the private key from a local record.
+// It checks if the private key is available in the provided Record_Local instance.
+// Parameters:
+// - rl: A pointer to a Record_Local instance from which the private key will be extracted.
+// Returns:
+// - priv: The extracted cryptotypes.PrivKey if successful.
+// - error: An error if the private key is not available or if the casting fails.
func extractPrivKeyFromLocal(rl *Record_Local) (cryptotypes.PrivKey, error) {
if rl.PrivKey == nil {
return nil, ErrPrivKeyNotAvailable
diff --git a/crypto/keys/jsonkey.go b/crypto/keys/jsonkey.go
new file mode 100644
index 000000000000..8edbd91e7246
--- /dev/null
+++ b/crypto/keys/jsonkey.go
@@ -0,0 +1,41 @@
+package keys
+
+import (
+ "github.com/cosmos/cosmos-sdk/crypto/keys/bls12_381"
+ "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
+ "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
+ "github.com/cosmos/cosmos-sdk/crypto/types"
+)
+
+// JSONPubKey defines a public key that are parse from JSON file.
+// convert PubKey to JSONPubKey needs a in between step
+type JSONPubkey struct {
+ KeyType string `json:"type"`
+ Value []byte `json:"value"`
+}
+
+func (pk JSONPubkey) Address() types.Address {
+ switch pk.KeyType {
+ case ed25519.PubKeyName:
+ ed25519 := ed25519.PubKey{
+ Key: pk.Value,
+ }
+ return ed25519.Address()
+ case secp256k1.PubKeyName:
+ secp256k1 := secp256k1.PubKey{
+ Key: pk.Value,
+ }
+ return secp256k1.Address()
+ case bls12_381.PubKeyName:
+ bls12_381 := bls12_381.PubKey{
+ Key: pk.Value,
+ }
+ return bls12_381.Address()
+ default:
+ return nil
+ }
+}
+
+func (pk JSONPubkey) Bytes() []byte {
+ return pk.Value
+}
diff --git a/depinject/go.mod b/depinject/go.mod
index 12e18e6a5c56..b4da7af01100 100644
--- a/depinject/go.mod
+++ b/depinject/go.mod
@@ -8,7 +8,7 @@ require (
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
sigs.k8s.io/yaml v1.4.0
)
diff --git a/depinject/go.sum b/depinject/go.sum
index 252c8bd7d025..84f26c7a7c86 100644
--- a/depinject/go.sum
+++ b/depinject/go.sum
@@ -50,8 +50,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/docs/architecture/adr-003-dynamic-capability-store.md b/docs/architecture/adr-003-dynamic-capability-store.md
index 89f0c996755b..ce8aa8963295 100644
--- a/docs/architecture/adr-003-dynamic-capability-store.md
+++ b/docs/architecture/adr-003-dynamic-capability-store.md
@@ -34,8 +34,8 @@ chain is running.
The `CapabilityKeeper` will include a persistent `KVStore`, a `MemoryStore`, and an in-memory map.
The persistent `KVStore` tracks which capability is owned by which modules.
-The `MemoryStore` stores a forward mapping that map from module name, capability tuples to capability names and
-a reverse mapping that map from module name, capability name to the capability index.
+The `MemoryStore` stores a forward mapping that maps from module name, capability tuples to capability names and
+a reverse mapping that maps from module name, capability name to the capability index.
Since we cannot marshal the capability into a `KVStore` and unmarshal without changing the memory location of the capability,
the reverse mapping in the KVStore will simply map to an index. This index can then be used as a key in the ephemeral
go-map to retrieve the capability at the original memory location.
@@ -277,7 +277,7 @@ ck.InitialiseAndSeal(initialContext)
#### Creating, passing, claiming and using capabilities
-Consider the case where `mod1` wants to create a capability, associate it with a resource (e.g. an IBC channel) by name, then pass it to `mod2` which will use it later:
+Consider the case where `mod1` wants to create a capability, associate it with a resource (e.g. an IBC channel) by name, and then pass it to `mod2` which will use it later:
Module 1 would have the following code:
@@ -327,12 +327,12 @@ Proposed.
### Positive
* Dynamic capability support.
-* Allows CapabilityKeeper to return same capability pointer from go-map while reverting any writes to the persistent `KVStore` and in-memory `MemoryStore` on tx failure.
+* Allows CapabilityKeeper to return the same capability pointer from go-map while reverting any writes to the persistent `KVStore` and in-memory `MemoryStore` on tx failure.
### Negative
* Requires an additional keeper.
-* Some overlap with existing `StoreKey` system (in the future they could be combined, since this is a superset functionality-wise).
+* Some overlap with the existing `StoreKey` system (in the future they could be combined, since this is a superset functionality-wise).
* Requires an extra level of indirection in the reverse mapping, since MemoryStore must map to index which must then be used as key in a go map to retrieve the actual capability
### Neutral
diff --git a/docs/architecture/adr-010-modular-antehandler.md b/docs/architecture/adr-010-modular-antehandler.md
index 4eb5b8855f7b..4fa6e4f2c3d2 100644
--- a/docs/architecture/adr-010-modular-antehandler.md
+++ b/docs/architecture/adr-010-modular-antehandler.md
@@ -29,7 +29,7 @@ Pros:
Cons:
1. Improves granularity but still cannot get more granular than a per-module basis. e.g. If auth's `AnteHandle` function is in charge of validating memo and signatures, users cannot swap the signature-checking functionality while keeping the rest of auth's `AnteHandle` functionality.
-2. Module AnteHandler are run one after the other. There is no way for one AnteHandler to wrap or "decorate" another.
+2. Module AnteHandlers are run one after the other. There is no way for one AnteHandler to wrap or "decorate" another.
### Decorator Pattern
@@ -157,7 +157,7 @@ app.SetAnteHandler(mm.GetAnteHandler())
#### Custom Workflow
-This is an example workflow for a user that wants to implement custom antehandler logic. In this example, the user wants to implement custom signature verification and change the order of antehandler so that validate memo runs before signature verification.
+This is an example workflow for a user who wants to implement custom antehandler logic. In this example, the user wants to implement custom signature verification and change the order of antehandler so that validate memo runs before signature verification.
##### User Code
@@ -192,7 +192,7 @@ In addition, this approach will not break any core Cosmos SDK API's. Since we pr
Allow Decorator interface that can be chained together to create a Cosmos SDK AnteHandler.
-This allows users to choose between implementing an AnteHandler by themselves and setting it in the baseapp, or use the decorator pattern to chain their custom decorators with the Cosmos SDK provided decorators in the order they wish.
+This allows users to choose between implementing an AnteHandler by themselves and setting it in the baseapp, or using the decorator pattern to chain their custom decorators with the Cosmos SDK provided decorators in the order they wish.
```go
// An AnteDecorator wraps an AnteHandler, and can do pre- and post-processing on the next AnteHandler
diff --git a/docs/architecture/adr-012-state-accessors.md b/docs/architecture/adr-012-state-accessors.md
index 93600000ff1c..49a9ba1fd94f 100644
--- a/docs/architecture/adr-012-state-accessors.md
+++ b/docs/architecture/adr-012-state-accessors.md
@@ -15,7 +15,7 @@ value and finally unmarshal. Usually this is done by declaring `Keeper.GetXXX` a
which are repetitive and hard to maintain.
Second, this makes it harder to align with the object capability theorem: the right to access the
-state is defined as a `StoreKey`, which gives full access on the entire Merkle tree, so a module cannot
+state is defined as a `StoreKey`, which gives full access to the entire Merkle tree, so a module cannot
send the access right to a specific key-value pair (or a set of key-value pairs) to another module safely.
Finally, because the getter/setter functions are defined as methods of a module's `Keeper`, the reviewers
diff --git a/docs/architecture/adr-013-metrics.md b/docs/architecture/adr-013-metrics.md
index b0808d462514..e2bce3a04219 100644
--- a/docs/architecture/adr-013-metrics.md
+++ b/docs/architecture/adr-013-metrics.md
@@ -10,7 +10,7 @@ Proposed
## Context
-Telemetry is paramount into debugging and understanding what the application is doing and how it is
+Telemetry is paramount in debugging and understanding what the application is doing and how it is
performing. We aim to expose metrics from modules and other core parts of the Cosmos SDK.
In addition, we should aim to support multiple configurable sinks that an operator may choose from.
@@ -148,7 +148,7 @@ func (k BaseKeeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins)
### Positive
-* Exposure into the performance and behavior of an application
+* Exposure to the performance and behavior of an application
### Negative
diff --git a/docs/architecture/adr-016-validator-consensus-key-rotation.md b/docs/architecture/adr-016-validator-consensus-key-rotation.md
index 7085f033c635..998627a43deb 100644
--- a/docs/architecture/adr-016-validator-consensus-key-rotation.md
+++ b/docs/architecture/adr-016-validator-consensus-key-rotation.md
@@ -7,7 +7,7 @@
## Context
-Validator consensus key rotation feature has been discussed and requested for a long time, for the sake of safer validator key management policy (e.g. https://github.com/tendermint/tendermint/issues/1136). So, we suggest one of the simplest form of validator consensus key rotation implementation mostly onto Cosmos SDK.
+Validator consensus key rotation feature has been discussed and requested for a long time, for the sake of safer validator key management policy (e.g. https://github.com/tendermint/tendermint/issues/1136). So, we suggest one of the simplest forms of validator consensus key rotation implementation mostly onto Cosmos SDK.
We don't need to make any update on consensus logic in Tendermint because Tendermint does not have any mapping information of consensus key and validator operator key, meaning that from Tendermint point of view, a consensus key rotation of a validator is simply a replacement of a consensus key to another.
@@ -21,33 +21,33 @@ Also, it should be noted that this ADR includes only the simplest form of consen
* create and broadcast a transaction with a `MsgRotateConsPubKey` that states the new consensus key is now coupled with the validator operator with signature from the validator's operator key.
* old consensus key becomes unable to participate on consensus immediately after the update of key mapping state on-chain.
* start validating with new consensus key.
-* validators using HSM and KMS should update the consensus key in HSM to use the new rotated key after the height `h` when `MsgRotateConsPubKey` committed to the blockchain.
+* validators using HSM and KMS should update the consensus key in HSM to use the new rotated key after the height `h` when `MsgRotateConsPubKey` is committed to the blockchain.
### Considerations
* consensus key mapping information management strategy
- * store history of each key mapping changes in the kvstore.
- * the state machine can search corresponding consensus key paired with given validator operator for any arbitrary height in a recent unbonding period.
+ * store history of each key mapping change in the kvstore.
+ * the state machine can search corresponding consensus key paired with the given validator operator for any arbitrary height in a recent unbonding period.
* the state machine does not need any historical mapping information which is past more than unbonding period.
* key rotation costs related to LCD and IBC
* LCD and IBC will have traffic/computation burden when there exists frequent power changes
* In current Tendermint design, consensus key rotations are seen as power changes from LCD or IBC perspective
- * Therefore, to minimize unnecessary frequent key rotation behavior, we limited maximum number of rotation in recent unbonding period and also applied exponentially increasing rotation fee
+ * Therefore, to minimize unnecessary frequent key rotation behavior, we limited the maximum number of rotations in recent unbonding period and also applied an exponentially increasing rotation fee
* limits
* rotations are limited to 1 time in an unbonding window. In future rewrites of the staking module it could be made to happen more times than 1
- * parameters can be decided by governance and stored in genesis file.
+ * parameters can be decided by governance and stored in the genesis file.
* key rotation fee
* a validator should pay `KeyRotationFee` to rotate the consensus key which is calculated as below
* `KeyRotationFee` = (max(`VotingPowerPercentage`, 1)* `InitialKeyRotationFee`) * 2^(number of rotations in `ConsPubKeyRotationHistory` in recent unbonding period)
* evidence module
- * evidence module can search corresponding consensus key for any height from slashing keeper so that it can decide which consensus key is supposed to be used for given height.
+ * evidence module can search corresponding consensus key for any height from slashing keeper so that it can decide which consensus key is supposed to be used for a given height.
* abci.ValidatorUpdate
* tendermint already has ability to change a consensus key by ABCI communication(`ValidatorUpdate`).
* validator consensus key update can be done via creating new + delete old by change the power to zero.
* therefore, we expect we even do not need to change tendermint codebase at all to implement this feature.
* new genesis parameters in `staking` module
- * `MaxConsPubKeyRotations` : maximum number of rotation can be executed by a validator in recent unbonding period. default value 10 is suggested(11th key rotation will be rejected)
- * `InitialKeyRotationFee` : the initial key rotation fee when no key rotation has happened in recent unbonding period. default value 1atom is suggested(1atom fee for the first key rotation in recent unbonding period)
+ * `MaxConsPubKeyRotations` : maximum number of rotations can be executed by a validator in the recent unbonding period. default value 10 is suggested(11th key rotation will be rejected)
+ * `InitialKeyRotationFee` : the initial key rotation fee when no key rotation has happened in the recent unbonding period. default value 1atom is suggested(1atom fee for the first key rotation in recent unbonding period)
### Workflow
@@ -64,7 +64,7 @@ Also, it should be noted that this ADR includes only the simplest form of consen
3. `handleMsgRotateConsPubKey` gets `MsgRotateConsPubKey`, calls `RotateConsPubKey` with emits event
4. `RotateConsPubKey`
* checks if `NewPubKey` is not duplicated on `ValidatorsByConsAddr`
- * checks if the validator is does not exceed parameter `MaxConsPubKeyRotations` by iterating `ConsPubKeyRotationHistory`
+ * checks if the validator does not exceed parameter `MaxConsPubKeyRotations` by iterating `ConsPubKeyRotationHistory`
* checks if the signing account has enough balance to pay `KeyRotationFee`
* pays `KeyRotationFee` to community fund
* overwrites `NewPubKey` in `validator.ConsPubKey`
@@ -81,7 +81,7 @@ Also, it should be noted that this ADR includes only the simplest form of consen
}
```
-5. `ApplyAndReturnValidatorSetUpdates` checks if there is `ConsPubKeyRotationHistory` with `ConsPubKeyRotationHistory.RotatedHeight == ctx.BlockHeight()` and if so, generates 2 `ValidatorUpdate` , one for a remove validator and one for create new validator
+5. `ApplyAndReturnValidatorSetUpdates` checks if there is `ConsPubKeyRotationHistory` with `ConsPubKeyRotationHistory.RotatedHeight == ctx.BlockHeight()` and if so, generates 2 `ValidatorUpdate` , one for a remove validator and one for create a new validator
```go
abci.ValidatorUpdate{
diff --git a/docs/architecture/adr-019-protobuf-state-encoding.md b/docs/architecture/adr-019-protobuf-state-encoding.md
index 5ad1b953e796..267896d9621b 100644
--- a/docs/architecture/adr-019-protobuf-state-encoding.md
+++ b/docs/architecture/adr-019-protobuf-state-encoding.md
@@ -21,7 +21,7 @@ and JSON object encoding over the wire bringing parity between logical objects a
From the Amino docs:
> Amino is an object encoding specification. It is a subset of Proto3 with an extension for interface
-> support. See the [Proto3 spec](https://developers.google.com/protocol-buffers/docs/proto3) for more
+> support. See the [Proto3 spec](https://protobuf.dev/programming-guides/proto3/) for more
> information on Proto3, which Amino is largely compatible with (but not with Proto2).
>
> The goal of the Amino encoding protocol is to bring parity into logic objects and persistence objects.
@@ -56,7 +56,7 @@ made to address client-side encoding.
## Decision
-We will adopt [Protocol Buffers](https://developers.google.com/protocol-buffers) for serializing
+We will adopt [Protocol Buffers](https://protobuf.dev) for serializing
persisted structured data in the Cosmos SDK while providing a clean mechanism and developer UX for
applications wishing to continue to use Amino. We will provide this mechanism by updating modules to
accept a codec interface, `Marshaler`, instead of a concrete Amino codec. Furthermore, the Cosmos SDK
diff --git a/docs/architecture/adr-023-protobuf-naming.md b/docs/architecture/adr-023-protobuf-naming.md
index a192dfce3264..01bfd8bd94ca 100644
--- a/docs/architecture/adr-023-protobuf-naming.md
+++ b/docs/architecture/adr-023-protobuf-naming.md
@@ -11,7 +11,7 @@ Accepted
## Context
-Protocol Buffers provide a basic [style guide](https://developers.google.com/protocol-buffers/docs/style)
+Protocol Buffers provide a basic [style guide](https://protobuf.dev/programming-guides/style/)
and [Buf](https://buf.build/docs/style-guide) builds upon that. To the
extent possible, we want to follow industry accepted guidelines and wisdom for
the effective usage of protobuf, deviating from those only when there is clear
diff --git a/docs/architecture/adr-027-deterministic-protobuf-serialization.md b/docs/architecture/adr-027-deterministic-protobuf-serialization.md
index 66ce6e2b75e2..41e0d28e33d9 100644
--- a/docs/architecture/adr-027-deterministic-protobuf-serialization.md
+++ b/docs/architecture/adr-027-deterministic-protobuf-serialization.md
@@ -15,7 +15,7 @@ Fully deterministic structure serialization, which works across many languages a
is needed when signing messages. We need to be sure that whenever we serialize
a data structure, no matter in which supported language, the raw bytes
will stay the same.
-[Protobuf](https://developers.google.com/protocol-buffers/docs/proto3)
+[Protobuf](https://protobuf.dev/programming-guides/proto3/)
serialization is not bijective (i.e. there exist a practically unlimited number of
valid binary representations for a given protobuf document)1.
@@ -55,7 +55,7 @@ reject documents containing maps as invalid input.
### Background - Protobuf3 Encoding
Most numeric types in protobuf3 are encoded as
-[varints](https://developers.google.com/protocol-buffers/docs/encoding#varints).
+[varints](https://protobuf.dev/programming-guides/encoding/#varints).
Varints are at most 10 bytes, and since each varint byte has 7 bits of data,
varints are a representation of `uint70` (70-bit unsigned integer). When
encoding, numeric values are casted from their base type to `uint70`, and when
@@ -74,15 +74,15 @@ encoding malleability.
### Serialization rules
The serialization is based on the
-[protobuf3 encoding](https://developers.google.com/protocol-buffers/docs/encoding)
+[protobuf3 encoding](https://protobuf.dev/programming-guides/encoding/)
with the following additions:
1. Fields must be serialized only once in ascending order
2. Extra fields or any extra data must not be added
-3. [Default values](https://developers.google.com/protocol-buffers/docs/proto3#default)
+3. [Default values](https://protobuf.dev/programming-guides/proto3/#default)
must be omitted
4. `repeated` fields of scalar numeric types must use
- [packed encoding](https://developers.google.com/protocol-buffers/docs/encoding#packed)
+ [packed encoding](https://protobuf.dev/programming-guides/encoding/#packed)
5. Varint encoding must not be longer than needed:
* No trailing zero bytes (in little endian, i.e. no leading zeroes in big
endian). Per rule 3 above, the default value of `0` must be omitted, so
@@ -288,27 +288,27 @@ the need of implementing a custom serializer that adheres to this standard (and
implementation detail and the details of any particular implementation may
change in the future. Therefore, protocol buffer parsers must be able to parse
fields in any order._ from
- https://developers.google.com/protocol-buffers/docs/encoding#order
-* 2 https://developers.google.com/protocol-buffers/docs/encoding#signed_integers
+ https://protobuf.dev/programming-guides/encoding/#order
+* 2 https://protobuf.dev/programming-guides/encoding/#signed_integers
* 3 _Note that for scalar message fields, once a message is parsed
there's no way of telling whether a field was explicitly set to the default
value (for example whether a boolean was set to false) or just not set at all:
you should bear this in mind when defining your message types. For example,
don't have a boolean that switches on some behavior when set to false if you
don't want that behavior to also happen by default._ from
- https://developers.google.com/protocol-buffers/docs/proto3#default
+ https://protobuf.dev/programming-guides/proto3/#default
* 4 _When a message is parsed, if the encoded message does not
contain a particular singular element, the corresponding field in the parsed
object is set to the default value for that field._ from
- https://developers.google.com/protocol-buffers/docs/proto3#default
+ https://protobuf.dev/programming-guides/proto3/#default
* 5 _Also note that if a scalar message field is set to its default,
the value will not be serialized on the wire._ from
- https://developers.google.com/protocol-buffers/docs/proto3#default
+ https://protobuf.dev/programming-guides/proto3/#default
* 6 _For enums, the default value is the first defined enum value,
which must be 0._ from
- https://developers.google.com/protocol-buffers/docs/proto3#default
+ https://protobuf.dev/programming-guides/proto3/#default
* 7 _For message fields, the field is not set. Its exact value is
language-dependent._ from
- https://developers.google.com/protocol-buffers/docs/proto3#default
+ https://protobuf.dev/programming-guides/proto3/#default
* Encoding rules and parts of the reasoning taken from
[canonical-proto3 Aaron Craelius](https://github.com/regen-network/canonical-proto3)
diff --git a/docs/architecture/adr-031-msg-service.md b/docs/architecture/adr-031-msg-service.md
index 8aa78c82d25f..8185509bd190 100644
--- a/docs/architecture/adr-031-msg-service.md
+++ b/docs/architecture/adr-031-msg-service.md
@@ -77,7 +77,7 @@ message MsgSubmitProposalResponse {
```
While this is most commonly used for gRPC, overloading protobuf `service` definitions like this does not violate
-the intent of the [protobuf spec](https://developers.google.com/protocol-buffers/docs/proto3#services) which says:
+the intent of the [protobuf spec](https://protobuf.dev/programming-guides/proto3/#services) which says:
> If you don’t want to use gRPC, it’s also possible to use protocol buffers with your own RPC implementation.
With this approach, we would get an auto-generated `MsgServer` interface:
@@ -175,7 +175,7 @@ Separate handler definition is no longer needed with this approach.
## Consequences
-This design changes how a module functionality is exposed and accessed. It deprecates the existing `Handler` interface and `AppModule.Route` in favor of [Protocol Buffer Services](https://developers.google.com/protocol-buffers/docs/proto3#services) and Service Routing described above. This dramatically simplifies the code. We don't need to create handlers and keepers any more. Use of Protocol Buffer auto-generated clients clearly separates the communication interfaces between the module and a modules user. The control logic (aka handlers and keepers) is not exposed any more. A module interface can be seen as a black box accessible through a client API. It's worth to note that the client interfaces are also generated by Protocol Buffers.
+This design changes how a module functionality is exposed and accessed. It deprecates the existing `Handler` interface and `AppModule.Route` in favor of [Protocol Buffer Services](https://protobuf.dev/programming-guides/proto3/#services) and Service Routing described above. This dramatically simplifies the code. We don't need to create handlers and keepers any more. Use of Protocol Buffer auto-generated clients clearly separates the communication interfaces between the module and a modules user. The control logic (aka handlers and keepers) is not exposed any more. A module interface can be seen as a black box accessible through a client API. It's worth to note that the client interfaces are also generated by Protocol Buffers.
This also allows us to change how we perform functional tests. Instead of mocking AppModules and Router, we will mock a client (server will stay hidden). More specifically: we will never mock `moduleA.MsgServer` in `moduleB`, but rather `moduleA.MsgClient`. One can think about it as working with external services (eg DBs, or online servers...). We assume that the transmission between clients and servers is correctly handled by generated Protocol Buffers.
@@ -196,6 +196,6 @@ Finally, closing a module to client API opens desirable OCAP patterns discussed
## References
* [Initial Github Issue \#7122](https://github.com/cosmos/cosmos-sdk/issues/7122)
-* [proto 3 Language Guide: Defining Services](https://developers.google.com/protocol-buffers/docs/proto3#services)
+* [proto 3 Language Guide: Defining Services](https://protobuf.dev/programming-guides/proto3/#services)
* [ADR 020](./adr-020-protobuf-transaction-encoding.md)
* [ADR 021](./adr-021-protobuf-query-encoding.md)
diff --git a/docs/architecture/adr-044-protobuf-updates-guidelines.md b/docs/architecture/adr-044-protobuf-updates-guidelines.md
index c2d41a1a37e0..93e28d2d1731 100644
--- a/docs/architecture/adr-044-protobuf-updates-guidelines.md
+++ b/docs/architecture/adr-044-protobuf-updates-guidelines.md
@@ -73,7 +73,7 @@ and the following ones are NOT valid:
#### 2. Fields MAY be marked as `deprecated`, and nodes MAY implement a protocol-breaking change for handling these fields
-Protobuf supports the [`deprecated` field option](https://developers.google.com/protocol-buffers/docs/proto#options), and this option MAY be used on any field, including `Msg` fields. If a node handles a Protobuf message with a non-empty deprecated field, the node MAY change its behavior upon processing it, even in a protocol-breaking way. When possible, the node MUST handle backwards compatibility without breaking the consensus (unless we increment the proto version).
+Protobuf supports the [`deprecated` field option](https://protobuf.dev/programming-guides/proto2/), and this option MAY be used on any field, including `Msg` fields. If a node handles a Protobuf message with a non-empty deprecated field, the node MAY change its behavior upon processing it, even in a protocol-breaking way. When possible, the node MUST handle backwards compatibility without breaking the consensus (unless we increment the proto version).
As an example, the Cosmos SDK v0.42 to v0.43 update contained two Protobuf-breaking changes, listed below. Instead of bumping the package versions from `v1beta1` to `v1`, the SDK team decided to follow this guideline, by reverting the breaking changes, marking those changes as deprecated, and modifying the node implementation when processing messages with deprecated fields. More specifically:
diff --git a/docs/architecture/adr-054-semver-compatible-modules.md b/docs/architecture/adr-054-semver-compatible-modules.md
index 5dc0a666f69b..40dd60810633 100644
--- a/docs/architecture/adr-054-semver-compatible-modules.md
+++ b/docs/architecture/adr-054-semver-compatible-modules.md
@@ -37,7 +37,7 @@ In order to achieve this, we need to solve the following problems:
2. circular dependencies between modules need to be broken to actually release
many modules in the SDK independently
3. pernicious minor version incompatibilities introduced through correctly
- [evolving protobuf schemas](https://developers.google.com/protocol-buffers/docs/proto3#updating)
+ [evolving protobuf schemas](https://protobuf.dev/programming-guides/proto3/#updating)
without correct [unknown field filtering](./adr-020-protobuf-transaction-encoding.md#unknown-field-filtering)
Note that all the following discussion assumes that the proto file versioning and state machine versioning of a module
@@ -320,7 +320,7 @@ generate its own version of `MsgDoSomething` as `bar/internal/foo/v1.MsgDoSometh
inter-module router which would somehow convert it to the version which foo needs (ex. `foo/internal.MsgDoSomething`).
Currently, two generated structs for the same protobuf type cannot exist in the same go binary without special
-build flags (see https://developers.google.com/protocol-buffers/docs/reference/go/faq#fix-namespace-conflict).
+build flags (see https://protobuf.dev/reference/go/faq/#fix-namespace-conflict).
A relatively simple mitigation to this issue would be to set up the protobuf code to not register protobuf types
globally if they are generated in an `internal/` package. This will require modules to register their types manually
with the app-level level protobuf registry, this is similar to what modules already do with the `InterfaceRegistry`
diff --git a/docs/build/_category_.json b/docs/build/_category_.json
new file mode 100644
index 000000000000..9f3088236274
--- /dev/null
+++ b/docs/build/_category_.json
@@ -0,0 +1,5 @@
+{
+ "label": "Build",
+ "position": 0,
+ "link": null
+}
\ No newline at end of file
diff --git a/docs/build/build.md b/docs/build/build.md
new file mode 100644
index 000000000000..3b86eb472b52
--- /dev/null
+++ b/docs/build/build.md
@@ -0,0 +1,13 @@
+---
+sidebar_position: 0
+---
+
+# Build
+
+* [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.
+* [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.
+* [Migrations](./migrations/01-intro.md) - See what has been updated in each release the process of the transition between versions.
+* [Packages](./packages/README.md) - Explore a curated collection of pre-built modules and functionalities, streamlining the development process.
+* [Tooling](./tooling/README.md) - A suite of utilities designed to enhance the development workflow, optimizing the efficiency of Cosmos SDK-based projects.
+* [ADR's](./architecture/README.md) - Provides a structured repository of key decisions made during the development process, which have been documented and offers rationale behind key decisions being made.
+* [REST API](https://docs.cosmos.network/api) - A comprehensive reference for the application programming interfaces (APIs) provided by the SDK.
diff --git a/docs/build/building-modules/01-module-manager.md b/docs/build/building-modules/01-module-manager.md
index d5e0aac04daa..9742454320ec 100644
--- a/docs/build/building-modules/01-module-manager.md
+++ b/docs/build/building-modules/01-module-manager.md
@@ -40,7 +40,6 @@ The above interfaces are mostly embedding smaller interfaces (extension interfac
* [`appmodule.HasEndBlocker`](#hasendblocker): The extension interface that contains information about the `AppModule` and `EndBlock`.
* [`appmodule.HasService` / `module.HasServices`](#hasservices): The extension interface for modules to register services.
* [`module.HasABCIEndBlock`](#hasabciendblock): The extension interface that contains information about the `AppModule`, `EndBlock` and returns an updated validator set.
-* (legacy) [`module.HasInvariants`](#hasinvariants): The extension interface for registering invariants.
* (legacy) [`module.HasConsensusVersion`](#hasconsensusversion): The extension interface for declaring a module consensus version.
The `AppModule` interface exists to define inter-dependent module methods. Many modules need to interact with other modules, typically through [`keeper`s](./06-keeper.md), which means there is a need for an interface where modules list their `keeper`s and other methods that require a reference to another module's object. `AppModule` interface extension, such as `HasBeginBlocker` and `HasEndBlocker`, also enables the module manager to set the order of execution between module's methods like `BeginBlock` and `EndBlock`, which is important in cases where the order of execution between modules matters in the context of the application.
@@ -125,16 +124,6 @@ Previously the `module.AppModule` interface was containing all the methods that
https://github.com/cosmos/cosmos-sdk/blob/28fa3b8/core/appmodule/v2/module.go#L14-L20
```
-### `HasInvariants`
-
-This interface defines one method. It allows to checks if a module can register invariants.
-
-```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/module/module.go#L202-L205
-```
-
-* `RegisterInvariants(sdk.InvariantRegistry)`: Registers the [`invariants`](./07-invariants.md) of the module. If an invariant deviates from its predicted value, the [`InvariantRegistry`](./07-invariants.md#registry) triggers appropriate logic (most often the chain will be halted).
-
### `HasServices`
This interface defines one method. It allows to checks if a module can register invariants.
@@ -238,14 +227,13 @@ The module manager is used throughout the application whenever an action on a co
* `SetOrderPrecommiters(moduleNames ...string)`: Sets the order in which the `Precommit()` function of each module will be called during commit of each block. This function is generally called from the application's main [constructor function](../../learn/beginner/00-app-anatomy.md#constructor-function).
* `SetOrderPrepareCheckStaters(moduleNames ...string)`: Sets the order in which the `PrepareCheckState()` function of each module will be called during commit of each block. This function is generally called from the application's main [constructor function](../../learn/beginner/00-app-anatomy.md#constructor-function).
* `SetOrderMigrations(moduleNames ...string)`: Sets the order of migrations to be run. If not set then migrations will be run with an order defined in `DefaultMigrationsOrder`.
-* `RegisterInvariants(ir sdk.InvariantRegistry)`: Registers the [invariants](./07-invariants.md) of module implementing the `HasInvariants` interface.
* `RegisterServices(cfg Configurator)`: Registers the services of modules implementing the `HasServices` interface.
* `InitGenesis(ctx context.Context, genesisData map[string]json.RawMessage)`: Calls the [`InitGenesis`](./08-genesis.md#initgenesis) function of each module when the application is first started, in the order defined in `OrderInitGenesis`. Returns an `abci.InitChainResponse` to the underlying consensus engine, which can contain validator updates.
* `ExportGenesis(ctx context.Context)`: Calls the [`ExportGenesis`](./08-genesis.md#exportgenesis) function of each module, in the order defined in `OrderExportGenesis`. The export constructs a genesis file from a previously existing state, and is mainly used when a hard-fork upgrade of the chain is required.
* `ExportGenesisForModules(ctx context.Context, modulesToExport []string)`: Behaves the same as `ExportGenesis`, except takes a list of modules to export.
-* `BeginBlock(ctx context.Context) error`: At the beginning of each block, this function is called from [`BaseApp`](../../learn/advanced/00-baseapp.md#beginblock) and, in turn, calls the [`BeginBlock`](./06-beginblock-endblock.md) function of each modules implementing the `appmodule.HasBeginBlocker` interface, in the order defined in `OrderBeginBlockers`. It creates a child [context](../../learn/advanced/02-context.md) with an event manager to aggregate [events](../../learn/advanced/08-events.md) emitted from each modules.
-* `EndBlock(ctx context.Context) error`: At the end of each block, this function is called from [`BaseApp`](../../learn/advanced/00-baseapp.md#endblock) and, in turn, calls the [`EndBlock`](./06-beginblock-endblock.md) function of each modules implementing the `appmodule.HasEndBlocker` interface, in the order defined in `OrderEndBlockers`. It creates a child [context](../../learn/advanced/02-context.md) with an event manager to aggregate [events](../../learn/advanced/08-events.md) emitted from all modules. The function returns an `abci` which contains the aforementioned events, as well as validator set updates (if any).
-* `EndBlock(context.Context) ([]abci.ValidatorUpdate, error)`: At the end of each block, this function is called from [`BaseApp`](../../learn/advanced/00-baseapp.md#endblock) and, in turn, calls the [`EndBlock`](./06-beginblock-endblock.md) function of each modules implementing the `module.HasABCIEndBlock` interface, in the order defined in `OrderEndBlockers`. It creates a child [context](../../learn/advanced/02-context.md) with an event manager to aggregate [events](../../learn/advanced/08-events.md) emitted from all modules. The function returns an `abci` which contains the aforementioned events, as well as validator set updates (if any).
+* `BeginBlock(ctx context.Context) error`: At the beginning of each block, this function is called from [`BaseApp`](../../learn/advanced/00-baseapp.md#beginblock) and, in turn, calls the [`BeginBlock`](./06-preblock-beginblock-endblock.md) function of each modules implementing the `appmodule.HasBeginBlocker` interface, in the order defined in `OrderBeginBlockers`. It creates a child [context](../../learn/advanced/02-context.md) with an event manager to aggregate [events](../../learn/advanced/08-events.md) emitted from each modules.
+* `EndBlock(ctx context.Context) error`: At the end of each block, this function is called from [`BaseApp`](../../learn/advanced/00-baseapp.md#endblock) and, in turn, calls the [`EndBlock`](./06-preblock-beginblock-endblock.md) function of each modules implementing the `appmodule.HasEndBlocker` interface, in the order defined in `OrderEndBlockers`. It creates a child [context](../../learn/advanced/02-context.md) with an event manager to aggregate [events](../../learn/advanced/08-events.md) emitted from all modules. The function returns an `abci` which contains the aforementioned events, as well as validator set updates (if any).
+* `EndBlock(context.Context) ([]abci.ValidatorUpdate, error)`: At the end of each block, this function is called from [`BaseApp`](../../learn/advanced/00-baseapp.md#endblock) and, in turn, calls the [`EndBlock`](./06-preblock-beginblock-endblock.md) function of each modules implementing the `module.HasABCIEndBlock` interface, in the order defined in `OrderEndBlockers`. It creates a child [context](../../learn/advanced/02-context.md) with an event manager to aggregate [events](../../learn/advanced/08-events.md) emitted from all modules. The function returns an `abci` which contains the aforementioned events, as well as validator set updates (if any).
* `Precommit(ctx context.Context)`: During [`Commit`](../../learn/advanced/00-baseapp.md#commit), this function is called from `BaseApp` immediately before the [`deliverState`](../../learn/advanced/00-baseapp.md#state-updates) is written to the underlying [`rootMultiStore`](../../learn/advanced/04-store.md#commitmultistore) and, in turn calls the `Precommit` function of each modules implementing the `HasPrecommit` interface, in the order defined in `OrderPrecommiters`. It creates a child [context](../../learn/advanced/02-context.md) where the underlying `CacheMultiStore` is that of the newly committed block's [`finalizeblockstate`](../../learn/advanced/00-baseapp.md#state-updates).
* `PrepareCheckState(ctx context.Context)`: During [`Commit`](../../learn/advanced/00-baseapp.md#commit), this function is called from `BaseApp` immediately after the [`deliverState`](../../learn/advanced/00-baseapp.md#state-updates) is written to the underlying [`rootMultiStore`](../../learn/advanced/04-store.md#commitmultistore) and, in turn calls the `PrepareCheckState` function of each module implementing the `HasPrepareCheckState` interface, in the order defined in `OrderPrepareCheckStaters`. It creates a child [context](../../learn/advanced/02-context.md) where the underlying `CacheMultiStore` is that of the next block's [`checkState`](../../learn/advanced/00-baseapp.md#state-updates). Writes to this state will be present in the [`checkState`](../../learn/advanced/00-baseapp.md#state-updates) of the next block, and therefore this method can be used to prepare the `checkState` for the next block.
* (Optional) `RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)`: Registers the [`codec.LegacyAmino`s](../../learn/advanced/05-encoding.md#amino) of each of the application module. This function is usually called early on in the [application's construction](../../learn/beginner/00-app-anatomy.md#constructor).
diff --git a/docs/build/building-modules/02-messages-and-queries.md b/docs/build/building-modules/02-messages-and-queries.md
index 4dfeae41e4c6..5ec1c7a707e9 100644
--- a/docs/build/building-modules/02-messages-and-queries.md
+++ b/docs/build/building-modules/02-messages-and-queries.md
@@ -97,7 +97,7 @@ A `query` is a request for information made by end-users of applications through
### gRPC Queries
-Queries should be defined using [Protobuf services](https://developers.google.com/protocol-buffers/docs/proto#services). A `Query` service should be created per module in `query.proto`. This service lists endpoints starting with `rpc`.
+Queries should be defined using [Protobuf services](https://protobuf.dev/programming-guides/proto2/). A `Query` service should be created per module in `query.proto`. This service lists endpoints starting with `rpc`.
Here's an example of such a `Query` service definition:
diff --git a/docs/build/building-modules/06-beginblock-endblock.md b/docs/build/building-modules/06-preblock-beginblock-endblock.md
similarity index 62%
rename from docs/build/building-modules/06-beginblock-endblock.md
rename to docs/build/building-modules/06-preblock-beginblock-endblock.md
index 21c1a3303d3f..a7a890eff19c 100644
--- a/docs/build/building-modules/06-beginblock-endblock.md
+++ b/docs/build/building-modules/06-preblock-beginblock-endblock.md
@@ -2,10 +2,11 @@
sidebar_position: 1
---
-# BeginBlocker and EndBlocker
+# PreBlocker, BeginBlocker and EndBlocker
:::note Synopsis
-`BeginBlocker` and `EndBlocker` are optional methods module developers can implement in their module. They will be triggered at the beginning and at the end of each block respectively, when the [`BeginBlock`](../../learn/advanced/00-baseapp.md#beginblock) and [`EndBlock`](../../learn/advanced/00-baseapp.md#endblock) ABCI messages are received from the underlying consensus engine.
+`PreBlocker`, `BeginBlocker` and `EndBlocker` are optional methods module developers can implement in their module.
+They will be triggered at the beginning and at the end of each block respectively, when the [`BeginBlock`](../../learn/advanced/00-baseapp.md#beginblock) and [`EndBlock`](../../learn/advanced/00-baseapp.md#endblock) inside within ABCI `FinalizeBlock`
:::
:::note Pre-requisite Readings
@@ -14,11 +15,22 @@ sidebar_position: 1
:::
+## PreBlocker
+
+There are two semantics around the new lifecycle method:
+
+* It runs before the `BeginBlocker` of all modules
+* It can modify consensus parameters in storage, and signal the caller through the return value.
+
+:::warning
+Modules are required to get the consensus params from the consensus module. Consensus params located in `sdk.Context` were deprecated and should be treated as unsafe. `sdk.Context` is deprecated due to it being a global state within the entire state machine, it has been replaced with `appmodule.Environment`.
+:::
+
## BeginBlocker and EndBlocker
`BeginBlocker` and `EndBlocker` are a way for module developers to add automatic execution of logic to their module. This is a powerful tool that should be used carefully, as complex automatic functions can slow down or even halt the chain.
-In 0.47.0, Prepare and Process Proposal were added that allow app developers to do arbitrary work at those phases, but they do not influence the work that will be done in BeginBlock. If an application required `BeginBlock` to execute prior to any sort of work is done then this is not possible today (0.50.0).
+In 0.47.0, `PrepareProposal` and `ProcessProposal` were added that allow app developers to do arbitrary work at those phases, but they do not influence the work that will be done in `BeginBlock`, nor are they accessible from modules.
When needed, `BeginBlocker` and `EndBlocker` are implemented as part of the [`HasBeginBlocker`, `HasABCIEndBlocker` and `EndBlocker` interfaces](./01-module-manager.md#appmodule). This means either can be left-out if not required. The `BeginBlock` and `EndBlock` methods of the interface implemented in `module.go` generally defer to `BeginBlocker` and `EndBlocker` methods respectively, which are usually implemented in `abci.go`.
@@ -28,10 +40,18 @@ The actual implementation of `BeginBlocker` and `EndBlocker` in `abci.go` are ve
* If needed, they use the `keeper` and `ctx` to trigger state-transitions.
* If needed, they can emit [`events`](../../learn/advanced/08-events.md) via the `environments`'s `EventManager`.
-A specific method (`UpdateValidators`) is available to return validator updates to the underlying consensus engine in the form of an [`[]appmodule.ValidatorUpdates`](https://github.com/cosmos/cosmos-sdk/blob/07151304e2ec6a185243d083f59a2d543253cb15/core/appmodule/v2/module.go#L87-L101). This is the preferred way to implement custom validator changes.
+A specific method (`UpdateValidators`) is available to return validator updates to the underlying consensus engine in the form of an [`[]appmodule.ValidatorUpdates`](https://github.com/cosmos/cosmos-sdk/blob/07151304e2ec6a185243d083f59a2d543253cb15/core/appmodule/v2/module.go#L87-L101). This is the preferred way to implement custom validator changes (in v1).
It is possible for developers to define the order of execution between the `BeginBlocker`/`EndBlocker` functions of each of their application's modules via the module's manager `SetOrderBeginBlocker`/`SetOrderEndBlocker` methods. For more on the module manager, click [here](./01-module-manager.md#manager).
+### Implementation
+
+A module must implement those core interface to make use of the `PreBlocker`, `BeginBlocker` or `EndBlocker` capabilities:
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/core/v1.0.0-alpha.4/core/appmodule/v2/module.go#L22-L48
+```
+
See an example implementation of `BeginBlocker` from the `distribution` module:
```go reference
@@ -49,6 +69,3 @@ and an example implementation of `EndBlocker` with validator updates from the `s
```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/staking/keeper/abci.go#L12-L17
```
-
-
-
diff --git a/docs/build/building-modules/07-invariants.md b/docs/build/building-modules/07-invariants.md
deleted file mode 100644
index 2e8edfcada68..000000000000
--- a/docs/build/building-modules/07-invariants.md
+++ /dev/null
@@ -1,92 +0,0 @@
----
-sidebar_position: 1
----
-
-# Invariants
-
-
-
-:::note Synopsis
-An invariant is a property of the application that should always be true. In the context of the Cosmos SDK, an `Invariant` is a function that checks for a particular invariant. These functions are useful to detect bugs early on and act upon them to limit their potential consequences (e.g. by halting the chain). They are also useful in the development process of the application to detect bugs via simulations.
-:::
-
-:::note Pre-requisite Readings
-
-* [Keepers](./06-keeper.md)
-
-:::
-
-## Implementing `Invariant`s
-
-An `Invariant` is a function that checks for a particular invariant within a module. Module `Invariant`s must follow the `Invariant` type:
-
-```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/invariant.go#L9
-```
-
-The `string` return value is the invariant message, which can be used when printing logs, and the `bool` return value is the actual result of the invariant check.
-
-In practice, each module implements `Invariant`s in a `keeper/invariants.go` file within the module's folder. The standard is to implement one `Invariant` function per logical grouping of invariants with the following model:
-
-```go
-// Example for an Invariant that checks balance-related invariants
-
-func BalanceInvariants(k Keeper) sdk.Invariant {
- return func(ctx context.Context) (string, bool) {
- // Implement checks for balance-related invariants
- }
-}
-```
-
-Additionally, module developers should generally implement an `AllInvariants` function that runs all the `Invariant`s functions of the module:
-
-```go
-// AllInvariants runs all invariants of the module.
-// In this example, the module implements two Invariants: BalanceInvariants and DepositsInvariants
-
-func AllInvariants(k Keeper) sdk.Invariant {
-
- return func(ctx context.Context) (string, bool) {
- res, stop := BalanceInvariants(k)(ctx)
- if stop {
- return res, stop
- }
-
- return DepositsInvariant(k)(ctx)
- }
-}
-```
-
-Finally, module developers need to implement the `RegisterInvariants` method as part of the [`AppModule` interface](./01-module-manager.md#appmodule). Indeed, the `RegisterInvariants` method of the module, implemented in the `module/module.go` file, typically only defers the call to a `RegisterInvariants` method implemented in the `keeper/invariants.go` file. The `RegisterInvariants` method registers a route for each `Invariant` function in the [`InvariantRegistry`](#invariant-registry):
-
-```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/staking/keeper/invariants.go#L12-L22
-```
-
-For more, see an example of [`Invariant`s implementation from the `staking` module](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/staking/keeper/invariants.go).
-
-## Invariant Registry
-
-The `InvariantRegistry` is a registry where the `Invariant`s of all the modules of an application are registered. There is only one `InvariantRegistry` per **application**, meaning module developers need not implement their own `InvariantRegistry` when building a module. **All module developers need to do is to register their modules' invariants in the `InvariantRegistry`, as explained in the section above**. The rest of this section gives more information on the `InvariantRegistry` itself, and does not contain anything directly relevant to module developers.
-
-At its core, the `InvariantRegistry` is defined in the Cosmos SDK as an interface:
-
-```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/invariant.go#L14-L17
-```
-
-Typically, this interface is implemented in the `keeper` of a specific module. The most used implementation of an `InvariantRegistry` can be found in the `crisis` module:
-
-```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/crisis/keeper/keeper.go#L48-L50
-```
-
-The `InvariantRegistry` is therefore typically instantiated by instantiating the `keeper` of the `crisis` module in the [application's constructor function](../../learn/beginner/00-app-anatomy.md#constructor-function).
-
-`Invariant`s can be checked manually via [`message`s](./02-messages-and-queries.md), but most often they are checked automatically at the end of each block. Here is an example from the `crisis` module:
-
-```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/crisis/abci.go#L13-L23
-```
-
-In both cases, if one of the `Invariant`s returns false, the `InvariantRegistry` can trigger special logic (e.g. have the application panic and print the `Invariant`s message in the log).
diff --git a/docs/build/building-modules/15-depinject.md b/docs/build/building-modules/15-depinject.md
index e9a5f4486eb9..c07c9aa96d20 100644
--- a/docs/build/building-modules/15-depinject.md
+++ b/docs/build/building-modules/15-depinject.md
@@ -52,7 +52,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/api/cosmos/group/modul
```
:::note
-Pulsar is optional. The official [`protoc-gen-go`](https://developers.google.com/protocol-buffers/docs/reference/go-generated) can be used as well.
+Pulsar is optional. The official [`protoc-gen-go`](https://protobuf.dev/reference/go/go-generated/) can be used as well.
:::
## Dependency Definition
diff --git a/docs/build/building-modules/16-testing.md b/docs/build/building-modules/16-testing.md
index 65ed52a8a142..6b9441bbee06 100644
--- a/docs/build/building-modules/16-testing.md
+++ b/docs/build/building-modules/16-testing.md
@@ -104,7 +104,7 @@ System tests are at the top of the [test pyramid](https://martinfowler.com/artic
They test the whole application flow as black box, from the user perspective. They are located under [`/tests/systemtests`](https://github.com/cosmos/cosmos-sdk/tree/main/tests/systemtests).
For that, the SDK is using the `simapp` binary, but you should use your own binary.
-More details about system test can be found in [building-apps](https://docs.cosmos.network/main/build/building-apps/06-system-tests.md)
+More details about system test can be found in [building-apps](https://docs.cosmos.network/main/build/building-apps/system-tests)
## Learn More
diff --git a/docs/build/building-modules/17-preblock.md b/docs/build/building-modules/17-preblock.md
deleted file mode 100644
index 81c81bd94b63..000000000000
--- a/docs/build/building-modules/17-preblock.md
+++ /dev/null
@@ -1,24 +0,0 @@
----
-sidebar_position: 1
----
-
-# PreBlocker
-
-:::note Synopsis
-`PreBlocker` is optional method module developers can implement in their module. They will be triggered before [`BeginBlock`](../../learn/advanced/00-baseapp.md#beginblock).
-:::
-
-:::note Pre-requisite Readings
-
-* [Module Manager](./01-module-manager.md)
-
-:::
-
-## PreBlocker
-
-There are two semantics around the new lifecycle method:
-
-* It runs before the `BeginBlocker` of all modules
-* It can modify consensus parameters in storage, and signal the caller through the return value.
-
-Modules are required to get the consensus params from the consensus module. Consensus params located in `sdk.Context` were deprecated and should be treated as unsafe. `sdk.Context` is deprecated due to it being a global state within the entire state machine, it has been replaced with `appmodule.Environment`.
diff --git a/docs/build/building-modules/18-define-hooks.md b/docs/build/building-modules/18-define-hooks.md
new file mode 100644
index 000000000000..8b19f238b0e9
--- /dev/null
+++ b/docs/build/building-modules/18-define-hooks.md
@@ -0,0 +1,57 @@
+---
+sidebar_position: 1
+---
+
+# Hooks
+
+Hooks are functions that are called before and/or after certain events in the module's lifecycle.
+
+## Defining Hooks
+
+1. Define the hook interface and a wrapper implementing `depinject.OnePerModuleType`:
+
+ ```go reference
+ https://github.com/cosmos/cosmos-sdk/blob/71c603a2a5a103df00f216d78ec8b108ed64ae28/testutil/x/counter/types/expected_keepers.go#L5-L12
+ ```
+
+2. Add a `CounterHooks` field to the keeper:
+
+ ```go reference
+ https://github.com/cosmos/cosmos-sdk/blob/71c603a2a5a103df00f216d78ec8b108ed64ae28/testutil/x/counter/keeper/keeper.go#L25
+
+ ```
+
+3. Create a `depinject` invoker function
+
+ ```go reference
+ https://github.com/cosmos/cosmos-sdk/blob/71c603a2a5a103df00f216d78ec8b108ed64ae28/testutil/x/counter/depinject.go#L53-L75
+ ```
+
+4. Inject the hooks during app initialization:
+
+ ```go
+ appConfig = appconfig.Compose(&appv1alpha1.Config{
+ Modules: []*appv1alpha1.ModuleConfig{
+ // ....
+ {
+ Name: types.ModuleName,
+ Config: appconfig.WrapAny(&types.Module{}),
+ },
+ }
+ })
+ appConfig = depinject.Configs(
+ AppConfig(),
+ runtime.DefaultServiceBindings(),
+ depinject.Supply(
+ logger,
+ viper,
+ map[string]types.CounterHooksWrapper{
+ "counter": types.CounterHooksWrapper{&types.Hooks{}},
+ },
+ ))
+ ```
+
+## Examples in the SDK
+
+For examples of hooks implementation in the Cosmos SDK, refer to the [Epochs Hooks documentation](https://docs.cosmos.network/main/build/modules/epochs#hooks) and [Distribution Hooks Documentation](https://docs.cosmos.network/main/build/modules/distribution#hooks).
+
diff --git a/docs/learn/advanced/00-baseapp.md b/docs/learn/advanced/00-baseapp.md
index 20968f91bd0f..95f1fc9b5b93 100644
--- a/docs/learn/advanced/00-baseapp.md
+++ b/docs/learn/advanced/00-baseapp.md
@@ -49,7 +49,7 @@ management logic.
The `BaseApp` type holds many important parameters for any Cosmos SDK based application.
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/baseapp.go#L58-L182
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/baseapp.go#L63-L191
Let us go through the most important components.
@@ -71,7 +71,7 @@ First, the important parameters that are initialized during the bootstrapping of
* [gRPC Query Router](#grpc-query-router): The `grpcQueryRouter` facilitates the routing of gRPC queries to the
appropriate module for it to be processed. These queries are not ABCI messages themselves, but they
are relayed to the relevant module's gRPC `Query` service.
-* [`TxDecoder`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk/types#TxDecoder): It is used to decode
+* [`TxDecoder`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk@v0.52.0-beta.2/types#TxDecoder): It is used to decode
raw transaction bytes relayed by the underlying CometBFT engine.
* [`AnteHandler`](#antehandler): This handler is used to handle signature verification, fee payment,
and other pre-message execution checks when a transaction is received. It's executed during
@@ -216,7 +216,7 @@ When messages and queries are received by the application, they must be routed t
[`sdk.Msg`s](../../build/building-modules/02-messages-and-queries.md#messages) need to be routed after they are extracted from transactions, which are sent from the underlying CometBFT engine via the [`CheckTx`](#checktx) and [`FinalizeBlock`](#finalizeblock) ABCI messages. To do so, `BaseApp` holds a `msgServiceRouter` which maps fully-qualified service methods (`string`, defined in each module's Protobuf `Msg` service) to the appropriate module's `MsgServer` implementation.
-The [default `msgServiceRouter` included in `BaseApp`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/msg_service_router.go) is stateless. However, some applications may want to make use of more stateful routing mechanisms such as allowing governance to disable certain routes or point them to new modules for upgrade purposes. For this reason, the `sdk.Context` is also passed into each [route handler inside `msgServiceRouter`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/msg_service_router.go#L31-L32). For a stateless router that doesn't want to make use of this, you can just ignore the `ctx`.
+The [default `msgServiceRouter` included in `BaseApp`](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/msg_service_router.go) is stateless. However, some applications may want to make use of more stateful routing mechanisms such as allowing governance to disable certain routes or point them to new modules for upgrade purposes. For this reason, the `sdk.Context` is also passed into each [route handler inside `msgServiceRouter`](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/msg_service_router.go#L42). For a stateless router that doesn't want to make use of this, you can just ignore the `ctx`.
The application's `msgServiceRouter` is initialized with all the routes using the application's [module manager](../../build/building-modules/01-module-manager.md#manager) (via the `RegisterServices` method), which itself is initialized with all the application's modules in the application's [constructor](../beginner/00-app-anatomy.md#constructor-function).
@@ -224,7 +224,7 @@ The application's `msgServiceRouter` is initialized with all the routes using th
Similar to `sdk.Msg`s, [`queries`](../../build/building-modules/02-messages-and-queries.md#queries) need to be routed to the appropriate module's [`Query` service](../../build/building-modules/04-query-services.md). To do so, `BaseApp` holds a `grpcQueryRouter`, which maps modules' fully-qualified service methods (`string`, defined in their Protobuf `Query` gRPC) to their `QueryServer` implementation. The `grpcQueryRouter` is called during the initial stages of query processing, which can be either by directly sending a gRPC query to the gRPC endpoint, or via the [`Query` ABCI message](#query) on the CometBFT RPC endpoint.
-Just like the `msgServiceRouter`, the `grpcQueryRouter` is initialized with all the query routes using the application's [module manager](../../build/building-modules/01-module-manager.md) (via the `RegisterServices` method), which itself is initialized with all the application's modules in the application's [constructor](../beginner/00-app-anatomy.md#app-constructor).
+Just like the `msgServiceRouter`, the `grpcQueryRouter` is initialized with all the query routes using the application's [module manager](../../build/building-modules/01-module-manager.md) (via the `RegisterServices` method), which itself is initialized with all the application's modules in the application's [constructor](../beginner/00-app-anatomy.md#constructor-function).
## Main ABCI 2.0 Messages
@@ -237,7 +237,7 @@ The consensus engine handles two main tasks:
It is **not** the role of the consensus engine to define the state or the validity of transactions. Generally, transactions are handled by the consensus engine in the form of `[]bytes`, and relayed to the application via the ABCI to be decoded and processed. At keys moments in the networking and consensus processes (e.g. beginning of a block, commit of a block, reception of an unconfirmed transaction, ...), the consensus engine emits ABCI messages for the state-machine to act on.
-Developers building on top of the Cosmos SDK need not implement the ABCI themselves, as `BaseApp` comes with a built-in implementation of the interface. Let us go through the main ABCI messages that `BaseApp` implements:
+Developers building on top of the Cosmos SDK don't need to implement the ABCI themselves, as `BaseApp` comes with a built-in implementation of the interface. Let us go through the main ABCI messages that `BaseApp` implements:
* [`Prepare Proposal`](#prepare-proposal)
* [`Process Proposal`](#process-proposal)
@@ -255,7 +255,7 @@ Here is how the `PrepareProposal` function can be implemented:
1. Extract the `sdk.Msg`s from the transaction.
2. Perform _stateful_ checks by calling `Validate()` on each of the `sdk.Msg`'s. This is done after _stateless_ checks as _stateful_ checks are more computationally expensive. If `Validate()` fails, `PrepareProposal` returns before running further checks, which saves resources.
-3. Perform any additional checks that are specific to the application, such as checking account balances, or ensuring that certain conditions are met before a transaction is proposed.hey are processed by the consensus engine, if necessary.
+3. Perform any additional checks that are specific to the application, such as checking account balances, or ensuring that certain conditions are met before a transaction is proposed. They are processed by the consensus engine, if necessary.
4. Return the updated transactions to be processed by the consensus engine
Note that, unlike `CheckTx()`, `PrepareProposal` process `sdk.Msg`s, so it can directly update the state. However, unlike `FinalizeBlock()`, it does not commit the state updates. It's important to exercise caution when using `PrepareProposal` as incorrect coding could affect the overall liveness of the network.
@@ -289,7 +289,7 @@ However, developers must exercise greater caution when using these methods. Inco
* `Status (ProposalStatus)`: Status of the proposal processing
-where `ProposalStatus` can be one of the following status value:
+where `ProposalStatus` can be one of the [following status value](https://docs.cometbft.com/v1.0/spec/abci/abci++_methods#proposalstatus):
```
enum ProposalStatus {
@@ -311,7 +311,7 @@ make the checks **lightweight** because gas fees are not charged for the resourc
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`.
-In the Cosmos SDK, after [decoding transactions](https://docs.cosmos.network/main/learn/advanced/encoding), `CheckTx()` is implemented
+In the Cosmos SDK, after [decoding transactions](./05-encoding.md), `CheckTx()` is implemented
to do the following checks:
1. Extract the `sdk.Msg`s from the transaction.
@@ -351,7 +351,7 @@ The response contains:
* `GasUsed (int64)`: Amount of gas consumed by transaction. During `CheckTx`, this value is computed by multiplying the standard cost of a transaction byte by the size of the raw transaction. Next is an example:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/ante/basic.go#L102
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/auth/ante/basic.go#L141-L144
```
* `Events ([]cmn.KVPair)`: Key-Value tags for filtering and indexing transactions (eg. by account). See [`events`](./08-events.md) for more.
@@ -379,7 +379,7 @@ After that, `RunTx()` calls `ValidateBasic()`, when available and for backward c
Then, the [`anteHandler`](#antehandler) of the application is run (if it exists). In preparation of this step, both the `checkState`/`finalizeBlockState`'s `context` and `context`'s `CacheMultiStore` are branched using the `cacheTxContext()` function.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/baseapp.go#L663-L680
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/baseapp.go#L683-L699
```
This allows `RunTx` not to commit the changes made to the state during the execution of `anteHandler` if it ends up failing. It also prevents the module implementing the `anteHandler` from writing to state, which is an important part of the [object-capabilities](./10-ocap.md) of the Cosmos SDK.
@@ -394,21 +394,21 @@ The `AnteHandler` operates on a copy of the cached context, allowing it to perfo
Key operations performed by the `AnteHandler` include:
-- **Signature Verification**: Ensures that the transaction's signatures are valid.
-- **Sequence Checking**: Verifies and increments the sequence numbers to prevent replay attacks.
-- **Fee Deduction**: Deducts the transaction fees from the accounts involved, typically starting with the first signer.
+* **Signature Verification**: Ensures that the transaction's signatures are valid.
+* **Sequence Checking**: Verifies and increments the sequence numbers to prevent replay attacks.
+* **Fee Deduction**: Deducts the transaction fees from the accounts involved, typically starting with the first signer.
These operations are crucial for maintaining the security and integrity of transactions on the blockchain.
For more detailed examples, see the [`auth` module's `AnteHandler`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth) which is widely used for these purposes.
:::warning
-Ante handlers typically operate at the transaction level. By default, they process only the outermost message of a transaction. However, transactions that embed multiple messages, such as those found in modules like x/authz or x/gov, may have inner messages that are not automatically processed by these default ante handlers. These inner messages are generally routed directly to the [message router](https://docs.cosmos.network/main/learn/advanced/baseapp#msg-service-router) bypassing the ante handlers. To ensure comprehensive processing, custom ante handlers can be designed to recursively inspect and apply necessary checks to all embedded messages within a transaction. This capability must be explicitly implemented to extend the awareness of ante handlers to inner messages.
+Ante handlers typically operate at the transaction level. By default, they process only the outermost message of a transaction. However, transactions that embed multiple messages, such as those found in modules like x/authz or x/gov, may have inner messages that are not automatically processed by these default ante handlers. These inner messages are generally routed directly to the [message router](#msg-service-router) bypassing the ante handlers. To ensure comprehensive processing, custom ante handlers can be designed to recursively inspect and apply necessary checks to all embedded messages within a transaction. This capability must be explicitly implemented to extend the awareness of ante handlers to inner messages.
:::
The `AnteHandler` is a primary line of defense against spam and a second line of defense (the first one being the mempool) against transaction replay with fees deduction and [`sequence`](./01-transactions.md#transaction-generation) checking. It also performs preliminary _stateful_ validity checks like ensuring signatures are valid or that the sender has enough funds to pay for fees, and plays a role in the incentivisation of stakeholders via the collection of transaction fees.
-`BaseApp` holds an `anteHandler` as parameter that is initialized in the [application's constructor](../beginner/00-app-anatomy.md#application-constructor). The most widely used `anteHandler` is the [`auth` module](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/ante/ante.go).
+`BaseApp` holds an `anteHandler` as parameter that is initialized in the [application's constructor](../beginner/00-app-anatomy.md#constructor-function). The most widely used `anteHandler` is the [`auth` module](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/ante/ante.go).
Click [here](../beginner/04-gas-fees.md#antehandler) for more on the `anteHandler`.
@@ -431,7 +431,7 @@ Like `AnteHandler`s, `PostHandler`s are theoretically optional.
Other use cases like unused gas refund can also be enabled by `PostHandler`s.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/posthandler/post.go#L1-L15
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/auth/posthandler/post.go#L1-L15
```
Note, when `PostHandler`s fail, the state from `runMsgs` is also reverted, effectively making the transaction fail.
@@ -455,25 +455,25 @@ The [`FinalizeBlock` ABCI message](https://docs.cometbft.com/v1.0/spec/abci/abci
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/abci.go#L623
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/abci.go#L894
```
#### PreBlock
-* Run the application's [`preBlocker()`](../beginner/00-app-anatomy.md#preblocker), which mainly runs the [`PreBlocker()`](../../build/building-modules/17-preblock.md#preblock) method of each of the modules.
+* Run the application's [`preBlocker()`](../beginner/00-app-anatomy.md#preblocker), which mainly runs the [`PreBlocker()`](../../build/building-modules/06-preblock-beginblock-endblock.md#preblocker) method of each of the modules.
#### BeginBlock
* Initialize [`finalizeBlockState`](#state-updates) with the latest header using the `req abci.RequestFinalizeBlock` passed as parameter via the `setState` function.
```go reference
- https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/baseapp.go#L682-L706
+ https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/baseapp.go#L729-L754
```
This function also resets the [main gas meter](../beginner/04-gas-fees.md#main-gas-meter).
* Initialize the [block gas meter](../beginner/04-gas-fees.md#block-gas-meter) with the `maxGas` limit. The `gas` consumed within the block cannot go above `maxGas`. This parameter is defined in the application's consensus parameters.
-* Run the application's [`beginBlocker()`](../beginner/00-app-anatomy.md#beginblocker-and-endblocker), which mainly runs the [`BeginBlocker()`](../../build/building-modules/06-beginblock-endblock.md#beginblock) method of each of the modules.
+* Run the application's [`beginBlocker()`](../beginner/00-app-anatomy.md#beginblocker-and-endblocker), which mainly runs the [`BeginBlocker()`](../../build/building-modules/06-preblock-beginblock-endblock.md#beginblocker-and-endblocker) method of each of the modules.
* Set the [`VoteInfos`](https://docs.cometbft.com/v1.0/spec/abci/abci++_methods#voteinfo) of the application, i.e. the list of validators whose _precommit_ for the previous block was included by the proposer of the current block. This information is carried into the [`Context`](./02-context.md) so that it can be used during transaction execution and EndBlock.
#### Transaction Execution
@@ -490,8 +490,7 @@ The `FinalizeBlock` ABCI function defined in `BaseApp` does the bulk of the stat
Instead of using their `checkState`, full-nodes use `finalizeblock`:
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/baseapp.go#LL708-L743
-
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/baseapp.go#L756-L791
Transaction execution within `FinalizeBlock` performs the **exact same steps as `CheckTx`**, with a little caveat at step 3 and the addition of a fifth step:
@@ -501,7 +500,7 @@ Transaction execution within `FinalizeBlock` performs the **exact same steps as
During the additional fifth step outlined in (2), each read/write to the store increases the value of `GasConsumed`. You can find the default cost of each operation:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/gas.go#L230-L241
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/gas.go#L231-L242
```
At any point, if `GasConsumed > GasWanted`, the function returns with `Code != 0` and the execution fails.
@@ -524,7 +523,7 @@ Each transaction returns a response to the underlying consensus engine of type [
EndBlock is run after transaction execution completes. It allows developers to have logic be executed at the end of each block. In the Cosmos SDK, the bulk EndBlock() method is to run the application's EndBlocker(), which mainly runs the EndBlocker() method of each of the application's modules.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/baseapp.go#L747-L769
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/baseapp.go#L729-L754
```
### Commit
@@ -560,7 +559,7 @@ Each CometBFT `query` comes with a `path`, which is a `string` which denotes wha
In the Cosmos-SDK this is implemented as a NoOp:
``` go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/abci_utils.go#L274-L281
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/baseapp/abci_utils.go#L456-L462
```
### VerifyVoteExtension
diff --git a/docs/learn/advanced/01-transactions.md b/docs/learn/advanced/01-transactions.md
index 6bb246cfcca8..5eba0acc1759 100644
--- a/docs/learn/advanced/01-transactions.md
+++ b/docs/learn/advanced/01-transactions.md
@@ -25,13 +25,18 @@ When users want to interact with an application and make state changes (e.g. sen
Transaction objects are Cosmos SDK types that implement the `Tx` interface
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/tx_msg.go#L51-L56
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/tx_msg.go#L53-L66
```
It contains the following methods:
* **GetMsgs:** unwraps the transaction and returns a list of contained `sdk.Msg`s - one transaction may have one or multiple messages, which are defined by module developers.
-* **ValidateBasic:** lightweight, [_stateless_](../beginner/01-tx-lifecycle.md#types-of-checks) checks used by ABCI messages [`CheckTx`](./00-baseapp.md#checktx) and [`DeliverTx`](./00-baseapp.md#delivertx) to make sure transactions are not invalid. For example, the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth) module's `ValidateBasic` function checks that its transactions are signed by the correct number of signers and that the fees do not exceed the user's maximum. When [`runTx`](./00-baseapp.md#runtx) is checking a transaction created from the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth/) module, it first runs `ValidateBasic` on each message, then runs the `auth` module AnteHandler which calls `ValidateBasic` for the transaction itself.
+* **ValidateBasic:** lightweight, [_stateless_](../beginner/01-tx-lifecycle.md#types-of-checks) checks used by ABCI messages [`CheckTx`](./00-baseapp.md#checktx) and [`RunTx`](./00-baseapp.md#runtx) to make sure transactions are not invalid. For example, the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth) module's `ValidateBasic` function checks that its transactions are signed by the correct number of signers and that the fees do not exceed the user's maximum. When [`runTx`](./00-baseapp.md#runtx) is checking a transaction created from the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth/) module, it first runs `ValidateBasic` on each message, then runs the `auth` module AnteHandler which calls `ValidateBasic` for the transaction itself.
+* **Hash()**: returns the unique identifier for the Tx.
+* **GetMessages:** returns the list of `sdk.Msg`s contained in the transaction.
+* **GetSenders:** returns the addresses of the signers who signed the transaction.
+* **GetGasLimit:** returns the gas limit for the transaction. Returns `math.MaxUint64` for transactions with unlimited gas.
+* **Bytes:** returns the encoded bytes of the transaction. This is typically cached after the first decoding of the transaction.
:::note
This function is different from the deprecated `sdk.Msg` [`ValidateBasic`](../beginner/01-tx-lifecycle.md#ValidateBasic) methods, which was performing basic validity checks on messages only.
@@ -48,13 +53,13 @@ Every message in a transaction must be signed by the addresses specified by its
The most used implementation of the `Tx` interface is the Protobuf `Tx` message, which is used in `SIGN_MODE_DIRECT`:
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L13-L26
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/proto/cosmos/tx/v1beta1/tx.proto#L15-L28
```
Because Protobuf serialization is not deterministic, the Cosmos SDK uses an additional `TxRaw` type to denote the pinned bytes over which a transaction is signed. Any user can generate a valid `body` and `auth_info` for a transaction, and serialize these two messages using Protobuf. `TxRaw` then pins the user's exact binary representation of `body` and `auth_info`, called respectively `body_bytes` and `auth_info_bytes`. The document that is signed by all signers of the transaction is `SignDoc` (deterministically serialized using [ADR-027](../../architecture/adr-027-deterministic-protobuf-serialization.md)):
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L48-L65
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/proto/cosmos/tx/v1beta1/tx.proto#L50-L67
```
Once signed by all signers, the `body_bytes`, `auth_info_bytes` and `signatures` are gathered into `TxRaw`, whose serialized bytes are broadcasted over the network.
@@ -64,13 +69,13 @@ Once signed by all signers, the `body_bytes`, `auth_info_bytes` and `signatures`
The legacy implementation of the `Tx` interface is the `StdTx` struct from `x/auth`:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/migrations/legacytx/stdtx.go#L83-L90
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/auth/migrations/legacytx/stdtx.go#L81-L91
```
The document signed by all signers is `StdSignDoc`:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/migrations/legacytx/stdsign.go#L31-L45
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/auth/migrations/legacytx/stdsign.go#L32-L45
```
which is encoded into bytes using Amino JSON. Once all signatures are gathered into `StdTx`, `StdTx` is serialized using Amino JSON, and these bytes are broadcasted over the network.
@@ -85,7 +90,7 @@ The Cosmos SDK also provides a couple of other sign modes for particular use cas
need to sign over the fees:
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L67-L98
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/proto/cosmos/tx/v1beta1/tx.proto#L69-L93
```
The use case is a multi-signer transaction, where one of the signers is appointed to gather all signatures, broadcast the signature and pay for fees, and the others only care about the transaction body. This generally allows for a better multi-signing UX. If Alice, Bob and Charlie are part of a 3-signer transaction, then Alice and Bob can both use `SIGN_MODE_DIRECT_AUX` to sign over the `TxBody` and their own signer info (no need an additional step to gather other signers' ones, like in `SIGN_MODE_DIRECT`), without specifying a fee in their SignDoc. Charlie can then gather both signatures from Alice and Bob, and
@@ -104,7 +109,7 @@ If you wish to learn more, please refer to [ADR-050](../../architecture/adr-050-
#### Custom Sign modes
-There is the opportunity to add your own custom sign mode to the Cosmos-SDK. While we can not accept the implementation of the sign mode to the repository, we can accept a pull request to add the custom signmode to the SignMode enum located [here](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/signing/v1beta1/signing.proto#L17)
+There is the opportunity to add your own custom sign mode to the Cosmos-SDK. While we can not accept the implementation of the sign mode to the repository, we can accept a pull request to add the custom signmode to the SignMode enum located [here](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/proto/cosmos/tx/signing/v1beta1/signing.proto#L9-L17)
## Transaction Process
@@ -136,7 +141,7 @@ While messages contain the information for state transition logic, a transaction
The `TxBuilder` interface contains data closely related with the generation of transactions, which an end-user can freely set to generate the desired transaction:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/tx_config.go#L40-L53
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/client/tx_config.go#L39-L57
```
* `Msg`s, the array of [messages](#messages) included in the transaction.
@@ -148,13 +153,13 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/tx_config.go#L4
As there are currently two sign modes for signing transactions, there are also two implementations of `TxBuilder`:
-* [wrapper](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/tx/builder.go#L26-L43) for creating transactions for `SIGN_MODE_DIRECT`,
-* [StdTxBuilder](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/auth/migrations/legacytx/stdtx_builder.go#L14-L17) for `SIGN_MODE_LEGACY_AMINO_JSON`.
+* [builder](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/auth/tx/builder.go#L79-L98) for creating transactions for `SIGN_MODE_DIRECT`,
+* [StdTxBuilder](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/auth/migrations/legacytx/stdtx_builder.go#L11-L17) for `SIGN_MODE_LEGACY_AMINO_JSON`.
However, the two implementations of `TxBuilder` should be hidden away from end-users, as they should prefer using the overarching `TxConfig` interface:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/tx_config.go#L24-L34
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/client/tx_config.go#L27-L37
```
`TxConfig` is an app-wide configuration for managing transactions. Most importantly, it holds the information about whether to sign each transaction with `SIGN_MODE_DIRECT` or `SIGN_MODE_LEGACY_AMINO_JSON`. By calling `txBuilder := txConfig.NewTxBuilder()`, a new `TxBuilder` will be created with the appropriate sign mode.
@@ -187,8 +192,7 @@ simd tx send $MY_VALIDATOR_ADDRESS $RECIPIENT 1000stake
[gRPC](https://grpc.io) is the main component for the Cosmos SDK's RPC layer. Its principal usage is in the context of modules' [`Query` services](../../build/building-modules/04-query-services.md). However, the Cosmos SDK also exposes a few other module-agnostic gRPC services, one of them being the `Tx` service:
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/service.proto
-
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/proto/cosmos/tx/v1beta1/service.proto
The `Tx` service exposes a handful of utility functions, such as simulating a transaction or querying a transaction, and also one method to broadcast transactions.
diff --git a/docs/learn/advanced/02-context.md b/docs/learn/advanced/02-context.md
index 33d530b52988..eb0405df3fab 100644
--- a/docs/learn/advanced/02-context.md
+++ b/docs/learn/advanced/02-context.md
@@ -20,7 +20,7 @@ The `context` is a data structure intended to be passed from function to functio
The Cosmos SDK `Context` is a custom data structure that contains Go's stdlib [`context`](https://pkg.go.dev/context) as its base, and has many additional types within its definition that are specific to the Cosmos SDK. The `Context` is integral to transaction processing in that it allows modules to easily access their respective [store](./04-store.md#base-layer-kvstores) in the [`multistore`](./04-store.md#multistore) and retrieve transactional context such as the block header and gas meter.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/context.go#L41-L67
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/context.go#L40-L64
```
* **Base Context:** The base type is a Go [Context](https://pkg.go.dev/context), which is explained further in the [Go Context Package](#go-context-package) section below.
@@ -32,7 +32,8 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/context.go#L41-L
* **Logger:** A `logger` from the CometBFT libraries. Learn more about logs [here](https://docs.cometbft.com/v1.0/references/config/config.toml#log_level). Modules call this method to create their own unique module-specific logger.
* **VoteInfo:** A list of the ABCI type [`VoteInfo`](https://docs.cometbft.com/v1.0/spec/abci/abci++_methods#voteinfo), which includes the name of a validator and a boolean indicating whether they have signed the block.
* **Gas Meters:** Specifically, a [`gasMeter`](../beginner/04-gas-fees.md#main-gas-meter) for the transaction currently being processed using the context and a [`blockGasMeter`](../beginner/04-gas-fees.md#block-gas-meter) for the entire block it belongs to. Users specify how much in fees they wish to pay for the execution of their transaction; these gas meters keep track of how much [gas](../beginner/04-gas-fees.md) has been used in the transaction or block so far. If the gas meter runs out, execution halts.
-* **CheckTx Mode:** A boolean value indicating whether a transaction should be processed in `CheckTx` or `DeliverTx` mode.
+* **CheckTx Mode:** A boolean value indicating whether a transaction should be processed in `CheckTx` or `DeliverTx` mode. It is deprecated and replaced by `execMode`.
+* **execMode**: defines the execution mode of the transaction.
* **Min Gas Price:** The minimum [gas](../beginner/04-gas-fees.md) price a node is willing to take in order to include a transaction in its block. This price is a local value configured by each node individually, and should therefore **not be used in any functions used in sequences leading to state-transitions**.
* **Consensus Params:** The ABCI type [Consensus Parameters](https://docs.cometbft.com/v1.0/spec/abci/abci++_app_requirements#consensus-parameters), which specify certain limits for the blockchain, such as maximum gas for a block.
* **Event Manager:** The event manager allows any caller with access to a `Context` to emit [`Events`](./08-events.md). Modules may define module specific
diff --git a/docs/learn/advanced/03-node.md b/docs/learn/advanced/03-node.md
index 65dc867939f5..af1cbaf85e0d 100644
--- a/docs/learn/advanced/03-node.md
+++ b/docs/learn/advanced/03-node.md
@@ -24,7 +24,7 @@ In general, developers will implement the `main.go` function with the following
* Then, the `config` is retrieved and config parameters are set. This mainly involves setting the Bech32 prefixes for [addresses](../beginner/03-accounts.md#addresses).
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/config.go#L14-L29
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/config.go#L20-L29
```
* Using [cobra](https://github.com/spf13/cobra), the root command of the full-node client is created. After that, all the custom commands of the application are added using the `AddCommand()` method of `rootCmd`.
@@ -32,13 +32,13 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/config.go#L14-L2
* Prepare and execute the `executor`.
```go reference
-https://github.com/cometbft/cometbft/blob/v0.37.0/libs/cli/setup.go#L74-L78
+https://github.com/cometbft/cometbft/blob/v1.0.0-rc1/libs/cli/setup.go#L74-L78
```
See an example of `main` function from the `simapp` application, the Cosmos SDK's application for demo purposes:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/simd/main.go
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/simapp/simd/main.go
```
## `start` command
@@ -60,25 +60,25 @@ The flow of the `start` command is pretty straightforward. First, it retrieves t
With the `db`, the `start` command creates a new instance of the application using an `appCreator` function:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/server/start.go#L220
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/server/start.go#L201
```
Note that an `appCreator` is a function that fulfills the `AppCreator` signature:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/server/types/app.go#L68
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/server/types/app.go#L69-L71
```
In practice, the [constructor of the application](../beginner/00-app-anatomy.md#constructor-function) is passed as the `appCreator`.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/simd/cmd/root_v2.go#L294-L308
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/server/util.go#L334-L360
```
Then, the instance of `app` is used to instantiate a new CometBFT node:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/server/start.go#L341-L378
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/server/start.go#L367-L410
```
The CometBFT node can be created with `app` because the latter satisfies the [`abci.Application` interface](https://pkg.go.dev/github.com/cometbft/cometbft/api/cometbft/abci/v1#Application) (given that `app` extends [`baseapp`](./00-baseapp.md)). As part of the `node.New` method, CometBFT makes sure that the height of the application (i.e. number of blocks since genesis) is equal to the height of the CometBFT node. The difference between these two heights should always be negative or null. If it is strictly negative, `node.New` will replay blocks until the height of the application reaches the height of the CometBFT node. Finally, if the height of the application is `0`, the CometBFT node will call [`InitChain`](./00-baseapp.md#initchain) on the application to initialize the state from the genesis file.
@@ -86,7 +86,7 @@ The CometBFT node can be created with `app` because the latter satisfies the [`a
Once the CometBFT node is instantiated and in sync with the application, the node can be started:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/server/start.go#L350-L352
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/server/start.go#L383-L384
```
Upon starting, the node will bootstrap its RPC and P2P server and start dialing peers. During handshake with its peers, if the node realizes they are ahead, it will query all the blocks sequentially in order to catch up. Then, it will wait for new block proposals and block signatures from validators in order to make progress.
diff --git a/docs/learn/advanced/04-store.md b/docs/learn/advanced/04-store.md
index 4d084f1a357c..9c5b7dd9913b 100644
--- a/docs/learn/advanced/04-store.md
+++ b/docs/learn/advanced/04-store.md
@@ -36,29 +36,29 @@ flowchart TB
At its very core, a Cosmos SDK `store` is an object that holds a `CacheWrapper` and has a `GetStoreType()` method:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/store.go#L15-L18
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/store.go#L15-L18
```
The `GetStoreType` is a simple method that returns the type of store, whereas a `CacheWrapper` is a simple interface that implements store read caching and write branching through the `Write` method:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/store.go#L287-L320
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/store.go#L287-L303
```
-Branching and cache is used ubiquitously in the Cosmos SDK and required to be implemented on every store type. A storage branch creates an isolated, ephemeral branch of a store that can be passed around and updated without affecting the main underlying store. This is used to trigger temporary state-transitions that may be reverted later should an error occur. Read more about it in [context](./02-context.md#Store-branching)
+Branching and cache is used ubiquitously in the Cosmos SDK and required to be implemented on every store type. A storage branch creates an isolated, ephemeral branch of a store that can be passed around and updated without affecting the main underlying store. This is used to trigger temporary state-transitions that may be reverted later should an error occur. Read more about it in [context](./02-context.md#store-branching)
### Commit Store
A commit store is a store that has the ability to commit changes made to the underlying tree or db. The Cosmos SDK differentiates simple stores from commit stores by extending the basic store interfaces with a `Committer`:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/store.go#L32-L37
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/store.go#L32-L36
```
The `Committer` is an interface that defines methods to persist changes to disk:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/store.go#L20-L30
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/store.go#L20-L30
```
The `CommitID` is a deterministic commit of the state tree. Its hash is returned to the underlying consensus engine and stored in the block header. Note that commit store interfaces exist for various purposes, one of which is to make sure not every object can commit the store. As part of the [object-capabilities model](./10-ocap.md) of the Cosmos SDK, only `baseapp` should have the ability to commit stores. For example, this is the reason why the `ctx.KVStore()` method by which modules typically access stores returns a `KVStore` and not a `CommitKVStore`.
@@ -72,7 +72,7 @@ The Cosmos SDK comes with many types of stores, the most used being [`CommitMult
Each Cosmos SDK application holds a multistore at its root to persist its state. The multistore is a store of `KVStores` that follows the `Multistore` interface:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/store.go#L123-L155
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/store.go#L123-L155
```
If tracing is enabled, then branching the multistore will firstly wrap all the underlying `KVStore` in [`TraceKv.Store`](#tracekv-store).
@@ -82,23 +82,23 @@ If tracing is enabled, then branching the multistore will firstly wrap all the u
The main type of `Multistore` used in the Cosmos SDK is `CommitMultiStore`, which is an extension of the `Multistore` interface:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/store.go#L164-L227
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/store.go#L163-L227
```
-As for concrete implementation, the [`rootMulti.Store`] is the go-to implementation of the `CommitMultiStore` interface.
+As for concrete implementation, the [`rootMulti.Store`](https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/rootmulti/store.go) is the go-to implementation of the `CommitMultiStore` interface.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/rootmulti/store.go#L53-L77
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/rootmulti/store.go#L55-L77
```
The `rootMulti.Store` is a base-layer multistore built around a `db` on top of which multiple `KVStores` can be mounted, and is the default multistore store used in [`baseapp`](./00-baseapp.md).
### CacheMultiStore
-Whenever the `rootMulti.Store` needs to be branched, a [`cachemulti.Store`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/cachemulti/store.go) is used.
+Whenever the `rootMulti.Store` needs to be branched, a [`cachemulti.Store`](https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/cachemulti/store.go) is used.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/cachemulti/store.go#L19-L33
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/cachemulti/store.go#L20-L33
```
`cachemulti.Store` branches all substores (creates a virtual store for each substore) in its constructor and hold them in `Store.stores`. Moreover caches all read queries. `Store.GetKVStore()` returns the store from `Store.stores`, and `Store.Write()` recursively calls `CacheWrap.Write()` on all the substores.
@@ -114,13 +114,13 @@ Individual `KVStore`s are used by modules to manage a subset of the global state
`CommitKVStore`s are declared by proxy of their respective `key` and mounted on the application's [multistore](#multistore) in the [main application file](../beginner/00-app-anatomy.md#core-application-file). In the same file, the `key` is also passed to the module's `keeper` that is responsible for managing the store.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/store.go#L229-L266
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/store.go#L229-L266
```
Apart from the traditional `Get` and `Set` methods, that a `KVStore` must implement via the `BasicKVStore` interface; a `KVStore` must provide an `Iterator(start, end)` method which returns an `Iterator` object. It is used to iterate over a range of keys, typically keys that share a common prefix. Below is an example from the bank's module keeper, used to iterate over all account balances:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/bank/keeper/view.go#L125-L140
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/bank/keeper/view.go#L114-L134
```
### `IAVL` Store
@@ -128,7 +128,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/bank/keeper/view.go#
The default implementation of `KVStore` and `CommitKVStore` used in `baseapp` is the `iavl.Store`.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/iavl/store.go#L35-L40
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/iavl/store.go#L36-L41
```
`iavl` stores are based around an [IAVL Tree](https://github.com/cosmos/iavl), a self-balancing binary tree which guarantees that:
@@ -144,7 +144,7 @@ The documentation on the IAVL Tree is located [here](https://github.com/cosmos/i
`dbadapter.Store` is an adapter for `corestore.KVStoreWithBatch` making it fulfilling the `KVStore` interface.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/dbadapter/store.go#L13-L16
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/dbadapter/store.go#L13-L16
```
`dbadapter.Store` embeds `corestore.KVStoreWithBatch`, meaning most of the `KVStore` interface functions are implemented. The other functions (mostly miscellaneous) are manually implemented. This store is primarily used within [Transient Stores](#transient-store)
@@ -154,7 +154,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/dbadapter/store.
`Transient.Store` is a base-layer `KVStore` which is automatically discarded at the end of the block.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/transient/store.go#L16-L19
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/transient/store.go#L16-L19
```
`Transient.Store` is a `dbadapter.Store` with a `coretesting.NewMemDB()`. All `KVStore` methods are reused. When `Store.Commit()` is called, a new `dbadapter.Store` is assigned, discarding previous reference and making it garbage collected.
@@ -162,13 +162,13 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/transient/store.
This type of store is useful to persist information that is only relevant per-block. One example would be to store parameter changes (i.e. a bool set to `true` if a parameter changed in a block).
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/params/types/subspace.go#L21-L31
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/params/types/subspace.go#L23-L33
```
Transient stores are typically accessed via the [`context`](./02-context.md) via the `TransientStore()` method:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/context.go#L340-L343
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/context.go#L344-L347
```
## KVStore Wrappers
@@ -178,7 +178,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/context.go#L340-
`cachekv.Store` is a wrapper `KVStore` which provides buffered writing / cached reading functionalities over the underlying `KVStore`.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/cachekv/store.go#L26-L36
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/cachekv/store.go#L26-L35
```
This is the type used whenever an IAVL Store needs to be branched to create an isolated store (typically when we need to mutate a state that might be reverted later).
@@ -197,29 +197,29 @@ This is the type used whenever an IAVL Store needs to be branched to create an i
### `GasKv` Store
-Cosmos SDK applications use [`gas`](../beginner/04-gas-fees.md) to track resources usage and prevent spam. [`GasKv.Store`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/gaskv/store.go) is a `KVStore` wrapper that enables automatic gas consumption each time a read or write to the store is made. It is the solution of choice to track storage usage in Cosmos SDK applications.
+Cosmos SDK applications use [`gas`](../beginner/04-gas-fees.md) to track resources usage and prevent spam. [`GasKv.Store`](https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/gaskv/store.go) is a `KVStore` wrapper that enables automatic gas consumption each time a read or write to the store is made. It is the solution of choice to track storage usage in Cosmos SDK applications.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/gaskv/store.go#L11-L17
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/gaskv/store.go#L11-L17
```
When methods of the parent `KVStore` are called, `GasKv.Store` automatically consumes appropriate amount of gas depending on the `Store.gasConfig`:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/gas.go#L219-L228
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/gas.go#L220-L229
```
By default, all `KVStores` are wrapped in `GasKv.Stores` when retrieved. This is done in the `KVStore()` method of the [`context`](./02-context.md):
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/context.go#L335-L338
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/context.go#L339-L342
```
In this case, the gas configuration set in the `context` is used. The gas configuration can be set using the `WithKVGasConfig` method of the `context`.
Otherwise it uses the following default:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/gas.go#L230-L241
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/types/gas.go#L231-L242
```
### `TraceKv` Store
@@ -227,7 +227,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/types/gas.go#L23
`tracekv.Store` is a wrapper `KVStore` which provides operation tracing functionalities over the underlying `KVStore`. It is applied automatically by the Cosmos SDK on all `KVStore` if tracing is enabled on the parent `MultiStore`.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/tracekv/store.go#L20-L43
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/tracekv/store.go#L20-L43
```
When each `KVStore` methods are called, `tracekv.Store` automatically logs `traceOperation` to the `Store.writer`. `traceOperation.Metadata` is filled with `Store.context` when it is not nil. `TraceContext` is a `map[string]interface{}`.
@@ -237,7 +237,7 @@ When each `KVStore` methods are called, `tracekv.Store` automatically logs `trac
`prefix.Store` is a wrapper `KVStore` which provides automatic key-prefixing functionalities over the underlying `KVStore`.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/prefix/store.go#L15-L21
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/prefix/store.go#L15-L21
```
When `Store.{Get, Set}()` is called, the store forwards the call to its parent, with the key prefixed with the `Store.prefix`.
@@ -248,10 +248,10 @@ When `Store.Iterator()` is called, it does not simply prefix the `Store.prefix`,
`listenkv.Store` is a wrapper `KVStore` which provides state listening capabilities over the underlying `KVStore`.
It is applied automatically by the Cosmos SDK on any `KVStore` whose `StoreKey` is specified during state streaming configuration.
-Additional information about state streaming configuration can be found in the [store/streaming/README.md](https://github.com/cosmos/cosmos-sdk/tree/v0.50.0-alpha.0/store/streaming).
+Additional information about state streaming configuration can be found in the [store/streaming/README.md](https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/streaming/README.md).
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/store/listenkv/store.go#L11-L18
+https://github.com/cosmos/cosmos-sdk/blob/store/v1.1.1/store/listenkv/store.go#L11-L18
```
When `KVStore.Set` or `KVStore.Delete` methods are called, `listenkv.Store` automatically writes the operations to the set of `Store.listeners`.
diff --git a/docs/learn/advanced/05-encoding.md b/docs/learn/advanced/05-encoding.md
index 4a3af677d61d..13703f892ecb 100644
--- a/docs/learn/advanced/05-encoding.md
+++ b/docs/learn/advanced/05-encoding.md
@@ -16,14 +16,15 @@ While encoding in the Cosmos SDK used to be mainly handled by `go-amino` codec,
## Encoding
-The Cosmos SDK utilizes two binary wire encoding protocols, [Amino](https://github.com/tendermint/go-amino/) which is an object encoding specification and [Protocol Buffers](https://developers.google.com/protocol-buffers), a subset of Proto3 with an extension for
-interface support. See the [Proto3 spec](https://developers.google.com/protocol-buffers/docs/proto3)
-for more information on Proto3, which Amino is largely compatible with (but not with Proto2).
+The Cosmos SDK supports two wire encoding protocols. Binary encoding is fulfilled by [Protocol
+Buffers](https://protobuf.dev/), specifically the
+[gogoprotobuf](https://github.com/cosmos/gogoproto/) implementation, which is a subset of
+[Proto3](https://protobuf.dev/programming-guides/proto3/) with an extension for
+interface support. Text encoding is fulfilled by [Amino](https://github.com/tendermint/go-amino).
-Due to Amino having significant performance drawbacks, being reflection-based, and
-not having any meaningful cross-language/client support, Protocol Buffers, specifically
-[gogoprotobuf](https://github.com/cosmos/gogoproto/), is being used in place of Amino.
-Note, this process of using Protocol Buffers over Amino is still an ongoing process.
+Due to Amino having significant performance drawbacks, being reflection-based, and not having
+any meaningful cross-language/client support, Amino is only used to generate JSON (Amino
+JSON) in order to support the Amino JSON sign mode, and for JSON RPC endpoints.
Binary wire encoding of types in the Cosmos SDK can be broken down into two main
categories, client encoding and store encoding. Client encoding mainly revolves
@@ -31,23 +32,19 @@ around transaction processing and signing, whereas store encoding revolves aroun
types used in state-machine transitions and what is ultimately stored in the Merkle
tree.
-For store encoding, protobuf definitions can exist for any type and will typically
-have an Amino-based "intermediary" type. Specifically, the protobuf-based type
-definition is used for serialization and persistence, whereas the Amino-based type
-is used for business logic in the state-machine where they may convert back-n-forth.
-Note, the Amino-based types may slowly be phased-out in the future, so developers
-should take note to use the protobuf message definitions where possible.
+For storage encoding, module developers are encouraged to use Protobuf encoding for their types
+but may choose any encoding schema they like. The
+[collections](../../build/packages/02-collections.md) package automatically handles encoding and
+decoding of state for you.
In the `codec` package, there exists two core interfaces, `BinaryCodec` and `JSONCodec`,
where the former encapsulates the current Amino interface except it operates on
types implementing the latter instead of generic `interface{}` types.
-The `ProtoCodec`, where both binary and JSON serialization is handled
-via Protobuf. This means that modules may use Protobuf encoding, but the types must
-implement `ProtoMarshaler`. If modules wish to avoid implementing this interface
-for their types, this is autogenerated via [buf](https://buf.build/)
-
-Modules are recommended to use [collections](../../build/packages/02-collections.md) for handling encoding and decoding of state. Usage of collections handles marshal and unmarshal for you. By default protobuf is used but other encodings can be used if preferred.
+The `ProtoCodec`, where both binary and JSON serialization is handled via Protobuf. This means
+that modules may use Protobuf encoding, but the types must implement `ProtoMarshaler`. If
+modules wish to avoid implementing this interface for their types, this is autogenerated via
+[buf](https://buf.build/)
### Gogoproto
@@ -55,7 +52,7 @@ Modules are encouraged to utilize Protobuf encoding for their respective types.
### Guidelines for protobuf message definitions
-In addition to [following official Protocol Buffer guidelines](https://developers.google.com/protocol-buffers/docs/proto3#simple), we recommend using these annotations in .proto files when dealing with interfaces:
+In addition to [following official Protocol Buffer guidelines](https://protobuf.dev/programming-guides/proto3/#simple), we recommend using these annotations in .proto files when dealing with interfaces:
* use `cosmos_proto.accepts_interface` to annotate `Any` fields that accept interfaces
* pass the same fully qualified name as `protoName` to `InterfaceRegistry.RegisterInterface`
@@ -243,5 +240,5 @@ Protobuf types can be defined to encode:
#### Naming and conventions
-We encourage developers to follow industry guidelines: [Protocol Buffers style guide](https://developers.google.com/protocol-buffers/docs/style)
+We encourage developers to follow industry guidelines: [Protocol Buffers style guide](https://protobuf.dev/programming-guides/style/)
and [Buf](https://buf.build/docs/style-guide), see more details in [ADR 023](../../architecture/adr-023-protobuf-naming.md)
diff --git a/docs/learn/advanced/12-simulation.md b/docs/learn/advanced/12-simulation.md
index c30d398c32e9..6a43bb10ff51 100644
--- a/docs/learn/advanced/12-simulation.md
+++ b/docs/learn/advanced/12-simulation.md
@@ -4,7 +4,7 @@ sidebar_position: 1
# Cosmos Blockchain Simulator
-The Cosmos SDK offers a full fledged simulation framework to fuzz test every
+The Cosmos SDK offers a full fledged simulation framework to [fuzz test](https://en.wikipedia.org/wiki/Fuzzing) every
message defined by a module.
On the Cosmos SDK, this functionality is provided by [`SimApp`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/app_v2.go), which is a `Baseapp` application that is used for running the [`simulation`](https://github.com/cosmos/cosmos-sdk/blob/23cf89cce1882ba9c8280e64735ae200504bfdce/simsx/README.md#L1) package. This package defines all the simulation logic as well as the operations for randomized parameters like accounts, balances etc.
@@ -17,16 +17,15 @@ Its main difference with integration testing is that the simulator app allows yo
## Simulation commands
-The simulation app has different commands, each of which tests a different
+The simulation test setup has different scenarios, each of which tests a different
failure type:
* `AppImportExport`: The simulator exports the initial app state and then it creates a new app with the exported `genesis.json` as an input, checking for inconsistencies between the stores.
* `AppSimulationAfterImport`: Queues two simulations together. The first one provides the app state (_i.e_ genesis) to the second. Useful to test software upgrades or hard-forks from a live chain.
-* `AppStateDeterminism`: Checks that all the nodes return the same values, in the same order.
+* `AppStateDeterminism`: Runs a few seeds many times to test that the apphash is deterministic across the runs.
* `BenchmarkInvariants`: Analysis of the performance of running all modules' invariants (_i.e_ sequentially runs a [benchmark](https://pkg.go.dev/testing/#hdr-Benchmarks) test). An invariant checks for differences between the values that are on the store and the passive tracker. Eg: total coins held by accounts vs total supply tracker.
* `FullAppSimulation`: General simulation mode. Runs the chain and the specified operations for a given number of blocks. Tests that there're no `panics` on the simulation. It does also run invariant checks on every `Period` but they are not benchmarked.
* `FuzzFullAppSimulation`: Runs general simulation mode with the [go fuzzer](https://go.dev/doc/security/fuzz/) to find panics.
-* `AppStateDeterminism`: Runs a few seeds many times to test that the apphash is deterministic across the runs.
Each simulation must receive a set of inputs (_i.e_ flags) such as the number of
blocks that the simulation is run, seed, block size, etc.
@@ -66,13 +65,10 @@ Here are some suggestions when encountering a simulation failure:
involved.
* Reduce the simulation `-Period`. This will run the invariants checks more
frequently.
-* Print all the failed invariants at once with `-PrintAllInvariants`.
* Try using another `-Seed`. If it can reproduce the same error and if it fails
sooner, you will spend less time running the simulations.
* Reduce the `-NumBlocks` . How's the app state at the height previous to the
failure?
-* Run invariants on every operation with `-SimulateEveryOperation`. _Note_: this
- will slow down your simulation **a lot**.
* Try adding logs to operations that are not logged. You will have to define a
[Logger](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/staking/keeper/keeper.go#L65-L68) on your `Keeper`.
diff --git a/docs/learn/advanced/17-core.md b/docs/learn/advanced/17-core.md
new file mode 100644
index 000000000000..b6a453fbb130
--- /dev/null
+++ b/docs/learn/advanced/17-core.md
@@ -0,0 +1,141 @@
+---
+sidebar_position: 1
+---
+
+# Core
+
+Core is package which specifies the interfaces for core components of the Cosmos SDK. Other
+packages in the SDK implement these interfaces to provide the core functionality. This design
+provides modularity and flexibility to the SDK, allowing developers to swap out implementations
+of core components as needed. As such it is often referred to as the Core API.
+
+## Environment
+
+The `Environment` struct is a core component of the Cosmos SDK. It provides access to the core
+services of the SDK, such as the KVStore, EventManager, and Logger. The `Environment` struct is
+passed to modules and other components of the SDK to provide access to these services.
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/core/v1.0.0-alpha.4/core/appmodule/v2/environment.go#L16-L29
+```
+
+Historically the SDK has used an [sdk.Context](02-context.md) to pass around services and data.
+`Environment` is a newer construct that is intended to replace an `sdk.Context` in many cases.
+`sdk.Context` will be deprecated in the future on the same timeline as [Baseapp](00-baseapp.md).
+
+## Branch Service
+
+The [BranchService](https://pkg.go.dev/cosmossdk.io/core/branch#Service.Execute) provides an
+interface to execute arbitrary code in a branched store. This is useful for executing code
+that needs to make changes to the store, but may need to be rolled back if an error occurs.
+Below is a contrived example based on the `x/epoch` module's BeginBlocker logic.
+
+```go
+func (k Keeper) BeginBlocker(ctx context.Context) error {
+ err := k.EpochInfo.Walk(
+ // ...
+ ctx,
+ nil,
+ func(key string, epochInfo types.EpochInfo) (stop bool, err error) {
+ // ...
+ if err := k.BranchService.Execute(ctx, func(ctx context.Context) error {
+ return k.AfterEpochEnd(ctx, epochInfo.Identifier, epochInfo.CurrentEpoch)
+ }); err != nil {
+ return true, err
+ }
+ })
+}
+```
+
+Note that calls to `BranchService.Execute` are atomic and cannot share state with each other
+except when the transaction is successful. If successful, the changes made to the store will be
+committed. If an error occurs, the changes will be rolled back.
+
+## Event Service
+
+The Event Service returns a handle to an [EventManager](https://pkg.go.dev/cosmossdk.io/core@v1.0.0-alpha.4/event#Manager)
+which can be used to emit events. For information on how to emit events and their meaning
+in the SDK see the [Events](08-events.md) document.
+
+Note that core's `EventManager` API is a subset of the EventManager API described above; the
+latter will be deprecated and removed in the future. Roughly speaking legacy `EmitTypeEvent`
+maps to `Emit` and legacy `EmitEvent` maps to `EmitKV`.
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/core/v1.0.0-alpha.4/core/event/service.go#L18-L29
+```
+
+## Gas Service
+
+The gas service encapsulates both gas configuration and a gas meter. Gas consumption is largely
+handled at the framework level for transaction processing and state access but modules can
+choose to use the gas service directly if needed.
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/core/v1.0.0-alpha.4/core/gas/service.go#L26-L54
+```
+
+## Header Service
+
+The header service provides access to the current block header. This is useful for modules that
+need to access the block header fields like `Time` and `Height` during transaction processing.
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/a3729c1ad6ba2fb46f879ec7ea67c3afc02e9859/core/header/service.go#L11-L23
+```
+
+### Custom Header Service
+
+Core's service oriented architecture (SOA) allows for chain developers to define a custom
+implementation of the `HeaderService` interface. This would involve creating a new struct that
+satisfies `HeaderService` but composes additional logic on top. An example of where this would
+happen (when using depinject is shown below). Note this example is taken from `runtime/v2` but
+could easily be adapted to `runtime/v1` (the default runtime 0.52). This same pattern can be
+replicated for any core service.
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/489aaae40234f1015a7bbcfa9384a89dc8de8153/runtime/v2/module.go#L262-L288
+```
+
+These bindings are applied to the `depinject` container in simapp/v2 as shown below.
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/489aaae40234f1015a7bbcfa9384a89dc8de8153/simapp/v2/app_di.go#L72-L74
+```
+
+## Query and Message Router Service
+
+Both the query and message router services are implementation of the same interface, `router.Service`.
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/core/v1.0.0-alpha.4/core/router/service.go#L11-L16
+```
+
+Both are exposed to modules so that arbitrary messages and queries can be routed to the
+appropriate handler. This powerful abstraction allows module developers to fully decouple
+modules from each other by using only the proto message for dispatching. This is particularly
+useful for modules like `x/accounts` which require a dynamic dispatch mechanism in order to
+function.
+
+## TransactionService
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/core/v1.0.0-alpha.4/core/transaction/service.go#L21-L25
+```
+
+The transaction service provides access to the execution mode a state machine transaction is
+running in, which may be one of `Check`, `Recheck`, `Simulate` or `Finalize`. The SDK primarily
+uses these flags in ante handlers to skip certain checks while in `Check` or `Simulate` modes,
+but module developers may find uses for them as well.
+
+## KVStore Service
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/core/v1.0.0-alpha.4/core/store/service.go#L5-L11
+```
+
+The KVStore service abstracts access to, and creation of, key-value stores. Most use cases will
+be backed by a merkle-tree store, but developers can provide their own implementations if
+needed. In the case of the `KVStoreService` implementation provided in `Environment`, module
+developers should understand that calling `OpenKVStore` will return a store already scoped to
+the module's prefix. The wiring for this scoping is specified in `runtime`.
diff --git a/docs/learn/beginner/00-app-anatomy.md b/docs/learn/beginner/00-app-anatomy.md
index 9757e7e95af3..edd8611c3e46 100644
--- a/docs/learn/beginner/00-app-anatomy.md
+++ b/docs/learn/beginner/00-app-anatomy.md
@@ -59,17 +59,17 @@ In general, the core of the state-machine is defined in a file called `app.go`.
The first thing defined in `app.go` is the `type` of the application. It is generally comprised of the following parts:
-* **A reference to [`baseapp`](../advanced/00-baseapp.md).** The custom application defined in `app.go` is an extension of `baseapp`. When a transaction is relayed by CometBFT to the application, `app` uses `baseapp`'s methods to route them to the appropriate module. `baseapp` implements most of the core logic for the application, including all the [ABCI methods](https://docs.cometbft.com/v1.0/spec/abci/) and the [routing logic](../advanced/00-baseapp.md#routing).
+* **A reference to [`baseapp`](../advanced/00-baseapp.md).** The custom application defined in `app.go` is an extension of `baseapp`. When a transaction is relayed by CometBFT to the application, `app` uses `baseapp`'s methods to route them to the appropriate module. `baseapp` implements most of the core logic for the application, including all the [ABCI methods](https://docs.cometbft.com/v1.0/spec/abci/) and the [routing logic](../advanced/00-baseapp.md#service-routers).
* **A list of store keys**. The [store](../advanced/04-store.md), which contains the entire state, is implemented as a [`multistore`](../advanced/04-store.md#multistore) (i.e. a store of stores) in the Cosmos SDK. Each module uses one or multiple stores in the multistore to persist their part of the state. These stores can be accessed with specific keys that are declared in the `app` type. These keys, along with the `keepers`, are at the heart of the [object-capabilities model](../advanced/10-ocap.md) of the Cosmos SDK.
* **A list of module's `keeper`s.** Each module defines an abstraction called [`keeper`](../../build/building-modules/06-keeper.md), which handles reads and writes for this module's store(s). The `keeper`'s methods of one module can be called from other modules (if authorized), which is why they are declared in the application's type and exported as interfaces to other modules so that the latter can only access the authorized functions.
* **A reference to an [`appCodec`](../advanced/05-encoding.md).** The application's `appCodec` is used to serialize and deserialize data structures in order to store them, as stores can only persist `[]bytes`. The default codec is [Protocol Buffers](../advanced/05-encoding.md).
* **A reference to a [`legacyAmino`](../advanced/05-encoding.md) codec.** Some parts of the Cosmos SDK have not been migrated to use the `appCodec` above, and are still hardcoded to use Amino. Other parts explicitly use Amino for backwards compatibility. For these reasons, the application still holds a reference to the legacy Amino codec. Please note that the Amino codec will be removed from the SDK in the upcoming releases.
-* **A reference to a [module manager](../../build/building-modules/01-module-manager.md#manager)**. The module manager is an object that contains a list of the application's modules. It facilitates operations related to these modules, like registering their [`Msg` service](../advanced/00-baseapp.md#msg-services) and [gRPC `Query` service](../advanced/00-baseapp.md#grpc-query-services), or setting the order of execution between modules for various functions like [`InitChainer`](#initchainer), [`PreBlocker`](#preblocker) and [`BeginBlocker` and `EndBlocker`](#beginblocker-and-endblocker).
+* **A reference to a [module manager](../../build/building-modules/01-module-manager.md#manager)**. The module manager is an object that contains a list of the application's modules. It facilitates operations related to these modules, like registering their [`Msg` service](../../build/building-modules/03-msg-services.md) and [gRPC `Query` service](#grpc-query-services), or setting the order of execution between modules for various functions like [`InitChainer`](#initchainer), [`PreBlocker`](#preblocker) and [`BeginBlocker` and `EndBlocker`](#beginblocker-and-endblocker).
See an example of application type definition from `simapp`, the Cosmos SDK's own app used for demo and testing purposes:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/app.go#L173-L212
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/simapp/app.go#L145-L186
```
### Constructor Function
@@ -77,7 +77,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/app.go#L173-L21
Also defined in `app.go` is the constructor function, which constructs a new application of the type defined in the preceding section. The function must fulfill the `AppCreator` signature in order to be used in the [`start` command](../advanced/03-node.md#start-command) of the application's daemon command.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/server/types/app.go#L66-L68
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/server/types/app.go#L66-L68
```
Here are the main actions performed by this function:
@@ -86,8 +86,7 @@ Here are the main actions performed by this function:
* Instantiate a new application with a reference to a `baseapp` instance, a codec, and all the appropriate store keys.
* Instantiate all the [`keeper`](#keeper) objects defined in the application's `type` using the `NewKeeper` function of each of the application's modules. Note that keepers must be instantiated in the correct order, as the `NewKeeper` of one module might require a reference to another module's `keeper`.
* Instantiate the application's [module manager](../../build/building-modules/01-module-manager.md#manager) with the [`AppModule`](#application-module-interface) object of each of the application's modules.
-* With the module manager, initialize the application's [`Msg` services](../advanced/00-baseapp.md#msg-services), [gRPC `Query` services](../advanced/00-baseapp.md#grpc-query-services), [legacy `Msg` routes](../advanced/00-baseapp.md#routing), and [legacy query routes](../advanced/00-baseapp.md#query-routing). When a transaction is relayed to the application by CometBFT via the ABCI, it is routed to the appropriate module's [`Msg` service](#msg-services) using the routes defined here. Likewise, when a gRPC query request is received by the application, it is routed to the appropriate module's [`gRPC query service`](#grpc-query-services) using the gRPC routes defined here. The Cosmos SDK still supports legacy `Msg`s and legacy CometBFT queries, which are routed using the legacy `Msg` routes and the legacy query routes, respectively.
-* With the module manager, register the [application's modules' invariants](../../build/building-modules/07-invariants.md). Invariants are variables (e.g. total supply of a token) that are evaluated at the end of each block. The process of checking invariants is done via a special module called the [`InvariantsRegistry`](../../build/building-modules/07-invariants.md#invariant-registry). The value of the invariant should be equal to a predicted value defined in the module. Should the value be different than the predicted one, special logic defined in the invariant registry is triggered (usually the chain is halted). This is useful to make sure that no critical bug goes unnoticed, producing long-lasting effects that are hard to fix.
+* With the module manager, initialize the application's [`Msg` services](../../build/building-modules/03-msg-services.md), [gRPC `Query` services](#grpc-query-services), [legacy `Msg` routes](../advanced/00-baseapp.md#routing), and [legacy query routes](../advanced/00-baseapp.md#query-routing). When a transaction is relayed to the application by CometBFT via the ABCI, it is routed to the appropriate module's [`Msg` service](#msg-services) using the routes defined here. Likewise, when a gRPC query request is received by the application, it is routed to the appropriate module's [`gRPC query service`](#grpc-query-services) using the gRPC routes defined here. The Cosmos SDK still supports legacy `Msg`s and legacy CometBFT queries, which are routed using the legacy `Msg` routes and the legacy query routes, respectively.
* With the module manager, set the order of execution between the `InitGenesis`, `PreBlocker`, `BeginBlocker`, and `EndBlocker` functions of each of the [application's modules](#application-module-interface). Note that not all modules implement these functions.
* Set the remaining application parameters:
* [`InitChainer`](#initchainer): used to initialize the application when it is first started.
@@ -102,19 +101,19 @@ Note that the constructor function only creates an instance of the app, while th
See an example of application constructor from `simapp`:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/app.go#L223-L575
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/simapp/app.go#L199-L643
```
### InitChainer
-The `InitChainer` is a function that initializes the state of the application from a genesis file (i.e. token balances of genesis accounts). It is called when the application receives the `InitChain` message from the CometBFT engine, which happens when the node is started at `appBlockHeight == 0` (i.e. on genesis). The application must set the `InitChainer` in its [constructor](#constructor-function) via the [`SetInitChainer`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk/baseapp#BaseApp.SetInitChainer) method.
+The `InitChainer` is a function that initializes the state of the application from a genesis file (i.e. token balances of genesis accounts). It is called when the application receives the `InitChain` message from the CometBFT engine, which happens when the node is started at `appBlockHeight == 0` (i.e. on genesis). The application must set the `InitChainer` in its [constructor](#constructor-function) via the [`SetInitChainer`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk@v0.52.0-beta.1/baseapp#BaseApp.SetInitChainer) method.
In general, the `InitChainer` is mostly composed of the [`InitGenesis`](../../build/building-modules/08-genesis.md#initgenesis) function of each of the application's modules. This is done by calling the `InitGenesis` function of the module manager, which in turn calls the `InitGenesis` function of each of the modules it contains. Note that the order in which the modules' `InitGenesis` functions must be called has to be set in the module manager using the [module manager's](../../build/building-modules/01-module-manager.md) `SetOrderInitGenesis` method. This is done in the [application's constructor](#constructor-function), and the `SetOrderInitGenesis` has to be called before the `SetInitChainer`.
See an example of an `InitChainer` from `simapp`:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/app.go#L626-L634
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/simapp/app.go#L714-L726
```
### PreBlocker
@@ -134,24 +133,24 @@ The new ctx must be passed to all the other lifecycle methods.
### BeginBlocker and EndBlocker
-The Cosmos SDK offers developers the possibility to implement automatic execution of code as part of their application. This is implemented through two functions called `BeginBlocker` and `EndBlocker`. They are called when the application receives the `FinalizeBlock` messages from the CometBFT consensus engine, which happens respectively at the beginning and at the end of each block. The application must set the `BeginBlocker` and `EndBlocker` in its [constructor](#constructor-function) via the [`SetBeginBlocker`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk/baseapp#BaseApp.SetBeginBlocker) and [`SetEndBlocker`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk/baseapp#BaseApp.SetEndBlocker) methods.
+The Cosmos SDK offers developers the possibility to implement automatic execution of code as part of their application. This is implemented through two functions called `BeginBlocker` and `EndBlocker`. They are called when the application receives the `FinalizeBlock` messages from the CometBFT consensus engine, which happens respectively at the beginning and at the end of each block. The application must set the `BeginBlocker` and `EndBlocker` in its [constructor](#constructor-function) via the [`SetBeginBlocker`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk@v0.52.0-beta.1/baseapp#BaseApp.SetBeginBlocker) and [`SetEndBlocker`](https://pkg.go.dev/github.com/cosmos/cosmos-sdk@v0.52.0-beta.1/baseapp#BaseApp.SetEndBlocker) methods.
-In general, the `BeginBlocker` and `EndBlocker` functions are mostly composed of the [`BeginBlock` and `EndBlock`](../../build/building-modules/06-beginblock-endblock.md) functions of each of the application's modules. This is done by calling the `BeginBlock` and `EndBlock` functions of the module manager, which in turn calls the `BeginBlock` and `EndBlock` functions of each of the modules it contains. Note that the order in which the modules' `BeginBlock` and `EndBlock` functions must be called has to be set in the module manager using the `SetOrderBeginBlockers` and `SetOrderEndBlockers` methods, respectively. This is done via the [module manager](../../build/building-modules/01-module-manager.md) in the [application's constructor](#constructor-function), and the `SetOrderBeginBlockers` and `SetOrderEndBlockers` methods have to be called before the `SetBeginBlocker` and `SetEndBlocker` functions.
+In general, the `BeginBlocker` and `EndBlocker` functions are mostly composed of the [`BeginBlock` and `EndBlock`](../../build/building-modules/06-preblock-beginblock-endblock.md) functions of each of the application's modules. This is done by calling the `BeginBlock` and `EndBlock` functions of the module manager, which in turn calls the `BeginBlock` and `EndBlock` functions of each of the modules it contains. Note that the order in which the modules' `BeginBlock` and `EndBlock` functions must be called has to be set in the module manager using the `SetOrderBeginBlockers` and `SetOrderEndBlockers` methods, respectively. This is done via the [module manager](../../build/building-modules/01-module-manager.md) in the [application's constructor](#constructor-function), and the `SetOrderBeginBlockers` and `SetOrderEndBlockers` methods have to be called before the `SetBeginBlocker` and `SetEndBlocker` functions.
As a sidenote, it is important to remember that application-specific blockchains are deterministic. Developers must be careful not to introduce non-determinism in `BeginBlocker` or `EndBlocker`, and must also be careful not to make them too computationally expensive, as [gas](./04-gas-fees.md) does not constrain the cost of `BeginBlocker` and `EndBlocker` execution.
See an example of `BeginBlocker` and `EndBlocker` functions from `simapp`
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/app.go#L613-L620
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/simapp/app.go#L700-L708
```
### Register Codec
-The `EncodingConfig` structure is the last important part of the `app.go` file. The goal of this structure is to define the codecs that will be used throughout the app.
+The `EncodingConfig` structure is the last important part of the `app.go` file. This structure's purpose is to define the codecs that will be used throughout the app.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/params/encoding.go#L9-L16
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/simapp/params/encoding.go#L9-L16
```
Here are descriptions of what each of the four fields means:
@@ -167,7 +166,7 @@ An application should create its own encoding config.
See an example of a `simappparams.EncodingConfig` from `simapp`:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/simapp/params/encoding.go#L11-L16
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/simapp/params/encoding.go#L9-L16
```
## Modules
@@ -182,7 +181,7 @@ Modules must implement [interfaces](../../build/building-modules/01-module-manag
### `Msg` Services
-Each application module defines two [Protobuf services](https://developers.google.com/protocol-buffers/docs/proto#services): one `Msg` service to handle messages, and one gRPC `Query` service to handle queries. If we consider the module as a state-machine, then a `Msg` service is a set of state transition RPC methods.
+Each application module defines two [Protobuf services](https://protobuf.dev/programming-guides/proto2/): one `Msg` service to handle messages, and one gRPC `Query` service to handle queries. If we consider the module as a state-machine, then a `Msg` service is a set of state transition RPC methods.
Each Protobuf `Msg` service method is 1:1 related to a Protobuf request type, which must implement `sdk.Msg` interface.
Note that `sdk.Msg`s are bundled in [transactions](../advanced/01-transactions.md), and each transaction contains one or multiple messages.
@@ -198,7 +197,7 @@ For more details, see [transaction lifecycle](./01-tx-lifecycle.md).
Module developers create custom `Msg` services when they build their own module. The general practice is to define the `Msg` Protobuf service in a `tx.proto` file. For example, the `x/bank` module defines a service with two methods to transfer tokens:
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/bank/v1beta1/tx.proto#L13-L36
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/bank/proto/cosmos/bank/v1beta1/tx.proto#L13-L41
```
Service methods use `keeper` in order to update the module state.
@@ -209,7 +208,7 @@ Each module should also implement the `RegisterServices` method as part of the [
gRPC `Query` services allow users to query the state using [gRPC](https://grpc.io). They are enabled by default, and can be configured under the `grpc.enable` and `grpc.address` fields inside [`app.toml`](../../user/run-node/01-run-node.md#configuring-the-node-using-apptoml-and-configtoml).
-gRPC `Query` services are defined in the module's Protobuf definition files, specifically inside `query.proto`. The `query.proto` definition file exposes a single `Query` [Protobuf service](https://developers.google.com/protocol-buffers/docs/proto#services). Each gRPC query endpoint corresponds to a service method, starting with the `rpc` keyword, inside the `Query` service.
+gRPC `Query` services are defined in the module's Protobuf definition files, specifically inside `query.proto`. The `query.proto` definition file exposes a single `Query` [Protobuf service](https://protobuf.dev/programming-guides/proto2/). Each gRPC query endpoint corresponds to a service method, starting with the `rpc` keyword, inside the `Query` service.
Protobuf generates a `QueryServer` interface for each module, containing all the service methods. A module's [`keeper`](#keeper) then needs to implement this `QueryServer` interface, by providing the concrete implementation of each service method. This concrete implementation is the handler of the corresponding gRPC query endpoint.
@@ -238,7 +237,7 @@ Each module defines command-line commands, gRPC services, and REST routes to be
Generally, the [commands related to a module](../../build/building-modules/09-module-interfaces.md#cli) are defined in a folder called `client/cli` in the module's folder. The CLI divides commands into two categories, transactions and queries, defined in `client/cli/tx.go` and `client/cli/query.go`, respectively. Both commands are built on top of the [Cobra Library](https://github.com/spf13/cobra):
* Transactions commands let users generate new transactions so that they can be included in a block and eventually update the state. One command should be created for each [message type](#msg-services) defined in the module. The command calls the constructor of the message with the parameters provided by the end-user, and wraps it into a transaction. The Cosmos SDK handles signing and the addition of other transaction metadata.
-* Queries let users query the subset of the state defined by the module. Query commands forward queries to the [application's query router](../advanced/00-baseapp.md#query-routing), which routes them to the appropriate [querier](#grpc-query-services) the `queryRoute` parameter supplied.
+* Queries let users query the subset of the state defined by the module. Query commands forward queries to the [application's query router](../advanced/00-baseapp.md#grpc-query-router), which routes them to the appropriate [querier](#grpc-query-services) the `queryRoute` parameter supplied.
#### gRPC
diff --git a/docs/learn/beginner/01-tx-lifecycle.md b/docs/learn/beginner/01-tx-lifecycle.md
index 4888baa60a61..f329e74f7c79 100644
--- a/docs/learn/beginner/01-tx-lifecycle.md
+++ b/docs/learn/beginner/01-tx-lifecycle.md
@@ -33,7 +33,7 @@ Additionally, there are several [flags](../advanced/07-cli.md) users can use to
* `--gas-adjustment` (optional) can be used to scale `gas` up in order to avoid underestimating. For example, users can specify their gas adjustment as 1.5 to use 1.5 times the estimated gas.
* `--gas-prices` specifies how much the user is willing to pay per unit of gas, which can be one or multiple denominations of tokens. For example, `--gas-prices=0.025uatom, 0.025upho` means the user is willing to pay 0.025uatom AND 0.025upho per unit of gas.
* `--fees` specifies how much in fees the user is willing to pay in total.
-* `--timeout-height` specifies a block timeout height to prevent the tx from being committed past a certain height.
+* `--timeout-timestamp` specifies a block timeout timestamp to prevent the tx from being committed past a certain time.
The ultimate value of the fees paid is equal to the gas multiplied by the gas prices. In other words, `fees = ceil(gas * gasPrices)`. Thus, since fees can be calculated using gas prices and vice versa, the users specify only one of the two.
@@ -49,7 +49,7 @@ appd tx send 1000uatom --from --gas auto --ga
### Other Transaction Creation Methods
-The command-line is an easy way to interact with an application, but `Tx` can also be created using a [gRPC or REST interface](../advanced/06-grpc_rest.md) or some other entry point defined by the application developer. From the user's perspective, the interaction depends on the web interface or wallet they are using (e.g. creating `Tx` using [Keplr](https://www.keplr.app/) and signing it with a Ledger Nano S).
+The command-line is an easy way to interact with an application, but `Tx` can also be created using a [gRPC or REST interface](../advanced/06-grpc_rest.md) or some other entry point defined by the application developer. From the user's perspective, the interaction depends on the web interface or wallet they are using (e.g. creating `Tx` using [Keplr](https://www.keplr.app/) and signing it with any [Ledger device](https://www.ledger.com/)).
## Transaction Broadcasting
@@ -108,7 +108,7 @@ Let's say there is a transaction that involves transferring tokens. The message
### Validation
-Preliminary checks are performed. These include signature verification to ensure the transaction hasn't been tampered with and checking if the transaction meets the minimum fee requirements, which is handled by the `AnteHandler`. The `Antehandler` is invoked during the `runTx` method in `BaseApp`.
+Preliminary checks are performed. These include signature verification to ensure the transaction hasn't been tampered with and checking if the transaction meets the minimum fee requirements, which is handled by the `AnteHandler`. The `AnteHandler` is invoked during the `runTx` method in `BaseApp`.
#### Types of Transaction Checks
@@ -133,11 +133,11 @@ Full-nodes use these checks during the validation process to quickly reject inva
#### ValidateBasic (deprecated)
* Messages ([`sdk.Msg`](../advanced/01-transactions.md#messages)) are extracted from transactions (`Tx`). The `ValidateBasic` method of the `sdk.Msg` interface implemented by the module developer is run for each transaction.
-* To discard obviously invalid messages, the `BaseApp` type calls the `ValidateBasic` method very early in the processing of the message in the [`CheckTx`](../advanced/00-baseapp.md#checktx) and [`DeliverTx`](../advanced/00-baseapp.md#delivertx) transactions.
+* To discard obviously invalid messages, the `BaseApp` type calls the `ValidateBasic` method very early in the processing of the message in the [`CheckTx`](../advanced/00-baseapp.md#checktx) and `DeliverTx` transactions.
`ValidateBasic` can include only **stateless** checks (the checks that do not require access to the state).
:::warning
-The `ValidateBasic` method on messages has been deprecated in favor of validating messages directly in their respective [`Msg` services](../../build/building-modules/03-msg-services.md#Validation).
+The `ValidateBasic` method on messages has been deprecated in favor of validating messages directly in their respective [`Msg` services](../../build/building-modules/03-msg-services.md#validation).
Read [RFC 001](https://docs.cosmos.network/main/rfc/rfc-001-tx-validation) for more details.
:::
@@ -162,9 +162,9 @@ After the transaction has been appropriately routed to the correct module by the
For messages that adhere to older standards or specific formats, a routing function retrieves the route name from the message, identifying the corresponding module. The message is then processed by the designated handler within that module, ensuring accurate and consistent application of the transaction's logic.
-4. During the execution, the module's handler will modify the state as required by the business logic. This could involve writing to the module's portion of the state store.
+1. During the execution, the module's handler will modify the state as required by the business logic. This could involve writing to the module's portion of the state store.
-5. Modules can emit events and log information during execution, which are used for monitoring and querying transaction outcomes.
+2. Modules can emit events and log information during execution, which are used for monitoring and querying transaction outcomes.
During the module execution phase, each message that has been routed to the appropriate module is processed according to the module-specific business logic. For example, the `handleMsgSend` function in the bank module processes `MsgSend` messages by checking balances, transferring tokens, and emitting events:
diff --git a/docs/learn/beginner/02-query-lifecycle.md b/docs/learn/beginner/02-query-lifecycle.md
index 2c3600f7fe30..a83bbe112a47 100644
--- a/docs/learn/beginner/02-query-lifecycle.md
+++ b/docs/learn/beginner/02-query-lifecycle.md
@@ -41,7 +41,7 @@ The CLI understands a specific set of commands, defined in a hierarchical struct
### gRPC
-Another interface through which users can make queries is [gRPC](https://grpc.io) requests to a [gRPC server](../advanced/06-grpc_rest.md#grpc-server). The endpoints are defined as [Protocol Buffers](https://developers.google.com/protocol-buffers) service methods inside `.proto` files, written in Protobuf's own language-agnostic interface definition language (IDL). The Protobuf ecosystem developed tools for code-generation from `*.proto` files into various languages. These tools allow to build gRPC clients easily.
+Another interface through which users can make queries is [gRPC](https://grpc.io) requests to a [gRPC server](../advanced/06-grpc_rest.md#grpc-server). The endpoints are defined as [Protocol Buffers](https://protobuf.dev/) service methods inside `.proto` files, written in Protobuf's own language-agnostic interface definition language (IDL). The Protobuf ecosystem developed tools for code-generation from `*.proto` files into various languages. These tools allow to build gRPC clients easily.
One such tool is [grpcurl](https://github.com/fullstorydev/grpcurl), and a gRPC request for `MyQuery` using this client looks like:
@@ -83,14 +83,14 @@ The first thing that is created in the execution of a CLI command is a `client.C
The `client.Context` also contains various functions such as `Query()`, which retrieves the RPC Client and makes an ABCI call to relay a query to a full-node.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/context.go#L25-L68
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/client/context.go#L29-L86
```
The `client.Context`'s primary role is to store data used during interactions with the end-user and provide methods to interact with this data - it is used before and after the query is processed by the full-node. Specifically, in handling `MyQuery`, the `client.Context` is utilized to encode the query parameters, retrieve the full-node, and write the output. Prior to being relayed to a full-node, the query needs to be encoded into a `[]byte` form, as full-nodes are application-agnostic and do not understand specific types. The full-node (RPC Client) itself is retrieved using the `client.Context`, which knows which node the user CLI is connected to. The query is relayed to this full-node to be processed. Finally, the `client.Context` contains a `Writer` to write output when the response is returned. These steps are further described in later sections.
### Arguments and Route Creation
-At this point in the lifecycle, the user has created a CLI command with all of the data they wish to include in their query. A `client.Context` exists to assist in the rest of the `MyQuery`'s journey. Now, the next step is to parse the command or request, extract the arguments, and encode everything. These steps all happen on the user side within the interface they are interacting with.
+At this point in the lifecycle, the user has created a CLI command with all of the data they wish to include in their query. A `client.Context` exists to assist in the rest of the `MyQuery`'s journey. Now, the next steps are to parse the command or request, extract the arguments, and encode everything. These steps all happen on the user side within the interface they are interacting with.
#### Encoding
@@ -99,23 +99,25 @@ In our case (querying an address's delegations), `MyQuery` contains an [address]
Here is what the code looks like for the CLI command:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/staking/client/cli/query.go#L315-L318
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/client/grpc_query.go#L64-L68
```
#### gRPC Query Client Creation
-The Cosmos SDK leverages code generated from Protobuf services to make queries. The `staking` module's `MyQuery` service generates a `queryClient`, which the CLI uses to make queries. Here is the relevant code:
+The Cosmos SDK uses Protobuf-generated services for queries. The `staking` module's `MyQuery` service generates a `queryClient` used by the CLI.
+
+With the introduction of AutoCLI, query client creation is now automated and integrated into the module's setup. This approach simplifies the process of exposing module queries through the CLI.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/staking/client/cli/query.go#L308-L343
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/x/staking/autocli.go#L73-L81
```
-Under the hood, the `client.Context` has a `Query()` function used to retrieve the pre-configured node and relay a query to it; the function takes the query fully-qualified service method name as path (in our case: `/cosmos.staking.v1beta1.Query/Delegations`), and arguments as parameters. It first retrieves the RPC Client (called the [**node**](../advanced/03-node.md)) configured by the user to relay this query to, and creates the `ABCIQueryOptions` (parameters formatted for the ABCI call). The node is then used to make the ABCI call, `ABCIQueryWithOptions()`.
+The `client.Context` still contains a `Query()` function to retrieve the pre-configured node and relay queries. It takes the fully-qualified service method name as a path (e.g. `/cosmos.staking.v1beta1.Query/Delegations`) and arguments as parameters. The function retrieves the RPC Client, creates `ABCIQueryOptions`, and makes the ABCI call using `ABCIQueryWithOptions()`.
Here is what the code looks like:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/query.go#L79-L113
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/client/query.go#L64-L98
```
## RPC
@@ -141,7 +143,7 @@ Since `Query()` is an ABCI function, `baseapp` returns the response as an [`abci
The application [`codec`](../advanced/05-encoding.md) is used to unmarshal the response to a JSON and the `client.Context` prints the output to the command line, applying any configurations such as the output type (text, JSON or YAML).
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/context.go#L341-L349
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/client/context.go#L391-L398
```
And that's a wrap! The result of the query is outputted to the console by the CLI.
diff --git a/docs/learn/beginner/03-accounts.md b/docs/learn/beginner/03-accounts.md
index b9f7eefa6016..99c9b30267f8 100644
--- a/docs/learn/beginner/03-accounts.md
+++ b/docs/learn/beginner/03-accounts.md
@@ -5,7 +5,7 @@ sidebar_position: 1
# Accounts
:::note Synopsis
-This document describes the in-built account and public key system of the Cosmos SDK.
+This document describes the built-in account and public key system of the Cosmos SDK.
:::
:::note Pre-requisite Readings
@@ -17,7 +17,7 @@ This document describes the in-built account and public key system of the Cosmos
## Account Definition
-In the Cosmos SDK, an _account_ designates a pair of _public key_ `PubKey` and _private key_ `PrivKey`. The `PubKey` can be derived to generate various `Addresses`, which are used to identify users (among other parties) in the application. `Addresses` are also associated with [`message`s](../../build/building-modules/02-messages-and-queries.md#messages) to identify the sender of the `message`. The `PrivKey` is used to generate [digital signatures](#keys-accounts-addresses-and-signatures) to prove that an `Address` associated with the `PrivKey` approved of a given `message`.
+In the Cosmos SDK, an _account_ designates a pair of _public key_ `PubKey` and _private key_ `PrivKey`. The `PubKey` can be used to derive different types of `Addresses` (such as account addresses, validator addresses, and consensus addresses), with one unique address generated for each type. These `Addresses` are used to identify various actors in the application. `Addresses` are also associated with [`message`s](../../build/building-modules/02-messages-and-queries.md#messages) to identify the sender of the `message`. The `PrivKey` is used to generate [digital signatures](#keys-accounts-addresses-and-signatures) to prove that an `Address` associated with the `PrivKey` approved of a given `message`.
For HD key derivation the Cosmos SDK uses a standard called [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). The BIP32 allows users to create an HD wallet (as specified in [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)) - a set of accounts derived from an initial secret seed. A seed is usually created from a 12- or 24-word mnemonic. A single seed can derive any number of `PrivKey`s using a one-way cryptographic function. Then, a `PubKey` can be derived from the `PrivKey`. Naturally, the mnemonic is the most sensitive information, as private keys can always be re-generated if the mnemonic is preserved.
@@ -48,9 +48,9 @@ In the node, all data is stored using Protocol Buffers serialization.
The Cosmos SDK supports the following digital key schemes for creating digital signatures:
-* `secp256k1`, as implemented in the [Cosmos SDK's `crypto/keys/secp256k1` package](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/keys/secp256k1/secp256k1.go).
-* `secp256r1`, as implemented in the [Cosmos SDK's `crypto/keys/secp256r1` package](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/keys/secp256r1/pubkey.go),
-* `tm-ed25519`, as implemented in the [Cosmos SDK `crypto/keys/ed25519` package](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/keys/ed25519/ed25519.go). This scheme is supported only for the consensus validation.
+* `secp256k1`, as implemented in the [Cosmos SDK's `crypto/keys/secp256k1` package](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keys/secp256k1/secp256k1.go).
+* `secp256r1`, as implemented in the [Cosmos SDK's `crypto/keys/secp256r1` package](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keys/secp256r1/pubkey.go),
+* `tm-ed25519`, as implemented in the [Cosmos SDK `crypto/keys/ed25519` package](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keys/ed25519/ed25519.go). This scheme is supported only for the consensus validation.
| | Address length in bytes | Public key length in bytes | Used for transaction authentication | Used for consensus (cometbft) |
| :----------: | :---------------------: | :------------------------: | :---------------------------------: | :-----------------------------: |
@@ -62,7 +62,7 @@ The Cosmos SDK supports the following digital key schemes for creating digital s
`Addresses` and `PubKey`s are both public information that identifies actors in the application. `Account` is used to store authentication information. The basic account implementation is provided by a `BaseAccount` object.
-Each account is identified using `Address` which is a sequence of bytes derived from a public key. In the Cosmos SDK, we define 3 types of addresses that specify a context where an account is used:
+Each account is identified using an `Address` which is a sequence of bytes derived from a public key. In the Cosmos SDK, we define 3 types of addresses that specify a context where an account is used:
* `AccAddress` identifies users (the sender of a `message`).
* `ValAddress` identifies validator operators.
@@ -71,7 +71,7 @@ Each account is identified using `Address` which is a sequence of bytes derived
These types implement the `Address` interface:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/address.go#L126-L134
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/address.go#L145-L155
```
Address construction algorithm is defined in [ADR-28](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-028-public-key-addresses.md).
@@ -83,10 +83,10 @@ sdk.AccAddress(pub.Address().Bytes())
Of note, the `Marshal()` and `Bytes()` method both return the same raw `[]byte` form of the address. `Marshal()` is required for Protobuf compatibility.
-For user interaction, addresses are formatted using [Bech32](https://en.bitcoin.it/wiki/Bech32) and implemented by the `String` method. The Bech32 method is the only supported format to use when interacting with a blockchain. The Bech32 human-readable part (Bech32 prefix) is used to denote an address type. Example:
+For user interaction, addresses are formatted using [Bech32](https://en.bitcoin.it/wiki/Bech32). This formatting is handled by an address codec. The Bech32 format is the only supported format for interacting with a blockchain. The Bech32 human-readable part (Bech32 prefix) is used to denote an address type. The address codec is responsible for encoding and decoding addresses between their binary representation and the Bech32 string format. Here's an example of how the address codec formats addresses:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/address.go#L299-L316
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/codec/address/bech32_codec.go#L95-L111
```
| | Address Bech32 Prefix |
@@ -97,10 +97,10 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/address.go#L299-
### Public Keys
-Public keys in Cosmos SDK are defined by `cryptotypes.PubKey` interface. Since public keys are saved in a store, `cryptotypes.PubKey` extends the `proto.Message` interface:
+Public keys in Cosmos SDK are defined by `cryptotypes.PubKey` interface. Since public keys are saved in a store, the `cryptotypes.PubKey` extends the `proto.Message` interface:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/types/types.go#L8-L17
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/types/types.go#L8-L17
```
A compressed format is used for `secp256k1` and `secp256r1` serialization.
@@ -110,11 +110,11 @@ A compressed format is used for `secp256k1` and `secp256r1` serialization.
This prefix is followed by the `x`-coordinate.
-Public Keys are not used to reference accounts (or users) and in general are not used when composing transaction messages (with few exceptions: `MsgCreateValidator`, `Validator` and `Multisig` messages).
-For user interactions, `PubKey` is formatted using Protobufs JSON ([ProtoMarshalJSON](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/codec/json.go#L14-L34) function). Example:
+Public Keys are not used to reference accounts (or users) and in general are not used when composing transaction messages (with a few exceptions: `MsgCreateValidator`, `Validator` and `Multisig` messages).
+For user interactions, `PubKey` is formatted using Protobufs JSON ([ProtoMarshalJSON](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/codec/json.go#L14-L34) function). Example:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/keys/output.go#L23-L39
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/client/keys/output.go#L24-L47
```
## Keyring
@@ -122,7 +122,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/keys/output.go#
A `Keyring` is an object that stores and manages accounts. In the Cosmos SDK, a `Keyring` implementation follows the `Keyring` interface:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/keyring/keyring.go#L57-L105
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keyring/keyring.go#L57-L109
```
The default implementation of `Keyring` comes from the third-party [`99designs/keyring`](https://github.com/99designs/keyring) library.
@@ -132,34 +132,34 @@ A few notes on the `Keyring` methods:
* `Sign(uid string, msg []byte) ([]byte, types.PubKey, error)` strictly deals with the signature of the `msg` bytes. You must prepare and encode the transaction into a canonical `[]byte` form. Because protobuf is not deterministic, it has been decided in [ADR-020](../../architecture/adr-020-protobuf-transaction-encoding.md) that the canonical `payload` to sign is the `SignDoc` struct, deterministically encoded using [ADR-027](../../architecture/adr-027-deterministic-protobuf-serialization.md). Note that signature verification is not implemented in the Cosmos SDK by default, it is deferred to the [`anteHandler`](../advanced/00-baseapp.md#antehandler).
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L50-L66
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/proto/cosmos/tx/v1beta1/tx.proto#L50-L67
```
-* `NewAccount(uid, mnemonic, bip39Passphrase, hdPath string, algo SignatureAlgo) (*Record, error)` creates a new account based on the [`bip44 path`](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) and persists it on disk. The `PrivKey` is **never stored unencrypted**, instead it is [encrypted with a passphrase](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/armor.go) before being persisted. In the context of this method, the key type and sequence number refers to the segment of the BIP44 derivation path (for example, `0`, `1`, `2`, ...) that is used to derive a private and a public key from the mnemonic. Using the same mnemonic and derivation path, the same `PrivKey`, `PubKey` and `Address` is generated. The following keys are supported by the keyring:
+* `NewAccount(uid, mnemonic, bip39Passphrase, hdPath string, algo SignatureAlgo) (*Record, error)` creates a new account based on the [`bip44 path`](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) and persists it on selected backend. The `PrivKey` is **never stored unencrypted**, instead it is [encrypted with a passphrase](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/crypto/armor.go) before being persisted. In the context of this method, the key type and sequence number refers to the segment of the BIP44 derivation path (for example, `0`, `1`, `2`, ...) that is used to derive a private and a public key from the mnemonic. Using the same mnemonic and derivation path, the same `PrivKey`, `PubKey` and `Address` is generated. The following keys are supported by the keyring:
-* `secp256k1`
-* `ed25519`
+ * `secp256k1`
+ * `ed25519`
* `ExportPrivKeyArmor(uid, encryptPassphrase string) (armor string, err error)` exports a private key in ASCII-armored encrypted format using the given passphrase. You can then either import the private key again into the keyring using the `ImportPrivKey(uid, armor, passphrase string)` function or decrypt it into a raw private key using the `UnarmorDecryptPrivKey(armorStr string, passphrase string)` function.
### Create New Key Type
-To create a new key type for using in keyring, `keyring.SignatureAlgo` interface must be fulfilled.
+To create a new key type for use in the keyring, the `keyring.SignatureAlgo` interface must be fulfilled.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/keyring/signing_algorithms.go#L10-L15
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keyring/signing_algorithms.go#L11-L16
```
The interface consists in three methods where `Name()` returns the name of the algorithm as a `hd.PubKeyType` and `Derive()` and `Generate()` must return the following functions respectively:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/hd/algo.go#L28-L31
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/hd/algo.go#L32-L35
```
-Once the `keyring.SignatureAlgo` has been implemented it must be added to the [list of supported algos](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/keyring/keyring.go#L217) of the keyring.
+Once the `keyring.SignatureAlgo` has been implemented it must be added to the [list of supported algos](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keyring/keyring.go#L209) of the keyring. You can add your new algo to the list by using the [`Option` function](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keyring/keyring_other.go#L17).
For simplicity the implementation of a new key type should be done inside the `crypto/hd` package.
-There is an example of a working `secp256k1` implementation in [algo.go](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/hd/algo.go#L38).
+There is an example of a working `secp256k1` implementation in [algo.go](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/hd/algo.go#L42-L79).
#### Implementing secp256r1 algo
@@ -238,21 +238,21 @@ func (s secp256r1Algo) Generate() GenerateFn {
}
```
-Finally, the algo must be added to the list of [supported algos](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/crypto/keyring/keyring.go#L217) by the keyring.
+Finally, the algo must be added to the list of [supported algos](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/crypto/keyring/keyring.go#L209) by the keyring.
```go
// cosmos-sdk/crypto/keyring/keyring.go
-func newKeystore(kr keyring.Keyring, cdc codec.Codec, backend string, opts ...Option) keystore {
- // Default options for keybase, these can be overwritten using the
- // Option function
- options := Options{
- SupportedAlgos: SigningAlgoList{hd.Secp256k1, hd.Secp256r1}, // added here
- SupportedAlgosLedger: SigningAlgoList{hd.Secp256k1},
+func setSupportedAlgos(algos SigningAlgoList) Option {
+ return func(options *Options) {
+ options.SupportedAlgos = algos
}
-...
+}
+
+k, err := New("", "", "", userInput, cdc, setSupportedAlgos(SigningAlgoList{hd.Secp256k1, hd.Secp256r1}))
+
```
-Hereafter to create new keys using your algo, you must specify it with the flag `--algo` :
+Hereafter, to create new keys using your algo, you must specify it with the flag `--algo` :
`simd keys add myKey --algo secp256r1`
diff --git a/docs/learn/beginner/04-gas-fees.md b/docs/learn/beginner/04-gas-fees.md
index 783a2228b829..ea9af2e492b7 100644
--- a/docs/learn/beginner/04-gas-fees.md
+++ b/docs/learn/beginner/04-gas-fees.md
@@ -16,10 +16,10 @@ This document describes the default strategies to handle gas and fees within a C
## Introduction to `Gas` and `Fees`
-In the Cosmos SDK, `gas` is a special unit that is used to track the consumption of resources during execution. `gas` is typically consumed whenever read and writes are made to the store, but it can also be consumed if expensive computation needs to be done. It serves two main purposes:
+In the Cosmos SDK, `gas` is a special unit that is used to track the consumption of resources during execution. `gas` is typically consumed whenever reads and writes are made to the store, but it can also be consumed if expensive computation needs to be done. It serves two main purposes:
* Make sure blocks are not consuming too many resources and are finalized. This is implemented by default in the Cosmos SDK via the [block gas meter](#block-gas-meter).
-* Prevent spam and abuse from end-user. To this end, `gas` consumed during [`message`](../../build/building-modules/02-messages-and-queries.md#messages) execution is typically priced, resulting in a `fee` (`fees = gas * gas-prices`). `fees` generally have to be paid by the sender of the `message`. Note that the Cosmos SDK does not enforce `gas` pricing by default, as there may be other ways to prevent spam (e.g. bandwidth schemes). Still, most applications implement `fee` mechanisms to prevent spam by using the [`AnteHandler`](#antehandler).
+* Prevent spam and abuse from end-users. To this end, `gas` consumed during [`message`](../../build/building-modules/02-messages-and-queries.md#messages) execution is typically priced, resulting in a `fee` (`fees = gas * gas-prices`). `fees` generally have to be paid by the sender of the `message`. Note that the Cosmos SDK does not enforce `gas` pricing by default, as there may be other ways to prevent spam (e.g. bandwidth schemes). Still, most applications implement `fee` mechanisms to prevent spam by using the [`AnteHandler`](#antehandler).
## Gas Meter
@@ -52,7 +52,7 @@ By default, the Cosmos SDK makes use of two different gas meters, the [main gas
`ctx.GasMeter()` is the main gas meter of the application. The main gas meter is initialized in `FinalizeBlock` via `setFinalizeBlockState`, and then tracks gas consumption during execution sequences that lead to state-transitions, i.e. those originally triggered by [`FinalizeBlock`](../advanced/00-baseapp.md#finalizeblock). At the beginning of each transaction execution, the main gas meter **must be set to 0** in the [`AnteHandler`](#antehandler), so that it can track gas consumption per-transaction.
-Gas consumption can be done manually, generally by the module developer in the [`BeginBlocker`, `EndBlocker`](../../build/building-modules/06-beginblock-endblock.md) or [`Msg` service](../../build/building-modules/03-msg-services.md), but most of the time it is done automatically whenever there is a read or write to the store. This automatic gas consumption logic is implemented in a special store called [`GasKv`](../advanced/04-store.md#gaskv-store).
+Gas consumption can be done manually, generally by the module developer in the [`BeginBlocker`, `EndBlocker`](../../build/building-modules/06-preblock-beginblock-endblock.md) or [`Msg` service](../../build/building-modules/03-msg-services.md), but most of the time it is done automatically whenever there is a read or write to the store. This automatic gas consumption logic is implemented in a special store called [`GasKv`](../advanced/04-store.md#gaskv-store).
### Block Gas Meter
@@ -84,18 +84,18 @@ The anteHandler is not implemented in the core Cosmos SDK but in a module. That
* Verify that the transactions are of the correct type. Transaction types are defined in the module that implements the `anteHandler`, and they follow the transaction interface:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/tx_msg.go#L51-L56
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/types/tx_msg.go#L53-L66
```
This enables developers to play with various types for the transaction of their application. In the default `auth` module, the default transaction type is `Tx`:
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/proto/cosmos/tx/v1beta1/tx.proto#L14-L27
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.2/proto/cosmos/tx/v1beta1/tx.proto#L15-L28
```
* Verify signatures for each [`message`](../../build/building-modules/02-messages-and-queries.md#messages) contained in the transaction. Each `message` should be signed by one or multiple sender(s), and these signatures must be verified in the `anteHandler`.
-* During `CheckTx`, verify that the gas prices provided with the transaction is greater than the local `min-gas-prices` (as a reminder, gas-prices can be deduced from the following equation: `fees = gas * gas-prices`). `min-gas-prices` is a parameter local to each full-node and used during `CheckTx` to discard transactions that do not provide a minimum amount of fees. This ensures that the mempool cannot be spammed with garbage transactions.
+* During `CheckTx`, verify that the gas prices provided with the transaction are greater than the local `min-gas-prices` (as a reminder, gas-prices can be deduced from the following equation: `fees = gas * gas-prices`). `min-gas-prices` is a parameter local to each full-node and used during `CheckTx` to discard transactions that do not provide a minimum amount of fees. This ensures that the mempool cannot be spammed with garbage transactions.
* Verify that the sender of the transaction has enough funds to cover for the `fees`. When the end-user generates a transaction, they must indicate 2 of the 3 following parameters (the third one being implicit): `fees`, `gas` and `gas-prices`. This signals how much they are willing to pay for nodes to execute their transaction. The provided `gas` value is stored in a parameter called `GasWanted` for later use.
* Set `newCtx.GasMeter` to 0, with a limit of `GasWanted`. **This step is crucial**, as it not only makes sure the transaction cannot consume infinite gas, but also that `ctx.GasMeter` is reset in-between each transaction (`ctx` is set to `newCtx` after `anteHandler` is run, and the `anteHandler` is run each time a transactions executes).
-As explained above, the `anteHandler` returns a maximum limit of `gas` the transaction can consume during execution called `GasWanted`. The actual amount consumed in the end is denominated `GasUsed`, and we must therefore have `GasUsed =< GasWanted`. Both `GasWanted` and `GasUsed` are relayed to the underlying consensus engine when [`FinalizeBlock`](../advanced/00-baseapp.md#finalizeblock) returns.
+As explained above, the `anteHandler` returns a maximum limit of `gas` the transaction can consume during execution called `GasWanted`. The actual amount consumed in the end is denominated `GasUsed`, and we must therefore have `GasUsed <= GasWanted`. Both `GasWanted` and `GasUsed` are relayed to the underlying consensus engine when [`FinalizeBlock`](../advanced/00-baseapp.md#finalizeblock) returns.
diff --git a/docs/post.sh b/docs/post.sh
index f6e465409af7..62264248e924 100755
--- a/docs/post.sh
+++ b/docs/post.sh
@@ -7,9 +7,9 @@ rm -rf build/tooling/03-hubl.md
rm -rf build/packages/01-depinject.md
rm -rf build/packages/02-collections.md
rm -rf build/packages/03-orm.md
-rm -rf learn/advaced-concepts/17-autocli.md
rm -rf build/architecture
rm -rf build/spec
rm -rf build/rfc
rm -rf learn/advanced/17-autocli.md
rm -rf build/migrations/02-upgrading.md
+rm -rf user/run-node/04-rosetta.md
\ No newline at end of file
diff --git a/docs/pre.sh b/docs/pre.sh
index 0be94c2bf8ee..3c12a9a67d06 100755
--- a/docs/pre.sh
+++ b/docs/pre.sh
@@ -7,7 +7,7 @@ for D in ../x/*; do
# Skip specific directories
if [[ "$DIR_NAME" != "counter" ]]; then
- MODULE_DIRECTORY=docs/build/modules/$DIR_NAME
+ MODULE_DIRECTORY=build/modules/$DIR_NAME
rm -rf "$MODULE_DIRECTORY"
mkdir -p "$MODULE_DIRECTORY"
if [ -f "$D"/README.md ]; then
@@ -36,6 +36,9 @@ cp ../depinject/README.md ./build/packages/01-depinject.md
cp ../collections/README.md ./build/packages/02-collections.md
cp ../orm/README.md ./build/packages/03-orm.md
+## Update user docs with rosetta
+wget -O "./user/run-node/04-rosetta.md" "https://raw.githubusercontent.com/cosmos/rosetta/main/README.md"
+
## Add architecture documentation
cp -r ./architecture ./build
diff --git a/docs/user/run-node/00-keyring.md b/docs/user/run-node/00-keyring.md
new file mode 100644
index 000000000000..b4a2020068fe
--- /dev/null
+++ b/docs/user/run-node/00-keyring.md
@@ -0,0 +1,134 @@
+---
+sidebar_position: 1
+---
+
+# Setting up the keyring
+
+:::note Synopsis
+This document describes how to configure and use the keyring and its various backends for an [**application**](../../learn/beginner/00-app-anatomy.md).
+:::
+
+The keyring holds the private/public keypairs used to interact with a node. For instance, a validator key needs to be set up before running the blockchain node, so that blocks can be correctly signed. The private key can be stored in different locations, called "backends", such as a file or the operating system's own key storage.
+
+## Available backends for the keyring
+
+Starting with the v0.38.0 release, Cosmos SDK comes with a new keyring implementation
+that provides a set of commands to manage cryptographic keys in a secure fashion. The
+new keyring supports multiple storage backends, some of which may not be available on
+all operating systems.
+
+### The `os` backend
+
+The `os` backend relies on operating system-specific defaults to handle key storage
+securely. Typically, an operating system's credential sub-system handles password prompts,
+private keys storage, and user sessions according to the user's password policies. Here
+is a list of the most popular operating systems and their respective passwords manager:
+
+* macOS: [Keychain](https://support.apple.com/en-gb/guide/keychain-access/welcome/mac)
+* Windows: [Credentials Management API](https://docs.microsoft.com/en-us/windows/win32/secauthn/credentials-management)
+* GNU/Linux:
+ * [libsecret](https://gitlab.gnome.org/GNOME/libsecret)
+ * [kwallet](https://api.kde.org/frameworks/kwallet/html/index.html)
+
+GNU/Linux distributions that use GNOME as default desktop environment typically come with
+[Seahorse](https://wiki.gnome.org/Apps/Seahorse). Users of KDE based distributions are
+commonly provided with [KDE Wallet Manager](https://userbase.kde.org/KDE_Wallet_Manager).
+Whilst the former is in fact a `libsecret` convenient frontend, the latter is a `kwallet`
+client.
+
+`os` is the default option since operating system's default credentials managers are
+designed to meet users' most common needs and provide them with a comfortable
+experience without compromising on security.
+
+The recommended backends for headless environments are `file` and `pass`.
+
+### The `file` backend
+
+The `file` backend more closely resembles the keybase implementation used prior to
+v0.38.1. It stores the keyring encrypted within the app's configuration directory. This
+keyring will request a password each time it is accessed, which may occur multiple
+times in a single command resulting in repeated password prompts. If using bash scripts
+to execute commands using the `file` option you may want to utilize the following format
+for multiple prompts:
+
+```shell
+# assuming that KEYPASSWD is set in the environment
+$ gaiacli config keyring-backend file # use file backend
+$ (echo $KEYPASSWD; echo $KEYPASSWD) | gaiacli keys add me # multiple prompts
+$ echo $KEYPASSWD | gaiacli keys show me # single prompt
+```
+
+:::tip
+The first time you add a key to an empty keyring, you will be prompted to type the password twice.
+:::
+
+### The `pass` backend
+
+The `pass` backend uses the [pass](https://www.passwordstore.org/) utility to manage on-disk
+encryption of keys' sensitive data and metadata. Keys are stored inside `gpg` encrypted files
+within app-specific directories. `pass` is available for the most popular UNIX
+operating systems as well as GNU/Linux distributions. Please refer to its manual page for
+information on how to download and install it.
+
+:::tip
+**pass** uses [GnuPG](https://gnupg.org/) for encryption. `gpg` automatically invokes the `gpg-agent`
+daemon upon execution, which handles the caching of GnuPG credentials. Please refer to `gpg-agent`
+man page for more information on how to configure cache parameters such as credentials TTL and
+passphrase expiration.
+:::
+
+The password store must be set up prior to first use:
+
+```shell
+pass init
+```
+
+Replace `` with your GPG key ID. You can use your personal GPG key or an alternative
+one you may want to use specifically to encrypt the password store.
+
+### The `kwallet` backend
+
+The `kwallet` backend uses `KDE Wallet Manager`, which comes installed by default on the
+GNU/Linux distributions that ships KDE as default desktop environment. Please refer to
+[KWallet Handbook](https://docs.kde.org/stable5/en/kdeutils/kwallet5/index.html) for more
+information.
+
+### The `test` backend
+
+The `test` backend is a password-less variation of the `file` backend. Keys are stored
+unencrypted on disk.
+
+**Provided for testing purposes only. The `test` backend is not recommended for use in production environments**.
+
+### The `memory` backend
+
+The `memory` backend stores keys in memory. The keys are immediately deleted after the program has exited.
+
+**Provided for testing purposes only. The `memory` backend is not recommended for use in production environments**.
+
+### Setting backend using the env variable
+
+You can set the keyring-backend using env variable: `BINNAME_KEYRING_BACKEND`. For example, if your binary name is `gaia-v5` then set: `export GAIA_V5_KEYRING_BACKEND=pass`
+
+## Adding keys to the keyring
+
+:::warning
+Make sure you can build your own binary, and replace `simd` with the name of your binary in the snippets.
+:::
+
+Applications developed using the Cosmos SDK come with the `keys` subcommand. For the purpose of this tutorial, we're running the `simd` CLI, which is an application built using the Cosmos SDK for testing and educational purposes. For more information, see [`simapp`](https://github.com/cosmos/cosmos-sdk/tree/main/simapp).
+
+You can use `simd keys` for help about the keys command and `simd keys [command] --help` for more information about a particular subcommand.
+
+To create a new key in the keyring, run the `add` subcommand with a `` argument. For the purpose of this tutorial, we will solely use the `test` backend, and call our new key `my_validator`. This key will be used in the next section.
+
+```bash
+$ simd keys add my_validator --keyring-backend test
+
+# Put the generated address in a variable for later use.
+MY_VALIDATOR_ADDRESS=$(simd keys show my_validator -a --keyring-backend test)
+```
+
+This command generates a new 24-word mnemonic phrase, persists it to the relevant backend, and outputs information about the keypair. If this keypair will be used to hold value-bearing tokens, be sure to write down the mnemonic phrase somewhere safe!
+
+By default, the keyring generates a `secp256k1` keypair. The keyring also supports `ed25519` keys, which may be created by passing the `--algo ed25519` flag. A keyring can of course hold both types of keys simultaneously, and the Cosmos SDK's `x/auth` module supports natively these two public key algorithms.
diff --git a/docs/user/run-node/01-run-node.md b/docs/user/run-node/01-run-node.md
new file mode 100644
index 000000000000..9b1dfb4ebd59
--- /dev/null
+++ b/docs/user/run-node/01-run-node.md
@@ -0,0 +1,228 @@
+---
+sidebar_position: 1
+---
+
+# Running a Node
+
+:::note Synopsis
+Now that the application is ready and the keyring populated, it's time to see how to run the blockchain node. In this section, the application we are running is called [`simapp`](https://github.com/cosmos/cosmos-sdk/tree/main/simapp), and its corresponding CLI binary `simd`.
+:::
+
+:::note Pre-requisite Readings
+
+* [Anatomy of a Cosmos SDK Application](../../learn/beginner/00-app-anatomy.md)
+* [Setting up the keyring](./00-keyring.md)
+
+:::
+
+## Initialize the Chain
+
+:::warning
+Make sure you can build your own binary, and replace `simd` with the name of your binary in the snippets.
+:::
+
+Before actually running the node, we need to initialize the chain, and most importantly its genesis file. This is done with the `init` subcommand:
+
+```bash
+# The argument is the custom username of your node, it should be human-readable.
+simd init --chain-id my-test-chain
+```
+
+The command above creates all the configuration files needed for your node to run, as well as a default genesis file, which defines the initial state of the network.
+
+:::tip
+All these configuration files are in `~/.simapp` by default, but you can overwrite the location of this folder by passing the `--home` flag to each commands,
+or set an `$APPD_HOME` environment variable (where `APPD` is the name of the binary).
+:::
+
+The `~/.simapp` folder has the following structure:
+
+```bash
+. # ~/.simapp
+ |- data # Contains the databases used by the node.
+ |- config/
+ |- app.toml # Application-related configuration file.
+ |- config.toml # CometBFT-related configuration file.
+ |- genesis.json # The genesis file.
+ |- node_key.json # Private key to use for node authentication in the p2p protocol.
+ |- priv_validator_key.json # Private key to use as a validator in the consensus protocol.
+```
+
+## Updating Some Default Settings
+
+If you want to change any field values in configuration files (for ex: genesis.json) you can use `jq` ([installation](https://stedolan.github.io/jq/download/) & [docs](https://stedolan.github.io/jq/manual/#Assignment)) & `sed` commands to do that. Few examples are listed here.
+
+```bash
+# to change the chain-id
+jq '.chain_id = "testing"' genesis.json > temp.json && mv temp.json genesis.json
+
+# to enable the api server
+sed -i '/\[api\]/,+3 s/enable = false/enable = true/' app.toml
+
+# to change the voting_period
+jq '.app_state.gov.voting_params.voting_period = "600s"' genesis.json > temp.json && mv temp.json genesis.json
+
+# to change the inflation
+jq '.app_state.mint.minter.inflation = "0.300000000000000000"' genesis.json > temp.json && mv temp.json genesis.json
+```
+
+### Client Interaction
+
+When instantiating a node, GRPC and REST are defaulted to localhost to avoid unknown exposure of your node to the public. It is recommended to not expose these endpoints without a proxy that can handle load balancing or authentication is setup between your node and the public.
+
+:::tip
+A commonly used tool for this is [nginx](https://nginx.org).
+:::
+
+
+## Adding Genesis Accounts
+
+Before starting the chain, you need to populate the state with at least one account. To do so, first [create a new account in the keyring](./00-keyring.md#adding-keys-to-the-keyring) named `my_validator` under the `test` keyring backend (feel free to choose another name and another backend).
+
+Now that you have created a local account, go ahead and grant it some `stake` tokens in your chain's genesis file. Doing so will also make sure your chain is aware of this account's existence:
+
+```bash
+simd genesis add-genesis-account $MY_VALIDATOR_ADDRESS 100000000000stake
+```
+
+Recall that `$MY_VALIDATOR_ADDRESS` is a variable that holds the address of the `my_validator` key in the [keyring](./00-keyring.md#adding-keys-to-the-keyring). Also note that the tokens in the Cosmos SDK have the `{amount}{denom}` format: `amount` is an 18-digit-precision decimal number, and `denom` is the unique token identifier with its denomination key (e.g. `atom` or `uatom`). Here, we are granting `stake` tokens, as `stake` is the token identifier used for staking in [`simapp`](https://github.com/cosmos/cosmos-sdk/tree/main/simapp). For your own chain with its own staking denom, that token identifier should be used instead.
+
+Now that your account has some tokens, you need to add a validator to your chain. Validators are special full-nodes that participate in the consensus process (implemented in the [underlying consensus engine](../../learn/intro/02-sdk-app-architecture.md#cometbft)) in order to add new blocks to the chain. Any account can declare its intention to become a validator operator, but only those with sufficient delegation get to enter the active set (for example, only the top 125 validator candidates with the most delegation get to be validators in the Cosmos Hub). For this guide, you will add your local node (created via the `init` command above) as a validator of your chain. Validators can be declared before a chain is first started via a special transaction included in the genesis file called a `gentx`:
+
+```bash
+# Create a gentx.
+simd genesis gentx my_validator 100000000stake --chain-id my-test-chain --keyring-backend test
+
+# Add the gentx to the genesis file.
+simd genesis collect-gentxs
+```
+
+A `gentx` does three things:
+
+1. Registers the `validator` account you created as a validator operator account (i.e. the account that controls the validator).
+2. Self-delegates the provided `amount` of staking tokens.
+3. Link the operator account with a CometBFT node pubkey that will be used for signing blocks. If no `--pubkey` flag is provided, it defaults to the local node pubkey created via the `simd init` command above.
+
+For more information on `gentx`, use the following command:
+
+```bash
+simd genesis gentx --help
+```
+
+## Configuring the Node Using `app.toml` and `config.toml`
+
+The Cosmos SDK automatically generates two configuration files inside `~/.simapp/config`:
+
+* `config.toml`: used to configure the CometBFT, learn more on [CometBFT's documentation](https://docs.cometbft.com/v0.37/core/configuration),
+* `app.toml`: generated by the Cosmos SDK, and used to configure your app, such as state pruning strategies, telemetry, gRPC and REST servers configuration, state sync...
+
+Both files are heavily commented, please refer to them directly to tweak your node.
+
+One example config to tweak is the `minimum-gas-prices` field inside `app.toml`, which defines the minimum gas prices the validator node is willing to accept for processing a transaction. Depending on the chain, it might be an empty string or not. If it's empty, make sure to edit the field with some value, for example `10token`, or else the node will halt on startup. For the purpose of this tutorial, let's set the minimum gas price to 0:
+
+```toml
+ # The minimum gas prices a validator is willing to accept for processing a
+ # transaction. A transaction's fees must meet the minimum of any denomination
+ # specified in this config (e.g. 0.25token1;0.0001token2).
+ minimum-gas-prices = "0stake"
+```
+
+:::tip
+When running a node (not a validator!) and not wanting to run the application mempool, set the `max-txs` field to `-1`.
+
+```toml
+[mempool]
+# Setting max-txs to 0 will allow for a unbounded amount of transactions in the mempool.
+# Setting max_txs to negative 1 (-1) will disable transactions from being inserted into the mempool.
+# Setting max_txs to a positive number (> 0) will limit the number of transactions in the mempool, by the specified amount.
+#
+# Note, this configuration only applies to SDK built-in app-side mempool
+# implementations.
+max-txs = "-1"
+```
+
+:::
+
+## Run a Localnet
+
+Now that everything is set up, you can finally start your node:
+
+```bash
+simd start
+```
+
+You should see blocks come in.
+
+The previous command allow you to run a single node. This is enough for the next section on interacting with this node, but you may wish to run multiple nodes at the same time, and see how consensus happens between them.
+
+The naive way would be to run the same commands again in separate terminal windows. This is possible, however in the Cosmos SDK, we leverage the power of [Docker Compose](https://docs.docker.com/compose/) to run a localnet. If you need inspiration on how to set up your own localnet with Docker Compose, you can have a look at the Cosmos SDK's [`docker-compose.yml`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/docker-compose.yml).
+
+### Standalone App/CometBFT
+
+By default, the Cosmos SDK runs CometBFT in-process with the application
+If you want to run the application and CometBFT in separate processes,
+start the application with the `--with-comet=false` flag
+and set `rpc.laddr` in `config.toml` to the CometBFT node's RPC address.
+
+## Logging
+
+Logging provides a way to see what is going on with a node. By default the `info` level is set. This is a global level and all info logs will be outputted to the terminal.
+
+If you would like to filter specific logs to the terminal instead of all, then setting `:` is how this can work.
+Example:
+
+In `config.toml`:
+
+```toml
+log_level: "state:info,p2p:info,consensus:info,x/staking:info,x/ibc:info,*:error"
+```
+
+Or directly in the command line:
+
+```bash
+ start --log_level "state:info,p2p:info,consensus:info,x/staking:info,x/ibc:info,*:error"
+```
+
+The above will show info logs for the state, p2p, consensus, staking, and ibc modules, and error logs for all other modules.
+When no log filtering is required, simply use one of the supported global log levels: `trace`, `debug`, `info`, `warn`, `error`, `fatal`, `panic` or `disabled`.
+
+## State Sync
+
+State sync is the act in which a node syncs the latest or close to the latest state of a blockchain. This is useful for users who don't want to sync all the blocks in history. Read more in [CometBFT documentation](https://docs.cometbft.com/v0.37/core/state-sync).
+
+State sync works thanks to snapshots. Read how the SDK handles snapshots [here](https://github.com/cosmos/cosmos-sdk/blob/825245d/store/snapshots/README.md).
+
+### Local State Sync
+
+Local state sync work similar to normal state sync except that it works off a local snapshot of state instead of one provided via the p2p network. The steps to start local state sync are similar to normal state sync with a few different designs.
+
+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 ` ` 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 ` comet bootstrap-state`
+
+### Snapshots Commands
+
+The Cosmos SDK provides commands for managing snapshots.
+These commands can be added in an app with the following snippet in `cmd//root.go`:
+
+```go
+import (
+ "github.com/cosmos/cosmos-sdk/client/snapshot"
+)
+
+func initRootCmd(/* ... */) {
+ // ...
+ rootCmd.AddCommand(
+ snapshot.Cmd(appCreator),
+ )
+}
+```
+
+Then following commands are available at ` snapshots [command]`:
+
+* **list**: list local snapshots
+* **load**: Load a snapshot archive file into snapshot store
+* **restore**: Restore app state from local snapshot
+* **export**: Export app state to snapshot store
+* **dump**: Dump the snapshot as portable archive format
+* **delete**: Delete a local snapshot
diff --git a/docs/user/run-node/02-interact-node.md b/docs/user/run-node/02-interact-node.md
new file mode 100644
index 000000000000..a511aec41836
--- /dev/null
+++ b/docs/user/run-node/02-interact-node.md
@@ -0,0 +1,289 @@
+---
+sidebar_position: 1
+---
+
+# Interacting with the Node
+
+:::note Synopsis
+There are multiple ways to interact with a node: using the CLI, using gRPC or using the REST endpoints.
+:::
+
+:::note Pre-requisite Readings
+
+* [gRPC, REST and CometBFT Endpoints](../../learn/advanced/06-grpc_rest.md)
+* [Running a Node](./01-run-node.md)
+
+:::
+
+## Using the CLI
+
+Now that your chain is running, it is time to try sending tokens from the first account you created to a second account. In a new terminal window, start by running the following query command:
+
+```bash
+simd query bank balances $MY_VALIDATOR_ADDRESS
+```
+
+You should see the current balance of the account you created, equal to the original balance of `stake` you granted it minus the amount you delegated via the `gentx`. Now, create a second account:
+
+```bash
+simd keys add recipient --keyring-backend test
+
+# Put the generated address in a variable for later use.
+RECIPIENT=$(simd keys show recipient -a --keyring-backend test)
+```
+
+The command above creates a local key-pair that is not yet registered on the chain. An account is created the first time it receives tokens from another account. Now, run the following command to send tokens to the `recipient` account:
+
+```bash
+simd tx bank send $MY_VALIDATOR_ADDRESS $RECIPIENT 1000000stake --chain-id my-test-chain --keyring-backend test
+
+# Check that the recipient account did receive the tokens.
+simd query bank balances $RECIPIENT
+```
+
+Finally, delegate some of the stake tokens sent to the `recipient` account to the validator:
+
+```bash
+simd tx staking delegate $(simd keys show my_validator --bech val -a --keyring-backend test) 500stake --from recipient --chain-id my-test-chain --keyring-backend test
+
+# Query the total delegations to `validator`.
+simd query staking delegations-to $(simd keys show my_validator --bech val -a --keyring-backend test)
+```
+
+You should see two delegations, the first one made from the `gentx`, and the second one you just performed from the `recipient` account.
+
+## Using gRPC
+
+The Protobuf ecosystem developed tools for different use cases, including code-generation from `*.proto` files into various languages. These tools allow the building of clients easily. Often, the client connection (i.e. the transport) can be plugged and replaced very easily. Let's explore one of the most popular transport: [gRPC](../../learn/advanced/06-grpc_rest.md).
+
+Since the code generation library largely depends on your own tech stack, we will only present three alternatives:
+
+* `grpcurl` for generic debugging and testing,
+* programmatically via Go,
+* CosmJS for JavaScript/TypeScript developers.
+
+### grpcurl
+
+[grpcurl](https://github.com/fullstorydev/grpcurl) is like `curl` but for gRPC. It is also available as a Go library, but we will use it only as a CLI command for debugging and testing purposes. Follow the instructions in the previous link to install it.
+
+Assuming you have a local node running (either a localnet, or connected a live network), you should be able to run the following command to list the Protobuf services available (you can replace `localhost:9000` by the gRPC server endpoint of another node, which is configured under the `grpc.address` field inside [`app.toml`](../run-node/01-run-node.md#configuring-the-node-using-apptoml-and-configtoml)):
+
+```bash
+grpcurl -plaintext localhost:9090 list
+```
+
+You should see a list of gRPC services, like `cosmos.bank.v1beta1.Query`. This is called reflection, which is a Protobuf endpoint returning a description of all available endpoints. Each of these represents a different Protobuf service, and each service exposes multiple RPC methods you can query against.
+
+In order to get a description of the service you can run the following command:
+
+```bash
+grpcurl -plaintext \
+ localhost:9090 \
+ describe cosmos.bank.v1beta1.Query # Service we want to inspect
+```
+
+It's also possible to execute an RPC call to query the node for information:
+
+```bash
+grpcurl \
+ -plaintext \
+ -d "{\"address\":\"$MY_VALIDATOR_ADDRESS\"}" \
+ localhost:9090 \
+ cosmos.bank.v1beta1.Query/AllBalances
+```
+
+The list of all available gRPC query endpoints is [coming soon](https://github.com/cosmos/cosmos-sdk/issues/7786).
+
+#### Query for historical state using grpcurl
+
+You may also query for historical data by passing some [gRPC metadata](https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md) to the query: the `x-cosmos-block-height` metadata should contain the block to query. Using grpcurl as above, the command looks like:
+
+```bash
+grpcurl \
+ -plaintext \
+ -H "x-cosmos-block-height: 123" \
+ -d "{\"address\":\"$MY_VALIDATOR_ADDRESS\"}" \
+ localhost:9090 \
+ cosmos.bank.v1beta1.Query/AllBalances
+```
+
+Assuming the state at that block has not yet been pruned by the node, this query should return a non-empty response.
+
+### Programmatically via Go
+
+The following snippet shows how to query the state using gRPC inside a Go program. The idea is to create a gRPC connection, and use the Protobuf-generated client code to query the gRPC server.
+
+#### Install Cosmos SDK
+
+
+```bash
+go get github.com/cosmos/cosmos-sdk@main
+```
+
+```go
+package main
+
+import (
+ "context"
+ "fmt"
+
+ "google.golang.org/grpc"
+
+ "github.com/cosmos/cosmos-sdk/codec"
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
+)
+
+func queryState() error {
+ myAddress, err := sdk.AccAddressFromBech32("cosmos1...") // the my_validator or recipient address.
+ if err != nil {
+ return err
+ }
+
+ // Create a connection to the gRPC server.
+ grpcConn, err := grpc.Dial(
+ "127.0.0.1:9090", // your gRPC server address.
+ grpc.WithInsecure(), // The Cosmos SDK doesn't support any transport security mechanism.
+ // This instantiates a general gRPC codec which handles proto bytes. We pass in a nil interface registry
+ // if the request/response types contain interface instead of 'nil' you should pass the application specific codec.
+ grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
+ )
+ if err != nil {
+ return err
+ }
+ defer grpcConn.Close()
+
+ // This creates a gRPC client to query the x/bank service.
+ bankClient := banktypes.NewQueryClient(grpcConn)
+ bankRes, err := bankClient.Balance(
+ context.Background(),
+ &banktypes.QueryBalanceRequest{Address: myAddress.String(), Denom: "stake"},
+ )
+ if err != nil {
+ return err
+ }
+
+ fmt.Println(bankRes.GetBalance()) // Prints the account balance
+
+ return nil
+}
+
+func main() {
+ if err := queryState(); err != nil {
+ panic(err)
+ }
+}
+```
+
+You can replace the query client (here we are using `x/bank`'s) with one generated from any other Protobuf service. The list of all available gRPC query endpoints is [coming soon](https://github.com/cosmos/cosmos-sdk/issues/7786).
+
+#### Query for historical state using Go
+
+Querying for historical blocks is done by adding the block height metadata in the gRPC request.
+
+```go
+package main
+
+import (
+ "context"
+ "fmt"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/metadata"
+
+ "github.com/cosmos/cosmos-sdk/codec"
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
+ banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
+)
+
+func queryState() error {
+ myAddress, err := sdk.AccAddressFromBech32("cosmos1yerherx4d43gj5wa3zl5vflj9d4pln42n7kuzu") // the my_validator or recipient address.
+ if err != nil {
+ return err
+ }
+
+ // Create a connection to the gRPC server.
+ grpcConn, err := grpc.Dial(
+ "127.0.0.1:9090", // your gRPC server address.
+ grpc.WithInsecure(), // The Cosmos SDK doesn't support any transport security mechanism.
+ // This instantiates a general gRPC codec which handles proto bytes. We pass in a nil interface registry
+ // if the request/response types contain interface instead of 'nil' you should pass the application specific codec.
+ grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
+ )
+ if err != nil {
+ return err
+ }
+ defer grpcConn.Close()
+
+ // This creates a gRPC client to query the x/bank service.
+ bankClient := banktypes.NewQueryClient(grpcConn)
+
+ var header metadata.MD
+ _, err = bankClient.Balance(
+ metadata.AppendToOutgoingContext(context.Background(), grpctypes.GRPCBlockHeightHeader, "12"), // Add metadata to request
+ &banktypes.QueryBalanceRequest{Address: myAddress.String(), Denom: "stake"},
+ grpc.Header(&header), // Retrieve header from response
+ )
+ if err != nil {
+ return err
+ }
+ blockHeight := header.Get(grpctypes.GRPCBlockHeightHeader)
+
+ fmt.Println(blockHeight) // Prints the block height (12)
+
+ return nil
+}
+
+func main() {
+ if err := queryState(); err != nil {
+ panic(err)
+ }
+}
+```
+
+### CosmJS
+
+CosmJS documentation can be found at [https://cosmos.github.io/cosmjs](https://cosmos.github.io/cosmjs). As of January 2021, CosmJS documentation is still work in progress.
+
+## Using the REST Endpoints
+
+As described in the [gRPC guide](../../learn/advanced/06-grpc_rest.md), all gRPC services on the Cosmos SDK are made available for more convenient REST-based queries through gRPC-gateway. The format of the URL path is based on the Protobuf service method's full-qualified name, but may contain small customizations so that final URLs look more idiomatic. For example, the REST endpoint for the `cosmos.bank.v1beta1.Query/AllBalances` method is `GET /cosmos/bank/v1beta1/balances/{address}`. Request arguments are passed as query parameters.
+
+Note that the REST endpoints are not enabled by default. To enable them, edit the `api` section of your `~/.simapp/config/app.toml` file:
+
+```toml
+# Enable defines if the API server should be enabled.
+enable = true
+```
+
+As a concrete example, the `curl` command to make balances request is:
+
+```bash
+curl \
+ -X GET \
+ -H "Content-Type: application/json" \
+ http://localhost:1317/cosmos/bank/v1beta1/balances/$MY_VALIDATOR_ADDRESS
+```
+
+Make sure to replace `localhost:1317` with the REST endpoint of your node, configured under the `api.address` field.
+
+The list of all available REST endpoints is available as a Swagger specification file, it can be viewed at `localhost:1317/swagger`. Make sure that the `api.swagger` field is set to true in your [`app.toml`](../run-node/01-run-node.md#configuring-the-node-using-apptoml-and-configtoml) file.
+
+### Query for historical state using REST
+
+Querying for historical state is done using the HTTP header `x-cosmos-block-height`. For example, a curl command would look like:
+
+```bash
+curl \
+ -X GET \
+ -H "Content-Type: application/json" \
+ -H "x-cosmos-block-height: 123" \
+ http://localhost:1317/cosmos/bank/v1beta1/balances/$MY_VALIDATOR_ADDRESS
+```
+
+Assuming the state at that block has not yet been pruned by the node, this query should return a non-empty response.
+
+### Cross-Origin Resource Sharing (CORS)
+
+[CORS policies](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) are not enabled by default to help with security. If you would like to use the rest-server in a public environment we recommend you provide a reverse proxy, this can be done with [nginx](https://www.nginx.com/). For testing and development purposes there is an `enabled-unsafe-cors` field inside [`app.toml`](../run-node/01-run-node.md#configuring-the-node-using-apptoml-and-configtoml).
diff --git a/docs/user/run-node/03-txs.md b/docs/user/run-node/03-txs.md
new file mode 100644
index 000000000000..106f02e8e8e8
--- /dev/null
+++ b/docs/user/run-node/03-txs.md
@@ -0,0 +1,387 @@
+---
+sidebar_position: 1
+---
+
+# Generating, Signing and Broadcasting Transactions
+
+:::note Synopsis
+This document describes how to generate an (unsigned) transaction, signing it (with one or multiple keys), and broadcasting it to the network.
+:::
+
+## Using the CLI
+
+The easiest way to send transactions is using the CLI, as we have seen in the previous page when [interacting with a node](./02-interact-node.md#using-the-cli). For example, running the following command
+
+```bash
+simd tx bank send $MY_VALIDATOR_ADDRESS $RECIPIENT 1000stake --chain-id my-test-chain --keyring-backend test
+```
+
+will run the following steps:
+
+* generate a transaction with one `Msg` (`x/bank`'s `MsgSend`), and print the generated transaction to the console.
+* ask the user for confirmation to send the transaction from the `$MY_VALIDATOR_ADDRESS` account.
+* fetch `$MY_VALIDATOR_ADDRESS` from the keyring. This is possible because we have [set up the CLI's keyring](./00-keyring.md) in a previous step.
+* sign the generated transaction with the keyring's account.
+* broadcast the signed transaction to the network. This is possible because the CLI connects to the node's CometBFT RPC endpoint.
+
+The CLI bundles all the necessary steps into a simple-to-use user experience. However, it's possible to run all the steps individually too.
+
+### Generating a Transaction
+
+Generating a transaction can simply be done by appending the `--generate-only` flag on any `tx` command, e.g.:
+
+```bash
+simd tx bank send $MY_VALIDATOR_ADDRESS $RECIPIENT 1000stake --chain-id my-test-chain --generate-only
+```
+
+This will output the unsigned transaction as JSON in the console. We can also save the unsigned transaction to a file (to be passed around between signers more easily) by appending `> unsigned_tx.json` to the above command.
+
+### Signing a Transaction
+
+Signing a transaction using the CLI requires the unsigned transaction to be saved in a file. Let's assume the unsigned transaction is in a file called `unsigned_tx.json` in the current directory (see previous paragraph on how to do that). Then, simply run the following command:
+
+```bash
+simd tx sign unsigned_tx.json --chain-id my-test-chain --keyring-backend test --from $MY_VALIDATOR_ADDRESS
+```
+
+This command will decode the unsigned transaction and sign it with `SIGN_MODE_DIRECT` with `$MY_VALIDATOR_ADDRESS`'s key, which we already set up in the keyring. The signed transaction will be output as JSON to the console, and, as above, we can save it to a file by appending `--output-document signed_tx.json`.
+
+Some useful flags to consider in the `tx sign` command:
+
+* `--sign-mode`: you may use `amino-json` to sign the transaction using `SIGN_MODE_LEGACY_AMINO_JSON`,
+* `--offline`: sign in offline mode. This means that the `tx sign` command doesn't connect to the node to retrieve the signer's account number and sequence, both needed for signing. In this case, you must manually supply the `--account-number` and `--sequence` flags. This is useful for offline signing, i.e. signing in a secure environment which doesn't have access to the internet.
+
+#### Signing with Multiple Signers
+
+:::warning
+Please note that signing a transaction with multiple signers or with a multisig account, where at least one signer uses `SIGN_MODE_DIRECT`, is not yet possible. You may follow [this Github issue](https://github.com/cosmos/cosmos-sdk/issues/8141) for more info.
+:::
+
+Signing with multiple signers is done with the `tx multisign` command. This command assumes that all signers use `SIGN_MODE_LEGACY_AMINO_JSON`. The flow is similar to the `tx sign` command flow, but instead of signing an unsigned transaction file, each signer signs the file signed by previous signer(s). The `tx multisign` command will append signatures to the existing transactions. It is important that signers sign the transaction **in the same order** as given by the transaction, which is retrievable using the `GetSigners()` method.
+
+For example, starting with the `unsigned_tx.json`, and assuming the transaction has 4 signers, we would run:
+
+```bash
+# Let signer1 sign the unsigned tx.
+simd tx multisign unsigned_tx.json signer_key_1 --chain-id my-test-chain --keyring-backend test > partial_tx_1.json
+# Now signer1 will send the partial_tx_1.json to the signer2.
+# Signer2 appends their signature:
+simd tx multisign partial_tx_1.json signer_key_2 --chain-id my-test-chain --keyring-backend test > partial_tx_2.json
+# Signer2 sends the partial_tx_2.json file to signer3, and signer3 can append his signature:
+simd tx multisign partial_tx_2.json signer_key_3 --chain-id my-test-chain --keyring-backend test > partial_tx_3.json
+```
+
+### Broadcasting a Transaction
+
+Broadcasting a transaction is done using the following command:
+
+```bash
+simd tx broadcast tx_signed.json
+```
+
+You may optionally pass the `--broadcast-mode` flag to specify which response to receive from the node:
+
+* `sync`: the CLI waits for a CheckTx execution response only.
+* `async`: the CLI returns immediately (transaction might fail).
+
+### Encoding a Transaction
+
+In order to broadcast a transaction using the gRPC or REST endpoints, the transaction will need to be encoded first. This can be done using the CLI.
+
+Encoding a transaction is done using the following command:
+
+```bash
+simd tx encode tx_signed.json
+```
+
+This will read the transaction from the file, serialize it using Protobuf, and output the transaction bytes as base64 in the console.
+
+### Decoding a Transaction
+
+The CLI can also be used to decode transaction bytes.
+
+Decoding a transaction is done using the following command:
+
+```bash
+simd tx decode [protobuf-byte-string]
+```
+
+This will decode the transaction bytes and output the transaction as JSON in the console. You can also save the transaction to a file by appending `> tx.json` to the above command.
+
+## Programmatically with Go
+
+It is possible to manipulate transactions programmatically via Go using the Cosmos SDK's `TxBuilder` interface.
+
+### Generating a Transaction
+
+Before generating a transaction, a new instance of a `TxBuilder` needs to be created. Since the Cosmos SDK supports both Amino and Protobuf transactions, the first step would be to decide which encoding scheme to use. All the subsequent steps remain unchanged, whether you're using Amino or Protobuf, as `TxBuilder` abstracts the encoding mechanisms. In the following snippet, we will use Protobuf.
+
+```go
+import (
+ "github.com/cosmos/cosmos-sdk/simapp"
+)
+
+func sendTx() error {
+ // Choose your codec: Amino or Protobuf. Here, we use Protobuf, given by the following function.
+ app := simapp.NewSimApp(...)
+
+ // Create a new TxBuilder.
+ txBuilder := app.TxConfig().NewTxBuilder()
+
+ // --snip--
+}
+```
+
+We can also set up some keys and addresses that will send and receive the transactions. Here, for the purpose of the tutorial, we will be using some dummy data to create keys.
+
+```go
+import (
+ "github.com/cosmos/cosmos-sdk/testutil/testdata"
+)
+
+priv1, _, addr1 := testdata.KeyTestPubAddr()
+priv2, _, addr2 := testdata.KeyTestPubAddr()
+priv3, _, addr3 := testdata.KeyTestPubAddr()
+```
+
+Populating the `TxBuilder` can be done via its methods:
+
+```go reference
+https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/client/tx_config.go#L33-L50
+```
+
+```go
+import (
+ banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
+)
+
+func sendTx() error {
+ // --snip--
+
+ // Define two x/bank MsgSend messages:
+ // - from addr1 to addr3,
+ // - from addr2 to addr3.
+ // This means that the transactions needs two signers: addr1 and addr2.
+ msg1 := banktypes.NewMsgSend(addr1, addr3, types.NewCoins(types.NewInt64Coin("atom", 12)))
+ msg2 := banktypes.NewMsgSend(addr2, addr3, types.NewCoins(types.NewInt64Coin("atom", 34)))
+
+ err := txBuilder.SetMsgs(msg1, msg2)
+ if err != nil {
+ return err
+ }
+
+ txBuilder.SetGasLimit(...)
+ txBuilder.SetFeeAmount(...)
+ txBuilder.SetMemo(...)
+ txBuilder.SetTimeoutHeight(...)
+}
+```
+
+At this point, `TxBuilder`'s underlying transaction is ready to be signed.
+
+### Signing a Transaction
+
+We set encoding config to use Protobuf, which will use `SIGN_MODE_DIRECT` by default. As per [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-020-protobuf-transaction-encoding.md), each signer needs to sign the `SignerInfo`s of all other signers. This means that we need to perform two steps sequentially:
+
+* for each signer, populate the signer's `SignerInfo` inside `TxBuilder`,
+* once all `SignerInfo`s are populated, for each signer, sign the `SignDoc` (the payload to be signed).
+
+In the current `TxBuilder`'s API, both steps are done using the same method: `SetSignatures()`. The current API requires us to first perform a round of `SetSignatures()` _with empty signatures_, only to populate `SignerInfo`s, and a second round of `SetSignatures()` to actually sign the correct payload.
+
+```go
+import (
+ cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
+ "github.com/cosmos/cosmos-sdk/types/tx/signing"
+ xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
+)
+
+func sendTx() error {
+ // --snip--
+
+ privs := []cryptotypes.PrivKey{priv1, priv2}
+ accNums:= []uint64{..., ...} // The accounts' account numbers
+ accSeqs:= []uint64{..., ...} // The accounts' sequence numbers
+
+ // First round: we gather all the signer infos. We use the "set empty
+ // signature" hack to do that.
+ var sigsV2 []signing.SignatureV2
+ for i, priv := range privs {
+ sigV2 := signing.SignatureV2{
+ PubKey: priv.PubKey(),
+ Data: &signing.SingleSignatureData{
+ SignMode: encCfg.TxConfig.SignModeHandler().DefaultMode(),
+ Signature: nil,
+ },
+ Sequence: accSeqs[i],
+ }
+
+ sigsV2 = append(sigsV2, sigV2)
+ }
+ err := txBuilder.SetSignatures(sigsV2...)
+ if err != nil {
+ return err
+ }
+
+ // Second round: all signer infos are set, so each signer can sign.
+ sigsV2 = []signing.SignatureV2{}
+ for i, priv := range privs {
+ signerData := xauthsigning.SignerData{
+ ChainID: chainID,
+ AccountNumber: accNums[i],
+ Sequence: accSeqs[i],
+ }
+ sigV2, err := tx.SignWithPrivKey(
+ encCfg.TxConfig.SignModeHandler().DefaultMode(), signerData,
+ txBuilder, priv, encCfg.TxConfig, accSeqs[i])
+ if err != nil {
+ return nil, err
+ }
+
+ sigsV2 = append(sigsV2, sigV2)
+ }
+ err = txBuilder.SetSignatures(sigsV2...)
+ if err != nil {
+ return err
+ }
+}
+```
+
+The `TxBuilder` is now correctly populated. To print it, you can use the `TxConfig` interface from the initial encoding config `encCfg`:
+
+```go
+func sendTx() error {
+ // --snip--
+
+ // Generated Protobuf-encoded bytes.
+ txBytes, err := encCfg.TxConfig.TxEncoder()(txBuilder.GetTx())
+ if err != nil {
+ return err
+ }
+
+ // Generate a JSON string.
+ txJSONBytes, err := encCfg.TxConfig.TxJSONEncoder()(txBuilder.GetTx())
+ if err != nil {
+ return err
+ }
+ txJSON := string(txJSONBytes)
+}
+```
+
+### Broadcasting a Transaction
+
+The preferred way to broadcast a transaction is to use gRPC, though using REST (via `gRPC-gateway`) or the CometBFT RPC is also posible. An overview of the differences between these methods is exposed [here](../../learn/advanced/06-grpc_rest.md). For this tutorial, we will only describe the gRPC method.
+
+```go
+import (
+ "context"
+ "fmt"
+
+ "google.golang.org/grpc"
+
+ "github.com/cosmos/cosmos-sdk/types/tx"
+)
+
+func sendTx(ctx context.Context) error {
+ // --snip--
+
+ // Create a connection to the gRPC server.
+ grpcConn := grpc.Dial(
+ "127.0.0.1:9090", // Or your gRPC server address.
+ grpc.WithInsecure(), // The Cosmos SDK doesn't support any transport security mechanism.
+ )
+ defer grpcConn.Close()
+
+ // Broadcast the tx via gRPC. We create a new client for the Protobuf Tx
+ // service.
+ txClient := tx.NewServiceClient(grpcConn)
+ // We then call the BroadcastTx method on this client.
+ grpcRes, err := txClient.BroadcastTx(
+ ctx,
+ &tx.BroadcastTxRequest{
+ Mode: tx.BroadcastMode_BROADCAST_MODE_SYNC,
+ TxBytes: txBytes, // Proto-binary of the signed transaction, see previous step.
+ },
+ )
+ if err != nil {
+ return err
+ }
+
+ fmt.Println(grpcRes.TxResponse.Code) // Should be `0` if the tx is successful
+
+ return nil
+}
+```
+
+#### Simulating a Transaction
+
+Before broadcasting a transaction, we sometimes may want to dry-run the transaction, to estimate some information about the transaction without actually committing it. This is called simulating a transaction, and can be done as follows:
+
+```go
+import (
+ "context"
+ "fmt"
+ "testing"
+
+ "github.com/cosmos/cosmos-sdk/client"
+ "github.com/cosmos/cosmos-sdk/types/tx"
+ authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
+)
+
+func simulateTx() error {
+ // --snip--
+
+ // Simulate the tx via gRPC. We create a new client for the Protobuf Tx
+ // service.
+ txClient := tx.NewServiceClient(grpcConn)
+ txBytes := /* Fill in with your signed transaction bytes. */
+
+ // We then call the Simulate method on this client.
+ grpcRes, err := txClient.Simulate(
+ context.Background(),
+ &tx.SimulateRequest{
+ TxBytes: txBytes,
+ },
+ )
+ if err != nil {
+ return err
+ }
+
+ fmt.Println(grpcRes.GasInfo) // Prints estimated gas used.
+
+ return nil
+}
+```
+
+## Using gRPC
+
+It is not possible to generate or sign a transaction using gRPC, only to broadcast one. In order to broadcast a transaction using gRPC, you will need to generate, sign, and encode the transaction using either the CLI or programmatically with Go.
+
+### Broadcasting a Transaction
+
+Broadcasting a transaction using the gRPC endpoint can be done by sending a `BroadcastTx` request as follows, where the `txBytes` are the protobuf-encoded bytes of a signed transaction:
+
+```bash
+grpcurl -plaintext \
+ -d '{"tx_bytes":"{{txBytes}}","mode":"BROADCAST_MODE_SYNC"}' \
+ localhost:9090 \
+ cosmos.tx.v1beta1.Service/BroadcastTx
+```
+
+## Using REST
+
+It is not possible to generate or sign a transaction using REST, only to broadcast one. In order to broadcast a transaction using REST, you will need to generate, sign, and encode the transaction using either the CLI or programmatically with Go.
+
+### Broadcasting a Transaction
+
+Broadcasting a transaction using the REST endpoint (served by `gRPC-gateway`) can be done by sending a POST request as follows, where the `txBytes` are the protobuf-encoded bytes of a signed transaction:
+
+```bash
+curl -X POST \
+ -H "Content-Type: application/json" \
+ -d'{"tx_bytes":"{{txBytes}}","mode":"BROADCAST_MODE_SYNC"}' \
+ localhost:1317/cosmos/tx/v1beta1/txs
+```
+
+## Using CosmJS (JavaScript & TypeScript)
+
+CosmJS aims to build client libraries in JavaScript that can be embedded in web applications. Please see [https://cosmos.github.io/cosmjs](https://cosmos.github.io/cosmjs) for more information. As of January 2021, CosmJS documentation is still work in progress.
diff --git a/docs/user/run-node/04-rosetta.md b/docs/user/run-node/04-rosetta.md
new file mode 100644
index 000000000000..de74d9898b0c
--- /dev/null
+++ b/docs/user/run-node/04-rosetta.md
@@ -0,0 +1,144 @@
+# Rosetta
+
+The `rosetta` project implements Coinbase's [Rosetta API](https://www.rosetta-api.org). This document provides instructions on how to use the Rosetta API integration. For information about the motivation and design choices, refer to [ADR 035](https://docs.cosmos.network/main/architecture/adr-035-rosetta-api-support).
+
+## Installing Rosetta
+
+The Rosetta API server is a stand-alone server that connects to a node of a chain developed with Cosmos SDK.
+
+Rosetta can be added to any cosmos chain node. standalone or natively.
+
+### Standalone
+
+Rosetta can be executed as a standalone service, it connects to the node endpoints and expose the required endpoints.
+
+Install Rosetta standalone server with the following command:
+
+```bash
+go install github.com/cosmos/rosetta
+```
+
+Alternatively, for building from source, simply run `make build`. The binary will be located in the root folder.
+
+### Native - As a node command
+
+To enable Native Rosetta API support, it's required to add the `RosettaCommand` to your application's root command file (e.g. `simd/cmd/root.go`).
+
+Import the `rosettaCmd` package:
+
+```go
+import "github.com/cosmos/rosetta/cmd"
+```
+
+Find the following line:
+
+```go
+initRootCmd(rootCmd, encodingConfig)
+```
+
+After that line, add the following:
+
+```go
+rootCmd.AddCommand(
+ rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec)
+)
+```
+
+The `RosettaCommand` function builds the `rosetta` root command and is defined in the `rosettaCmd` package (`github.com/cosmos/rosetta/cmd`).
+
+Since we’ve updated the Cosmos SDK to work with the Rosetta API, updating the application's root command file is all you need to do.
+
+An implementation example can be found in `simapp` package.
+
+## Use Rosetta Command
+
+To run Rosetta in your application CLI, use the following command:
+
+> **Note:** if using the native approach, add your node name before any rosetta comand.
+
+```shell
+rosetta --help
+```
+
+To test and run Rosetta API endpoints for applications that are running and exposed, use the following command:
+
+```shell
+rosetta
+ --blockchain "your application name (ex: gaia)"
+ --network "your chain identifier (ex: testnet-1)"
+ --tendermint "tendermint endpoint (ex: localhost:26657)"
+ --grpc "gRPC endpoint (ex: localhost:9090)"
+ --addr "rosetta binding address (ex: :8080)"
+ --grpc-types-server (optional) "gRPC endpoint for message descriptor types"
+```
+
+## Plugins - Multi chain connections
+
+Rosetta will try to reflect the node types trough reflection over the node gRPC endpoints, there may be cases were this approach is not enough. It is possible to extend or implement the required types easily trough plugins.
+
+To use Rosetta over any chain, it is required to set up prefixes and registering zone specific interfaces through plugins.
+
+Each plugin is a minimalist implementation of `InitZone` and `RegisterInterfaces` which allow Rosetta to parse chain specific data. There is an example for cosmos-hub chain under `plugins/cosmos-hun/` folder
+- **InitZone**: An empty method that is executed first and defines prefixes, parameters and other settings.
+- **RegisterInterfaces**: This method receives an interface registry which is were the zone specific types and interfaces will be loaded
+
+In order to add a new plugin:
+1. Create a folder over `plugins` folder with the name of the desired zone
+2. Add a `main.go` file with the mentioned methods above.
+3. Build the code binary through `go build -buildmode=plugin -o main.so main.go`
+
+The plugin folder is selected through the cli `--plugin` flag and loaded into the Rosetta server.
+
+## Extensions
+
+There are two ways in which you can customize and extend the implementation with your custom settings.
+
+### Message extension
+
+In order to make an `sdk.Msg` understandable by rosetta the only thing which is required is adding the methods to your messages that satisfy the `rosetta.Msg` interface. Examples on how to do so can be found in the staking types such as `MsgDelegate`, or in bank types such as `MsgSend`.
+
+### Client interface override
+
+In case more customization is required, it's possible to embed the Client type and override the methods which require customizations.
+
+Example:
+
+```go
+package custom_client
+import (
+
+"context"
+"github.com/coinbase/rosetta-sdk-go/types"
+"github.com/cosmos/rosetta/lib"
+)
+
+// CustomClient embeds the standard cosmos client
+// which means that it implements the cosmos-rosetta-gateway Client
+// interface while at the same time allowing to customize certain methods
+type CustomClient struct {
+ *rosetta.Client
+}
+
+func (c *CustomClient) ConstructionPayload(_ context.Context, request *types.ConstructionPayloadsRequest) (resp *types.ConstructionPayloadsResponse, err error) {
+ // provide custom signature bytes
+ panic("implement me")
+}
+```
+
+NOTE: when using a customized client, the command cannot be used as the constructors required **may** differ, so it's required to create a new one. We intend to provide a way to init a customized client without writing extra code in the future.
+
+### Error extension
+
+Since rosetta requires to provide 'returned' errors to network options. In order to declare a new rosetta error, we use the `errors` package in cosmos-rosetta-gateway.
+
+Example:
+
+```go
+package custom_errors
+import crgerrs "github.com/cosmos/rosetta/lib/errors"
+
+var customErrRetriable = true
+var CustomError = crgerrs.RegisterError(100, "custom message", customErrRetriable, "description")
+```
+
+Note: errors must be registered before cosmos-rosetta-gateway's `Server`.`Start` method is called. Otherwise the registration will be ignored. Errors with same code will be ignored too.
diff --git a/docs/user/run-node/05-run-testnet.md b/docs/user/run-node/05-run-testnet.md
new file mode 100644
index 000000000000..c2b5da598186
--- /dev/null
+++ b/docs/user/run-node/05-run-testnet.md
@@ -0,0 +1,101 @@
+---
+sidebar_position: 1
+---
+
+# Running a Testnet
+
+:::note Synopsis
+The `simd testnet` subcommand makes it easy to initialize and start a simulated test network for testing purposes.
+:::
+
+In addition to the commands for [running a node](./01-run-node.md), the `simd` binary also includes a `testnet` command that allows you to start a simulated test network in-process or to initialize files for a simulated test network that runs in a separate process.
+
+## Initialize Files
+
+First, let's take a look at the `init-files` subcommand.
+
+This is similar to the `init` command when initializing a single node, but in this case we are initializing multiple nodes, generating the genesis transactions for each node, and then collecting those transactions.
+
+The `init-files` subcommand initializes the necessary files to run a test network in a separate process (i.e. using a Docker container). Running this command is not a prerequisite for the `start` subcommand ([see below](#start-testnet)).
+
+In order to initialize the files for a test network, run the following command:
+
+```bash
+simd testnet init-files
+```
+
+You should see the following output in your terminal:
+
+```bash
+Successfully initialized 4 node directories
+```
+
+The default output directory is a relative `.testnets` directory. Let's take a look at the files created within the `.testnets` directory.
+
+### gentxs
+
+The `gentxs` directory includes a genesis transaction for each validator node. Each file includes a JSON encoded genesis transaction used to register a validator node at the time of genesis. The genesis transactions are added to the `genesis.json` file within each node directory during the initilization process.
+
+### nodes
+
+A node directory is created for each validator node. Within each node directory is a `simd` directory. The `simd` directory is the home directory for each node, which includes the configuration and data files for that node (i.e. the same files included in the default `~/.simapp` directory when running a single node).
+
+## Start Testnet
+
+Now, let's take a look at the `start` subcommand.
+
+The `start` subcommand both initializes and starts an in-process test network. This is the fastest way to spin up a local test network for testing purposes.
+
+You can start the local test network by running the following command:
+
+```bash
+simd testnet start
+```
+
+You should see something similar to the following:
+
+```bash
+acquiring test network lock
+preparing test network with chain-id "chain-mtoD9v"
+
+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ THIS MNEMONIC IS FOR TESTING PURPOSES ONLY ++
+++ DO NOT USE IN PRODUCTION ++
+++ ++
+++ sustain know debris minute gate hybrid stereo custom ++
+++ divorce cross spoon machine latin vibrant term oblige ++
+++ moment beauty laundry repeat grab game bronze truly ++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+starting test network...
+started test network
+press the Enter Key to terminate
+```
+
+The first validator node is now running in-process, which means the test network will terminate once you either close the terminal window or you press the Enter key. In the output, the mnemonic phrase for the first validator node is provided for testing purposes. The validator node is using the same default addresses being used when initializing and starting a single node (no need to provide a `--node` flag).
+
+Check the status of the first validator node:
+
+```shell
+simd status
+```
+
+Import the key from the provided mnemonic:
+
+```shell
+simd keys add test --recover --keyring-backend test
+```
+
+Check the balance of the account address:
+
+```shell
+simd q bank balances [address]
+```
+
+Use this test account to manually test against the test network.
+
+## Testnet Options
+
+You can customize the configuration of the test network with flags. In order to see all flag options, append the `--help` flag to each command.
diff --git a/docs/user/run-node/06-run-production.md b/docs/user/run-node/06-run-production.md
new file mode 100644
index 000000000000..807ceea56efc
--- /dev/null
+++ b/docs/user/run-node/06-run-production.md
@@ -0,0 +1,269 @@
+---
+sidebar_position: 1
+---
+
+# Running in Production
+
+:::note Synopsis
+This section describes how to securely run a node in a public setting and/or on a mainnet on one of the many Cosmos SDK public blockchains.
+:::
+
+When operating a node, full node or validator, in production it is important to set your server up securely.
+
+:::note
+There are many different ways to secure a server and your node, the described steps here is one way. To see another way of setting up a server see the [run in production tutorial](https://tutorials.cosmos.network/hands-on-exercise/5-run-in-prod/1-overview.html).
+:::
+
+:::note
+This walkthrough assumes the underlying operating system is Ubuntu.
+:::
+
+## Sever Setup
+
+### User
+
+When creating a server most times it is created as user `root`. This user has heightened privileges on the server. When operating a node, it is recommended to not run your node as the root user.
+
+1. Create a new user
+
+```bash
+sudo adduser change_me
+```
+
+2. We want to allow this user to perform sudo tasks
+
+```bash
+sudo usermod -aG sudo change_me
+```
+
+Now when logging into the server, the non `root` user can be used.
+
+### Go
+
+1. Install the [Go](https://go.dev/doc/install) version preconized by the application.
+
+:::warning
+In the past, validators [have had issues](https://github.com/cosmos/cosmos-sdk/issues/13976) when using different versions of Go. It is recommended that the whole validator set uses the version of Go that is preconized by the application.
+:::
+
+### Firewall
+
+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.
+
+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.
+
+Most, if not all servers come equipped with [ufw](https://help.ubuntu.com/community/UFW). Ufw will be used in this tutorial.
+
+1. Reset UFW to disallow all incoming connections and allow outgoing
+
+```bash
+sudo ufw default deny incoming
+sudo ufw default allow outgoing
+```
+
+2. Lets make sure that port 22 (ssh) stays open.
+
+```bash
+sudo ufw allow ssh
+```
+
+or
+
+```bash
+sudo ufw allow 22
+```
+
+Both of the above commands are the same.
+
+3. Allow Port 26656 (cometbft p2p port). If the node has a modified p2p port then that port must be used here.
+
+```bash
+sudo ufw allow 26656/tcp
+```
+
+4. Allow port 26660 (cometbft [prometheus](https://prometheus.io)). This acts as the applications monitoring port as well.
+
+```bash
+sudo ufw allow 26660/tcp
+```
+
+5. IF the node which is being setup would like to expose CometBFTs jsonRPC and Cosmos SDK GRPC and REST then follow this step. (Optional)
+
+##### CometBFT JsonRPC
+
+```bash
+sudo ufw allow 26657/tcp
+```
+
+##### Cosmos SDK GRPC
+
+```bash
+sudo ufw allow 9090/tcp
+```
+
+##### Cosmos SDK REST
+
+```bash
+sudo ufw allow 1317/tcp
+```
+
+6. Lastly, enable ufw
+
+```bash
+sudo ufw enable
+```
+
+### Signing
+
+If the node that is being started is a validator there are multiple ways a validator could sign blocks.
+
+#### File
+
+File based signing is the simplest and default approach. This approach works by storing the consensus key, generated on initialization, to sign blocks. This approach is only as safe as your server setup as if the server is compromised so is your key. This key is located in the `config/priv_val_key.json` directory generated on initialization.
+
+A second file exists that user must be aware of, the file is located in the data directory `data/priv_val_state.json`. This file protects your node from double signing. It keeps track of the consensus keys last sign height, round and latest signature. If the node crashes and needs to be recovered this file must be kept in order to ensure that the consensus key will not be used for signing a block that was previously signed.
+
+#### Remote Signer
+
+A remote signer is a secondary server that is separate from the running node that signs blocks with the consensus key. This means that the consensus key does not live on the node itself. This increases security because your full node which is connected to the remote signer can be swapped without missing blocks.
+
+The two most used remote signers are [tmkms](https://github.com/iqlusioninc/tmkms) from [Iqlusion](https://www.iqlusion.io) and [horcrux](https://github.com/strangelove-ventures/horcrux) from [Strangelove](https://strange.love).
+
+##### TMKMS
+
+###### Dependencies
+
+1. Update server dependencies and install extras needed.
+
+```sh
+sudo apt update -y && sudo apt install build-essential curl jq -y
+```
+
+2. Install Rust:
+
+```sh
+curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+```
+
+3. Install Libusb:
+
+```sh
+sudo apt install libusb-1.0-0-dev
+```
+
+###### Setup
+
+There are two ways to install tmkms, from source or `cargo install`. In the examples we will cover downloading or building from source and using softsign. Softsign stands for software signing, but you could use a [yubihsm](https://www.yubico.com/products/hardware-security-module/) as your signing key if you wish.
+
+1. Build:
+
+From source:
+
+```bash
+cd $HOME
+git clone https://github.com/iqlusioninc/tmkms.git
+cd $HOME/tmkms
+cargo install tmkms --features=softsign
+tmkms init config
+tmkms softsign keygen ./config/secrets/secret_connection_key
+```
+
+or
+
+Cargo install:
+
+```bash
+cargo install tmkms --features=softsign
+tmkms init config
+tmkms softsign keygen ./config/secrets/secret_connection_key
+```
+
+:::note
+To use tmkms with a yubikey install the binary with `--features=yubihsm`.
+:::
+
+2. Migrate the validator key from the full node to the new tmkms instance.
+
+```bash
+scp user@123.456.32.123:~/.simd/config/priv_validator_key.json ~/tmkms/config/secrets
+```
+
+3. Import the validator key into tmkms.
+
+```bash
+tmkms softsign import $HOME/tmkms/config/secrets/priv_validator_key.json $HOME/tmkms/config/secrets/priv_validator_key
+```
+
+At this point, it is necessary to delete the `priv_validator_key.json` from the validator node and the tmkms node. Since the key has been imported into tmkms (above) it is no longer necessary on the nodes. The key can be safely stored offline.
+
+4. Modifiy the `tmkms.toml`.
+
+```bash
+vim $HOME/tmkms/config/tmkms.toml
+```
+
+This example shows a configuration that could be used for soft signing. The example has an IP of `123.456.12.345` with a port of `26659` a chain_id of `test-chain-waSDSe`. These are items that most be modified for the usecase of tmkms and the network.
+
+```toml
+# CometBFT KMS configuration file
+
+## Chain Configuration
+
+[[chain]]
+id = "osmosis-1"
+key_format = { type = "bech32", account_key_prefix = "cosmospub", consensus_key_prefix = "cosmosvalconspub" }
+state_file = "/root/tmkms/config/state/priv_validator_state.json"
+
+## Signing Provider Configuration
+
+### Software-based Signer Configuration
+
+[[providers.softsign]]
+chain_ids = ["test-chain-waSDSe"]
+key_type = "consensus"
+path = "/root/tmkms/config/secrets/priv_validator_key"
+
+## Validator Configuration
+
+[[validator]]
+chain_id = "test-chain-waSDSe"
+addr = "tcp://123.456.12.345:26659"
+secret_key = "/root/tmkms/config/secrets/secret_connection_key"
+protocol_version = "v0.34"
+reconnect = true
+```
+
+5. Set the address of the tmkms instance.
+
+```bash
+vim $HOME/.simd/config/config.toml
+
+priv_validator_laddr = "tcp://127.0.0.1:26659"
+```
+
+:::tip
+The above address it set to `127.0.0.1` but it is recommended to set the tmkms server to secure the startup
+:::
+
+:::tip
+It is recommended to comment or delete the lines that specify the path of the validator key and validator:
+
+```toml
+# Path to the JSON file containing the private key to use as a validator in the consensus protocol
+# priv_validator_key_file = "config/priv_validator_key.json"
+
+# Path to the JSON file containing the last sign state of a validator
+# priv_validator_state_file = "data/priv_validator_state.json"
+```
+
+:::
+
+6. Start the two processes.
+
+```bash
+tmkms start -c $HOME/tmkms/config/tmkms.toml
+```
+
+```bash
+simd start
+```
diff --git a/docs/user/run-node/07-multisig-guide.md b/docs/user/run-node/07-multisig-guide.md
new file mode 100644
index 000000000000..f7be5b1f4574
--- /dev/null
+++ b/docs/user/run-node/07-multisig-guide.md
@@ -0,0 +1,108 @@
+---
+sidebar_position: 1
+---
+
+# Guide to Multisig transactions
+
+## Overview
+
+Multisignature accounts are accounts that are generated from multiple public keys. A multisig necessitates that any transaction made on its behalf must be signed by a specified threshold of its members.
+
+A common use case for multisigs is to increase security of a signing account, and/or enable multiple parties to agree on and authorize a transaction.
+
+The first step is to create a multisig signing key by using the public keys of all possible signers and the minimum threshold of addresses that are needed to sign any transaction from the account. The threshold can be the same amount as the total number of addresses comprising the multisig.
+
+Whatever machine is generating the multisig, it should at least have all of the public keys imported into the same keyring.
+
+When you want to create a multisig transaction, you would create the transaction as normal, but instead of signing it with a single account's private key, you would need to sign it with the private keys of the accounts that make up the multisig key.
+
+This is done by signing the transaction multiple times, once with each private key. The order of the signatures matters and must match the order of the public keys in the multisig key.
+
+Once you have a transaction with the necessary signatures, it can be broadcasted to the network. The network will verify that the transaction has the necessary signatures from the accounts in the multisig key before it is executed.
+
+## Step by step guide to multisig transactions
+
+This tutorial will use the test keyring which will store the keys in the default home directory `~/.simapp` unless otherwise specified.
+Verify which keys are available in the test keyring by running `--keyring-backend test`.
+
+Prior to this tutorial set the keyring backend to "test" in `~/.simapp/client.toml` to always the test keyring which will specify a consistent keyring for the entirety of the tutorial. Additionally, set the default keyring by running `simd config set client keyring-backend test`.
+
+```shell
+simd keys list
+```
+
+If you don't already have accounts listed create the accounts using the below.
+
+```shell
+simd keys add alice
+simd keys add bob
+simd keys add recipient
+```
+
+Alternatively the public keys comprising the multisig can be imported into the keyring.
+
+```shell
+simd keys add alice --pubkey --keyring backend test
+```
+
+Create the multisig account between bob and alice.
+
+```shell
+simd keys add alice-bob-multisig --multisig alice,bob --multisig-threshold 2
+```
+
+Before generating any transaction, verify the balance of each account and note the amount. This step is crucial to confirm that the transaction can be processed successfully.
+
+```shell
+simd query bank balances my_validator
+simd query bank balances alice-bob-multisig
+```
+
+Ensure that the alice-bob-multisig account is funded with a sufficient balance to complete the transaction (gas included). In our case, the genesis account, my_validator, holds our funds. Therefore, we will transfer funds from the `my_validator` account to the `alice-bob-multisig` account.
+Fund the multisig by sending it `stake` from the genesis account.
+
+```shell
+ simd tx bank send my_validator alice-bob-multisig "10000stake"
+```
+
+Check both accounts again to see if the funds have transferred.
+
+```shell
+simd query bank balances alice-bob-multisig
+```
+
+Initiate the transaction. This command will create a transaction from the multisignature account `alice-bob-multisig` to send 1000stake to the recipient account. The transaction will be generated but not broadcasted yet.
+
+```shell
+simd tx bank send alice-bob-multisig recipient 1000stake --generate-only --chain-id my-test-chain > tx.json
+```
+
+Alice signs the transaction using their key and refers to the multisig address. Execute the command below to accomplish this:
+
+```shell
+simd tx sign --from alice --multisig=cosmos1re6mg24kvzjzmwmly3dqrqzdkruxwvctw8wwds tx.json --chain-id my-test-chain > tx-signed-alice.json
+```
+
+Let's repeat for Bob.
+
+```shell
+simd tx sign --from bob --multisig=cosmos1re6mg24kvzjzmwmly3dqrqzdkruxwvctw8wwds tx.json --chain-id my-test-chain > tx-signed-bob.json
+```
+
+Execute a multisign transaction by using the `simd tx multisign` command. This command requires the names and signed transactions of all the participants in the multisig account. Here, Alice and Bob are the participants:
+
+```shell
+simd tx multisign tx.json alice-bob-multisig tx-signed-alice.json tx-signed-bob.json --chain-id my-test-chain > tx-signed.json
+```
+
+Once the multisigned transaction is generated, it needs to be broadcasted to the network. This is done using the simd tx broadcast command:
+
+```shell
+simd tx broadcast tx-signed.json --chain-id my-test-chain --gas auto --fees 250stake
+```
+
+Once the transaction is broadcasted, it's a good practice to verify if the transaction was successful. You can query the recipient's account balance again to confirm if the funds were indeed transferred:
+
+```shell
+simd query bank balances alice-bob-multisig
+```
diff --git a/docs/user/run-node/08-onchain-multisig.md b/docs/user/run-node/08-onchain-multisig.md
new file mode 100644
index 000000000000..a93e59620e54
--- /dev/null
+++ b/docs/user/run-node/08-onchain-multisig.md
@@ -0,0 +1,248 @@
+---
+sidebar_position: 1
+---
+
+# Guide to On-Chain Multisig transactions
+
+## Overview
+
+Multisignature **on-chain** accounts are an improvement over the previous implementation as these introduce a new set of
+features.
+
+### Threshold and quorums
+
+The previous implementation only allowed for m-of-n multisig accounts, where m is the number of signatures required to
+authorize a transaction and n is the total number of signers. The new implementation allows for more flexibility by
+introducing threshold and quorum values. The quorum is the minimum voting power to make a proposal valid, while the
+threshol is the minimum of voting power of YES votes to pass a proposal.
+
+### Revote
+
+Multisigs can allow members to change their votes after the initial vote. This is useful when a member changes their mind
+or when new information becomes available.
+
+### Early execution
+
+Multisigs can be configured to allow for early execution of proposals. This is useful when a proposal is time-sensitive or
+when the proposer wants to execute the proposal as soon as it reaches the threshold. It can also be used to mimic the
+behavior of the previous multisig implementation.
+
+### Voting period
+
+Multisigs can be configured to have a voting period. This is the time window during which members can vote on a proposal.
+If the proposal does not reach the threshold within the voting period, it is considered failed.
+
+## Setup
+
+We'll create a multisig with 3 members with a 2/3 passing threshold.
+
+First create the 3 members, Alice, Bob and Carol:
+
+```bash!
+simd keys add alice --keyring-backend test --home ./.testnets/node0/simd/
+simd keys add bob --keyring-backend test --home ./.testnets/node0/simd/
+simd keys add carol --keyring-backend test --home ./.testnets/node0/simd/
+```
+
+And we initialize them with some tokens (sent from one of our nodes):
+
+```bash!
+simd tx bank send $(simd keys show node0 --address --keyring-backend=test --home ./.testnets/node0/simd/) $(simd keys show alice --address --keyring-backend=test --home ./.testnets/node0/simd/) 100stake --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/
+simd tx bank send $(simd keys show node0 --address --keyring-backend=test --home ./.testnets/node0/simd/) $(simd keys show bob --address --keyring-backend=test --home ./.testnets/node0/simd/) 100stake --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/
+simd tx bank send $(simd keys show node0 --address --keyring-backend=test --home ./.testnets/node0/simd/) $(simd keys show carol --address --keyring-backend=test --home ./.testnets/node0/simd/) 100stake --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/
+```
+
+Now we craft our initialization message, in it we'll include the members' addresses, their weights and the configuration of our multisig.
+
+```json
+{
+ "members": [
+ {
+ "address": "cosmos1pr26h2vq9adq3acvh37pz6wtk65u3y8798scq0",
+ "weight": 1000
+ },
+ {
+ "address": "cosmos1j4p2xlg393rg4mma0058alzgvkrjdddd2f5fll",
+ "weight": 1000
+ },
+ {
+ "address": "cosmos1vaqh39cdex9sgr46ef0tdln5cn0hdyd3s0lx4l",
+ "weight": 1000
+ }
+ ],
+ "config": {
+ "threshold": 2000,
+ "quorum": 2000,
+ "voting_period": 86400,
+ "revote": false,
+ "early_execution": true
+ }
+}
+```
+
+In the configuration we set the threshold and quorum to the same, 2/3 of the members must vote yes to pass the proposal. Other configurations can set the quorum and threshold to different values to mimic how organizations work.
+
+We've also set `early_execution` to true, to allow executing as soon as the proposal passes.
+
+Voting period is in seconds, so we've set that to 24h. And finally `revote` was set to false, because we don't want to allow members to change their vote mid-way through.
+
+To initialize the multisig, we have to run the `accounts init` passing the account type and the json we created.
+
+
+```bash!
+initcontents=$(cat init.json)
+simd tx accounts init multisig $initcontents --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/ --from alice
+```
+
+If everything goes well, we'll get back a tx hash, and we'll check the tx result to get our newly created multisig's address.
+
+```bash!
+simd q tx 472B5B4E181D2F399C0ACE4DEEB26FE4351D13E593ED8E793B005C48BFD32621 --output json | jq -r '.events[] | select(.type == "account_creation") | .attributes[] | select(.key == "address") | .value'
+```
+
+In this case, the address is `cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu`. We can now send tokens to it, just like to a normal account.
+
+```bash!
+simd tx bank send $(simd keys show node0 --address --keyring-backend=test --home ./.testnets/node0/simd/) cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu 10000stake --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/
+```
+
+## Proposals
+
+#### Create proposal
+
+In this multisig, every action is a proposal. We'll do a simple proposal to send tokens from the multisig to Alice.
+
+```json
+{
+ "proposal": {
+ "title": "Send 1000 tokens to Alice",
+ "summary": "Alice is a great multisig member so let's pay her.",
+ "messages": [
+ {
+ "@type": "/cosmos.bank.v1beta1.MsgSend",
+ "from_address": "cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu",
+ "to_address": "cosmos1pr26h2vq9adq3acvh37pz6wtk65u3y8798scq0",
+ "amount": [
+ {
+ "denom": "stake",
+ "amount": "1000"
+ }
+ ]
+ }
+ ]
+ }
+}
+```
+
+> The content of messages was created using a simple `tx send` command and passing the flag `--generate-only` so we could copy the message.
+
+Now we send the tx that will create the proposal:
+
+```bash!
+propcontents=$(cat createprop.json)
+simd tx accounts execute cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu cosmos.accounts.defaults.multisig.v1.MsgCreateProposal $propcontents --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/ --from alice
+```
+
+This will again return a tx hash that we can use to find out the newly created proposal.
+
+```bash!
+simd q tx 5CA4420B67FB040B3DF2484CB875E030123662F43AE9958A9F8028C1281C8654 --output json | jq -r '.events[] | select(.type == "proposal_created") | .attributes[] | select(.key == "proposal_id") | .value'
+```
+
+In this case, because this is the first proposal, we'll get that the proposal ID is 0. We can use this to query it.
+
+```bash!
+simd q accounts query cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu cosmos.accounts.defaults.multisig.v1.QueryProposal '{"proposal_id":1}'
+```
+
+We get back all the details from the proposal, including the end of the voting period and the current status of the proposal.
+
+```yaml
+response:
+ '@type': /cosmos.accounts.defaults.multisig.v1.QueryProposalResponse
+ proposal:
+ messages:
+ - '@type': /cosmos.bank.v1beta1.MsgSend
+ amount:
+ - amount: "1000"
+ denom: stake
+ from_address: cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu
+ to_address: cosmos1pr26h2vq9adq3acvh37pz6wtk65u3y8798scq0
+ status: PROPOSAL_STATUS_VOTING_PERIOD
+ summary: Alice is a great multisig member so let's pay her.
+ title: Send 1000 tokens to Alice
+ voting_period_end: "1717064354"
+```
+
+### Vote on the proposal
+
+Just like before, we'll use `tx accounts execute`, but this time to vote. As we have a 2/3 passing threshold, we have to vote with at least 2 members.
+
+```bash!
+simd tx accounts execute cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu cosmos.accounts.defaults.multisig.v1.MsgVote '{"proposal_id":0, "vote":"VOTE_OPTION_YES"}' --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/ --from alice --yes
+simd tx accounts execute cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu cosmos.accounts.defaults.multisig.v1.MsgVote '{"proposal_id":0, "vote":"VOTE_OPTION_YES"}' --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/ --from bob --yes
+```
+
+### Execute the proposal
+
+Once we got enough votes, we can execute the proposal.
+
+```bash!
+simd tx accounts execute cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu cosmos.accounts.defaults.multisig.v1.MsgExecuteProposal '{"proposal_id":0}' --fees 5stake --chain-id $CHAINID --keyring-backend test --home ./.testnets/node0/simd/ --from bob --yes
+```
+
+Querying the tx hash will get us information about the success or failure of the proposal execution.
+
+```yaml
+- attributes:
+ - index: true
+ key: proposal_id
+ value: "0"
+ - index: true
+ key: yes_votes
+ value: "2000"
+ - index: true
+ key: no_votes
+ value: "0"
+ - index: true
+ key: abstain_votes
+ value: "0"
+ - index: true
+ key: status
+ value: PROPOSAL_STATUS_PASSED
+ - index: true
+ key: reject_err
+ value:
+ - index: true
+ key: exec_err
+ value:
+ - index: true
+ key: msg_index
+ value: "0"
+ type: proposal_tally
+```
+
+Now checking the multisig and Alice's balance, we'll see that the send was performed correctly.
+
+```bash!
+simd q bank balances cosmos1uds6tz96dxfllz7tz3s3tm8tlg6x95g0mc2987sx6psjz98qlpss89sheu
+
+balances:
+- amount: "9000"
+ denom: stake
+pagination:
+ total: "1"
+```
+
+```bash!
+simd q bank balances $(./build/simd keys show alice --address)
+
+balances:
+- amount: "1080"
+ denom: stake
+pagination:
+ total: "1"
+```
+
+
+
diff --git a/docs/user/run-node/_category_.json b/docs/user/run-node/_category_.json
new file mode 100644
index 000000000000..7fcac509a58b
--- /dev/null
+++ b/docs/user/run-node/_category_.json
@@ -0,0 +1,5 @@
+{
+ "label": "Running a Node, API and CLI",
+ "position": 1,
+ "link": null
+}
\ No newline at end of file
diff --git a/docs/user/user.md b/docs/user/user.md
new file mode 100644
index 000000000000..5429e8ad6e29
--- /dev/null
+++ b/docs/user/user.md
@@ -0,0 +1,10 @@
+---
+sidebar_position: 0
+---
+# User Guides
+
+This section is designed for developers who are using the Cosmos SDK to build applications. It provides essential guides and references to effectively use the SDK's features.
+
+* [Setting up keys](./run-node/00-keyring.md) - Learn how to set up secure key management using the Cosmos SDK's keyring feature. This guide provides a streamlined approach to cryptographic key handling, which is crucial for securing your application.
+* [Running a node](./run-node/01-run-node.md) - This guide provides step-by-step instructions to deploy and manage a node in the Cosmos network. It ensures a smooth and reliable operation of your blockchain application by covering all the necessary setup and maintenance steps.
+* [CLI](./run-node/02-interact-node.md) - Discover how to navigate and interact with the Cosmos SDK using the Command Line Interface (CLI). This section covers efficient and powerful command-based operations that can help you manage your application effectively.
diff --git a/go.mod b/go.mod
index 316ed8448cf6..58dba9be0b5c 100644
--- a/go.mod
+++ b/go.mod
@@ -44,7 +44,7 @@ require (
github.com/mattn/go-isatty v0.0.20
github.com/mdp/qrterminal/v3 v3.2.0
github.com/muesli/termenv v0.15.2
- github.com/prometheus/client_golang v1.20.4
+ github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.60.0
github.com/rs/zerolog v1.33.0
github.com/spf13/cast v1.7.0
@@ -54,19 +54,19 @@ require (
github.com/stretchr/testify v1.9.0
github.com/tendermint/go-amino v0.16.0
gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b
- golang.org/x/crypto v0.27.0
+ golang.org/x/crypto v0.28.0
golang.org/x/sync v0.8.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
pgregory.net/rapid v1.1.0
sigs.k8s.io/yaml v1.4.0
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
@@ -163,9 +163,9 @@ require (
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/go.sum b/go.sum
index 5aff95150b03..5c0c2f19141f 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -401,8 +401,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -512,8 +512,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -590,19 +590,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -660,8 +660,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/indexer/postgres/tests/go.mod b/indexer/postgres/tests/go.mod
index b02fb01dd8aa..f204ff8173a9 100644
--- a/indexer/postgres/tests/go.mod
+++ b/indexer/postgres/tests/go.mod
@@ -26,10 +26,10 @@ require (
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
pgregory.net/rapid v1.1.0 // indirect
)
diff --git a/indexer/postgres/tests/go.sum b/indexer/postgres/tests/go.sum
index 6fea319add7f..176e5ddaa9a3 100644
--- a/indexer/postgres/tests/go.sum
+++ b/indexer/postgres/tests/go.sum
@@ -40,14 +40,14 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofm
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/orm/go.mod b/orm/go.mod
index 8bd1d5f47d99..439116b77d9a 100644
--- a/orm/go.mod
+++ b/orm/go.mod
@@ -17,7 +17,7 @@ require (
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
pgregory.net/rapid v1.1.0
)
@@ -54,7 +54,7 @@ require (
github.com/onsi/gomega v1.20.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
diff --git a/orm/go.sum b/orm/go.sum
index 0635f05e49b4..726ff3f59a2d 100644
--- a/orm/go.sum
+++ b/orm/go.sum
@@ -138,8 +138,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA=
@@ -251,8 +251,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/runtime/v2/app.go b/runtime/v2/app.go
index caf55b92ce01..e52ea26c6e9f 100644
--- a/runtime/v2/app.go
+++ b/runtime/v2/app.go
@@ -2,14 +2,13 @@ package runtime
import (
"encoding/json"
- "errors"
- "slices"
runtimev2 "cosmossdk.io/api/cosmos/app/runtime/v2"
appmodulev2 "cosmossdk.io/core/appmodule/v2"
"cosmossdk.io/core/registry"
"cosmossdk.io/core/transaction"
"cosmossdk.io/log"
+ "cosmossdk.io/schema/decoding"
"cosmossdk.io/server/v2/appmanager"
"cosmossdk.io/server/v2/stf"
)
@@ -36,8 +35,6 @@ type App[T transaction.Tx] struct {
logger log.Logger
config *runtimev2.Module
- // modules configuration
- storeKeys []string
interfaceRegistrar registry.InterfaceRegistrar
amino registry.AminoRegistrar
moduleManager *MM[T]
@@ -93,27 +90,6 @@ func (a *App[T]) Close() error {
return nil
}
-// GetStoreKeys returns all the app store keys.
-func (a *App[T]) GetStoreKeys() []string {
- return a.storeKeys
-}
-
-// UnsafeFindStoreKey fetches a registered StoreKey from the App in linear time.
-// NOTE: This should only be used in testing.
-func (a *App[T]) UnsafeFindStoreKey(storeKey string) (string, error) {
- i := slices.IndexFunc(a.storeKeys, func(s string) bool { return s == storeKey })
- if i == -1 {
- return "", errors.New("store key not found")
- }
-
- return a.storeKeys[i], nil
-}
-
-// GetStore returns the app store.
-func (a *App[T]) GetStore() Store {
- return a.db
-}
-
func (a *App[T]) GetAppManager() *appmanager.AppManager[T] {
return a.AppManager
}
@@ -121,3 +97,12 @@ func (a *App[T]) GetAppManager() *appmanager.AppManager[T] {
func (a *App[T]) GetQueryHandlers() map[string]appmodulev2.Handler {
return a.QueryHandlers
}
+
+// GetSchemaDecoderResolver returns the module schema resolver.
+func (a *App[T]) GetSchemaDecoderResolver() decoding.DecoderResolver {
+ moduleSet := map[string]any{}
+ for moduleName, module := range a.moduleManager.Modules() {
+ moduleSet[moduleName] = module
+ }
+ return decoding.ModuleSetDecoderResolver(moduleSet)
+}
diff --git a/runtime/v2/builder.go b/runtime/v2/builder.go
index b28ddbc741b4..adb177d41eb0 100644
--- a/runtime/v2/builder.go
+++ b/runtime/v2/builder.go
@@ -15,13 +15,15 @@ import (
"cosmossdk.io/server/v2/appmanager"
"cosmossdk.io/server/v2/stf"
"cosmossdk.io/server/v2/stf/branch"
+ "cosmossdk.io/store/v2/root"
)
// AppBuilder is a type that is injected into a container by the runtime/v2 module
// (as *AppBuilder) which can be used to create an app which is compatible with
// the existing app.go initialization conventions.
type AppBuilder[T transaction.Tx] struct {
- app *App[T]
+ app *App[T]
+ storeBuilder root.Builder
// the following fields are used to overwrite the default
branch func(state store.ReaderMap) store.WriterMap
@@ -62,14 +64,6 @@ func (a *AppBuilder[T]) RegisterModules(modules map[string]appmodulev2.AppModule
return nil
}
-// RegisterStores registers the provided store keys.
-// This method should only be used for registering extra stores
-// which is necessary for modules that not registered using the app config.
-// To be used in combination of RegisterModules.
-func (a *AppBuilder[T]) RegisterStores(keys ...string) {
- a.app.storeKeys = append(a.app.storeKeys, keys...)
-}
-
// Build builds an *App instance.
func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {
for _, opt := range opts {
@@ -93,8 +87,9 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {
}
}
+ a.app.db = a.storeBuilder.Get()
if a.app.db == nil {
- return nil, fmt.Errorf("app.db is not set, it is required to build the app")
+ return nil, fmt.Errorf("storeBuilder did not return a db")
}
if err := a.app.moduleManager.RegisterServices(a.app); err != nil {
@@ -149,7 +144,7 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {
return nil, errors.New("cannot init genesis on non-zero state")
}
genesisCtx := services.NewGenesisContext(a.branch(zeroState))
- genesisState, err := genesisCtx.Run(ctx, func(ctx context.Context) error {
+ genesisState, err := genesisCtx.Mutate(ctx, func(ctx context.Context) error {
err = a.app.moduleManager.InitGenesisJSON(ctx, genesisJSON, txHandler)
if err != nil {
return fmt.Errorf("failed to init genesis: %w", err)
@@ -205,7 +200,11 @@ func AppBuilderWithBranch[T transaction.Tx](branch func(state store.ReaderMap) s
// AppBuilderWithTxValidator sets the tx validator for the app.
// It overrides all default tx validators defined by modules.
-func AppBuilderWithTxValidator[T transaction.Tx](txValidators func(ctx context.Context, tx T) error) AppBuilderOption[T] {
+func AppBuilderWithTxValidator[T transaction.Tx](
+ txValidators func(
+ ctx context.Context, tx T,
+ ) error,
+) AppBuilderOption[T] {
return func(a *AppBuilder[T]) {
a.txValidator = txValidators
}
@@ -213,7 +212,11 @@ func AppBuilderWithTxValidator[T transaction.Tx](txValidators func(ctx context.C
// AppBuilderWithPostTxExec sets logic that will be executed after each transaction.
// When not provided, a no-op function will be used.
-func AppBuilderWithPostTxExec[T transaction.Tx](postTxExec func(ctx context.Context, tx T, success bool) error) AppBuilderOption[T] {
+func AppBuilderWithPostTxExec[T transaction.Tx](
+ postTxExec func(
+ ctx context.Context, tx T, success bool,
+ ) error,
+) AppBuilderOption[T] {
return func(a *AppBuilder[T]) {
a.postTxExec = postTxExec
}
diff --git a/runtime/v2/go.mod b/runtime/v2/go.mod
index 1bd24cd1e26c..27ed971add6a 100644
--- a/runtime/v2/go.mod
+++ b/runtime/v2/go.mod
@@ -16,21 +16,22 @@ require (
cosmossdk.io/core v1.0.0-alpha.4
cosmossdk.io/depinject v1.0.0
cosmossdk.io/log v1.4.1
+ cosmossdk.io/schema v0.3.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/x/tx v0.13.3
github.com/cosmos/gogoproto v1.7.0
+ github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
- cosmossdk.io/schema v0.3.0 // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
@@ -63,23 +64,23 @@ require (
github.com/onsi/gomega v1.28.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
- github.com/stretchr/testify v1.9.0 // indirect
+ github.com/stretchr/objx v0.5.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
diff --git a/runtime/v2/go.sum b/runtime/v2/go.sum
index b273f05e2e32..3cde1737ee77 100644
--- a/runtime/v2/go.sum
+++ b/runtime/v2/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
cosmossdk.io/core v1.0.0-alpha.4/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY=
@@ -193,8 +193,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -221,6 +221,8 @@ github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
+github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
@@ -243,8 +245,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -294,16 +296,16 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -329,8 +331,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go
index 01b0c93971ab..2d6515b81225 100644
--- a/runtime/v2/manager.go
+++ b/runtime/v2/manager.go
@@ -230,15 +230,17 @@ func (m *MM[T]) ExportGenesisForModules(
channels[moduleName] = make(chan genesisResult)
go func(moduleI ModuleI, ch chan genesisResult) {
genesisCtx := services.NewGenesisContext(stateFactory())
- _, _ = genesisCtx.Run(ctx, func(ctx context.Context) error {
+ err := genesisCtx.Read(ctx, func(ctx context.Context) error {
jm, err := moduleI.ExportGenesis(ctx)
if err != nil {
- ch <- genesisResult{nil, err}
return err
}
ch <- genesisResult{jm, nil}
return nil
})
+ if err != nil {
+ ch <- genesisResult{nil, err}
+ }
}(moduleI, channels[moduleName])
}
@@ -783,7 +785,9 @@ func messagePassingInterceptor(msg transaction.Msg) grpc.UnaryServerInterceptor
}
// requestFullNameFromMethodDesc returns the fully-qualified name of the request message and response of the provided service's method.
-func requestFullNameFromMethodDesc(sd *grpc.ServiceDesc, method grpc.MethodDesc) (protoreflect.FullName, protoreflect.FullName, error) {
+func requestFullNameFromMethodDesc(sd *grpc.ServiceDesc, method grpc.MethodDesc) (
+ protoreflect.FullName, protoreflect.FullName, error,
+) {
methodFullName := protoreflect.FullName(fmt.Sprintf("%s.%s", sd.ServiceName, method.MethodName))
desc, err := gogoproto.HybridResolver.FindDescriptorByName(methodFullName)
if err != nil {
diff --git a/runtime/v2/module.go b/runtime/v2/module.go
index a95e38f96ea5..dcde5ae48772 100644
--- a/runtime/v2/module.go
+++ b/runtime/v2/module.go
@@ -19,7 +19,6 @@ import (
"cosmossdk.io/core/event"
"cosmossdk.io/core/header"
"cosmossdk.io/core/registry"
- "cosmossdk.io/core/server"
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
"cosmossdk.io/depinject"
@@ -27,7 +26,7 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/runtime/v2/services"
"cosmossdk.io/server/v2/stf"
- rootstore "cosmossdk.io/store/v2/root"
+ "cosmossdk.io/store/v2/root"
)
var (
@@ -97,9 +96,9 @@ func init() {
appconfig.Register(&runtimev2.Module{},
appconfig.Provide(
ProvideAppBuilder[transaction.Tx],
- ProvideEnvironment[transaction.Tx],
ProvideModuleManager[transaction.Tx],
- ProvideStoreBuilder,
+ ProvideEnvironment,
+ ProvideKVService,
),
appconfig.Invoke(SetupAppBuilder),
)
@@ -108,6 +107,7 @@ func init() {
func ProvideAppBuilder[T transaction.Tx](
interfaceRegistrar registry.InterfaceRegistrar,
amino registry.AminoRegistrar,
+ storeBuilder root.Builder,
) (
*AppBuilder[T],
*stf.MsgRouterBuilder,
@@ -127,7 +127,6 @@ func ProvideAppBuilder[T transaction.Tx](
msgRouterBuilder := stf.NewMsgRouterBuilder()
app := &App[T]{
- storeKeys: nil,
interfaceRegistrar: interfaceRegistrar,
amino: amino,
msgRouterBuilder: msgRouterBuilder,
@@ -135,7 +134,7 @@ func ProvideAppBuilder[T transaction.Tx](
QueryHandlers: map[string]appmodulev2.Handler{},
storeLoader: DefaultStoreLoader,
}
- appBuilder := &AppBuilder[T]{app: app}
+ appBuilder := &AppBuilder[T]{app: app, storeBuilder: storeBuilder}
return appBuilder, msgRouterBuilder, appModule[T]{app}, protoFiles, protoTypes
}
@@ -149,12 +148,7 @@ type AppInputs struct {
InterfaceRegistrar registry.InterfaceRegistrar
LegacyAmino registry.AminoRegistrar
Logger log.Logger
- // StoreBuilder is a builder for a store/v2 RootStore satisfying the Store interface
- StoreBuilder *StoreBuilder
- // StoreOptions are required as input for the StoreBuilder. If not provided, the default options are used.
- StoreOptions *rootstore.Options `optional:"true"`
- // DynamicConfig can be nil in client wiring, but is required in server wiring.
- DynamicConfig server.DynamicConfig `optional:"true"`
+ StoreBuilder root.Builder
}
func SetupAppBuilder(inputs AppInputs) {
@@ -164,24 +158,8 @@ func SetupAppBuilder(inputs AppInputs) {
app.moduleManager = inputs.ModuleManager
app.moduleManager.RegisterInterfaces(inputs.InterfaceRegistrar)
app.moduleManager.RegisterLegacyAminoCodec(inputs.LegacyAmino)
-
- if inputs.DynamicConfig == nil {
- return
- }
- storeOptions := rootstore.DefaultStoreOptions()
- if inputs.StoreOptions != nil {
- storeOptions = *inputs.StoreOptions
- }
- var err error
- app.db, err = inputs.StoreBuilder.Build(
- inputs.Logger,
- app.storeKeys,
- inputs.DynamicConfig,
- storeOptions,
- )
- if err != nil {
- panic(err)
- }
+ // STF requires some state to run
+ inputs.StoreBuilder.RegisterKey("stf")
}
func ProvideModuleManager[T transaction.Tx](
@@ -192,44 +170,47 @@ func ProvideModuleManager[T transaction.Tx](
return NewModuleManager[T](logger, config, modules)
}
-// ProvideEnvironment provides the environment for keeper modules, while maintaining backward compatibility and provide services directly as well.
-func ProvideEnvironment[T transaction.Tx](
- logger log.Logger,
+func ProvideKVService(
config *runtimev2.Module,
key depinject.ModuleKey,
- appBuilder *AppBuilder[T],
kvFactory store.KVStoreServiceFactory,
- headerService header.Service,
- eventService event.Service,
-) (
- appmodulev2.Environment,
- store.KVStoreService,
- store.MemoryStoreService,
-) {
- var (
- kvService store.KVStoreService = failingStoreService{}
- memKvService store.MemoryStoreService = failingStoreService{}
- )
-
+ storeBuilder root.Builder,
+) (store.KVStoreService, store.MemoryStoreService) {
// skips modules that have no store
- if !slices.Contains(config.SkipStoreKeys, key.Name()) {
- var kvStoreKey string
- storeKeyOverride := storeKeyOverride(config, key.Name())
- if storeKeyOverride != nil {
- kvStoreKey = storeKeyOverride.KvStoreKey
- } else {
- kvStoreKey = key.Name()
- }
+ if slices.Contains(config.SkipStoreKeys, key.Name()) {
+ return &failingStoreService{}, &failingStoreService{}
+ }
+ var kvStoreKey string
+ override := storeKeyOverride(config, key.Name())
+ if override != nil {
+ kvStoreKey = override.KvStoreKey
+ } else {
+ kvStoreKey = key.Name()
+ }
- registerStoreKey(appBuilder, kvStoreKey)
- kvService = kvFactory([]byte(kvStoreKey))
+ storeBuilder.RegisterKey(kvStoreKey)
+ return kvFactory([]byte(kvStoreKey)), stf.NewMemoryStoreService([]byte(fmt.Sprintf("memory:%s", kvStoreKey)))
+}
- memStoreKey := fmt.Sprintf("memory:%s", key.Name())
- registerStoreKey(appBuilder, memStoreKey)
- memKvService = stf.NewMemoryStoreService([]byte(memStoreKey))
+func storeKeyOverride(config *runtimev2.Module, moduleName string) *runtimev2.StoreKeyConfig {
+ for _, cfg := range config.OverrideStoreKeys {
+ if cfg.ModuleName == moduleName {
+ return cfg
+ }
}
+ return nil
+}
- env := appmodulev2.Environment{
+// ProvideEnvironment provides the environment for keeper modules, while maintaining backward compatibility and provide services directly as well.
+func ProvideEnvironment(
+ logger log.Logger,
+ key depinject.ModuleKey,
+ kvService store.KVStoreService,
+ memKvService store.MemoryStoreService,
+ headerService header.Service,
+ eventService event.Service,
+) appmodulev2.Environment {
+ return appmodulev2.Environment{
Logger: logger,
BranchService: stf.BranchService{},
EventService: eventService,
@@ -241,28 +222,14 @@ func ProvideEnvironment[T transaction.Tx](
KVStoreService: kvService,
MemStoreService: memKvService,
}
-
- return env, kvService, memKvService
-}
-
-func registerStoreKey[T transaction.Tx](builder *AppBuilder[T], key string) {
- builder.app.storeKeys = append(builder.app.storeKeys, key)
-}
-
-func storeKeyOverride(config *runtimev2.Module, moduleName string) *runtimev2.StoreKeyConfig {
- for _, cfg := range config.OverrideStoreKeys {
- if cfg.ModuleName == moduleName {
- return cfg
- }
- }
-
- return nil
}
// DefaultServiceBindings provides default services for the following service interfaces:
// - store.KVStoreServiceFactory
// - header.Service
// - comet.Service
+// - event.Service
+// - store/v2/root.Builder
//
// They are all required. For most use cases these default services bindings should be sufficient.
// Power users (or tests) may wish to provide their own services bindings, in which case they must
@@ -275,14 +242,16 @@ func DefaultServiceBindings() depinject.Config {
stf.NewKVStoreService(actor),
)
}
- headerService header.Service = services.NewGenesisHeaderService(stf.HeaderService{})
- cometService comet.Service = &services.ContextAwareCometInfoService{}
- eventService = stf.NewEventService()
+ cometService comet.Service = &services.ContextAwareCometInfoService{}
+ headerService = services.NewGenesisHeaderService(stf.HeaderService{})
+ eventService = services.NewGenesisEventService(stf.NewEventService())
+ storeBuilder = root.NewBuilder()
)
return depinject.Supply(
kvServiceFactory,
headerService,
cometService,
eventService,
+ storeBuilder,
)
}
diff --git a/runtime/v2/services/genesis.go b/runtime/v2/services/genesis.go
index 79ebd92852f8..7e748f562b5c 100644
--- a/runtime/v2/services/genesis.go
+++ b/runtime/v2/services/genesis.go
@@ -2,15 +2,19 @@ package services
import (
"context"
+ "errors"
"fmt"
+ "cosmossdk.io/core/event"
"cosmossdk.io/core/header"
"cosmossdk.io/core/store"
+ "cosmossdk.io/core/transaction"
)
var (
_ store.KVStoreService = (*GenesisKVStoreService)(nil)
_ header.Service = (*GenesisHeaderService)(nil)
+ _ store.KVStore = (*readonlyKVStore)(nil)
)
type genesisContextKeyType struct{}
@@ -21,28 +25,41 @@ var genesisContextKey = genesisContextKeyType{}
// it backs the store.KVStoreService and header.Service interface implementations
// defined in this file.
type genesisContext struct {
- state store.WriterMap
+ state store.ReaderMap
}
// NewGenesisContext creates a new genesis context.
-func NewGenesisContext(state store.WriterMap) genesisContext {
+func NewGenesisContext(state store.ReaderMap) genesisContext {
return genesisContext{
state: state,
}
}
-// Run runs the provided function within the genesis context and returns an
+// Mutate runs the provided function within the genesis context and returns an
// updated store.WriterMap containing the state modifications made during InitGenesis.
-func (g *genesisContext) Run(
+func (g genesisContext) Mutate(
ctx context.Context,
fn func(ctx context.Context) error,
) (store.WriterMap, error) {
+ writerMap, ok := g.state.(store.WriterMap)
+ if !ok {
+ return nil, fmt.Errorf("mutate requires a store.WriterMap, got a %T", g.state)
+ }
ctx = context.WithValue(ctx, genesisContextKey, g)
err := fn(ctx)
if err != nil {
return nil, err
}
- return g.state, nil
+ return writerMap, nil
+}
+
+// Read runs the provided function within the genesis context.
+func (g genesisContext) Read(
+ ctx context.Context,
+ fn func(ctx context.Context) error,
+) error {
+ ctx = context.WithValue(ctx, genesisContextKey, g)
+ return fn(ctx)
}
// GenesisKVStoreService is a store.KVStoreService implementation that is used during
@@ -71,15 +88,36 @@ func (g *GenesisKVStoreService) OpenKVStore(ctx context.Context) store.KVStore {
if v == nil {
return g.executionService.OpenKVStore(ctx)
}
- genCtx, ok := v.(*genesisContext)
+ genCtx, ok := v.(genesisContext)
if !ok {
panic(fmt.Errorf("unexpected genesis context type: %T", v))
}
- state, err := genCtx.state.GetWriter(g.actor)
+ writerMap, ok := genCtx.state.(store.WriterMap)
+ if ok {
+ state, err := writerMap.GetWriter(g.actor)
+ if err != nil {
+ panic(err)
+ }
+ return state
+
+ }
+ state, err := genCtx.state.GetReader(g.actor)
if err != nil {
panic(err)
}
- return state
+ return readonlyKVStore{state}
+}
+
+type readonlyKVStore struct {
+ store.Reader
+}
+
+func (r readonlyKVStore) Set(key, value []byte) error {
+ return errors.New("tried to call Set on a readonly store")
+}
+
+func (r readonlyKVStore) Delete(key []byte) error {
+ return errors.New("tried to call Delete on a readonly store")
}
// GenesisHeaderService is a header.Service implementation that is used during
@@ -100,8 +138,46 @@ func (g *GenesisHeaderService) HeaderInfo(ctx context.Context) header.Info {
// NewGenesisHeaderService creates a new GenesisHeaderService.
// - executionService is the header.Service to use when the genesis context is not active.
-func NewGenesisHeaderService(executionService header.Service) *GenesisHeaderService {
+func NewGenesisHeaderService(executionService header.Service) header.Service {
return &GenesisHeaderService{
executionService: executionService,
}
}
+
+// GenesisEventService is an event.Service implementation that is used during
+// genesis initialization. It wraps an inner execution context event.Service.
+// During genesis initialization, it returns a blackHoleEventManager into which
+// events enter and disappear completely.
+type GenesisEventService struct {
+ executionService event.Service
+}
+
+// NewGenesisEventService creates a new GenesisEventService.
+// - executionService is the event.Service to use when the genesis context is not active.
+func NewGenesisEventService(executionService event.Service) event.Service {
+ return &GenesisEventService{
+ executionService: executionService,
+ }
+}
+
+func (g *GenesisEventService) EventManager(ctx context.Context) event.Manager {
+ v := ctx.Value(genesisContextKey)
+ if v == nil {
+ return g.executionService.EventManager(ctx)
+ }
+ return &blackHoleEventManager{}
+}
+
+var _ event.Manager = (*blackHoleEventManager)(nil)
+
+// blackHoleEventManager is an event.Manager that does nothing.
+// It is used during genesis initialization, genesis events are not emitted.
+type blackHoleEventManager struct{}
+
+func (b *blackHoleEventManager) Emit(_ transaction.Msg) error {
+ return nil
+}
+
+func (b *blackHoleEventManager) EmitKV(_ string, _ ...event.Attribute) error {
+ return nil
+}
diff --git a/runtime/v2/services_test.go b/runtime/v2/services_test.go
new file mode 100644
index 000000000000..83e16d4e7141
--- /dev/null
+++ b/runtime/v2/services_test.go
@@ -0,0 +1,50 @@
+package runtime
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/mock"
+
+ appmodulev2 "cosmossdk.io/core/appmodule/v2"
+ "cosmossdk.io/core/transaction"
+ "cosmossdk.io/server/v2/stf"
+)
+
+// MockModule implements both HasMsgHandlers and HasQueryHandlers
+type MockModule struct {
+ mock.Mock
+ appmodulev2.AppModule
+}
+
+func (m *MockModule) RegisterMsgHandlers(router appmodulev2.MsgRouter) {
+ m.Called(router)
+}
+
+func (m *MockModule) RegisterQueryHandlers(router appmodulev2.QueryRouter) {
+ m.Called(router)
+}
+
+func TestRegisterServices(t *testing.T) {
+ mockModule := new(MockModule)
+
+ app := &App[transaction.Tx]{
+ msgRouterBuilder: stf.NewMsgRouterBuilder(),
+ queryRouterBuilder: stf.NewMsgRouterBuilder(),
+ }
+
+ mm := &MM[transaction.Tx]{
+ modules: map[string]appmodulev2.AppModule{
+ "mock": mockModule,
+ },
+ }
+
+ mockModule.On("RegisterMsgHandlers", app.msgRouterBuilder).Once()
+ mockModule.On("RegisterQueryHandlers", app.queryRouterBuilder).Once()
+
+ err := mm.RegisterServices(app)
+
+ assert.NoError(t, err)
+
+ mockModule.AssertExpectations(t)
+}
diff --git a/runtime/v2/store.go b/runtime/v2/store.go
index 6c45dd5e72db..40912ea41f48 100644
--- a/runtime/v2/store.go
+++ b/runtime/v2/store.go
@@ -3,16 +3,11 @@ package runtime
import (
"errors"
"fmt"
- "path/filepath"
- "cosmossdk.io/core/server"
"cosmossdk.io/core/store"
- "cosmossdk.io/log"
"cosmossdk.io/server/v2/stf"
storev2 "cosmossdk.io/store/v2"
- "cosmossdk.io/store/v2/db"
"cosmossdk.io/store/v2/proof"
- "cosmossdk.io/store/v2/root"
)
// NewKVStoreService creates a new KVStoreService.
@@ -64,58 +59,6 @@ type Store interface {
LastCommitID() (proof.CommitID, error)
}
-// StoreBuilder is a builder for a store/v2 RootStore satisfying the Store interface.
-type StoreBuilder struct {
- store Store
-}
-
-// Build creates a new store/v2 RootStore.
-func (sb *StoreBuilder) Build(
- logger log.Logger,
- storeKeys []string,
- config server.DynamicConfig,
- options root.Options,
-) (Store, error) {
- if sb.store != nil {
- return sb.store, nil
- }
- home := config.GetString(flagHome)
- scRawDb, err := db.NewDB(
- db.DBType(config.GetString("store.app-db-backend")),
- "application",
- filepath.Join(home, "data"),
- nil,
- )
- if err != nil {
- return nil, fmt.Errorf("failed to create SCRawDB: %w", err)
- }
-
- factoryOptions := &root.FactoryOptions{
- Logger: logger,
- RootDir: home,
- Options: options,
- // STF needs to store a bit of state
- StoreKeys: append(storeKeys, "stf"),
- SCRawDB: scRawDb,
- }
-
- rs, err := root.CreateRootStore(factoryOptions)
- if err != nil {
- return nil, fmt.Errorf("failed to create root store: %w", err)
- }
- sb.store = rs
- return sb.store, nil
-}
-
-// Get returns the Store. Build must be called before calling Get or the result will be nil.
-func (sb *StoreBuilder) Get() Store {
- return sb.store
-}
-
-func ProvideStoreBuilder() *StoreBuilder {
- return &StoreBuilder{}
-}
-
// StoreLoader allows for custom loading of the store, this is useful when upgrading the store from a previous version
type StoreLoader func(store Store) error
diff --git a/schema/indexer/start.go b/schema/indexer/start.go
index 909db71ed61a..f675c2916026 100644
--- a/schema/indexer/start.go
+++ b/schema/indexer/start.go
@@ -51,11 +51,11 @@ type IndexingOptions struct {
// IndexingConfig is the configuration of the indexer manager and contains the configuration for each indexer target.
type IndexingConfig struct {
// Target is a map of named indexer targets to their configuration.
- Target map[string]Config
+ Target map[string]Config `mapstructure:"target" toml:"target" json:"target" comment:"Target is a map of named indexer targets to their configuration."`
// ChannelBufferSize is the buffer size of the channels used for buffering data sent to indexer go routines.
// It defaults to 1024.
- ChannelBufferSize *int `json:"channel_buffer_size,omitempty"`
+ ChannelBufferSize int `mapstructure:"channel_buffer_size" toml:"channel_buffer_size" json:"channel_buffer_size,omitempty" comment:"Buffer size of the channels used for buffering data sent to indexer go routines."`
}
// IndexingTarget returns the indexing target listener and associated data.
@@ -142,8 +142,8 @@ func StartIndexing(opts IndexingOptions) (IndexingTarget, error) {
}
bufSize := 1024
- if cfg.ChannelBufferSize != nil {
- bufSize = *cfg.ChannelBufferSize
+ if cfg.ChannelBufferSize != 0 {
+ bufSize = cfg.ChannelBufferSize
}
asyncOpts := appdata.AsyncListenerOptions{
Context: ctx,
diff --git a/server/types/app.go b/server/types/app.go
index ca0a55ca1a0f..c1a67b2ceec3 100644
--- a/server/types/app.go
+++ b/server/types/app.go
@@ -6,7 +6,6 @@ import (
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
cmtcrypto "github.com/cometbft/cometbft/crypto"
- cmttypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/gogoproto/grpc"
"cosmossdk.io/core/server"
@@ -18,6 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
+ sdk "github.com/cosmos/cosmos-sdk/types"
)
type (
@@ -76,7 +76,7 @@ type (
// AppState is the application state as JSON.
AppState json.RawMessage
// Validators is the exported validator set.
- Validators []cmttypes.GenesisValidator
+ Validators []sdk.GenesisValidator
// Height is the app's latest block height.
Height int64
// ConsensusParams are the exported consensus params for ABCI.
diff --git a/server/v2/api/rest/README.md b/server/v2/api/rest/README.md
new file mode 100644
index 000000000000..dd53f848e58e
--- /dev/null
+++ b/server/v2/api/rest/README.md
@@ -0,0 +1,73 @@
+# Cosmos SDK REST API
+
+This document describes how to use a service that exposes endpoints based on Cosmos SDK Protobuf message types. Each endpoint responds with data in JSON format.
+
+## General Description
+
+The service allows querying the blockchain using any type of Protobuf message available in the Cosmos SDK application through HTTP `POST` requests. Each endpoint corresponds to a Cosmos SDK protocol message (`proto`), and responses are returned in JSON format.
+
+## Example
+
+### 1. `QueryBalanceRequest`
+
+This endpoint allows querying the balance of an account given an address and a token denomination.
+
+- **URL:** `localhost:8080/cosmos.bank.v2.QueryBalanceRequest`
+
+- **Method:** `POST`
+
+- **Headers:**
+
+ - `Content-Type: application/json`
+
+- **Body (JSON):**
+
+ ```json
+ {
+ "address": "",
+ "denom": ""
+ }
+ ```
+
+ - `address`: Account address on the Cosmos network.
+ - `denom`: Token denomination (e.g., `stake`).
+
+- **Request Example:**
+
+ ```
+ POST localhost:8080/cosmos.bank.v2.QueryBalanceRequest
+ Content-Type: application/json
+
+ {
+ "address": "cosmos16tms8tax3ha9exdu7x3maxrvall07yum3rdcu0",
+ "denom": "stake"
+ }
+ ```
+
+- **Response Example (JSON):**
+
+ ```json
+ {
+ "balance": {
+ "denom": "stake",
+ "amount": "1000000"
+ }
+ }
+ ```
+
+ The response shows the balance of the specified token for the given account.
+
+## Using Tools
+
+### 1. Using `curl`
+
+To make a request using `curl`, you can run the following command:
+
+```bash
+curl -X POST localhost:8080/cosmos.bank.v2.QueryBalanceRequest \
+ -H "Content-Type: application/json" \
+ -d '{
+ "address": "cosmos16tms8tax3ha9exdu7x3maxrvall07yum3rdcu0",
+ "denom": "stake"
+ }'
+```
\ No newline at end of file
diff --git a/server/v2/api/rest/config.go b/server/v2/api/rest/config.go
new file mode 100644
index 000000000000..c1e9eb260fc6
--- /dev/null
+++ b/server/v2/api/rest/config.go
@@ -0,0 +1,32 @@
+package rest
+
+func DefaultConfig() *Config {
+ return &Config{
+ Enable: true,
+ Address: "localhost:8080",
+ }
+}
+
+type CfgOption func(*Config)
+
+// Config defines configuration for the REST server.
+type Config struct {
+ // Enable defines if the REST server should be enabled.
+ Enable bool `mapstructure:"enable" toml:"enable" comment:"Enable defines if the REST server should be enabled."`
+ // Address defines the API server to listen on
+ Address string `mapstructure:"address" toml:"address" comment:"Address defines the REST server address to bind to."`
+}
+
+// OverwriteDefaultConfig overwrites the default config with the new config.
+func OverwriteDefaultConfig(newCfg *Config) CfgOption {
+ return func(cfg *Config) {
+ *cfg = *newCfg
+ }
+}
+
+// Disable the rest server by default (default enabled).
+func Disable() CfgOption {
+ return func(cfg *Config) {
+ cfg.Enable = false
+ }
+}
diff --git a/server/v2/api/rest/handler.go b/server/v2/api/rest/handler.go
new file mode 100644
index 000000000000..a5338f35cf31
--- /dev/null
+++ b/server/v2/api/rest/handler.go
@@ -0,0 +1,99 @@
+package rest
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "reflect"
+ "strings"
+
+ "github.com/cosmos/gogoproto/jsonpb"
+ gogoproto "github.com/cosmos/gogoproto/proto"
+
+ "cosmossdk.io/core/transaction"
+ "cosmossdk.io/server/v2/appmanager"
+)
+
+const (
+ ContentTypeJSON = "application/json"
+ MaxBodySize = 1 << 20 // 1 MB
+)
+
+func NewDefaultHandler[T transaction.Tx](appManager *appmanager.AppManager[T]) http.Handler {
+ return &DefaultHandler[T]{appManager: appManager}
+}
+
+type DefaultHandler[T transaction.Tx] struct {
+ appManager *appmanager.AppManager[T]
+}
+
+func (h *DefaultHandler[T]) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ if err := h.validateMethodIsPOST(r); err != nil {
+ http.Error(w, err.Error(), http.StatusMethodNotAllowed)
+ return
+ }
+
+ if err := h.validateContentTypeIsJSON(r); err != nil {
+ http.Error(w, err.Error(), http.StatusUnsupportedMediaType)
+ return
+ }
+
+ msg, err := h.createMessage(r)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ query, err := h.appManager.Query(r.Context(), 0, msg)
+ if err != nil {
+ http.Error(w, "Error querying", http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", ContentTypeJSON)
+ if err := json.NewEncoder(w).Encode(query); err != nil {
+ http.Error(w, fmt.Sprintf("Error encoding response: %v", err), http.StatusInternalServerError)
+ }
+}
+
+// validateMethodIsPOST validates that the request method is POST.
+func (h *DefaultHandler[T]) validateMethodIsPOST(r *http.Request) error {
+ if r.Method != http.MethodPost {
+ return fmt.Errorf("method not allowed")
+ }
+ return nil
+}
+
+// validateContentTypeIsJSON validates that the request content type is JSON.
+func (h *DefaultHandler[T]) validateContentTypeIsJSON(r *http.Request) error {
+ contentType := r.Header.Get("Content-Type")
+ if contentType != ContentTypeJSON {
+ return fmt.Errorf("unsupported content type, expected %s", ContentTypeJSON)
+ }
+
+ return nil
+}
+
+// createMessage creates the message by unmarshalling the request body.
+func (h *DefaultHandler[T]) createMessage(r *http.Request) (gogoproto.Message, error) {
+ path := strings.TrimPrefix(r.URL.Path, "/")
+ requestType := gogoproto.MessageType(path)
+ if requestType == nil {
+ return nil, fmt.Errorf("unknown request type")
+ }
+
+ msg, ok := reflect.New(requestType.Elem()).Interface().(gogoproto.Message)
+ if !ok {
+ return nil, fmt.Errorf("failed to create message instance")
+ }
+
+ defer r.Body.Close()
+ limitedReader := io.LimitReader(r.Body, MaxBodySize)
+ err := jsonpb.Unmarshal(limitedReader, msg)
+ if err != nil {
+ return nil, fmt.Errorf("error parsing body: %w", err)
+ }
+
+ return msg, nil
+}
diff --git a/server/v2/api/rest/server.go b/server/v2/api/rest/server.go
new file mode 100644
index 000000000000..eaa0fe8b6b94
--- /dev/null
+++ b/server/v2/api/rest/server.go
@@ -0,0 +1,96 @@
+package rest
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+
+ "cosmossdk.io/core/transaction"
+ "cosmossdk.io/log"
+ serverv2 "cosmossdk.io/server/v2"
+)
+
+const (
+ ServerName = "rest-v2"
+)
+
+type Server[T transaction.Tx] struct {
+ logger log.Logger
+ router *http.ServeMux
+
+ httpServer *http.Server
+ config *Config
+ cfgOptions []CfgOption
+}
+
+func New[T transaction.Tx](cfgOptions ...CfgOption) *Server[T] {
+ return &Server[T]{
+ cfgOptions: cfgOptions,
+ }
+}
+
+func (s *Server[T]) Name() string {
+ return ServerName
+}
+
+func (s *Server[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logger log.Logger) error {
+ s.logger = logger.With(log.ModuleKey, s.Name())
+
+ serverCfg := s.Config().(*Config)
+ if len(cfg) > 0 {
+ if err := serverv2.UnmarshalSubConfig(cfg, s.Name(), &serverCfg); err != nil {
+ return fmt.Errorf("failed to unmarshal config: %w", err)
+ }
+ }
+
+ s.router = http.NewServeMux()
+ s.router.Handle("/", NewDefaultHandler(appI.GetAppManager()))
+ s.config = serverCfg
+
+ return nil
+}
+
+func (s *Server[T]) Start(ctx context.Context) error {
+ if !s.config.Enable {
+ s.logger.Info(fmt.Sprintf("%s server is disabled via config", s.Name()))
+ return nil
+ }
+
+ s.httpServer = &http.Server{
+ Addr: s.config.Address,
+ Handler: s.router,
+ }
+
+ s.logger.Info("starting HTTP server", "address", s.config.Address)
+ if err := s.httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
+ s.logger.Error("failed to start HTTP server", "error", err)
+ return err
+ }
+
+ return nil
+}
+
+func (s *Server[T]) Stop(ctx context.Context) error {
+ if !s.config.Enable {
+ return nil
+ }
+
+ s.logger.Info("stopping HTTP server")
+
+ return s.httpServer.Shutdown(ctx)
+}
+
+func (s *Server[T]) Config() any {
+ if s.config == nil || s.config.Address == "" {
+ cfg := DefaultConfig()
+
+ for _, opt := range s.cfgOptions {
+ opt(cfg)
+ }
+
+ return cfg
+ }
+
+ return s.config
+}
diff --git a/server/v2/api/rest/server_test.go b/server/v2/api/rest/server_test.go
new file mode 100644
index 000000000000..cec027f5d24b
--- /dev/null
+++ b/server/v2/api/rest/server_test.go
@@ -0,0 +1,46 @@
+package rest
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "cosmossdk.io/core/transaction"
+)
+
+func TestServerConfig(t *testing.T) {
+ testCases := []struct {
+ name string
+ setupFunc func() *Config
+ expectedConfig *Config
+ }{
+ {
+ name: "Default configuration, no custom configuration",
+ setupFunc: func() *Config {
+ s := New[transaction.Tx]()
+ return s.Config().(*Config)
+ },
+ expectedConfig: DefaultConfig(),
+ },
+ {
+ name: "Custom configuration",
+ setupFunc: func() *Config {
+ s := New[transaction.Tx](func(config *Config) {
+ config.Enable = false
+ })
+ return s.Config().(*Config)
+ },
+ expectedConfig: &Config{
+ Enable: false, // Custom configuration
+ Address: "localhost:8080",
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ config := tc.setupFunc()
+ require.Equal(t, tc.expectedConfig, config)
+ })
+ }
+}
diff --git a/server/v2/appmanager/go.mod b/server/v2/appmanager/go.mod
index 110213b868b9..381fca3bdd29 100644
--- a/server/v2/appmanager/go.mod
+++ b/server/v2/appmanager/go.mod
@@ -2,6 +2,6 @@ module cosmossdk.io/server/v2/appmanager
go 1.23
-require cosmossdk.io/core v1.0.0-alpha.3
+require cosmossdk.io/core v1.0.0-alpha.4
require cosmossdk.io/schema v0.3.0 // indirect
diff --git a/server/v2/appmanager/go.sum b/server/v2/appmanager/go.sum
index e5d225b85b5e..f798f0c9257f 100644
--- a/server/v2/appmanager/go.sum
+++ b/server/v2/appmanager/go.sum
@@ -1,4 +1,4 @@
-cosmossdk.io/core v1.0.0-alpha.3 h1:pnxaYAas7llXgVz1lM7X6De74nWrhNKnB3yMKe4OUUA=
-cosmossdk.io/core v1.0.0-alpha.3/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
+cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
+cosmossdk.io/core v1.0.0-alpha.4/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
diff --git a/server/v2/cometbft/abci.go b/server/v2/cometbft/abci.go
index cbcf387168a2..d9e20a8ebe65 100644
--- a/server/v2/cometbft/abci.go
+++ b/server/v2/cometbft/abci.go
@@ -43,6 +43,7 @@ type Consensus[T transaction.Tx] struct {
logger log.Logger
appName, version string
app *appmanager.AppManager[T]
+ appCloser func() error
txCodec transaction.Codec[T]
store types.Store
streaming streaming.Manager
@@ -77,6 +78,7 @@ func NewConsensus[T transaction.Tx](
logger log.Logger,
appName string,
app *appmanager.AppManager[T],
+ appCloser func() error,
mp mempool.Mempool[T],
indexedEvents map[string]struct{},
queryHandlersMap map[string]appmodulev2.Handler,
@@ -89,6 +91,7 @@ func NewConsensus[T transaction.Tx](
appName: appName,
version: getCometBFTServerVersion(),
app: app,
+ appCloser: appCloser,
cfg: cfg,
store: store,
logger: logger,
@@ -105,7 +108,7 @@ func NewConsensus[T transaction.Tx](
indexedEvents: indexedEvents,
initialHeight: 0,
queryHandlersMap: queryHandlersMap,
- getProtoRegistry: sync.OnceValues(func() (*protoregistry.Files, error) { return gogoproto.MergedRegistry() }),
+ getProtoRegistry: sync.OnceValues(gogoproto.MergedRegistry),
}
}
@@ -114,11 +117,6 @@ func (c *Consensus[T]) SetStreamingManager(sm streaming.Manager) {
c.streaming = sm
}
-// SetListener sets the listener for the consensus module.
-func (c *Consensus[T]) SetListener(l *appdata.Listener) {
- c.listener = l
-}
-
// RegisterSnapshotExtensions registers the given extensions with the consensus module's snapshot manager.
// It allows additional snapshotter implementations to be used for creating and restoring snapshots.
func (c *Consensus[T]) RegisterSnapshotExtensions(extensions ...snapshots.ExtensionSnapshotter) error {
@@ -244,7 +242,7 @@ func (c *Consensus[T]) Query(ctx context.Context, req *abciproto.QueryRequest) (
}
func (c *Consensus[T]) maybeRunGRPCQuery(ctx context.Context, req *abci.QueryRequest) (resp *abciproto.QueryResponse, isGRPC bool, err error) {
- // if this fails then we cannot serve queries anymore
+ // if this fails then we cannot serve queries anymore
registry, err := c.getProtoRegistry()
if err != nil {
return nil, false, err
diff --git a/server/v2/cometbft/abci_test.go b/server/v2/cometbft/abci_test.go
index 3af3fbec8f29..9a42948c6c61 100644
--- a/server/v2/cometbft/abci_test.go
+++ b/server/v2/cometbft/abci_test.go
@@ -19,7 +19,7 @@ import (
"cosmossdk.io/core/store"
"cosmossdk.io/core/transaction"
"cosmossdk.io/log"
- am "cosmossdk.io/server/v2/appmanager"
+ "cosmossdk.io/server/v2/appmanager"
"cosmossdk.io/server/v2/cometbft/handlers"
cometmock "cosmossdk.io/server/v2/cometbft/internal/mock"
"cosmossdk.io/server/v2/cometbft/mempool"
@@ -672,7 +672,7 @@ func setUpConsensus(t *testing.T, gasLimit uint64, mempool mempool.Mempool[mock.
sc := cometmock.NewMockCommiter(log.NewNopLogger(), string(actorName), "stf")
mockStore := cometmock.NewMockStore(ss, sc)
- b := am.Builder[mock.Tx]{
+ b := appmanager.Builder[mock.Tx]{
STF: s,
DB: mockStore,
ValidateTxGasLimit: gasLimit,
@@ -688,7 +688,7 @@ func setUpConsensus(t *testing.T, gasLimit uint64, mempool mempool.Mempool[mock.
am, err := b.Build()
require.NoError(t, err)
- return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", am, mempool, map[string]struct{}{}, nil, mockStore, Config{AppTomlConfig: DefaultAppTomlConfig()}, mock.TxCodec{}, "test")
+ return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", am, func() error { return nil }, mempool, map[string]struct{}{}, nil, mockStore, Config{AppTomlConfig: DefaultAppTomlConfig()}, mock.TxCodec{}, "test")
}
// Check target version same with store's latest version
diff --git a/server/v2/cometbft/config.go b/server/v2/cometbft/config.go
index 4525e7563c27..d8e591a9695c 100644
--- a/server/v2/cometbft/config.go
+++ b/server/v2/cometbft/config.go
@@ -3,6 +3,7 @@ package cometbft
import (
cmtcfg "github.com/cometbft/cometbft/config"
+ "cosmossdk.io/schema/indexer"
"cosmossdk.io/server/v2/cometbft/mempool"
)
@@ -23,6 +24,10 @@ func DefaultAppTomlConfig() *AppTomlConfig {
Trace: false,
Standalone: false,
Mempool: mempool.DefaultConfig(),
+ Indexer: indexer.IndexingConfig{
+ Target: make(map[string]indexer.Config),
+ ChannelBufferSize: 1024,
+ },
}
}
@@ -37,7 +42,8 @@ type AppTomlConfig struct {
Standalone bool `mapstructure:"standalone" toml:"standalone" comment:"standalone starts the application without the CometBFT node. The node should be started separately."`
// Sub configs
- Mempool mempool.Config `mapstructure:"mempool" toml:"mempool" comment:"mempool defines the configuration for the SDK built-in app-side mempool implementations."`
+ Mempool mempool.Config `mapstructure:"mempool" toml:"mempool" comment:"mempool defines the configuration for the SDK built-in app-side mempool implementations."`
+ Indexer indexer.IndexingConfig `mapstructure:"indexer" toml:"indexer" comment:"indexer defines the configuration for the SDK built-in indexer implementation."`
}
// CfgOption is a function that allows to overwrite the default server configuration.
diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod
index e92a3221ada5..aa08bf57a0de 100644
--- a/server/v2/cometbft/go.mod
+++ b/server/v2/cometbft/go.mod
@@ -22,7 +22,7 @@ require (
cosmossdk.io/core v1.0.0-alpha.4
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
cosmossdk.io/log v1.4.1
- cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9
+ cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac
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
@@ -36,13 +36,13 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
sigs.k8s.io/yaml v1.4.0
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
cosmossdk.io/errors v1.0.1 // indirect
@@ -140,7 +140,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -167,14 +167,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
diff --git a/server/v2/cometbft/go.sum b/server/v2/cometbft/go.sum
index ea29392600d8..36ae82083f3f 100644
--- a/server/v2/cometbft/go.sum
+++ b/server/v2/cometbft/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -20,8 +20,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
-cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 h1:DmOoS/1PeY6Ih0hAVlJ69kLMUrLV+TCbfICrZtB1vdU=
-cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
+cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
+cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
@@ -408,8 +408,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -516,8 +516,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -596,19 +596,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -667,8 +667,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/server/v2/cometbft/internal/mock/mock_reader.go b/server/v2/cometbft/internal/mock/mock_reader.go
index 7638fc3f115b..9911ee55eb81 100644
--- a/server/v2/cometbft/internal/mock/mock_reader.go
+++ b/server/v2/cometbft/internal/mock/mock_reader.go
@@ -23,7 +23,7 @@ func (roa *ReaderMap) GetReader(actor []byte) (corestore.Reader, error) {
return NewMockReader(roa.version, roa.store, actor), nil
}
-// Reader represents a read-only adapter for accessing data from the root store.
+// MockReader represents a read-only adapter for accessing data from the root store.
type MockReader struct {
version uint64 // The version of the data.
store *MockStore // The root store to read data from.
diff --git a/server/v2/cometbft/server.go b/server/v2/cometbft/server.go
index b15f5695cf94..20cd63d07ca4 100644
--- a/server/v2/cometbft/server.go
+++ b/server/v2/cometbft/server.go
@@ -20,10 +20,10 @@ import (
"cosmossdk.io/core/transaction"
"cosmossdk.io/log"
+ "cosmossdk.io/schema/indexer"
serverv2 "cosmossdk.io/server/v2"
cometlog "cosmossdk.io/server/v2/cometbft/log"
"cosmossdk.io/server/v2/cometbft/mempool"
- "cosmossdk.io/server/v2/cometbft/types"
"cosmossdk.io/store/v2/snapshots"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
@@ -48,7 +48,11 @@ type CometBFTServer[T transaction.Tx] struct {
cfgOptions []CfgOption
}
-func New[T transaction.Tx](txCodec transaction.Codec[T], serverOptions ServerOptions[T], cfgOptions ...CfgOption) *CometBFTServer[T] {
+func New[T transaction.Tx](
+ txCodec transaction.Codec[T],
+ serverOptions ServerOptions[T],
+ cfgOptions ...CfgOption,
+) *CometBFTServer[T] {
return &CometBFTServer[T]{
initTxCodec: txCodec,
serverOptions: serverOptions,
@@ -98,15 +102,16 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
}
s.logger = logger.With(log.ModuleKey, s.Name())
- store := appI.GetStore().(types.Store)
+ rs := appI.GetStore()
consensus := NewConsensus(
s.logger,
appI.Name(),
appI.GetAppManager(),
+ appI.Close,
s.serverOptions.Mempool(cfg),
indexEvents,
appI.GetQueryHandlers(),
- store,
+ rs,
s.config,
s.initTxCodec,
chainID,
@@ -119,8 +124,8 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
consensus.addrPeerFilter = s.serverOptions.AddrPeerFilter
consensus.idPeerFilter = s.serverOptions.IdPeerFilter
- ss := store.GetStateStorage().(snapshots.StorageSnapshotter)
- sc := store.GetStateCommitment().(snapshots.CommitSnapshotter)
+ ss := rs.GetStateStorage().(snapshots.StorageSnapshotter)
+ sc := rs.GetStateCommitment().(snapshots.CommitSnapshotter)
snapshotStore, err := GetSnapshotStore(s.config.ConfigTomlConfig.RootDir)
if err != nil {
@@ -128,6 +133,19 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
}
consensus.snapshotManager = snapshots.NewManager(snapshotStore, s.serverOptions.SnapshotOptions(cfg), sc, ss, nil, s.logger)
+ // initialize the indexer
+ if indexerCfg := s.config.AppTomlConfig.Indexer; len(indexerCfg.Target) > 0 {
+ listener, err := indexer.StartIndexing(indexer.IndexingOptions{
+ Config: indexerCfg,
+ Resolver: appI.GetSchemaDecoderResolver(),
+ Logger: s.logger.With(log.ModuleKey, "indexer"),
+ })
+ if err != nil {
+ return fmt.Errorf("failed to start indexing: %w", err)
+ }
+ consensus.listener = &listener.Listener
+ }
+
s.Consensus = consensus
return nil
diff --git a/server/v2/cometbft/types/store.go b/server/v2/cometbft/types/store.go
index ff06163af5ab..3e603ff18ced 100644
--- a/server/v2/cometbft/types/store.go
+++ b/server/v2/cometbft/types/store.go
@@ -7,6 +7,8 @@ import (
)
type Store interface {
+ storev2.Backend
+
// GetLatestVersion returns the latest version that consensus has been made on
GetLatestVersion() (uint64, error)
// StateLatest returns a readonly view over the latest
@@ -30,10 +32,4 @@ type Store interface {
// LastCommitID returns a CommitID pertaining to the last commitment.
LastCommitID() (proof.CommitID, error)
-
- // GetStateStorage returns the SS backend.
- GetStateStorage() storev2.VersionedDatabase
-
- // GetStateCommitment returns the SC backend.
- GetStateCommitment() storev2.Committer
}
diff --git a/server/v2/commands.go b/server/v2/commands.go
index da8e0ec6e537..86f8e400467c 100644
--- a/server/v2/commands.go
+++ b/server/v2/commands.go
@@ -13,7 +13,6 @@ import (
"github.com/spf13/viper"
"cosmossdk.io/core/transaction"
- "cosmossdk.io/log"
)
// Execute executes the root command of an application.
@@ -33,11 +32,10 @@ func Execute(rootCmd *cobra.Command, envPrefix, defaultHome string) error {
}
// AddCommands add the server commands to the root command
-// It configure the config handling and the logger handling
+// It configures the config handling and the logger handling
func AddCommands[T transaction.Tx](
rootCmd *cobra.Command,
newApp AppCreator[T],
- logger log.Logger,
globalServerCfg ServerConfig,
components ...ServerComponent[T],
) error {
@@ -45,7 +43,7 @@ func AddCommands[T transaction.Tx](
return errors.New("no components provided")
}
- server := NewServer(logger, globalServerCfg, components...)
+ server := NewServer(globalServerCfg, components...)
originalPersistentPreRunE := rootCmd.PersistentPreRunE
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
// set the default command outputs
@@ -170,12 +168,12 @@ func configHandle[T transaction.Tx](s *Server[T], cmd *cobra.Command) error {
return err
}
- log, err := NewLogger(v, cmd.OutOrStdout())
+ logger, err := NewLogger(v, cmd.OutOrStdout())
if err != nil {
return err
}
- return SetCmdServerContext(cmd, v, log)
+ return SetCmdServerContext(cmd, v, logger)
}
// findSubCommand finds a sub-command of the provided command whose Use
diff --git a/server/v2/config.go b/server/v2/config.go
index 0670bc374a24..1ab396f0c148 100644
--- a/server/v2/config.go
+++ b/server/v2/config.go
@@ -44,11 +44,8 @@ func ReadConfig(configPath string) (*viper.Viper, error) {
func UnmarshalSubConfig(cfg map[string]any, subName string, target any) error {
var sub any
if subName != "" {
- for k, val := range cfg {
- if k == subName {
- sub = val
- break
- }
+ if val, ok := cfg[subName]; ok {
+ sub = val
}
} else {
sub = cfg
diff --git a/server/v2/config_test.go b/server/v2/config_test.go
index f69e2ed56769..3ddd7893a001 100644
--- a/server/v2/config_test.go
+++ b/server/v2/config_test.go
@@ -10,6 +10,7 @@ import (
serverv2 "cosmossdk.io/server/v2"
grpc "cosmossdk.io/server/v2/api/grpc"
store "cosmossdk.io/server/v2/store"
+ "cosmossdk.io/store/v2/root"
)
func TestReadConfig(t *testing.T) {
@@ -21,7 +22,7 @@ func TestReadConfig(t *testing.T) {
require.NoError(t, err)
require.Equal(t, v.GetString(grpc.FlagAddress), grpc.DefaultConfig().Address)
- require.Equal(t, v.GetString(store.FlagAppDBBackend), store.DefaultConfig().AppDBBackend)
+ require.Equal(t, v.GetString(store.FlagAppDBBackend), root.DefaultConfig().AppDBBackend)
}
func TestUnmarshalSubConfig(t *testing.T) {
@@ -40,8 +41,8 @@ func TestUnmarshalSubConfig(t *testing.T) {
require.True(t, grpc.DefaultConfig().Enable)
require.False(t, grpcConfig.Enable)
- storeConfig := store.Config{}
+ storeConfig := root.Config{}
err = serverv2.UnmarshalSubConfig(cfg, "store", &storeConfig)
require.NoError(t, err)
- require.Equal(t, *store.DefaultConfig(), storeConfig)
+ require.Equal(t, *root.DefaultConfig(), storeConfig)
}
diff --git a/server/v2/go.mod b/server/v2/go.mod
index 220989a6186e..c72f4efe0e1b 100644
--- a/server/v2/go.mod
+++ b/server/v2/go.mod
@@ -16,6 +16,7 @@ require (
cosmossdk.io/core v1.0.0-alpha.4
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29
cosmossdk.io/log v1.4.1
+ cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac
cosmossdk.io/server/v2/appmanager v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-00010101000000-000000000000
github.com/cosmos/cosmos-proto v1.0.0-beta.5
@@ -28,7 +29,7 @@ require (
github.com/hashicorp/go-plugin v1.6.1
github.com/mitchellh/mapstructure v1.5.0
github.com/pelletier/go-toml/v2 v2.2.2
- github.com/prometheus/client_golang v1.20.4
+ github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.60.0
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
@@ -37,12 +38,11 @@ require (
github.com/stretchr/testify v1.9.0
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
- cosmossdk.io/schema v0.3.0 // indirect
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
@@ -97,12 +97,12 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tidwall/btree v1.7.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
diff --git a/server/v2/go.sum b/server/v2/go.sum
index 842232d93dbb..ad080575a985 100644
--- a/server/v2/go.sum
+++ b/server/v2/go.sum
@@ -8,8 +8,8 @@ cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqF
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5/go.mod h1:0CuYKkFHxc1vw2JC+t21THBCALJVROrWVR/3PQ1urpc=
cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
-cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c=
-cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
+cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
+cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
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=
@@ -258,8 +258,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -336,8 +336,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -411,8 +411,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -420,8 +420,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -475,8 +475,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/server/v2/server.go b/server/v2/server.go
index 7ee91e649982..486f5c0ceecb 100644
--- a/server/v2/server.go
+++ b/server/v2/server.go
@@ -61,19 +61,17 @@ const (
var _ ServerComponent[transaction.Tx] = (*Server[transaction.Tx])(nil)
+// Server is the top-level server component which contains all other server components.
type Server[T transaction.Tx] struct {
- logger log.Logger
components []ServerComponent[T]
config ServerConfig
}
func NewServer[T transaction.Tx](
- logger log.Logger,
config ServerConfig,
components ...ServerComponent[T],
) *Server[T] {
return &Server[T]{
- logger: logger,
config: config,
components: components,
}
@@ -85,7 +83,8 @@ func (s *Server[T]) Name() string {
// Start starts all components concurrently.
func (s *Server[T]) Start(ctx context.Context) error {
- s.logger.Info("starting servers...")
+ logger := GetLoggerFromContext(ctx)
+ logger.With(log.ModuleKey, s.Name()).Info("starting servers...")
g, ctx := errgroup.WithContext(ctx)
for _, mod := range s.components {
@@ -105,7 +104,8 @@ func (s *Server[T]) Start(ctx context.Context) error {
// Stop stops all components concurrently.
func (s *Server[T]) Stop(ctx context.Context) error {
- s.logger.Info("stopping servers...")
+ logger := GetLoggerFromContext(ctx)
+ logger.With(log.ModuleKey, s.Name()).Info("stopping servers...")
g, ctx := errgroup.WithContext(ctx)
for _, mod := range s.components {
diff --git a/server/v2/server_test.go b/server/v2/server_test.go
index 97afa40fdaa9..c35dea1fc627 100644
--- a/server/v2/server_test.go
+++ b/server/v2/server_test.go
@@ -19,6 +19,7 @@ import (
grpc "cosmossdk.io/server/v2/api/grpc"
"cosmossdk.io/server/v2/appmanager"
"cosmossdk.io/server/v2/store"
+ storev2 "cosmossdk.io/store/v2"
)
type mockInterfaceRegistry struct{}
@@ -48,6 +49,10 @@ func (*mockApp[T]) InterfaceRegistry() coreserver.InterfaceRegistry {
return &mockInterfaceRegistry{}
}
+func (*mockApp[T]) GetStore() storev2.RootStore {
+ return nil
+}
+
func TestServer(t *testing.T) {
currentDir, err := os.Getwd()
require.NoError(t, err)
@@ -60,18 +65,21 @@ func TestServer(t *testing.T) {
cfg := v.AllSettings()
logger := log.NewLogger(os.Stdout)
+
+ ctx, err := serverv2.SetServerContext(context.Background(), v, logger)
+ require.NoError(t, err)
+
grpcServer := grpc.New[transaction.Tx]()
err = grpcServer.Init(&mockApp[transaction.Tx]{}, cfg, logger)
require.NoError(t, err)
- storeServer := store.New[transaction.Tx](nil /* nil appCreator as not using CLI commands */)
+ storeServer := store.New[transaction.Tx]()
err = storeServer.Init(&mockApp[transaction.Tx]{}, cfg, logger)
require.NoError(t, err)
mockServer := &mockServer{name: "mock-server-1", ch: make(chan string, 100)}
server := serverv2.NewServer(
- logger,
serverv2.DefaultServerConfig(),
grpcServer,
storeServer,
@@ -92,7 +100,7 @@ func TestServer(t *testing.T) {
require.Equal(t, v.GetString(grpcServer.Name()+".address"), grpc.DefaultConfig().Address)
// start empty
- ctx, cancelFn := context.WithCancel(context.TODO())
+ ctx, cancelFn := context.WithCancel(ctx)
go func() {
// wait 5sec and cancel context
<-time.After(5 * time.Second)
diff --git a/server/v2/stf/branch/mergeiter_test.go b/server/v2/stf/branch/mergeiter_test.go
new file mode 100644
index 000000000000..1a9e13bbe65c
--- /dev/null
+++ b/server/v2/stf/branch/mergeiter_test.go
@@ -0,0 +1,130 @@
+package branch
+
+import (
+ "reflect"
+ "testing"
+
+ corestore "cosmossdk.io/core/store"
+)
+
+func TestMergedIterator_Next(t *testing.T) {
+ specs := map[string]struct {
+ setup func() corestore.Iterator
+ exp [][2]string
+ }{
+ "both iterators are empty": {
+ setup: func() corestore.Iterator {
+ parent := newMemState()
+ cache := newMemState()
+ return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true)
+ },
+ },
+ "parent iterator has one item, cache is empty": {
+ setup: func() corestore.Iterator {
+ parent := newMemState()
+ if err := parent.Set([]byte("k1"), []byte("1")); err != nil {
+ t.Fatal(err)
+ }
+ cache := newMemState()
+ return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true)
+ },
+ exp: [][2]string{{"k1", "1"}},
+ },
+ "cache has one item, parent is empty": {
+ setup: func() corestore.Iterator {
+ parent := newMemState()
+ cache := newMemState()
+ if err := cache.Set([]byte("k1"), []byte("1")); err != nil {
+ t.Fatal(err)
+ }
+ return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true)
+ },
+ exp: [][2]string{{"k1", "1"}},
+ },
+ "both iterators have same key, cache preferred": {
+ setup: func() corestore.Iterator {
+ parent := newMemState()
+ if err := parent.Set([]byte("k1"), []byte("parent-val")); err != nil {
+ t.Fatal(err)
+ }
+ cache := newMemState()
+ if err := cache.Set([]byte("k1"), []byte("cache-val")); err != nil {
+ t.Fatal(err)
+ }
+ return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true)
+ },
+ exp: [][2]string{{"k1", "cache-val"}},
+ },
+ "both iterators have same key, but cache value is nil": {
+ setup: func() corestore.Iterator {
+ parent := newMemState()
+ if err := parent.Set([]byte("k1"), []byte("1")); err != nil {
+ t.Fatal(err)
+ }
+ cache := newMemState()
+ if err := cache.Set([]byte("k1"), nil); err != nil {
+ t.Fatal(err)
+ }
+ return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true)
+ },
+ },
+ "parent and cache are ascending": {
+ setup: func() corestore.Iterator {
+ parent := newMemState()
+ if err := parent.Set([]byte("k2"), []byte("v2")); err != nil {
+ t.Fatal(err)
+ }
+ if err := parent.Set([]byte("k3"), []byte("v3")); err != nil {
+ t.Fatal(err)
+ }
+ cache := newMemState()
+ if err := cache.Set([]byte("k1"), []byte("v1")); err != nil {
+ t.Fatal(err)
+ }
+ if err := cache.Set([]byte("k4"), []byte("v4")); err != nil {
+ t.Fatal(err)
+ }
+ return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true)
+ },
+ exp: [][2]string{{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}, {"k4", "v4"}},
+ },
+ "parent and cache are descending": {
+ setup: func() corestore.Iterator {
+ parent := newMemState()
+ if err := parent.Set([]byte("k3"), []byte("v3")); err != nil {
+ t.Fatal(err)
+ }
+ if err := parent.Set([]byte("k2"), []byte("v2")); err != nil {
+ t.Fatal(err)
+ }
+ cache := newMemState()
+ if err := cache.Set([]byte("k4"), []byte("v4")); err != nil {
+ t.Fatal(err)
+ }
+ if err := cache.Set([]byte("k1"), []byte("v1")); err != nil {
+ t.Fatal(err)
+ }
+ return mergeIterators(must(parent.ReverseIterator(nil, nil)), must(cache.ReverseIterator(nil, nil)), false)
+ },
+ exp: [][2]string{{"k4", "v4"}, {"k3", "v3"}, {"k2", "v2"}, {"k1", "v1"}},
+ },
+ }
+ for name, spec := range specs {
+ t.Run(name, func(t *testing.T) {
+ var got [][2]string
+ for iter := spec.setup(); iter.Valid(); iter.Next() {
+ got = append(got, [2]string{string(iter.Key()), string(iter.Value())})
+ }
+ if !reflect.DeepEqual(spec.exp, got) {
+ t.Errorf("expected: %#v, got: %#v", spec.exp, got)
+ }
+ })
+ }
+}
+
+func must[T any](r T, err error) T {
+ if err != nil {
+ panic(err)
+ }
+ return r
+}
diff --git a/server/v2/stf/core_router_service.go b/server/v2/stf/core_router_service.go
index e3a3f95940a6..7506372b8e9d 100644
--- a/server/v2/stf/core_router_service.go
+++ b/server/v2/stf/core_router_service.go
@@ -60,7 +60,7 @@ func (m queryRouterService) CanInvoke(ctx context.Context, typeURL string) error
return exCtx.queryRouter.CanInvoke(ctx, typeURL)
}
-// InvokeUntyped execute a message and returns a response.
+// Invoke execute a message and returns a response.
func (m queryRouterService) Invoke(
ctx context.Context,
req transaction.Msg,
diff --git a/server/v2/stf/gas/defaults.go b/server/v2/stf/gas/defaults.go
index 5b032e81da7e..54d092a83bbb 100644
--- a/server/v2/stf/gas/defaults.go
+++ b/server/v2/stf/gas/defaults.go
@@ -23,7 +23,7 @@ func DefaultGasMeter(gasLimit uint64) coregas.Meter {
return NewMeter(gasLimit)
}
-// DefaultGasConfig returns the default gas config.
+// DefaultConfig returns the default gas config.
// Unless overridden, the default gas costs are:
var DefaultConfig = coregas.GasConfig{
HasCost: 1000,
diff --git a/server/v2/stf/go.mod b/server/v2/stf/go.mod
index 06f5ca471a13..7f55feb3f3f2 100644
--- a/server/v2/stf/go.mod
+++ b/server/v2/stf/go.mod
@@ -11,5 +11,5 @@ require (
require (
github.com/google/go-cmp v0.6.0 // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
)
diff --git a/server/v2/stf/go.sum b/server/v2/stf/go.sum
index 95ab31efba84..29d26cc868dc 100644
--- a/server/v2/stf/go.sum
+++ b/server/v2/stf/go.sum
@@ -10,5 +10,5 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
diff --git a/server/v2/store/commands.go b/server/v2/store/commands.go
index 3b9f175c7b0f..2779ab5de20f 100644
--- a/server/v2/store/commands.go
+++ b/server/v2/store/commands.go
@@ -2,9 +2,6 @@ package store
import (
"fmt"
- "os"
- "path/filepath"
- "strings"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -12,7 +9,6 @@ import (
"cosmossdk.io/log"
serverv2 "cosmossdk.io/server/v2"
storev2 "cosmossdk.io/store/v2"
- "cosmossdk.io/store/v2/db"
"cosmossdk.io/store/v2/root"
)
@@ -45,7 +41,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
logger := log.NewLogger(cmd.OutOrStdout())
- rootStore, keepRecent, err := createRootStore(cmd, vp, logger)
+ rootStore, opts, err := createRootStore(vp, logger)
if err != nil {
return fmt.Errorf("can not create root store %w", err)
}
@@ -60,7 +56,7 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return fmt.Errorf("the database has no valid heights to prune, the latest height: %v", latestHeight)
}
- diff := latestHeight - keepRecent
+ diff := latestHeight - opts.SCPruningOption.KeepRecent
cmd.Printf("pruning heights up to %v\n", diff)
err = rootStore.Prune(latestHeight)
@@ -79,81 +75,14 @@ Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`,
return cmd
}
-func createRootStore(cmd *cobra.Command, v *viper.Viper, logger log.Logger) (storev2.RootStore, uint64, error) {
- tempViper := v
- rootDir := v.GetString(serverv2.FlagHome)
- // handle FlagAppDBBackend
- var dbType db.DBType
- if cmd.Flags().Changed(FlagAppDBBackend) {
- dbStr, err := cmd.Flags().GetString(FlagAppDBBackend)
- if err != nil {
- return nil, 0, err
- }
- dbType = db.DBType(dbStr)
- } else {
- dbType = db.DBType(v.GetString(FlagAppDBBackend))
- }
- scRawDb, err := db.NewDB(dbType, "application", filepath.Join(rootDir, "data"), nil)
+func createRootStore(v *viper.Viper, logger log.Logger) (storev2.RootStore, root.Options, error) {
+ storeConfig, err := UnmarshalConfig(v.AllSettings())
if err != nil {
- panic(err)
- }
-
- // handle KeepRecent & Interval flags
- if cmd.Flags().Changed(FlagKeepRecent) {
- keepRecent, err := cmd.Flags().GetUint64(FlagKeepRecent)
- if err != nil {
- return nil, 0, err
- }
-
- // viper has an issue that we could not override subitem then Unmarshal key
- // so we can not do viper.Set() as comment below
- // https://github.com/spf13/viper/issues/1106
- // Do it by a hacky: overwrite app.toml file then read config again.
-
- // v.Set("store.options.sc-pruning-option.keep-recent", keepRecent) // entry that read from app.toml
- // v.Set("store.options.ss-pruning-option.keep-recent", keepRecent)
-
- err = overrideKeepRecent(filepath.Join(rootDir, "config"), keepRecent)
- if err != nil {
- return nil, 0, err
- }
-
- tempViper, err = serverv2.ReadConfig(filepath.Join(rootDir, "config"))
- if err != nil {
- return nil, 0, err
- }
+ return nil, root.Options{}, fmt.Errorf("failed to unmarshal config: %w", err)
}
-
- storeOpts := root.DefaultStoreOptions()
- if v != nil && v.Sub("store.options") != nil {
- if err := v.Sub("store.options").Unmarshal(&storeOpts); err != nil {
- return nil, 0, fmt.Errorf("failed to store options: %w", err)
- }
- }
-
- store, err := root.CreateRootStore(&root.FactoryOptions{
- Logger: logger,
- RootDir: rootDir,
- Options: storeOpts,
- SCRawDB: scRawDb,
- })
-
- return store, tempViper.GetUint64("store.options.sc-pruning-option.keep-recent"), err
-}
-
-func overrideKeepRecent(configPath string, keepRecent uint64) error {
- bz, err := os.ReadFile(filepath.Join(configPath, "app.toml"))
+ store, err := root.NewBuilder().Build(logger, storeConfig)
if err != nil {
- return err
+ return nil, root.Options{}, fmt.Errorf("failed to create store backend: %w", err)
}
- lines := strings.Split(string(bz), "\n")
-
- for i, line := range lines {
- if strings.Contains(line, "keep-recent") {
- lines[i] = fmt.Sprintf("keep-recent = %d", keepRecent)
- }
- }
- output := strings.Join(lines, "\n")
-
- return os.WriteFile(filepath.Join(configPath, "app.toml"), []byte(output), 0o600)
+ return store, storeConfig.Options, nil
}
diff --git a/server/v2/store/config.go b/server/v2/store/config.go
deleted file mode 100644
index 457bfa9383cb..000000000000
--- a/server/v2/store/config.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package store
-
-import (
- "cosmossdk.io/store/v2/root"
-)
-
-func DefaultConfig() *Config {
- return &Config{
- AppDBBackend: "goleveldb",
- Options: root.DefaultStoreOptions(),
- }
-}
-
-type Config struct {
- AppDBBackend string `mapstructure:"app-db-backend" toml:"app-db-backend" comment:"The type of database for application and snapshots databases."`
- Options root.Options `mapstructure:"options" toml:"options"`
-}
diff --git a/server/v2/store/server.go b/server/v2/store/server.go
index c50a53dc6e24..20ed3b15b0ea 100644
--- a/server/v2/store/server.go
+++ b/server/v2/store/server.go
@@ -9,6 +9,8 @@ import (
"cosmossdk.io/core/transaction"
"cosmossdk.io/log"
serverv2 "cosmossdk.io/server/v2"
+ storev2 "cosmossdk.io/store/v2"
+ "cosmossdk.io/store/v2/root"
)
var (
@@ -21,36 +23,29 @@ const ServerName = "store"
// Server manages store config and contains prune & snapshot commands
type Server[T transaction.Tx] struct {
- config *Config
- // saving appCreator for only RestoreSnapshotCmd
- appCreator serverv2.AppCreator[T]
+ config *root.Config
+ backend storev2.Backend
}
-func New[T transaction.Tx](appCreator serverv2.AppCreator[T]) *Server[T] {
- return &Server[T]{appCreator: appCreator}
+func New[T transaction.Tx]() *Server[T] {
+ return &Server[T]{}
}
-func (s *Server[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logger log.Logger) error {
- serverCfg := s.Config().(*Config)
- if len(cfg) > 0 {
- if err := serverv2.UnmarshalSubConfig(cfg, s.Name(), &serverCfg); err != nil {
- return fmt.Errorf("failed to unmarshal config: %w", err)
- }
- }
-
- s.config = serverCfg
- return nil
+func (s *Server[T]) Init(app serverv2.AppI[T], v map[string]any, _ log.Logger) (err error) {
+ s.backend = app.GetStore()
+ s.config, err = UnmarshalConfig(v)
+ return err
}
func (s *Server[T]) Name() string {
return ServerName
}
-func (s *Server[T]) Start(ctx context.Context) error {
+func (s *Server[T]) Start(context.Context) error {
return nil
}
-func (s *Server[T]) Stop(ctx context.Context) error {
+func (s *Server[T]) Stop(context.Context) error {
return nil
}
@@ -63,15 +58,34 @@ func (s *Server[T]) CLICommands() serverv2.CLIConfig {
s.ListSnapshotsCmd(),
s.DumpArchiveCmd(),
s.LoadArchiveCmd(),
- s.RestoreSnapshotCmd(s.appCreator),
+ s.RestoreSnapshotCmd(s.backend),
},
}
}
func (s *Server[T]) Config() any {
if s.config == nil || s.config.AppDBBackend == "" {
- return DefaultConfig()
+ return root.DefaultConfig()
}
return s.config
}
+
+// UnmarshalConfig unmarshals the store config from the given map.
+// If the config is not found in the map, the default config is returned.
+// If the home directory is found in the map, it sets the home directory in the config.
+// An empty home directory *is* permitted at this stage, but attempting to build
+// the store with an empty home directory will fail.
+func UnmarshalConfig(cfg map[string]any) (*root.Config, error) {
+ config := &root.Config{
+ Options: root.DefaultStoreOptions(),
+ }
+ if err := serverv2.UnmarshalSubConfig(cfg, ServerName, config); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal store config: %w", err)
+ }
+ home := cfg[serverv2.FlagHome]
+ if home != nil {
+ config.Home = home.(string)
+ }
+ return config, nil
+}
diff --git a/server/v2/store/snapshot.go b/server/v2/store/snapshot.go
index b804e34b71c8..cbde7cd9a7d9 100644
--- a/server/v2/store/snapshot.go
+++ b/server/v2/store/snapshot.go
@@ -39,8 +39,7 @@ func (s *Server[T]) ExportSnapshotCmd() *cobra.Command {
}
logger := log.NewLogger(cmd.OutOrStdout())
- // app := appCreator(logger, db, nil, viper)
- rootStore, _, err := createRootStore(cmd, v, logger)
+ rootStore, _, err := createRootStore(v, logger)
if err != nil {
return err
}
@@ -76,7 +75,7 @@ func (s *Server[T]) ExportSnapshotCmd() *cobra.Command {
}
// RestoreSnapshotCmd returns a command to restore a snapshot
-func (s *Server[T]) RestoreSnapshotCmd(newApp serverv2.AppCreator[T]) *cobra.Command {
+func (s *Server[T]) RestoreSnapshotCmd(rootStore storev2.Backend) *cobra.Command {
cmd := &cobra.Command{
Use: "restore ",
Short: "Restore app state from local snapshot",
@@ -95,8 +94,6 @@ func (s *Server[T]) RestoreSnapshotCmd(newApp serverv2.AppCreator[T]) *cobra.Com
}
logger := log.NewLogger(cmd.OutOrStdout())
- app := newApp(logger, v)
- rootStore := app.GetStore().(storev2.RootStore)
sm, err := createSnapshotsManager(cmd, v, logger, rootStore)
if err != nil {
@@ -350,7 +347,9 @@ func (s *Server[T]) LoadArchiveCmd() *cobra.Command {
}
}
-func createSnapshotsManager(cmd *cobra.Command, v *viper.Viper, logger log.Logger, store storev2.RootStore) (*snapshots.Manager, error) {
+func createSnapshotsManager(
+ cmd *cobra.Command, v *viper.Viper, logger log.Logger, store storev2.Backend,
+) (*snapshots.Manager, error) {
home := v.GetString(serverv2.FlagHome)
snapshotStore, err := snapshots.NewStore(filepath.Join(home, "data", "snapshots"))
if err != nil {
@@ -371,7 +370,11 @@ func createSnapshotsManager(cmd *cobra.Command, v *viper.Viper, logger log.Logge
}
}
- sm := snapshots.NewManager(snapshotStore, snapshots.NewSnapshotOptions(interval, uint32(keepRecent)), store.GetStateCommitment().(snapshots.CommitSnapshotter), store.GetStateStorage().(snapshots.StorageSnapshotter), nil, logger)
+ sm := snapshots.NewManager(
+ snapshotStore, snapshots.NewSnapshotOptions(interval, uint32(keepRecent)),
+ store.GetStateCommitment().(snapshots.CommitSnapshotter),
+ store.GetStateStorage().(snapshots.StorageSnapshotter),
+ nil, logger)
return sm, nil
}
diff --git a/server/v2/testdata/app.toml b/server/v2/testdata/app.toml
index 094ac068d94a..3d32be7e57ef 100644
--- a/server/v2/testdata/app.toml
+++ b/server/v2/testdata/app.toml
@@ -25,7 +25,7 @@ minimum-gas-prices = '0stake'
app-db-backend = 'goleveldb'
[store.options]
-# SState storage database type. Currently we support: "sqlite", "pebble" and "rocksdb"
+# State storage database type. Currently we support: "sqlite", "pebble" and "rocksdb"
ss-type = 'sqlite'
# State commitment database type. Currently we support: "iavl" and "iavl-v2"
sc-type = 'iavl'
diff --git a/server/v2/types.go b/server/v2/types.go
index 7cd15fd10307..5406313b080e 100644
--- a/server/v2/types.go
+++ b/server/v2/types.go
@@ -7,7 +7,9 @@ import (
"cosmossdk.io/core/server"
"cosmossdk.io/core/transaction"
"cosmossdk.io/log"
+ "cosmossdk.io/schema/decoding"
"cosmossdk.io/server/v2/appmanager"
+ "cosmossdk.io/store/v2"
)
type AppCreator[T transaction.Tx] func(log.Logger, *viper.Viper) AppI[T]
@@ -17,5 +19,7 @@ type AppI[T transaction.Tx] interface {
InterfaceRegistry() server.InterfaceRegistry
GetAppManager() *appmanager.AppManager[T]
GetQueryHandlers() map[string]appmodulev2.Handler
- GetStore() any
+ GetStore() store.RootStore
+ GetSchemaDecoderResolver() decoding.DecoderResolver
+ Close() error
}
diff --git a/server/v2/util.go b/server/v2/util.go
index 72335621b44b..d02ea30125e5 100644
--- a/server/v2/util.go
+++ b/server/v2/util.go
@@ -13,44 +13,62 @@ import (
"cosmossdk.io/log"
)
+// SetServerContext sets the logger and viper in the context.
+// The server manager expects the logger and viper to be set in the context.
+func SetServerContext(ctx context.Context, viper *viper.Viper, logger log.Logger) (context.Context, error) {
+ if ctx == nil {
+ ctx = context.Background()
+ }
+
+ ctx = context.WithValue(ctx, corectx.LoggerContextKey, logger)
+ ctx = context.WithValue(ctx, corectx.ViperContextKey, viper)
+ return ctx, nil
+}
+
// SetCmdServerContext sets a command's Context value to the provided argument.
+// The server manager expects the logger and viper to be set in the context.
// If the context has not been set, set the given context as the default.
func SetCmdServerContext(cmd *cobra.Command, viper *viper.Viper, logger log.Logger) error {
- var cmdCtx context.Context
- if cmd.Context() == nil {
- cmdCtx = context.Background()
- } else {
- cmdCtx = cmd.Context()
+ ctx, err := SetServerContext(cmd.Context(), viper, logger)
+ if err != nil {
+ return err
}
-
- cmdCtx = context.WithValue(cmdCtx, corectx.LoggerContextKey, logger)
- cmdCtx = context.WithValue(cmdCtx, corectx.ViperContextKey, viper)
- cmd.SetContext(cmdCtx)
-
+ cmd.SetContext(ctx)
return nil
}
-func GetViperFromCmd(cmd *cobra.Command) *viper.Viper {
- value := cmd.Context().Value(corectx.ViperContextKey)
+// GetViperFromContext returns the viper instance from the context.
+func GetViperFromContext(ctx context.Context) *viper.Viper {
+ value := ctx.Value(corectx.ViperContextKey)
v, ok := value.(*viper.Viper)
if !ok {
- panic(fmt.Sprintf("incorrect viper type %T: expected *viper.Viper. Have you forgot to set the viper in the command context?", value))
+ panic(fmt.Sprintf("incorrect viper type %T: expected *viper.Viper. Have you forgot to set the viper in the context?", value))
}
return v
}
-func GetLoggerFromCmd(cmd *cobra.Command) log.Logger {
- v := cmd.Context().Value(corectx.LoggerContextKey)
+// GetViperFromCmd returns the viper instance from the command context.
+func GetViperFromCmd(cmd *cobra.Command) *viper.Viper {
+ return GetViperFromContext(cmd.Context())
+}
+
+// GetLoggerFromContext returns the logger instance from the context.
+func GetLoggerFromContext(ctx context.Context) log.Logger {
+ v := ctx.Value(corectx.LoggerContextKey)
logger, ok := v.(log.Logger)
if !ok {
- panic(fmt.Sprintf("incorrect logger type %T: expected log.Logger. Have you forgot to set the logger in the command context?", v))
+ panic(fmt.Sprintf("incorrect logger type %T: expected log.Logger. Have you forgot to set the logger in the context?", v))
}
return logger
}
+// GetLoggerFromCmd returns the logger instance from the command context.
+func GetLoggerFromCmd(cmd *cobra.Command) log.Logger {
+ return GetLoggerFromContext(cmd.Context())
+}
+
// ExternalIP https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go
-// TODO there must be a better way to get external IP
func ExternalIP() (string, error) {
ifaces, err := net.Interfaces()
if err != nil {
diff --git a/simapp/app.go b/simapp/app.go
index 96ae2f04dbae..3a322827185e 100644
--- a/simapp/app.go
+++ b/simapp/app.go
@@ -387,7 +387,7 @@ func NewSimApp(
appCodec, legacyAmino, app.StakingKeeper, govModuleAddr,
)
- app.FeeGrantKeeper = feegrantkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[feegrant.StoreKey]), logger.With(log.ModuleKey, "x/feegrant")), appCodec, app.AuthKeeper)
+ app.FeeGrantKeeper = feegrantkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[feegrant.StoreKey]), logger.With(log.ModuleKey, "x/feegrant")), appCodec, app.AuthKeeper.AddressCodec())
// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
diff --git a/simapp/export.go b/simapp/export.go
index 05346741b99e..28d15f507a9b 100644
--- a/simapp/export.go
+++ b/simapp/export.go
@@ -5,7 +5,6 @@ import (
"fmt"
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
- cmttypes "github.com/cometbft/cometbft/types"
"cosmossdk.io/collections"
storetypes "cosmossdk.io/store/types"
@@ -13,7 +12,6 @@ import (
"cosmossdk.io/x/staking"
stakingtypes "cosmossdk.io/x/staking/types"
- cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@@ -43,25 +41,10 @@ func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAd
}
validators, err := staking.WriteValidators(ctx, app.StakingKeeper)
- cmtValidators := []cmttypes.GenesisValidator{}
- for _, val := range validators {
- cmtPk, err := cryptocodec.ToCmtPubKeyInterface(val.PubKey)
- if err != nil {
- return servertypes.ExportedApp{}, err
- }
- cmtVal := cmttypes.GenesisValidator{
- Address: val.Address.Bytes(),
- PubKey: cmtPk,
- Power: val.Power,
- Name: val.Name,
- }
-
- cmtValidators = append(cmtValidators, cmtVal)
- }
return servertypes.ExportedApp{
AppState: appState,
- Validators: cmtValidators,
+ Validators: validators,
Height: height,
ConsensusParams: app.BaseApp.GetConsensusParams(ctx),
}, err
diff --git a/simapp/go.mod b/simapp/go.mod
index c2eeafc74d92..356623a6423f 100644
--- a/simapp/go.mod
+++ b/simapp/go.mod
@@ -43,7 +43,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
@@ -53,8 +53,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.8.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
@@ -177,7 +177,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -209,15 +209,15 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/api v0.192.0 // indirect
diff --git a/simapp/go.sum b/simapp/go.sum
index 84be5993cd65..41a4382b5de7 100644
--- a/simapp/go.sum
+++ b/simapp/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -721,8 +721,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -862,8 +862,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1083,13 +1083,13 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1100,8 +1100,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1393,8 +1393,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/simapp/v2/app_di.go b/simapp/v2/app_di.go
index 43ca45f99aed..3c9933721f12 100644
--- a/simapp/v2/app_di.go
+++ b/simapp/v2/app_di.go
@@ -12,10 +12,13 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
"cosmossdk.io/runtime/v2"
+ serverstore "cosmossdk.io/server/v2/store"
+ "cosmossdk.io/store/v2"
"cosmossdk.io/store/v2/root"
basedepinject "cosmossdk.io/x/accounts/defaults/base/depinject"
lockupdepinject "cosmossdk.io/x/accounts/defaults/lockup/depinject"
multisigdepinject "cosmossdk.io/x/accounts/defaults/multisig/depinject"
+ stakingkeeper "cosmossdk.io/x/staking/keeper"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/client"
@@ -37,10 +40,12 @@ type SimApp[T transaction.Tx] struct {
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry codectypes.InterfaceRegistry
+ store store.RootStore
// required keepers during wiring
// others keepers are all in the app
UpgradeKeeper *upgradekeeper.Keeper
+ StakingKeeper *stakingkeeper.Keeper
}
func init() {
@@ -55,6 +60,17 @@ func init() {
func AppConfig() depinject.Config {
return depinject.Configs(
appConfig, // Alternatively use appconfig.LoadYAML(AppConfigYAML)
+ runtime.DefaultServiceBindings(),
+ depinject.Provide(
+ codec.ProvideInterfaceRegistry,
+ codec.ProvideAddressCodec,
+ codec.ProvideProtoCodec,
+ codec.ProvideLegacyAmino,
+ ),
+ depinject.Invoke(
+ std.RegisterInterfaces,
+ std.RegisterLegacyAminoCodec,
+ ),
)
}
@@ -64,14 +80,14 @@ func NewSimApp[T transaction.Tx](
viper *viper.Viper,
) *SimApp[T] {
var (
- app = &SimApp[T]{}
- appBuilder *runtime.AppBuilder[T]
- err error
+ app = &SimApp[T]{}
+ appBuilder *runtime.AppBuilder[T]
+ err error
+ storeBuilder root.Builder
// merge the AppConfig and other configuration in one config
appConfig = depinject.Configs(
AppConfig(),
- runtime.DefaultServiceBindings(),
depinject.Supply(
logger,
viper,
@@ -117,10 +133,6 @@ func NewSimApp[T transaction.Tx](
// interface.
),
depinject.Provide(
- codec.ProvideInterfaceRegistry,
- codec.ProvideAddressCodec,
- codec.ProvideProtoCodec,
- codec.ProvideLegacyAmino,
// inject desired account types:
multisigdepinject.ProvideAccount,
basedepinject.ProvideAccount,
@@ -141,37 +153,33 @@ func NewSimApp[T transaction.Tx](
// }
// })
),
- depinject.Invoke(
- std.RegisterInterfaces,
- std.RegisterLegacyAminoCodec,
- ),
)
)
- // the subsection of config that contains the store options (in app.toml [store.options] header)
- // is unmarshaled into a store.Options struct and passed to the store builder.
- // future work may move this specification and retrieval into store/v2.
- // If these options are not specified then default values will be used.
- if sub := viper.Sub("store.options"); sub != nil {
- storeOptions := &root.Options{}
- err := sub.Unmarshal(storeOptions)
- if err != nil {
- panic(err)
- }
- appConfig = depinject.Configs(appConfig, depinject.Supply(storeOptions))
- }
-
if err := depinject.Inject(appConfig,
+ &storeBuilder,
&appBuilder,
&app.appCodec,
&app.legacyAmino,
&app.txConfig,
&app.interfaceRegistry,
&app.UpgradeKeeper,
+ &app.StakingKeeper,
); err != nil {
panic(err)
}
+ // store/v2 follows a slightly more eager config life cycle than server components
+ storeConfig, err := serverstore.UnmarshalConfig(viper.AllSettings())
+ if err != nil {
+ panic(err)
+ }
+
+ app.store, err = storeBuilder.Build(logger, storeConfig)
+ if err != nil {
+ panic(err)
+ }
+
app.App, err = appBuilder.Build()
if err != nil {
panic(err)
@@ -210,7 +218,16 @@ func (app *SimApp[T]) TxConfig() client.TxConfig {
return app.txConfig
}
-// GetStore gets the app store.
-func (app *SimApp[T]) GetStore() any {
- return app.App.GetStore()
+// GetStore returns the root store.
+func (app *SimApp[T]) GetStore() store.RootStore {
+ return app.store
+}
+
+// Close overwrites the base Close method to close the stores.
+func (app *SimApp[T]) Close() error {
+ if err := app.store.Close(); err != nil {
+ return err
+ }
+
+ return app.App.Close()
}
diff --git a/simapp/v2/app_test.go b/simapp/v2/app_test.go
index f634d2d67664..a5d7f352b4d9 100644
--- a/simapp/v2/app_test.go
+++ b/simapp/v2/app_test.go
@@ -19,7 +19,6 @@ import (
"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
serverv2 "cosmossdk.io/server/v2"
- comettypes "cosmossdk.io/server/v2/cometbft/types"
serverv2store "cosmossdk.io/server/v2/store"
"cosmossdk.io/store/v2/db"
banktypes "cosmossdk.io/x/bank/types"
@@ -73,7 +72,7 @@ func NewTestApp(t *testing.T) (*SimApp[transaction.Tx], context.Context) {
genesisBytes, err := json.Marshal(genesis)
require.NoError(t, err)
- st := app.GetStore().(comettypes.Store)
+ st := app.GetStore()
ci, err := st.LastCommitID()
require.NoError(t, err)
@@ -109,7 +108,7 @@ func MoveNextBlock(t *testing.T, app *SimApp[transaction.Tx], ctx context.Contex
bz := sha256.Sum256([]byte{})
- st := app.GetStore().(comettypes.Store)
+ st := app.GetStore()
ci, err := st.LastCommitID()
require.NoError(t, err)
diff --git a/simapp/v2/export.go b/simapp/v2/export.go
index 5a1757b16535..50f4a898bb37 100644
--- a/simapp/v2/export.go
+++ b/simapp/v2/export.go
@@ -3,27 +3,46 @@ package simapp
import (
"context"
+ "cosmossdk.io/runtime/v2/services"
+ "cosmossdk.io/x/staking"
+
v2 "github.com/cosmos/cosmos-sdk/x/genutil/v2"
)
// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
-func (app *SimApp[T]) ExportAppStateAndValidators(jailAllowedAddrs []string) (v2.ExportedApp, error) {
- // as if they could withdraw from the start of the next block
+// This is a demonstation of how to export a genesis file. Export may need extended at
+// the user discretion for cleaning the genesis state at the end provided with jailAllowedAddrs
+func (app *SimApp[T]) ExportAppStateAndValidators(
+ jailAllowedAddrs []string,
+) (v2.ExportedApp, error) {
ctx := context.Background()
+ var exportedApp v2.ExportedApp
latestHeight, err := app.LoadLatestHeight()
if err != nil {
- return v2.ExportedApp{}, err
+ return exportedApp, err
}
genesis, err := app.ExportGenesis(ctx, latestHeight)
if err != nil {
- return v2.ExportedApp{}, err
+ return exportedApp, err
+ }
+
+ readerMap, err := app.GetStore().StateAt(latestHeight)
+ if err != nil {
+ return exportedApp, err
+ }
+ genesisCtx := services.NewGenesisContext(readerMap)
+ err = genesisCtx.Read(ctx, func(ctx context.Context) error {
+ exportedApp.Validators, err = staking.WriteValidators(ctx, app.StakingKeeper)
+ return err
+ })
+ if err != nil {
+ return exportedApp, err
}
- return v2.ExportedApp{
- AppState: genesis,
- Height: int64(latestHeight),
- }, nil
+ exportedApp.AppState = genesis
+ exportedApp.Height = int64(latestHeight)
+ return exportedApp, nil
}
diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod
index 484d0de1e4ee..457c1e06364c 100644
--- a/simapp/v2/go.mod
+++ b/simapp/v2/go.mod
@@ -39,7 +39,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
@@ -49,8 +49,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.8.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
@@ -61,7 +61,7 @@ require (
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect
- cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
+ cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect
cosmossdk.io/server/v2/appmanager v0.0.0-20240802110823-cffeedff643d // indirect
cosmossdk.io/server/v2/stf v0.0.0-20240708142107-25e99c54bac1 // indirect
cosmossdk.io/store v1.1.1 // indirect
@@ -184,7 +184,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -216,15 +216,15 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/api v0.192.0 // indirect
diff --git a/simapp/v2/go.sum b/simapp/v2/go.sum
index b0eca7fdef2e..4417b3e85971 100644
--- a/simapp/v2/go.sum
+++ b/simapp/v2/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -206,8 +206,8 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
-cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 h1:DmOoS/1PeY6Ih0hAVlJ69kLMUrLV+TCbfICrZtB1vdU=
-cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
+cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
+cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
@@ -725,8 +725,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -866,8 +866,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1087,13 +1087,13 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1104,8 +1104,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1397,8 +1397,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/simapp/v2/simdv2/cmd/commands.go b/simapp/v2/simdv2/cmd/commands.go
index addc7eeb768b..4d669f91749b 100644
--- a/simapp/v2/simdv2/cmd/commands.go
+++ b/simapp/v2/simdv2/cmd/commands.go
@@ -15,9 +15,10 @@ import (
runtimev2 "cosmossdk.io/runtime/v2"
serverv2 "cosmossdk.io/server/v2"
"cosmossdk.io/server/v2/api/grpc"
+ "cosmossdk.io/server/v2/api/rest"
"cosmossdk.io/server/v2/api/telemetry"
"cosmossdk.io/server/v2/cometbft"
- "cosmossdk.io/server/v2/store"
+ serverstore "cosmossdk.io/server/v2/store"
"cosmossdk.io/simapp/v2"
confixcmd "cosmossdk.io/tools/confix/cmd"
@@ -55,11 +56,6 @@ func initRootCmd[T transaction.Tx](
NewTestnetCmd(moduleManager),
)
- logger, err := serverv2.NewLogger(viper.New(), rootCmd.OutOrStdout())
- if err != nil {
- panic(fmt.Sprintf("failed to create logger: %v", err))
- }
-
// add keybase, auxiliary RPC, query, genesis, and tx child commands
rootCmd.AddCommand(
genesisCommand(moduleManager),
@@ -70,10 +66,9 @@ func initRootCmd[T transaction.Tx](
)
// wire server commands
- if err = serverv2.AddCommands(
+ if err := serverv2.AddCommands(
rootCmd,
newApp,
- logger,
initServerConfig(),
cometbft.New(
&genericTxDecoder[T]{txConfig},
@@ -81,8 +76,9 @@ func initRootCmd[T transaction.Tx](
initCometConfig(),
),
grpc.New[T](),
- store.New[T](newApp),
+ serverstore.New[T](),
telemetry.New[T](),
+ rest.New[T](),
); err != nil {
panic(err)
}
diff --git a/simapp/v2/simdv2/cmd/config.go b/simapp/v2/simdv2/cmd/config.go
index 51a7adb178e9..16cb19db93e7 100644
--- a/simapp/v2/simdv2/cmd/config.go
+++ b/simapp/v2/simdv2/cmd/config.go
@@ -79,7 +79,7 @@ func initCometConfig() cometbft.CfgOption {
cfg := cmtcfg.DefaultConfig()
// display only warn logs by default except for p2p and state
- cfg.LogLevel = "*:warn,p2p:info,state:info"
+ cfg.LogLevel = "*:warn,server:info,p2p:info,state:info"
// increase block timeout
cfg.Consensus.TimeoutCommit = 5 * time.Second
// overwrite default pprof listen address
diff --git a/simapp/v2/simdv2/cmd/root_di.go b/simapp/v2/simdv2/cmd/root_di.go
index 1ad834b53a5a..6b13b7201342 100644
--- a/simapp/v2/simdv2/cmd/root_di.go
+++ b/simapp/v2/simdv2/cmd/root_di.go
@@ -20,7 +20,6 @@ import (
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
- "github.com/cosmos/cosmos-sdk/std"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
"github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -37,19 +36,8 @@ func NewRootCmd[T transaction.Tx]() *cobra.Command {
if err := depinject.Inject(
depinject.Configs(
simapp.AppConfig(),
- runtime.DefaultServiceBindings(),
+ depinject.Provide(ProvideClientContext),
depinject.Supply(log.NewNopLogger()),
- depinject.Provide(
- codec.ProvideInterfaceRegistry,
- codec.ProvideAddressCodec,
- codec.ProvideProtoCodec,
- codec.ProvideLegacyAmino,
- ProvideClientContext,
- ),
- depinject.Invoke(
- std.RegisterInterfaces,
- std.RegisterLegacyAminoCodec,
- ),
),
&autoCliOpts,
&moduleManager,
diff --git a/simapp/v2/simdv2/cmd/testnet.go b/simapp/v2/simdv2/cmd/testnet.go
index ae01310f9151..7b71e98b588d 100644
--- a/simapp/v2/simdv2/cmd/testnet.go
+++ b/simapp/v2/simdv2/cmd/testnet.go
@@ -15,7 +15,6 @@ import (
"github.com/spf13/pflag"
"cosmossdk.io/core/transaction"
- "cosmossdk.io/log"
"cosmossdk.io/math"
"cosmossdk.io/math/unsafe"
runtimev2 "cosmossdk.io/runtime/v2"
@@ -342,9 +341,9 @@ func initTestnetFiles[T transaction.Tx](
cometbft.ServerOptions[T]{},
cometbft.OverwriteDefaultConfigTomlConfig(nodeConfig),
)
- storeServer := store.New[T](newApp)
+ storeServer := store.New[T]()
grpcServer := grpc.New[T](grpc.OverwriteDefaultConfig(grpcConfig))
- server := serverv2.NewServer(log.NewNopLogger(), serverCfg, cometServer, grpcServer, storeServer)
+ server := serverv2.NewServer[T](serverCfg, cometServer, grpcServer, storeServer)
err = server.WriteConfig(filepath.Join(nodeDir, "config"))
if err != nil {
return err
diff --git a/store/go.mod b/store/go.mod
index 461c59aa71be..260e335619d5 100644
--- a/store/go.mod
+++ b/store/go.mod
@@ -22,7 +22,7 @@ require (
github.com/tidwall/btree v1.7.0
go.uber.org/mock v0.4.0
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
)
@@ -48,11 +48,11 @@ require (
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.29.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/store/go.sum b/store/go.sum
index ec2fd3014da1..43b213989e02 100644
--- a/store/go.sum
+++ b/store/go.sum
@@ -207,8 +207,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -260,16 +260,16 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -292,8 +292,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/store/prefix/store.go b/store/prefix/store.go
index 26b8b0344a79..d8efb5a62400 100644
--- a/store/prefix/store.go
+++ b/store/prefix/store.go
@@ -12,7 +12,7 @@ import (
var _ types.KVStore = Store{}
-// Store is similar with cometbft/cometbft/libs/db/prefix_db
+// Store is similar with cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
// both gives access only to the limited subset of the store
// for convenience or safety
type Store struct {
@@ -81,7 +81,7 @@ func (s Store) Delete(key []byte) {
}
// Iterator implements KVStore
-// Check https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db.go#L106
+// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L109
func (s Store) Iterator(start, end []byte) types.Iterator {
newstart := cloneAppend(s.prefix, start)
@@ -98,7 +98,7 @@ func (s Store) Iterator(start, end []byte) types.Iterator {
}
// ReverseIterator implements KVStore
-// Check https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db.go#L129
+// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L132
func (s Store) ReverseIterator(start, end []byte) types.Iterator {
newstart := cloneAppend(s.prefix, start)
@@ -192,7 +192,7 @@ func (pi *prefixIterator) Error() error {
return nil
}
-// copied from github.com/cometbft/cometbft/libs/db/prefix_db.go
+// copied from github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
func stripPrefix(key, prefix []byte) []byte {
if len(key) < len(prefix) || !bytes.Equal(key[:len(prefix)], prefix) {
panic("should not happen")
diff --git a/store/prefix/store_test.go b/store/prefix/store_test.go
index b586c37aaded..71846120a1c3 100644
--- a/store/prefix/store_test.go
+++ b/store/prefix/store_test.go
@@ -237,7 +237,7 @@ func TestPrefixStoreReverseIteratorEdgeCase(t *testing.T) {
iter.Close()
}
-// Tests below are ported from https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db_test.go
+// Tests below are ported from https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb_test.go
func mockStoreWithStuff() types.KVStore {
db := coretesting.NewMemDB()
diff --git a/store/v2/commitment/metadata.go b/store/v2/commitment/metadata.go
index 642e6b630dac..a054acf26e89 100644
--- a/store/v2/commitment/metadata.go
+++ b/store/v2/commitment/metadata.go
@@ -17,6 +17,7 @@ const (
)
// MetadataStore is a store for metadata related to the commitment store.
+// It isn't metadata store role to close the underlying KVStore.
type MetadataStore struct {
kv corestore.KVStoreWithBatch
}
diff --git a/store/v2/db/db.go b/store/v2/db/db.go
index a8c741e45424..3be46d750f39 100644
--- a/store/v2/db/db.go
+++ b/store/v2/db/db.go
@@ -3,8 +3,8 @@ package db
import (
"fmt"
+ coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
- "cosmossdk.io/store/v2"
)
type DBType string
@@ -18,7 +18,7 @@ const (
DBFileSuffix string = ".db"
)
-func NewDB(dbType DBType, name, dataDir string, opts store.DBOptions) (corestore.KVStoreWithBatch, error) {
+func NewDB(dbType DBType, name, dataDir string, opts coreserver.DynamicConfig) (corestore.KVStoreWithBatch, error) {
switch dbType {
case DBTypeGoLevelDB:
return NewGoLevelDB(name, dataDir, opts)
diff --git a/store/v2/db/goleveldb.go b/store/v2/db/goleveldb.go
index 59e2e08ad8e4..d1c1242e497d 100644
--- a/store/v2/db/goleveldb.go
+++ b/store/v2/db/goleveldb.go
@@ -14,8 +14,8 @@ import (
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/util"
+ coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
- "cosmossdk.io/store/v2"
storeerrors "cosmossdk.io/store/v2/errors"
)
@@ -28,7 +28,7 @@ type GoLevelDB struct {
db *leveldb.DB
}
-func NewGoLevelDB(name, dir string, opts store.DBOptions) (*GoLevelDB, error) {
+func NewGoLevelDB(name, dir string, opts coreserver.DynamicConfig) (*GoLevelDB, error) {
defaultOpts := &opt.Options{
Filter: filter.NewBloomFilter(10), // by default, goleveldb doesn't use a bloom filter.
}
diff --git a/store/v2/db/pebbledb.go b/store/v2/db/pebbledb.go
index 382ee7079911..e5265883c348 100644
--- a/store/v2/db/pebbledb.go
+++ b/store/v2/db/pebbledb.go
@@ -10,8 +10,8 @@ import (
"github.com/cockroachdb/pebble"
"github.com/spf13/cast"
+ coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
- "cosmossdk.io/store/v2"
storeerrors "cosmossdk.io/store/v2/errors"
)
@@ -28,7 +28,7 @@ func NewPebbleDB(name, dataDir string) (*PebbleDB, error) {
return NewPebbleDBWithOpts(name, dataDir, nil)
}
-func NewPebbleDBWithOpts(name, dataDir string, opts store.DBOptions) (*PebbleDB, error) {
+func NewPebbleDBWithOpts(name, dataDir string, opts coreserver.DynamicConfig) (*PebbleDB, error) {
do := &pebble.Options{
MaxConcurrentCompactions: func() int { return 3 }, // default 1
}
diff --git a/store/v2/db/rocksdb_noflag.go b/store/v2/db/rocksdb_noflag.go
index 6e05c9a10a38..ab6ecba70753 100644
--- a/store/v2/db/rocksdb_noflag.go
+++ b/store/v2/db/rocksdb_noflag.go
@@ -4,8 +4,8 @@
package db
import (
+ coreserver "cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
- "cosmossdk.io/store/v2"
)
var _ corestore.KVStoreWithBatch = (*RocksDB)(nil)
@@ -19,7 +19,7 @@ func NewRocksDB(name, dataDir string) (*RocksDB, error) {
panic("rocksdb must be built with -tags rocksdb")
}
-func NewRocksDBWithOpts(dataDir string, opts store.DBOptions) (*RocksDB, error) {
+func NewRocksDBWithOpts(dataDir string, opts coreserver.DynamicConfig) (*RocksDB, error) {
panic("rocksdb must be built with -tags rocksdb")
}
diff --git a/store/v2/go.mod b/store/v2/go.mod
index 1a0d84d80a8b..d54a715a3b4c 100644
--- a/store/v2/go.mod
+++ b/store/v2/go.mod
@@ -50,17 +50,17 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/text v0.18.0 // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/store/v2/go.sum b/store/v2/go.sum
index 8211266d41a1..eb52ef582617 100644
--- a/store/v2/go.sum
+++ b/store/v2/go.sum
@@ -180,8 +180,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -228,8 +228,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -278,16 +278,16 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -306,8 +306,8 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/store/v2/options.go b/store/v2/options.go
index f87475e4a6d2..a2e64ab2b269 100644
--- a/store/v2/options.go
+++ b/store/v2/options.go
@@ -77,8 +77,3 @@ func (opts *PruningOption) ShouldPrune(version uint64) (bool, uint64) {
return false, 0
}
-
-// DBOptions defines the interface of a database options.
-type DBOptions interface {
- Get(string) interface{}
-}
diff --git a/store/v2/root/builder.go b/store/v2/root/builder.go
new file mode 100644
index 000000000000..885c41d24484
--- /dev/null
+++ b/store/v2/root/builder.go
@@ -0,0 +1,95 @@
+package root
+
+import (
+ "fmt"
+ "path/filepath"
+
+ "cosmossdk.io/log"
+ "cosmossdk.io/store/v2"
+ "cosmossdk.io/store/v2/db"
+)
+
+// Builder is the interface for a store/v2 RootStore builder.
+// RootStores built by the Cosmos SDK typically involve a 2 phase initialization:
+// 1. Namespace registration
+// 2. Configuration and loading
+//
+// The Builder interface is used to facilitate this pattern. Namespaces (store keys) are registered
+// by calling RegisterKey before Build is called. Build is then called with a Config
+// object and a RootStore is returned. Calls to Get may return the `RootStore` if Build
+// was successful, but that's left up to the implementation.
+type Builder interface {
+ // Build creates a new store/v2 RootStore from the given Config.
+ Build(log.Logger, *Config) (store.RootStore, error)
+ // RegisterKey registers a store key (namespace) to be used when building the RootStore.
+ RegisterKey(string)
+ // Get returns the Store. Build should be called before calling Get or the result will be nil.
+ Get() store.RootStore
+}
+
+var _ Builder = (*builder)(nil)
+
+// builder is the default builder for a store/v2 RootStore satisfying the Store interface.
+// Tangibly it combines store key registration and a top-level Config to create a RootStore by calling
+// the CreateRootStore factory function.
+type builder struct {
+ // input
+ storeKeys map[string]struct{}
+
+ // output
+ store store.RootStore
+}
+
+func NewBuilder() Builder {
+ return &builder{storeKeys: make(map[string]struct{})}
+}
+
+// Build creates a new store/v2 RootStore.
+func (sb *builder) Build(
+ logger log.Logger,
+ config *Config,
+) (store.RootStore, error) {
+ if sb.store != nil {
+ return sb.store, nil
+ }
+ if config.Home == "" {
+ return nil, fmt.Errorf("home directory is required")
+ }
+ scRawDb, err := db.NewDB(
+ db.DBType(config.AppDBBackend),
+ "application",
+ filepath.Join(config.Home, "data"),
+ nil,
+ )
+ if err != nil {
+ return nil, fmt.Errorf("failed to create SCRawDB: %w", err)
+ }
+
+ var storeKeys []string
+ for key := range sb.storeKeys {
+ storeKeys = append(storeKeys, key)
+ }
+
+ factoryOptions := &FactoryOptions{
+ Logger: logger,
+ RootDir: config.Home,
+ Options: config.Options,
+ StoreKeys: storeKeys,
+ SCRawDB: scRawDb,
+ }
+
+ rs, err := CreateRootStore(factoryOptions)
+ if err != nil {
+ return nil, fmt.Errorf("failed to create root store: %w", err)
+ }
+ sb.store = rs
+ return sb.store, nil
+}
+
+func (sb *builder) Get() store.RootStore {
+ return sb.store
+}
+
+func (sb *builder) RegisterKey(key string) {
+ sb.storeKeys[key] = struct{}{}
+}
diff --git a/store/v2/root/config.go b/store/v2/root/config.go
new file mode 100644
index 000000000000..28f46a3879b7
--- /dev/null
+++ b/store/v2/root/config.go
@@ -0,0 +1,14 @@
+package root
+
+func DefaultConfig() *Config {
+ return &Config{
+ AppDBBackend: "goleveldb",
+ Options: DefaultStoreOptions(),
+ }
+}
+
+type Config struct {
+ Home string `toml:"-"` // this field is omitted in the TOML file
+ AppDBBackend string `mapstructure:"app-db-backend" toml:"app-db-backend" comment:"The type of database for application and snapshots databases."`
+ Options Options `mapstructure:"options" toml:"options"`
+}
diff --git a/store/v2/root/factory.go b/store/v2/root/factory.go
index e6f86917ab0d..2511a53b434e 100644
--- a/store/v2/root/factory.go
+++ b/store/v2/root/factory.go
@@ -33,9 +33,9 @@ const (
SCTypeIavlV2 SCType = "iavl-v2"
)
-// app.toml config options
+// Options are the options for creating a root store.
type Options struct {
- SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"SState storage database type. Currently we support: \"sqlite\", \"pebble\" and \"rocksdb\""`
+ SSType SSType `mapstructure:"ss-type" toml:"ss-type" comment:"State storage database type. Currently we support: \"sqlite\", \"pebble\" and \"rocksdb\""`
SCType SCType `mapstructure:"sc-type" toml:"sc-type" comment:"State commitment database type. Currently we support: \"iavl\" and \"iavl-v2\""`
SSPruningOption *store.PruningOption `mapstructure:"ss-pruning-option" toml:"ss-pruning-option" comment:"Pruning options for state storage"`
SCPruningOption *store.PruningOption `mapstructure:"sc-pruning-option" toml:"sc-pruning-option" comment:"Pruning options for state commitment"`
@@ -177,5 +177,5 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) {
}
pm := pruning.NewManager(sc, ss, storeOpts.SCPruningOption, storeOpts.SSPruningOption)
- return New(opts.Logger, ss, sc, pm, nil, nil)
+ return New(opts.SCRawDB, opts.Logger, ss, sc, pm, nil, nil)
}
diff --git a/store/v2/root/migrate_test.go b/store/v2/root/migrate_test.go
index 0cc20ae940d9..9bd8dfdd2ef8 100644
--- a/store/v2/root/migrate_test.go
+++ b/store/v2/root/migrate_test.go
@@ -80,7 +80,7 @@ func (s *MigrateStoreTestSuite) SetupTest() {
pm := pruning.NewManager(sc, ss, nil, nil)
// assume no storage store, simulate the migration process
- s.rootStore, err = New(testLog, ss, orgSC, pm, migrationManager, nil)
+ s.rootStore, err = New(dbm.NewMemDB(), testLog, ss, orgSC, pm, migrationManager, nil)
s.Require().NoError(err)
}
diff --git a/store/v2/root/reader.go b/store/v2/root/reader.go
index 39737f812266..b7d8c59fa27a 100644
--- a/store/v2/root/reader.go
+++ b/store/v2/root/reader.go
@@ -54,12 +54,7 @@ func (roa *Reader) Has(key []byte) (bool, error) {
}
func (roa *Reader) Get(key []byte) ([]byte, error) {
- result, err := roa.rootStore.GetStateStorage().Get(roa.actor, roa.version, key)
- if err != nil {
- return nil, err
- }
-
- return result, nil
+ return roa.rootStore.GetStateStorage().Get(roa.actor, roa.version, key)
}
func (roa *Reader) Iterator(start, end []byte) (corestore.Iterator, error) {
diff --git a/store/v2/root/store.go b/store/v2/root/store.go
index c39119a9aaf3..7447c60ae7b2 100644
--- a/store/v2/root/store.go
+++ b/store/v2/root/store.go
@@ -5,6 +5,7 @@ import (
"crypto/sha256"
"errors"
"fmt"
+ "io"
"sync"
"time"
@@ -33,6 +34,9 @@ type Store struct {
logger corelog.Logger
initialVersion uint64
+ // holds the db instance for closing it
+ dbCloser io.Closer
+
// stateStorage reflects the state storage backend
stateStorage store.VersionedDatabase
@@ -68,6 +72,7 @@ type Store struct {
//
// NOTE: The migration manager is optional and can be nil if no migration is required.
func New(
+ dbCloser io.Closer,
logger corelog.Logger,
ss store.VersionedDatabase,
sc store.Committer,
@@ -76,6 +81,7 @@ func New(
m metrics.StoreMetrics,
) (store.RootStore, error) {
return &Store{
+ dbCloser: dbCloser,
logger: logger,
initialVersion: 1,
stateStorage: ss,
@@ -92,6 +98,7 @@ func New(
func (s *Store) Close() (err error) {
err = errors.Join(err, s.stateStorage.Close())
err = errors.Join(err, s.stateCommitment.Close())
+ err = errors.Join(err, s.dbCloser.Close())
s.stateStorage = nil
s.stateCommitment = nil
diff --git a/store/v2/root/store_test.go b/store/v2/root/store_test.go
index e8cf34e014e0..9f925b098b9c 100644
--- a/store/v2/root/store_test.go
+++ b/store/v2/root/store_test.go
@@ -59,7 +59,7 @@ func (s *RootStoreTestSuite) SetupTest() {
s.Require().NoError(err)
pm := pruning.NewManager(sc, ss, nil, nil)
- rs, err := New(noopLog, ss, sc, pm, nil, nil)
+ rs, err := New(dbm.NewMemDB(), noopLog, ss, sc, pm, nil, nil)
s.Require().NoError(err)
s.rootStore = rs
@@ -84,7 +84,7 @@ func (s *RootStoreTestSuite) newStoreWithPruneConfig(config *store.PruningOption
pm := pruning.NewManager(sc, ss, config, config)
- rs, err := New(noopLog, ss, sc, pm, nil, nil)
+ rs, err := New(dbm.NewMemDB(), noopLog, ss, sc, pm, nil, nil)
s.Require().NoError(err)
s.rootStore = rs
@@ -93,7 +93,7 @@ func (s *RootStoreTestSuite) newStoreWithPruneConfig(config *store.PruningOption
func (s *RootStoreTestSuite) newStoreWithBackendMount(ss store.VersionedDatabase, sc store.Committer, pm *pruning.Manager) {
noopLog := coretesting.NewNopLogger()
- rs, err := New(noopLog, ss, sc, pm, nil, nil)
+ rs, err := New(dbm.NewMemDB(), noopLog, ss, sc, pm, nil, nil)
s.Require().NoError(err)
s.rootStore = rs
diff --git a/store/v2/root/upgrade_test.go b/store/v2/root/upgrade_test.go
index a4aee1d5bcfa..47c2882dc2ef 100644
--- a/store/v2/root/upgrade_test.go
+++ b/store/v2/root/upgrade_test.go
@@ -50,7 +50,7 @@ func (s *UpgradeStoreTestSuite) SetupTest() {
sc, err := commitment.NewCommitStore(multiTrees, nil, s.commitDB, testLog)
s.Require().NoError(err)
pm := pruning.NewManager(sc, ss, nil, nil)
- s.rootStore, err = New(testLog, ss, sc, pm, nil, nil)
+ s.rootStore, err = New(s.commitDB, testLog, ss, sc, pm, nil, nil)
s.Require().NoError(err)
// commit changeset
@@ -92,7 +92,7 @@ func (s *UpgradeStoreTestSuite) loadWithUpgrades(upgrades *corestore.StoreUpgrad
sc, err := commitment.NewCommitStore(multiTrees, oldTrees, s.commitDB, testLog)
s.Require().NoError(err)
pm := pruning.NewManager(sc, s.rootStore.GetStateStorage().(store.Pruner), nil, nil)
- s.rootStore, err = New(testLog, s.rootStore.GetStateStorage(), sc, pm, nil, nil)
+ s.rootStore, err = New(s.commitDB, testLog, s.rootStore.GetStateStorage(), sc, pm, nil, nil)
s.Require().NoError(err)
}
diff --git a/store/v2/store.go b/store/v2/store.go
index fee3ad39dbf2..1adf44f0b89b 100644
--- a/store/v2/store.go
+++ b/store/v2/store.go
@@ -12,6 +12,9 @@ import (
// RootStore defines an abstraction layer containing a State Storage (SS) engine
// and one or more State Commitment (SC) engines.
type RootStore interface {
+ Pruner
+ Backend
+
// StateLatest returns a read-only version of the RootStore at the latest
// height, alongside the associated version.
StateLatest() (uint64, corestore.ReaderMap, error)
@@ -21,12 +24,6 @@ type RootStore interface {
// an error must be returned.
StateAt(version uint64) (corestore.ReaderMap, error)
- // GetStateStorage returns the SS backend.
- GetStateStorage() VersionedDatabase
-
- // GetStateCommitment returns the SC backend.
- GetStateCommitment() Committer
-
// Query performs a query on the RootStore for a given store key, version (height),
// and key tuple. Queries should be routed to the underlying SS engine.
Query(storeKey []byte, version uint64, key []byte, prove bool) (QueryResult, error)
@@ -67,11 +64,18 @@ type RootStore interface {
// SetMetrics sets the telemetry handler on the RootStore.
SetMetrics(m metrics.Metrics)
- Prune(version uint64) error
-
io.Closer
}
+// Backend defines the interface for the RootStore backends.
+type Backend interface {
+ // GetStateStorage returns the SS backend.
+ GetStateStorage() VersionedDatabase
+
+ // GetStateCommitment returns the SC backend.
+ GetStateCommitment() Committer
+}
+
// UpgradeableStore defines the interface for upgrading store keys.
type UpgradeableStore interface {
// LoadVersionAndUpgrade behaves identically to LoadVersion except it also
diff --git a/tests/e2e/auth/cli_test.go b/tests/e2e/auth/cli_test.go
deleted file mode 100644
index a029338e3d57..000000000000
--- a/tests/e2e/auth/cli_test.go
+++ /dev/null
@@ -1,20 +0,0 @@
-//go:build e2e
-// +build e2e
-
-package auth
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-
- "cosmossdk.io/simapp"
-
- "github.com/cosmos/cosmos-sdk/testutil/network"
-)
-
-func TestE2ETestSuite(t *testing.T) {
- cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
- cfg.NumValidators = 2
- suite.Run(t, NewE2ETestSuite(cfg))
-}
diff --git a/tests/e2e/auth/suite.go b/tests/e2e/auth/suite.go
deleted file mode 100644
index 31dca150f87e..000000000000
--- a/tests/e2e/auth/suite.go
+++ /dev/null
@@ -1,1808 +0,0 @@
-package auth
-
-import (
- "context"
- "encoding/base64"
- "fmt"
- "strings"
- "testing"
-
- abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
- "github.com/stretchr/testify/require"
- "github.com/stretchr/testify/suite"
-
- "cosmossdk.io/core/address"
- "cosmossdk.io/depinject"
- "cosmossdk.io/math"
- banktypes "cosmossdk.io/x/bank/types"
- govtestutil "cosmossdk.io/x/gov/client/testutil"
- govtypes "cosmossdk.io/x/gov/types/v1beta1"
-
- "github.com/cosmos/cosmos-sdk/client"
- "github.com/cosmos/cosmos-sdk/client/flags"
- addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
- "github.com/cosmos/cosmos-sdk/crypto/hd"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
- authtestkeeper "github.com/cosmos/cosmos-sdk/tests/e2e/auth/keeper"
- "github.com/cosmos/cosmos-sdk/testutil"
- clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
- "github.com/cosmos/cosmos-sdk/testutil/network"
- "github.com/cosmos/cosmos-sdk/testutil/testdata"
- sdk "github.com/cosmos/cosmos-sdk/types"
- "github.com/cosmos/cosmos-sdk/types/tx"
- "github.com/cosmos/cosmos-sdk/types/tx/signing"
- authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
- authclitestutil "github.com/cosmos/cosmos-sdk/x/auth/client/testutil"
- "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
-)
-
-type E2ETestSuite struct {
- suite.Suite
-
- cfg network.Config
- ac address.Codec
- network network.NetworkI
-}
-
-func NewE2ETestSuite(cfg network.Config) *E2ETestSuite {
- return &E2ETestSuite{cfg: cfg}
-}
-
-func (s *E2ETestSuite) SetupSuite() {
- s.T().Log("setting up e2e test suite")
- var err error
- s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
- s.Require().NoError(err)
-
- kb := s.network.GetValidators()[0].GetClientCtx().Keyring
- _, _, err = kb.NewMnemonic("newAccount", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
- s.Require().NoError(err)
-
- account1, _, err := kb.NewMnemonic("newAccount1", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
- s.Require().NoError(err)
-
- account2, _, err := kb.NewMnemonic("newAccount2", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
- s.Require().NoError(err)
- pub1, err := account1.GetPubKey()
- s.Require().NoError(err)
- pub2, err := account2.GetPubKey()
- s.Require().NoError(err)
-
- // Create a dummy account for testing purpose
- _, _, err = kb.NewMnemonic("dummyAccount", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
- s.Require().NoError(err)
-
- multi := kmultisig.NewLegacyAminoPubKey(2, []cryptotypes.PubKey{pub1, pub2})
- _, err = kb.SaveMultisig("multi", multi)
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- s.ac = addresscodec.NewBech32Codec("cosmos")
-}
-
-func (s *E2ETestSuite) TearDownSuite() {
- s.T().Log("tearing down e2e test suite")
- s.network.Cleanup()
-}
-
-func (s *E2ETestSuite) TestCLISignGenOnly() {
- val := s.network.GetValidators()[0]
- val2 := s.network.GetValidators()[1]
-
- k, err := val.GetClientCtx().Keyring.KeyByAddress(val.GetAddress())
- s.Require().NoError(err)
- keyName := k.Name
-
- addr, err := k.GetAddress()
- s.Require().NoError(err)
-
- account, err := val.GetClientCtx().AccountRetriever.GetAccount(val.GetClientCtx(), addr)
- s.Require().NoError(err)
-
- sendTokens := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(10)))
- msgSend := &banktypes.MsgSend{
- FromAddress: val.GetAddress().String(),
- ToAddress: val2.GetAddress().String(),
- Amount: sendTokens,
- }
-
- generatedStd, err := clitestutil.SubmitTestTx(
- val.GetClientCtx(),
- msgSend,
- val.GetAddress(),
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
- opFile := testutil.WriteToNewTempFile(s.T(), generatedStd.String())
- defer opFile.Close()
-
- commonArgs := []string{
- fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
- fmt.Sprintf("--%s=%s", flags.FlagHome, strings.Replace(val.GetClientCtx().HomeDir, "simd", "simcli", 1)),
- fmt.Sprintf("--%s=%s", flags.FlagChainID, val.GetClientCtx().ChainID),
- }
-
- cases := []struct {
- name string
- args []string
- expErr bool
- errMsg string
- }{
- {
- "offline mode with account-number, sequence and keyname (valid)",
- []string{
- opFile.Name(),
- fmt.Sprintf("--%s=true", flags.FlagOffline),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName),
- fmt.Sprintf("--%s=%d", flags.FlagAccountNumber, account.GetAccountNumber()),
- fmt.Sprintf("--%s=%d", flags.FlagSequence, account.GetSequence()),
- },
- false,
- "",
- },
- {
- "offline mode with account-number, sequence and address key (valid)",
- []string{
- opFile.Name(),
- fmt.Sprintf("--%s=true", flags.FlagOffline),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, val.GetAddress().String()),
- fmt.Sprintf("--%s=%d", flags.FlagAccountNumber, account.GetAccountNumber()),
- fmt.Sprintf("--%s=%d", flags.FlagSequence, account.GetSequence()),
- },
- false,
- "",
- },
- {
- "offline mode without account-number and keyname (invalid)",
- []string{
- opFile.Name(),
- fmt.Sprintf("--%s=true", flags.FlagOffline),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName),
- fmt.Sprintf("--%s=%d", flags.FlagSequence, account.GetSequence()),
- },
- true,
- `required flag(s) "account-number" not set`,
- },
- {
- "offline mode without sequence and keyname (invalid)",
- []string{
- opFile.Name(),
- fmt.Sprintf("--%s=true", flags.FlagOffline),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName),
- fmt.Sprintf("--%s=%d", flags.FlagAccountNumber, account.GetAccountNumber()),
- },
- true,
- `required flag(s) "sequence" not set`,
- },
- {
- "offline mode without account-number, sequence and keyname (invalid)",
- []string{
- opFile.Name(),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, keyName),
- fmt.Sprintf("--%s=true", flags.FlagOffline),
- },
- true,
- `required flag(s) "account-number", "sequence" not set`,
- },
- }
-
- for _, tc := range cases {
- cmd := authcli.GetSignCommand()
- cmd.PersistentFlags().String(flags.FlagHome, val.GetClientCtx().HomeDir, "directory for config and data")
- out, err := clitestutil.ExecTestCLICmd(val.GetClientCtx(), cmd, append(tc.args, commonArgs...))
- if tc.expErr {
- s.Require().Error(err)
- s.Require().Contains(err.Error(), tc.errMsg)
- } else {
- s.Require().NoError(err)
- func() {
- signedTx := testutil.WriteToNewTempFile(s.T(), out.String())
- defer signedTx.Close()
- _, err := authclitestutil.TxBroadcastExec(val.GetClientCtx(), signedTx.Name())
- s.Require().NoError(err)
- }()
- }
- }
-}
-
-func (s *E2ETestSuite) TestCLISignBatch() {
- val := s.network.GetValidators()[0]
- clientCtx := val.GetClientCtx()
- sendTokens := sdk.NewCoins(
- sdk.NewCoin(fmt.Sprintf("%stoken", val.GetMoniker()), math.NewInt(10)),
- sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10)),
- )
-
- generatedStd, err := s.createBankMsg(
- val,
- val.GetAddress(),
- sendTokens, clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
-
- outputFile := testutil.WriteToNewTempFile(s.T(), strings.Repeat(generatedStd.String()+"\n", 3))
- defer outputFile.Close()
- clientCtx.HomeDir = strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)
-
- // sign-batch file - offline is set but account-number and sequence are not
- _, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--offline")
- s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
-
- // sign-batch file - offline and sequence is set but account-number is not set
- _, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), "--offline")
- s.Require().EqualError(err, "required flag(s) \"account-number\" not set")
-
- // sign-batch file - offline and account-number is set but sequence is not set
- _, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"), "--offline")
- s.Require().EqualError(err, "required flag(s) \"sequence\" not set")
-
- // sign-batch file - sequence and account-number are set when offline is false
- res, err := authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"))
- s.Require().NoError(err)
- s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
-
- // sign-batch file
- res, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID))
- s.Require().NoError(err)
- s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
-
- // sign-batch file signature only
- res, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--signature-only")
- s.Require().NoError(err)
- s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
-
- // Sign batch malformed tx file.
- malformedFile := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf("malformed%s", generatedStd))
- defer malformedFile.Close()
- _, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID))
- s.Require().Error(err)
-
- // Sign batch malformed tx file signature only.
- _, err = authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--signature-only")
- s.Require().Error(err)
-
- // make a txn to increase the sequence of sender
- _, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, val.GetAddress())
- s.Require().NoError(err)
-
- account1, err := clientCtx.Keyring.Key("newAccount1")
- s.Require().NoError(err)
-
- addr, err := account1.GetAddress()
- s.Require().NoError(err)
-
- // Send coins from validator to multisig.
- _, err = s.createBankMsg(
- val,
- addr,
- sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 1000)),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- // fetch the sequence after a tx, should be incremented.
- _, seq1, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, val.GetAddress())
- s.Require().NoError(err)
- s.Require().Equal(seq+1, seq1)
-
- // signing sign-batch should start from the last sequence.
- signed, err := authclitestutil.TxSignBatchExec(clientCtx, val.GetAddress(), outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--signature-only")
- s.Require().NoError(err)
- signedTxs := strings.Split(strings.Trim(signed.String(), "\n"), "\n")
- s.Require().GreaterOrEqual(len(signedTxs), 1)
-
- sigs, err := s.cfg.TxConfig.UnmarshalSignatureJSON([]byte(signedTxs[0]))
- s.Require().NoError(err)
- s.Require().Equal(sigs[0].Sequence, seq1)
-}
-
-func (s *E2ETestSuite) TestCLIQueryTxCmdByHash() {
- val := s.network.GetValidators()[0]
-
- account2, err := val.GetClientCtx().Keyring.Key("newAccount2")
- s.Require().NoError(err)
-
- sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
-
- addr, err := account2.GetAddress()
- s.Require().NoError(err)
-
- // Send coins.
- res, err := s.createBankMsg(
- val,
- addr,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- var txRes sdk.TxResponse
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(res.Bytes(), &txRes))
-
- testCases := []struct {
- name string
- args []string
- expectErr bool
- rawLogContains string
- }{
- {
- "not enough args",
- []string{},
- true, "",
- },
- {
- "with invalid hash",
- []string{"somethinginvalid", fmt.Sprintf("--%s=json", flags.FlagOutput)},
- true, "",
- },
- {
- "with valid and not existing hash",
- []string{"C7E7D3A86A17AB3A321172239F3B61357937AF0F25D9FA4D2F4DCCAD9B0D7747", fmt.Sprintf("--%s=json", flags.FlagOutput)},
- true, "",
- },
- {
- "happy case",
- []string{txRes.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)},
- false,
- sdk.MsgTypeURL(&banktypes.MsgSend{}),
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- cmd := authcli.QueryTxCmd()
- clientCtx := val.GetClientCtx()
- var (
- out testutil.BufferWriter
- err error
- )
-
- err = s.network.RetryForBlocks(func() error {
- out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
- return err
- }, 2)
- if tc.expectErr {
- s.Require().Error(err)
- s.Require().NotEqual("internal", err.Error())
- } else {
- var result sdk.TxResponse
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &result))
- s.Require().NotNil(result.Height)
- if ok := s.deepContains(result.Events, tc.rawLogContains); !ok {
- s.Require().Fail("raw log does not contain the expected value, expected value: %s", tc.rawLogContains)
- }
- }
- })
- }
-}
-
-func (s *E2ETestSuite) TestCLIQueryTxCmdByEvents() {
- val := s.network.GetValidators()[0]
-
- account2, err := val.GetClientCtx().Keyring.Key("newAccount2")
- s.Require().NoError(err)
-
- sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
-
- addr2, err := account2.GetAddress()
- s.Require().NoError(err)
-
- // Send coins.
- res, err := s.createBankMsg(
- val,
- addr2,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- var txRes sdk.TxResponse
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(res.Bytes(), &txRes))
- s.Require().NoError(s.network.WaitForNextBlock())
-
- var out testutil.BufferWriter
- // Query the tx by hash to get the inner tx.
- err = s.network.RetryForBlocks(func() error {
- out, err = clitestutil.ExecTestCLICmd(val.GetClientCtx(), authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
- return err
- }, 3)
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &txRes))
- protoTx := txRes.GetTx().(*tx.Tx)
-
- testCases := []struct {
- name string
- args []string
- expectErr bool
- expectErrStr string
- }{
- {
- "invalid --type",
- []string{
- fmt.Sprintf("--type=%s", "foo"),
- "bar",
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- true, "unknown --type value foo",
- },
- {
- "--type=acc_seq with no addr+seq",
- []string{
- "--type=acc_seq",
- "",
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- true, "`acc_seq` type takes an argument '/'",
- },
- {
- "non-existing addr+seq combo",
- []string{
- "--type=acc_seq",
- "foobar",
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- true, "found no txs matching given address and sequence combination",
- },
- {
- "addr+seq happy case",
- []string{
- "--type=acc_seq",
- fmt.Sprintf("%s/%d", val.GetAddress(), protoTx.AuthInfo.SignerInfos[0].Sequence),
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- false, "",
- },
- {
- "--type=signature with no signature",
- []string{
- "--type=signature",
- "",
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- true, "argument should be comma-separated signatures",
- },
- {
- "non-existing signatures",
- []string{
- "--type=signature",
- "foo",
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- true, "found no txs matching given signatures",
- },
- {
- "with --signatures happy case",
- []string{
- "--type=signature",
- base64.StdEncoding.EncodeToString(protoTx.Signatures[0]),
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- false, "",
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- cmd := authcli.QueryTxCmd()
- clientCtx := val.GetClientCtx()
-
- out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
- if tc.expectErr {
- s.Require().Error(err)
- s.Require().Contains(err.Error(), tc.expectErrStr)
- } else {
- var result sdk.TxResponse
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &result))
- s.Require().NotNil(result.Height)
- }
- })
- }
-}
-
-func (s *E2ETestSuite) TestCLIQueryTxsCmdByEvents() {
- val := s.network.GetValidators()[0]
-
- account2, err := val.GetClientCtx().Keyring.Key("newAccount2")
- s.Require().NoError(err)
-
- sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
-
- addr2, err := account2.GetAddress()
- s.Require().NoError(err)
- // Send coins.
- res, err := s.createBankMsg(
- val,
- addr2,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- var txRes sdk.TxResponse
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(res.Bytes(), &txRes))
- s.Require().NoError(s.network.WaitForNextBlock())
-
- var out testutil.BufferWriter
- // Query the tx by hash to get the inner tx.
- err = s.network.RetryForBlocks(func() error {
- out, err = clitestutil.ExecTestCLICmd(val.GetClientCtx(), authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
- return err
- }, 3)
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &txRes))
-
- testCases := []struct {
- name string
- args []string
- expectEmpty bool
- }{
- {
- "fee event happy case",
- []string{
- fmt.Sprintf(
- "--query=tx.fee='%s'",
- sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10))).String(),
- ),
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- false,
- },
- {
- "no matching fee event",
- []string{
- fmt.Sprintf(
- "--query=tx.fee='%s'",
- sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(0))).String(),
- ),
- fmt.Sprintf("--%s=json", flags.FlagOutput),
- },
- true,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- cmd := authcli.QueryTxsByEventsCmd()
- clientCtx := val.GetClientCtx()
-
- out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
- s.Require().NoError(err)
-
- var result sdk.SearchTxsResult
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(out.Bytes(), &result))
-
- if tc.expectEmpty {
- s.Require().Equal(0, len(result.Txs))
- } else {
- s.Require().NotEqual(0, len(result.Txs))
- s.Require().NotNil(result.Txs[0])
- }
- })
- }
-}
-
-func (s *E2ETestSuite) TestCLISendGenerateSignAndBroadcast() {
- val1 := s.network.GetValidators()[0]
- clientCtx := val1.GetClientCtx()
-
- account, err := clientCtx.Keyring.Key("newAccount")
- s.Require().NoError(err)
-
- sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction))
-
- addr, err := account.GetAddress()
- s.Require().NoError(err)
- normalGeneratedTx, err := s.createBankMsg(
- val1,
- addr,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
- txCfg := clientCtx.TxConfig
-
- normalGeneratedStdTx, err := txCfg.TxJSONDecoder()(normalGeneratedTx.Bytes())
- s.Require().NoError(err)
- txBuilder, err := txCfg.WrapTxBuilder(normalGeneratedStdTx)
- s.Require().NoError(err)
- s.Require().Equal(txBuilder.GetTx().GetGas(), uint64(flags.DefaultGasLimit))
- s.Require().Equal(len(txBuilder.GetTx().GetMsgs()), 1)
- sigs, err := txBuilder.GetTx().GetSignaturesV2()
- s.Require().NoError(err)
- s.Require().Equal(0, len(sigs))
-
- // Test generate sendTx with --gas=$amount
- limitedGasGeneratedTx, err := s.createBankMsg(val1, addr,
- sdk.NewCoins(sendTokens), clitestutil.TestTxConfig{
- GenOnly: true,
- Gas: 100,
- },
- )
- s.Require().NoError(err)
-
- limitedGasStdTx, err := txCfg.TxJSONDecoder()(limitedGasGeneratedTx.Bytes())
- s.Require().NoError(err)
- txBuilder, err = txCfg.WrapTxBuilder(limitedGasStdTx)
- s.Require().NoError(err)
- s.Require().Equal(txBuilder.GetTx().GetGas(), uint64(100))
- s.Require().Equal(len(txBuilder.GetTx().GetMsgs()), 1)
- sigs, err = txBuilder.GetTx().GetSignaturesV2()
- s.Require().NoError(err)
- s.Require().Equal(0, len(sigs))
-
- resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val1.GetAPIAddress(), val1.GetAddress()))
- s.Require().NoError(err)
-
- var balRes banktypes.QueryAllBalancesResponse
- err = clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- s.Require().NoError(err)
- startTokens := balRes.Balances.AmountOf(s.cfg.BondDenom)
-
- // Test generate sendTx, estimate gas
- finalGeneratedTx, err := s.createBankMsg(
- val1,
- addr,
- sdk.NewCoins(sendTokens), clitestutil.TestTxConfig{
- GenOnly: true,
- Gas: flags.DefaultGasLimit,
- })
- s.Require().NoError(err)
-
- finalStdTx, err := txCfg.TxJSONDecoder()(finalGeneratedTx.Bytes())
- s.Require().NoError(err)
- txBuilder, err = txCfg.WrapTxBuilder(finalStdTx)
- s.Require().NoError(err)
- s.Require().Equal(uint64(flags.DefaultGasLimit), txBuilder.GetTx().GetGas())
- s.Require().Equal(len(finalStdTx.GetMsgs()), 1)
-
- // Write the output to disk
- unsignedTxFile := testutil.WriteToNewTempFile(s.T(), finalGeneratedTx.String())
- defer unsignedTxFile.Close()
-
- // Test validate-signatures
- res, err := authclitestutil.TxValidateSignaturesExec(clientCtx, unsignedTxFile.Name())
- s.Require().EqualError(err, "signatures validation failed")
- s.Require().True(strings.Contains(res.String(), fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n\n", val1.GetAddress().String())))
-
- // Test sign
-
- // Does not work in offline mode
- _, err = authclitestutil.TxSignExec(clientCtx, val1.GetAddress(), unsignedTxFile.Name(), "--offline")
- s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
-
- // But works offline if we set account number and sequence
- clientCtx.HomeDir = strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)
- _, err = authclitestutil.TxSignExec(clientCtx, val1.GetAddress(), unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1")
- s.Require().NoError(err)
-
- // Sign transaction
- signedTx, err := authclitestutil.TxSignExec(clientCtx, val1.GetAddress(), unsignedTxFile.Name())
- s.Require().NoError(err)
- signedFinalTx, err := txCfg.TxJSONDecoder()(signedTx.Bytes())
- s.Require().NoError(err)
- txBuilder, err = clientCtx.TxConfig.WrapTxBuilder(signedFinalTx)
- s.Require().NoError(err)
- s.Require().Equal(len(txBuilder.GetTx().GetMsgs()), 1)
- sigs, err = txBuilder.GetTx().GetSignaturesV2()
- s.Require().NoError(err)
- s.Require().Equal(1, len(sigs))
- signers, err := txBuilder.GetTx().GetSigners()
- s.Require().NoError(err)
- s.Require().Equal([]byte(val1.GetAddress()), signers[0])
-
- // Write the output to disk
- signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String())
- defer signedTxFile.Close()
-
- // validate Signature
- res, err = authclitestutil.TxValidateSignaturesExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
- s.Require().True(strings.Contains(res.String(), "[OK]"))
- s.Require().NoError(s.network.WaitForNextBlock())
-
- // Ensure foo has right amount of funds
- resp, err = testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val1.GetAPIAddress(), val1.GetAddress()))
- s.Require().NoError(err)
- err = clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- s.Require().NoError(err)
- s.Require().Equal(startTokens, balRes.Balances.AmountOf(s.cfg.BondDenom))
-
- // Test broadcast
-
- // Does not work in offline mode
- _, err = authclitestutil.TxBroadcastExec(clientCtx, signedTxFile.Name(), "--offline")
- s.Require().EqualError(err, "cannot broadcast tx during offline mode")
- s.Require().NoError(s.network.WaitForNextBlock())
-
- // Broadcast correct transaction.
- clientCtx.BroadcastMode = flags.BroadcastSync
- _, err = authclitestutil.TxBroadcastExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- // Ensure destiny account state
- err = s.network.RetryForBlocks(func() error {
- resp, err = testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val1.GetAPIAddress(), addr))
- s.Require().NoError(err)
- return err
- }, 3)
- s.Require().NoError(err)
-
- err = clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- s.Require().NoError(err)
- s.Require().Equal(sendTokens.Amount, balRes.Balances.AmountOf(s.cfg.BondDenom))
-
- // Ensure origin account state
- resp, err = testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val1.GetAPIAddress(), val1.GetAddress()))
- s.Require().NoError(err)
- err = clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- s.Require().NoError(err)
-}
-
-func (s *E2ETestSuite) TestCLIMultisignInsufficientCosigners() {
- val1 := s.network.GetValidators()[0]
- clientCtx := val1.GetClientCtx()
-
- // Fetch account and a multisig info
- account1, err := clientCtx.Keyring.Key("newAccount1")
- s.Require().NoError(err)
-
- multisigRecord, err := clientCtx.Keyring.Key("multi")
- s.Require().NoError(err)
-
- addr, err := multisigRecord.GetAddress()
- s.Require().NoError(err)
- // Send coins from validator to multisig.
- _, err = s.createBankMsg(
- val1,
- addr,
- sdk.NewCoins(
- sdk.NewInt64Coin(s.cfg.BondDenom, 10),
- ),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- coins := sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 5))
- msgSend := &banktypes.MsgSend{
- FromAddress: addr.String(),
- ToAddress: val1.GetAddress().String(),
- Amount: coins,
- }
-
- // Generate multisig transaction.
- multiGeneratedTx, err := clitestutil.SubmitTestTx(
- clientCtx,
- msgSend,
- addr,
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
-
- // Save tx to file
- multiGeneratedTxFile := testutil.WriteToNewTempFile(s.T(), multiGeneratedTx.String())
- defer multiGeneratedTxFile.Close()
-
- // Multisign, sign with one signature
- clientCtx.HomeDir = strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)
- addr1, err := account1.GetAddress()
- s.Require().NoError(err)
- account1Signature, err := authclitestutil.TxSignExec(clientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
- s.Require().NoError(err)
-
- sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
- defer sign1File.Close()
-
- multiSigWith1Signature, err := authclitestutil.TxMultiSignExec(clientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name())
- s.Require().NoError(err)
-
- // Save tx to file
- multiSigWith1SignatureFile := testutil.WriteToNewTempFile(s.T(), multiSigWith1Signature.String())
- defer multiSigWith1SignatureFile.Close()
-
- _, err = authclitestutil.TxValidateSignaturesExec(clientCtx, multiSigWith1SignatureFile.Name())
- s.Require().Error(err)
-}
-
-func (s *E2ETestSuite) TestCLIEncode() {
- val1 := s.network.GetValidators()[0]
-
- sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction))
-
- normalGeneratedTx, err := s.createBankMsg(
- val1, val1.GetAddress(),
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{
- GenOnly: true,
- Memo: "deadbeef",
- },
- )
- s.Require().NoError(err)
- savedTxFile := testutil.WriteToNewTempFile(s.T(), normalGeneratedTx.String())
- defer savedTxFile.Close()
-
- // Encode
- encodeExec, err := authclitestutil.TxEncodeExec(val1.GetClientCtx(), savedTxFile.Name())
- s.Require().NoError(err)
- trimmedBase64 := strings.Trim(encodeExec.String(), "\"\n")
-
- // Check that the transaction decodes as expected
- decodedTx, err := authclitestutil.TxDecodeExec(val1.GetClientCtx(), trimmedBase64)
- s.Require().NoError(err)
-
- txCfg := val1.GetClientCtx().TxConfig
- theTx, err := txCfg.TxJSONDecoder()(decodedTx.Bytes())
- s.Require().NoError(err)
- txBuilder, err := val1.GetClientCtx().TxConfig.WrapTxBuilder(theTx)
- s.Require().NoError(err)
- s.Require().Equal("deadbeef", txBuilder.GetTx().GetMemo())
-}
-
-func (s *E2ETestSuite) TestCLIMultisignSortSignatures() {
- val1 := s.network.GetValidators()[0]
- clientCtx := val1.GetClientCtx()
-
- // Generate 2 accounts and a multisig.
- account1, err := clientCtx.Keyring.Key("newAccount1")
- s.Require().NoError(err)
-
- account2, err := clientCtx.Keyring.Key("newAccount2")
- s.Require().NoError(err)
-
- multisigRecord, err := clientCtx.Keyring.Key("multi")
- s.Require().NoError(err)
-
- // Generate dummy account which is not a part of multisig.
- dummyAcc, err := clientCtx.Keyring.Key("dummyAccount")
- s.Require().NoError(err)
-
- addr, err := multisigRecord.GetAddress()
- s.Require().NoError(err)
- resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val1.GetAPIAddress(), addr))
- s.Require().NoError(err)
-
- var balRes banktypes.QueryAllBalancesResponse
- err = clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- s.Require().NoError(err)
- initialCoins := balRes.Balances
-
- // Send coins from validator to multisig.
- sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
- _, err = s.createBankMsg(
- val1,
- addr,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- resp, err = testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val1.GetAPIAddress(), addr))
- s.Require().NoError(err)
- err = clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- s.Require().NoError(err)
- diff, _ := balRes.Balances.SafeSub(initialCoins...)
- s.Require().Equal(sendTokens.Amount, diff.AmountOf(s.cfg.BondDenom))
-
- tokens := sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 5))
- msgSend := &banktypes.MsgSend{
- FromAddress: addr.String(),
- ToAddress: val1.GetAddress().String(),
- Amount: tokens,
- }
-
- // Generate multisig transaction.
- multiGeneratedTx, err := clitestutil.SubmitTestTx(
- clientCtx,
- msgSend,
- addr,
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
-
- // Save tx to file
- multiGeneratedTxFile := testutil.WriteToNewTempFile(s.T(), multiGeneratedTx.String())
- defer multiGeneratedTxFile.Close()
-
- // Sign with account1
- addr1, err := account1.GetAddress()
- s.Require().NoError(err)
- clientCtx.HomeDir = strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)
- account1Signature, err := authclitestutil.TxSignExec(clientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
- s.Require().NoError(err)
-
- sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
- defer sign1File.Close()
-
- // Sign with account2
- addr2, err := account2.GetAddress()
- s.Require().NoError(err)
- account2Signature, err := authclitestutil.TxSignExec(clientCtx, addr2, multiGeneratedTxFile.Name(), "--multisig", addr.String())
- s.Require().NoError(err)
-
- sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
- defer sign2File.Close()
-
- // Sign with dummy account
- dummyAddr, err := dummyAcc.GetAddress()
- s.Require().NoError(err)
- _, err = authclitestutil.TxSignExec(clientCtx, dummyAddr, multiGeneratedTxFile.Name(), "--multisig", addr.String())
- s.Require().Error(err)
- s.Require().Contains(err.Error(), "signing key is not a part of multisig key")
-
- multiSigWith2Signatures, err := authclitestutil.TxMultiSignExec(clientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
- s.Require().NoError(err)
-
- // Write the output to disk
- signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
- defer signedTxFile.Close()
-
- _, err = authclitestutil.TxValidateSignaturesExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
-
- clientCtx.BroadcastMode = flags.BroadcastSync
- _, err = authclitestutil.TxBroadcastExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
-
- s.Require().NoError(s.network.WaitForNextBlock())
-}
-
-func (s *E2ETestSuite) TestSignWithMultisig() {
- val1 := s.network.GetValidators()[0]
-
- // Generate a account for signing.
- account1, err := val1.GetClientCtx().Keyring.Key("newAccount1")
- s.Require().NoError(err)
-
- addr1, err := account1.GetAddress()
- s.Require().NoError(err)
-
- // Create an address that is not in the keyring, will be used to simulate `--multisig`
- multisig := "cosmos1hd6fsrvnz6qkp87s3u86ludegq97agxsdkwzyh"
- multisigAddr, err := sdk.AccAddressFromBech32(multisig)
- s.Require().NoError(err)
-
- tokens := sdk.NewCoins(
- sdk.NewInt64Coin(s.cfg.BondDenom, 5),
- )
- msgSend := &banktypes.MsgSend{
- FromAddress: val1.GetAddress().String(),
- ToAddress: val1.GetAddress().String(),
- Amount: tokens,
- }
-
- // Generate a transaction for testing --multisig with an address not in the keyring.
- multisigTx, err := clitestutil.SubmitTestTx(
- val1.GetClientCtx(),
- msgSend,
- val1.GetAddress(),
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
-
- // Save multi tx to file
- multiGeneratedTx2File := testutil.WriteToNewTempFile(s.T(), multisigTx.String())
- defer multiGeneratedTx2File.Close()
-
- // Sign using multisig. We're signing a tx on behalf of the multisig address,
- // even though the tx signer is NOT the multisig address. This is fine though,
- // as the main point of this test is to test the `--multisig` flag with an address
- // that is not in the keyring.
- _, err = authclitestutil.TxSignExec(val1.GetClientCtx(), addr1, multiGeneratedTx2File.Name(), "--multisig", multisigAddr.String())
- s.Require().Contains(err.Error(), "error getting account from keybase")
-}
-
-func (s *E2ETestSuite) TestCLIMultisign() {
- val1 := s.network.GetValidators()[0]
- clientCtx := val1.GetClientCtx()
-
- // Generate 2 accounts and a multisig.
- account1, err := clientCtx.Keyring.Key("newAccount1")
- s.Require().NoError(err)
-
- account2, err := clientCtx.Keyring.Key("newAccount2")
- s.Require().NoError(err)
-
- multisigRecord, err := clientCtx.Keyring.Key("multi")
- s.Require().NoError(err)
-
- addr, err := multisigRecord.GetAddress()
- s.Require().NoError(err)
-
- // Send coins from validator to multisig.
- sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
- s.Require().NoError(s.network.WaitForNextBlock())
- _, err = s.createBankMsg(
- val1, addr,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- var balRes banktypes.QueryAllBalancesResponse
- err = s.network.RetryForBlocks(func() error {
- resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val1.GetAPIAddress(), addr))
- if err != nil {
- return err
- }
- return clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- }, 3)
- s.Require().NoError(err)
- s.Require().True(sendTokens.Amount.Equal(balRes.Balances.AmountOf(s.cfg.BondDenom)))
-
- tokens := sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 5))
- msgSend := &banktypes.MsgSend{
- FromAddress: addr.String(),
- ToAddress: val1.GetAddress().String(),
- Amount: tokens,
- }
-
- // Generate multisig transaction.
- multiGeneratedTx, err := clitestutil.SubmitTestTx(
- clientCtx,
- msgSend,
- addr,
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
-
- // Save tx to file
- multiGeneratedTxFile := testutil.WriteToNewTempFile(s.T(), multiGeneratedTx.String())
- defer multiGeneratedTxFile.Close()
-
- addr1, err := account1.GetAddress()
- s.Require().NoError(err)
- // Sign with account1
- clientCtx.HomeDir = strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)
- account1Signature, err := authclitestutil.TxSignExec(clientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
- s.Require().NoError(err)
-
- sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
- defer sign1File.Close()
-
- addr2, err := account2.GetAddress()
- s.Require().NoError(err)
- // Sign with account2
- account2Signature, err := authclitestutil.TxSignExec(clientCtx, addr2, multiGeneratedTxFile.Name(), "--multisig", addr.String())
- s.Require().NoError(err)
-
- sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
- defer sign2File.Close()
-
- // Work in offline mode.
- multisigAccNum, multisigSeq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, addr)
- s.Require().NoError(err)
- _, err = authclitestutil.TxMultiSignExec(
- clientCtx,
- multisigRecord.Name,
- multiGeneratedTxFile.Name(),
- fmt.Sprintf("--%s", flags.FlagOffline),
- fmt.Sprintf("--%s=%d", flags.FlagAccountNumber, multisigAccNum),
- fmt.Sprintf("--%s=%d", flags.FlagSequence, multisigSeq),
- sign1File.Name(),
- sign2File.Name(),
- )
- s.Require().NoError(err)
-
- clientCtx.Offline = false
- multiSigWith2Signatures, err := authclitestutil.TxMultiSignExec(clientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
- s.Require().NoError(err)
-
- // Write the output to disk
- signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
- defer signedTxFile.Close()
-
- _, err = authclitestutil.TxValidateSignaturesExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
-
- clientCtx.BroadcastMode = flags.BroadcastSync
- _, err = authclitestutil.TxBroadcastExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
-
- s.Require().NoError(s.network.WaitForNextBlock())
-}
-
-func (s *E2ETestSuite) TestSignBatchMultisig() {
- val := s.network.GetValidators()[0]
- clientCtx := val.GetClientCtx()
-
- // Fetch 2 accounts and a multisig.
- account1, err := clientCtx.Keyring.Key("newAccount1")
- s.Require().NoError(err)
- account2, err := clientCtx.Keyring.Key("newAccount2")
- s.Require().NoError(err)
- multisigRecord, err := clientCtx.Keyring.Key("multi")
- s.Require().NoError(err)
-
- addr, err := multisigRecord.GetAddress()
- s.Require().NoError(err)
- // Send coins from validator to multisig.
- sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
- _, err = s.createBankMsg(
- val,
- addr,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- tokens := sdk.NewCoins(
- sdk.NewCoin(s.cfg.BondDenom, math.NewInt(1)),
- )
- msgSend := &banktypes.MsgSend{
- FromAddress: addr.String(),
- ToAddress: val.GetAddress().String(),
- Amount: tokens,
- }
-
- generatedStd, err := clitestutil.SubmitTestTx(
- clientCtx,
- msgSend,
- addr,
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
-
- // Write the output to disk
- filename := testutil.WriteToNewTempFile(s.T(), strings.Repeat(generatedStd.String(), 1))
- defer filename.Close()
- clientCtx.HomeDir = strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)
-
- addr1, err := account1.GetAddress()
- s.Require().NoError(err)
- // sign-batch file
- res, err := authclitestutil.TxSignBatchExec(clientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
- s.Require().NoError(err)
- s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
- // write sigs to file
- file1 := testutil.WriteToNewTempFile(s.T(), res.String())
- defer file1.Close()
-
- addr2, err := account2.GetAddress()
- s.Require().NoError(err)
- // sign-batch file with account2
- res, err = authclitestutil.TxSignBatchExec(clientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
- s.Require().NoError(err)
- s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
- // write sigs to file2
- file2 := testutil.WriteToNewTempFile(s.T(), res.String())
- defer file2.Close()
- _, err = authclitestutil.TxMultiSignExec(clientCtx, multisigRecord.Name, filename.Name(), file1.Name(), file2.Name())
- s.Require().NoError(err)
-}
-
-func (s *E2ETestSuite) TestMultisignBatch() {
- val := s.network.GetValidators()[0]
- clientCtx := val.GetClientCtx()
-
- // Fetch 2 accounts and a multisig.
- account1, err := clientCtx.Keyring.Key("newAccount1")
- s.Require().NoError(err)
- account2, err := clientCtx.Keyring.Key("newAccount2")
- s.Require().NoError(err)
- multisigRecord, err := clientCtx.Keyring.Key("multi")
- s.Require().NoError(err)
-
- addr, err := multisigRecord.GetAddress()
- s.Require().NoError(err)
- // Send coins from validator to multisig.
- sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 1000)
- _, err = s.createBankMsg(
- val,
- addr,
- sdk.NewCoins(sendTokens),
- clitestutil.TestTxConfig{},
- )
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
-
- tokens := sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(1)))
- msgSend := &banktypes.MsgSend{
- FromAddress: addr.String(),
- ToAddress: val.GetAddress().String(),
- Amount: tokens,
- }
-
- generatedStd, err := clitestutil.SubmitTestTx(
- clientCtx,
- msgSend,
- addr,
- clitestutil.TestTxConfig{
- GenOnly: true,
- },
- )
- s.Require().NoError(err)
-
- // Write the output to disk
- filename := testutil.WriteToNewTempFile(s.T(), strings.Repeat(generatedStd.String()+"\n", 3))
- defer filename.Close()
- clientCtx.HomeDir = strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)
-
- account, err := clientCtx.AccountRetriever.GetAccount(clientCtx, addr)
- s.Require().NoError(err)
-
- // sign-batch file
- addr1, err := account1.GetAddress()
- s.Require().NoError(err)
- res, err := authclitestutil.TxSignBatchExec(clientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
- s.Require().NoError(err)
- s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
- // write sigs to file
- file1 := testutil.WriteToNewTempFile(s.T(), res.String())
- defer file1.Close()
-
- // sign-batch file with account2
- addr2, err := account2.GetAddress()
- s.Require().NoError(err)
- res, err = authclitestutil.TxSignBatchExec(clientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
- s.Require().NoError(err)
- s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
-
- // multisign the file
- file2 := testutil.WriteToNewTempFile(s.T(), res.String())
- defer file2.Close()
- res, err = authclitestutil.TxMultiSignBatchExec(clientCtx, filename.Name(), multisigRecord.Name, file1.Name(), file2.Name())
- s.Require().NoError(err)
- signedTxs := strings.Split(strings.Trim(res.String(), "\n"), "\n")
-
- // Broadcast transactions.
- for _, signedTx := range signedTxs {
- func() {
- signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx)
- defer signedTxFile.Close()
- clientCtx.BroadcastMode = flags.BroadcastSync
- _, err = authclitestutil.TxBroadcastExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
- s.Require().NoError(s.network.WaitForNextBlock())
- }()
- }
-}
-
-func TestGetBroadcastCommandOfflineFlag(t *testing.T) {
- cmd := authcli.GetBroadcastCommand()
- _ = testutil.ApplyMockIODiscardOutErr(cmd)
- cmd.SetArgs([]string{fmt.Sprintf("--%s=true", flags.FlagOffline), ""})
-
- require.EqualError(t, cmd.Execute(), "cannot broadcast tx during offline mode")
-}
-
-func TestGetBroadcastCommandWithoutOfflineFlag(t *testing.T) {
- var txCfg client.TxConfig
- err := depinject.Inject(authtestkeeper.AppConfig, &txCfg)
- require.NoError(t, err)
- clientCtx := client.Context{}
- clientCtx = clientCtx.WithTxConfig(txCfg)
-
- ctx := context.Background()
- ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
-
- cmd := authcli.GetBroadcastCommand()
- _, out := testutil.ApplyMockIO(cmd)
-
- // Create new file with tx
- builder := txCfg.NewTxBuilder()
- builder.SetGasLimit(200000)
- err = builder.SetMsgs(banktypes.NewMsgSend("cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw", "cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw", sdk.Coins{sdk.NewInt64Coin("stake", 10000)}))
- require.NoError(t, err)
- txContents, err := txCfg.TxJSONEncoder()(builder.GetTx())
- require.NoError(t, err)
- txFile := testutil.WriteToNewTempFile(t, string(txContents))
- defer txFile.Close()
-
- cmd.SetArgs([]string{txFile.Name()})
- err = cmd.ExecuteContext(ctx)
- require.Error(t, err)
- require.Contains(t, err.Error(), "connect: connection refused")
- require.Contains(t, out.String(), "connect: connection refused")
-}
-
-// TestTxWithoutPublicKey makes sure sending a proto tx message without the
-// public key doesn't cause any error in the RPC layer (broadcast).
-// See https://github.com/cosmos/cosmos-sdk/issues/7585 for more details.
-func (s *E2ETestSuite) TestTxWithoutPublicKey() {
- val1 := s.network.GetValidators()[0]
- clientCtx := val1.GetClientCtx()
- txCfg := clientCtx.TxConfig
-
- // Create a txBuilder with an unsigned tx.
- txBuilder := txCfg.NewTxBuilder()
- msg := banktypes.NewMsgSend(val1.GetAddress().String(), val1.GetAddress().String(), sdk.NewCoins(
- sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10)),
- ))
- err := txBuilder.SetMsgs(msg)
- s.Require().NoError(err)
- txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(150))))
- txBuilder.SetGasLimit(testdata.NewTestGasLimit())
- // Set empty signature to set signer infos.
- sigV2 := signing.SignatureV2{
- PubKey: val1.GetPubKey(),
- Data: &signing.SingleSignatureData{
- SignMode: signing.SignMode_SIGN_MODE_DIRECT,
- Signature: nil,
- },
- }
- err = txBuilder.SetSignatures(sigV2)
- s.Require().NoError(err)
-
- // Create a file with the unsigned tx.
- txJSON, err := txCfg.TxJSONEncoder()(txBuilder.GetTx())
- s.Require().NoError(err)
- unsignedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON))
- defer unsignedTxFile.Close()
-
- // Sign the file with the unsignedTx.
- signedTx, err := authclitestutil.TxSignExec(clientCtx, val1.GetAddress(), unsignedTxFile.Name(), fmt.Sprintf("--%s=true", cli.FlagOverwrite))
- s.Require().NoError(err)
-
- // Remove the signerInfo's `public_key` field manually from the signedTx.
- // Note: this method is only used for test purposes! In general, one should
- // use txBuilder and TxEncoder/TxDecoder to manipulate txs.
- var tx tx.Tx
- err = clientCtx.Codec.UnmarshalJSON(signedTx.Bytes(), &tx)
- s.Require().NoError(err)
- tx.AuthInfo.SignerInfos[0].PublicKey = nil
- // Re-encode the tx again, to another file.
- txJSON, err = clientCtx.Codec.MarshalJSON(&tx)
- s.Require().NoError(err)
- signedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON))
- defer signedTxFile.Close()
- s.Require().True(strings.Contains(string(txJSON), "\"public_key\":null"))
-
- // Broadcast tx, test that it shouldn't panic.
- clientCtx.BroadcastMode = flags.BroadcastSync
- out, err := authclitestutil.TxBroadcastExec(clientCtx, signedTxFile.Name())
- s.Require().NoError(err)
- var res sdk.TxResponse
- s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res))
- s.Require().NotEqual(0, res.Code)
-}
-
-// TestSignWithMultiSignersAminoJSON tests the case where a transaction with 2
-// messages which has to be signed with 2 different keys. Sign and append the
-// signatures using the CLI with Amino signing mode. Finally, send the
-// transaction to the blockchain.
-func (s *E2ETestSuite) TestSignWithMultiSignersAminoJSON() {
- require := s.Require()
- val0, val1 := s.network.GetValidators()[0], s.network.GetValidators()[1]
- val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val0.GetMoniker()), math.NewInt(10))
- val1Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val1.GetMoniker()), math.NewInt(10))
- _, _, addr1 := testdata.KeyTestPubAddr()
-
- // Creating a tx with 2 msgs from 2 signers: val0 and val1.
- // The validators need to sign with SIGN_MODE_LEGACY_AMINO_JSON,
- // because DIRECT doesn't support multi signers via the CLI.
- // Since we use amino, we don't need to pre-populate signer_infos.
- txBuilder := val0.GetClientCtx().TxConfig.NewTxBuilder()
- val0Str, err := s.ac.BytesToString(val0.GetAddress())
- s.Require().NoError(err)
- val1Str, err := s.ac.BytesToString(val1.GetAddress())
- s.Require().NoError(err)
- addrStr, err := s.ac.BytesToString(addr1)
- s.Require().NoError(err)
- err = txBuilder.SetMsgs(
- banktypes.NewMsgSend(val0Str, addrStr, sdk.NewCoins(val0Coin)),
- banktypes.NewMsgSend(val1Str, addrStr, sdk.NewCoins(val1Coin)),
- )
- require.NoError(err)
- txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10))))
- txBuilder.SetGasLimit(testdata.NewTestGasLimit() * 2)
- signers, err := txBuilder.GetTx().GetSigners()
- require.NoError(err)
- require.Equal([][]byte{val0.GetAddress(), val1.GetAddress()}, signers)
-
- // Write the unsigned tx into a file.
- txJSON, err := val0.GetClientCtx().TxConfig.TxJSONEncoder()(txBuilder.GetTx())
- require.NoError(err)
- unsignedTxFile := testutil.WriteToNewTempFile(s.T(), string(txJSON))
- defer unsignedTxFile.Close()
-
- // Let val0 sign first the file with the unsignedTx.
- signedByVal0, err := authclitestutil.TxSignExec(val0.GetClientCtx(), val0.GetAddress(), unsignedTxFile.Name(), "--overwrite", "--sign-mode=amino-json")
- require.NoError(err)
- signedByVal0File := testutil.WriteToNewTempFile(s.T(), signedByVal0.String())
- defer signedByVal0File.Close()
-
- // Then let val1 sign the file with signedByVal0.
- val1AccNum, val1Seq, err := val0.GetClientCtx().AccountRetriever.GetAccountNumberSequence(val0.GetClientCtx(), val1.GetAddress())
- require.NoError(err)
-
- signedTx, err := authclitestutil.TxSignExec(
- val1.GetClientCtx(),
- val1.GetAddress(),
- signedByVal0File.Name(),
- "--offline",
- fmt.Sprintf("--account-number=%d", val1AccNum),
- fmt.Sprintf("--sequence=%d", val1Seq),
- "--sign-mode=amino-json",
- )
- require.NoError(err)
- signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String())
- defer signedTxFile.Close()
-
- res, err := authclitestutil.TxBroadcastExec(
- val0.GetClientCtx(),
- signedTxFile.Name(),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- )
- require.NoError(err)
- require.NoError(s.network.WaitForNextBlock())
-
- var txRes sdk.TxResponse
- require.NoError(val0.GetClientCtx().Codec.UnmarshalJSON(res.Bytes(), &txRes))
- require.Equal(uint32(0), txRes.Code, txRes.RawLog)
-
- // Make sure the addr1's balance got funded.
- resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", val0.GetAPIAddress(), addr1))
- s.Require().NoError(err)
- var queryRes banktypes.QueryAllBalancesResponse
- err = val0.GetClientCtx().Codec.UnmarshalJSON(resp, &queryRes)
- require.NoError(err)
- require.Equal(sdk.NewCoins(val0Coin, val1Coin), queryRes.Balances)
-}
-
-func (s *E2ETestSuite) TestAuxSigner() {
- s.T().Skip("re-enable this when we bring back sign mode aux client testing")
- require := s.Require()
- val := s.network.GetValidators()[0]
- val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val.GetMoniker()), math.NewInt(10))
-
- testCases := []struct {
- name string
- args []string
- expectErr bool
- }{
- {
- "error with SIGN_MODE_DIRECT_AUX and --aux unset",
- []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- },
- true,
- },
- {
- "no error with SIGN_MDOE_DIRECT_AUX mode and generate-only set (ignores generate-only)",
- []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
- },
- false,
- },
- {
- "no error with SIGN_MDOE_DIRECT_AUX mode and generate-only, tip flag set",
- []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
- fmt.Sprintf("--%s=%s", flags.FlagTip, val0Coin.String()),
- },
- false,
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- _, err := govtestutil.MsgSubmitLegacyProposal(
- val.GetClientCtx(),
- val.GetAddress().String(),
- "test",
- "test desc",
- govtypes.ProposalTypeText,
- tc.args...,
- )
- if tc.expectErr {
- require.Error(err)
- } else {
- require.NoError(err)
- }
- })
- }
-}
-
-func (s *E2ETestSuite) TestAuxToFeeWithTips() {
- // Skipping this test as it needs a simapp with the TipDecorator in post handler.
- s.T().Skip()
-
- require := s.Require()
- val := s.network.GetValidators()[0]
-
- kb := s.network.GetValidators()[0].GetClientCtx().Keyring
- acc, _, err := kb.NewMnemonic("tipperAccount", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
- require.NoError(err)
-
- tipper, err := acc.GetAddress()
- require.NoError(err)
- tipperInitialBal := sdk.NewCoin(fmt.Sprintf("%stoken", val.GetMoniker()), math.NewInt(10000))
-
- feePayer := val.GetAddress()
- fee := sdk.NewCoin(s.cfg.BondDenom, math.NewInt(1000))
- tip := sdk.NewCoin(fmt.Sprintf("%stoken", val.GetMoniker()), math.NewInt(1000))
-
- require.NoError(s.network.WaitForNextBlock())
- _, err = s.createBankMsg(
- val,
- tipper,
- sdk.NewCoins(tipperInitialBal),
- clitestutil.TestTxConfig{},
- )
- require.NoError(err)
- require.NoError(s.network.WaitForNextBlock())
-
- bal := s.getBalances(val.GetClientCtx(), tipper, tip.Denom)
- require.True(bal.Equal(tipperInitialBal.Amount))
-
- testCases := []struct {
- name string
- tipper sdk.AccAddress
- feePayer sdk.AccAddress
- tip sdk.Coin
- expectErrAux bool
- expectErrBroadCast bool
- errMsg string
- tipperArgs []string
- feePayerArgs []string
- }{
- {
- name: "when --aux and --sign-mode = direct set: error",
- tipper: tipper,
- feePayer: feePayer,
- tip: tip,
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirect),
- fmt.Sprintf("--%s=%s", flags.FlagTip, tip),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- expectErrAux: true,
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- },
- },
- {
- name: "both tipper, fee payer uses AMINO: no error",
- tipper: tipper,
- feePayer: feePayer,
- tip: tip,
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON),
- fmt.Sprintf("--%s=%s", flags.FlagTip, tip),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- feePayerArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON),
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- },
- },
- {
- name: "tipper uses DIRECT_AUX, fee payer uses AMINO: no error",
- tipper: tipper,
- feePayer: feePayer,
- tip: tip,
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=%s", flags.FlagTip, tip),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- },
- },
- {
- name: "--tip flag unset: no error",
- tipper: tipper,
- feePayer: feePayer,
- tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.GetMoniker()), Amount: math.NewInt(0)},
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- },
- },
- {
- name: "legacy amino json: no error",
- tipper: tipper,
- feePayer: feePayer,
- tip: tip,
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON),
- fmt.Sprintf("--%s=%s", flags.FlagTip, tip),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- },
- },
- {
- name: "tipper uses direct aux, fee payer uses direct: happy case",
- tipper: tipper,
- feePayer: feePayer,
- tip: tip,
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=%s", flags.FlagTip, tip),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- },
- },
- {
- name: "chain-id mismatch: error",
- tipper: tipper,
- feePayer: feePayer,
- tip: tip,
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=%s", flags.FlagTip, tip),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- expectErrAux: false,
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- fmt.Sprintf("--%s=%s", flags.FlagChainID, "foobar"),
- },
- expectErrBroadCast: true,
- },
- {
- name: "wrong denom in tip: error",
- tipper: tipper,
- feePayer: feePayer,
- tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.GetMoniker()), Amount: math.NewInt(0)},
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagTip, "1000wrongDenom"),
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirect),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()),
- },
- errMsg: "insufficient funds",
- },
- {
- name: "insufficient fees: error",
- tipper: tipper,
- feePayer: feePayer,
- tip: sdk.Coin{Denom: fmt.Sprintf("%stoken", val.GetMoniker()), Amount: math.NewInt(0)},
- tipperArgs: []string{
- fmt.Sprintf("--%s=%s", flags.FlagTip, tip),
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirectAux),
- fmt.Sprintf("--%s=true", flags.FlagAux),
- },
- feePayerArgs: []string{
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirect),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer),
- },
- errMsg: "insufficient fees",
- },
- }
-
- for _, tc := range testCases {
- s.Run(tc.name, func() {
- res, err := govtestutil.MsgSubmitLegacyProposal(
- val.GetClientCtx(),
- tipper.String(),
- "test",
- "test desc",
- govtypes.ProposalTypeText,
- tc.tipperArgs...,
- )
-
- if tc.expectErrAux {
- require.Error(err)
- } else {
- require.NoError(err)
- genTxFile := testutil.WriteToNewTempFile(s.T(), string(res.Bytes()))
- defer genTxFile.Close()
-
- s.Require().NoError(s.network.WaitForNextBlock())
-
- switch {
- case tc.expectErrBroadCast:
- require.Error(err)
-
- case tc.errMsg != "":
- require.NoError(err)
-
- var txRes sdk.TxResponse
- require.NoError(val.GetClientCtx().Codec.UnmarshalJSON(res.Bytes(), &txRes))
-
- require.Contains(txRes.RawLog, tc.errMsg)
-
- default:
- require.NoError(err)
-
- var txRes sdk.TxResponse
- require.NoError(val.GetClientCtx().Codec.UnmarshalJSON(res.Bytes(), &txRes))
-
- require.Equal(uint32(0), txRes.Code)
- require.NotNil(int64(0), txRes.Height)
-
- bal = s.getBalances(val.GetClientCtx(), tipper, tc.tip.Denom)
- tipperInitialBal = tipperInitialBal.Sub(tc.tip)
- require.True(bal.Equal(tipperInitialBal.Amount))
- }
- }
- })
- }
-}
-
-func (s *E2ETestSuite) createBankMsg(val network.ValidatorI, toAddr sdk.AccAddress, amount sdk.Coins, config clitestutil.TestTxConfig) (testutil.BufferWriter, error) {
- msgSend := &banktypes.MsgSend{
- FromAddress: val.GetAddress().String(),
- ToAddress: toAddr.String(),
- Amount: amount,
- }
-
- return clitestutil.SubmitTestTx(val.GetClientCtx(), msgSend, val.GetAddress(), config)
-}
-
-func (s *E2ETestSuite) getBalances(clientCtx client.Context, addr sdk.AccAddress, denom string) math.Int {
- resp, err := testutil.GetRequest(fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s/by_denom?denom=%s", s.cfg.APIAddress, addr.String(), denom))
- s.Require().NoError(err)
-
- var balRes banktypes.QueryAllBalancesResponse
- err = clientCtx.Codec.UnmarshalJSON(resp, &balRes)
- s.Require().NoError(err)
- startTokens := balRes.Balances.AmountOf(denom)
- return startTokens
-}
-
-func (s *E2ETestSuite) deepContains(events []abci.Event, value string) bool {
- for _, e := range events {
- for _, attr := range e.Attributes {
- if strings.Contains(attr.Value, value) {
- return true
- }
- }
- }
- return false
-}
diff --git a/tests/e2e/distribution/cli_test.go b/tests/e2e/distribution/cli_test.go
deleted file mode 100644
index ad8e877d9611..000000000000
--- a/tests/e2e/distribution/cli_test.go
+++ /dev/null
@@ -1,18 +0,0 @@
-//go:build e2e
-// +build e2e
-
-package distribution
-
-import (
- "testing"
-
- "github.com/stretchr/testify/suite"
-)
-
-func TestWithdrawAllSuite(t *testing.T) {
- suite.Run(t, new(WithdrawAllTestSuite))
-}
-
-func TestGRPCQueryTestSuite(t *testing.T) {
- suite.Run(t, new(GRPCQueryTestSuite))
-}
diff --git a/tests/e2e/distribution/grpc_query_suite.go b/tests/e2e/distribution/grpc_query_suite.go
deleted file mode 100644
index 991567abfb4e..000000000000
--- a/tests/e2e/distribution/grpc_query_suite.go
+++ /dev/null
@@ -1,460 +0,0 @@
-package distribution
-
-import (
- "fmt"
-
- "github.com/cosmos/gogoproto/proto"
- "github.com/stretchr/testify/suite"
-
- "cosmossdk.io/simapp"
- "cosmossdk.io/x/distribution/types"
-
- sdktestutil "github.com/cosmos/cosmos-sdk/testutil"
- "github.com/cosmos/cosmos-sdk/testutil/network"
- sdk "github.com/cosmos/cosmos-sdk/types"
- grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
- "github.com/cosmos/cosmos-sdk/types/query"
-)
-
-type GRPCQueryTestSuite struct {
- suite.Suite
-
- cfg network.Config
- network network.NetworkI
-}
-
-func (s *GRPCQueryTestSuite) SetupSuite() {
- s.T().Log("setting up e2e test suite")
-
- cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
- cfg.NumValidators = 1
- s.cfg = cfg
-
- var err error
- s.network, err = network.New(s.T(), s.T().TempDir(), cfg)
- s.Require().NoError(err)
-
- s.Require().NoError(s.network.WaitForNextBlock())
-}
-
-// TearDownSuite cleans up the current test network after _each_ test.
-func (s *GRPCQueryTestSuite) TearDownSuite() {
- s.T().Log("tearing down e2e test suite1")
- s.network.Cleanup()
-}
-
-func (s *GRPCQueryTestSuite) TestQueryParamsGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- testCases := []struct {
- name string
- url string
- respType proto.Message
- expected proto.Message
- }{
- {
- "gRPC request params",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/params", baseURL),
- &types.QueryParamsResponse{},
- &types.QueryParamsResponse{
- Params: types.DefaultParams(),
- },
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequest(tc.url)
- s.Run(tc.name, func() {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- s.Require().Equal(tc.expected, tc.respType)
- })
- }
-}
-
-func (s *GRPCQueryTestSuite) TestQueryValidatorDistributionInfoGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- testCases := []struct {
- name string
- url string
- expErr bool
- respType proto.Message
- }{
- {
- "gRPC request with wrong validator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s", baseURL, "wrongAddress"),
- true,
- &types.QueryValidatorDistributionInfoResponse{},
- },
- {
- "gRPC request with valid validator address ",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s", baseURL, val.GetValAddress().String()),
- false,
- &types.QueryValidatorDistributionInfoResponse{},
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequest(tc.url)
- s.Run(tc.name, func() {
- if tc.expErr {
- s.Require().Error(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- } else {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- }
- })
- }
-}
-
-func (s *GRPCQueryTestSuite) TestQueryOutstandingRewardsGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- rewards, err := sdk.ParseDecCoins("46.06stake")
- s.Require().NoError(err)
-
- testCases := []struct {
- name string
- url string
- headers map[string]string
- expErr bool
- respType proto.Message
- expected proto.Message
- }{
- {
- "gRPC request params with wrong validator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/outstanding_rewards", baseURL, "wrongAddress"),
- map[string]string{},
- true,
- &types.QueryValidatorOutstandingRewardsResponse{},
- &types.QueryValidatorOutstandingRewardsResponse{},
- },
- {
- "gRPC request params valid address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/outstanding_rewards", baseURL, val.GetValAddress().String()),
- map[string]string{
- grpctypes.GRPCBlockHeightHeader: "2",
- },
- false,
- &types.QueryValidatorOutstandingRewardsResponse{},
- &types.QueryValidatorOutstandingRewardsResponse{
- Rewards: types.ValidatorOutstandingRewards{
- Rewards: rewards,
- },
- },
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequestWithHeaders(tc.url, tc.headers)
- s.Run(tc.name, func() {
- if tc.expErr {
- s.Require().Error(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- } else {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- s.Require().Equal(tc.expected.String(), tc.respType.String())
- }
- })
- }
-}
-
-func (s *GRPCQueryTestSuite) TestQueryValidatorCommissionGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- commission, err := sdk.ParseDecCoins("23.03stake")
- s.Require().NoError(err)
-
- testCases := []struct {
- name string
- url string
- headers map[string]string
- expErr bool
- respType proto.Message
- expected proto.Message
- }{
- {
- "gRPC request params with wrong validator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/commission", baseURL, "wrongAddress"),
- map[string]string{},
- true,
- &types.QueryValidatorCommissionResponse{},
- &types.QueryValidatorCommissionResponse{},
- },
- {
- "gRPC request params valid address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/commission", baseURL, val.GetValAddress().String()),
- map[string]string{
- grpctypes.GRPCBlockHeightHeader: "2",
- },
- false,
- &types.QueryValidatorCommissionResponse{},
- &types.QueryValidatorCommissionResponse{
- Commission: types.ValidatorAccumulatedCommission{
- Commission: commission,
- },
- },
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequestWithHeaders(tc.url, tc.headers)
- s.Run(tc.name, func() {
- if tc.expErr {
- s.Require().Error(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- } else {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- s.Require().Equal(tc.expected.String(), tc.respType.String())
- }
- })
- }
-}
-
-func (s *GRPCQueryTestSuite) TestQuerySlashesGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- testCases := []struct {
- name string
- url string
- expErr bool
- respType proto.Message
- expected proto.Message
- }{
- {
- "invalid validator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/slashes", baseURL, ""),
- true,
- &types.QueryValidatorSlashesResponse{},
- nil,
- },
- {
- "invalid start height",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/slashes?starting_height=%s&ending_height=%s", baseURL, val.GetValAddress().String(), "-1", "3"),
- true,
- &types.QueryValidatorSlashesResponse{},
- nil,
- },
- {
- "invalid start height",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/slashes?starting_height=%s&ending_height=%s", baseURL, val.GetValAddress().String(), "1", "-3"),
- true,
- &types.QueryValidatorSlashesResponse{},
- nil,
- },
- {
- "valid request get slashes",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/validators/%s/slashes?starting_height=%s&ending_height=%s", baseURL, val.GetValAddress().String(), "1", "3"),
- false,
- &types.QueryValidatorSlashesResponse{},
- &types.QueryValidatorSlashesResponse{
- Pagination: &query.PageResponse{},
- },
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequest(tc.url)
-
- s.Run(tc.name, func() {
- if tc.expErr {
- s.Require().Error(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- } else {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- s.Require().Equal(tc.expected.String(), tc.respType.String())
- }
- })
- }
-}
-
-func (s *GRPCQueryTestSuite) TestQueryDelegatorRewardsGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- rewards, err := sdk.ParseDecCoins("23.03stake")
- s.Require().NoError(err)
-
- testCases := []struct {
- name string
- url string
- headers map[string]string
- expErr bool
- respType proto.Message
- expected proto.Message
- }{
- {
- "wrong delegator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/rewards", baseURL, "wrongDelegatorAddress"),
- map[string]string{},
- true,
- &types.QueryDelegationTotalRewardsResponse{},
- nil,
- },
- {
- "valid request",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/rewards", baseURL, val.GetAddress().String()),
- map[string]string{
- grpctypes.GRPCBlockHeightHeader: "2",
- },
- false,
- &types.QueryDelegationTotalRewardsResponse{},
- &types.QueryDelegationTotalRewardsResponse{
- Rewards: []types.DelegationDelegatorReward{
- types.NewDelegationDelegatorReward(val.GetValAddress().String(), rewards),
- },
- Total: rewards,
- },
- },
- {
- "wrong validator address(specific validator rewards)",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/rewards/%s", baseURL, val.GetAddress().String(), "wrongValAddress"),
- map[string]string{},
- true,
- &types.QueryDelegationTotalRewardsResponse{},
- nil,
- },
- {
- "valid request(specific validator rewards)",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/rewards/%s", baseURL, val.GetAddress().String(), val.GetValAddress().String()),
- map[string]string{
- grpctypes.GRPCBlockHeightHeader: "2",
- },
- false,
- &types.QueryDelegationRewardsResponse{},
- &types.QueryDelegationRewardsResponse{
- Rewards: rewards,
- },
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequestWithHeaders(tc.url, tc.headers)
-
- s.Run(tc.name, func() {
- if tc.expErr {
- s.Require().Error(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- } else {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- s.Require().Equal(tc.expected.String(), tc.respType.String())
- }
- })
- }
-}
-
-func (s *GRPCQueryTestSuite) TestQueryDelegatorValidatorsGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- testCases := []struct {
- name string
- url string
- expErr bool
- respType proto.Message
- expected proto.Message
- }{
- {
- "empty delegator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/validators", baseURL, ""),
- true,
- &types.QueryDelegatorValidatorsResponse{},
- nil,
- },
- {
- "wrong delegator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/validators", baseURL, "wrongDelegatorAddress"),
- true,
- &types.QueryDelegatorValidatorsResponse{},
- nil,
- },
- {
- "valid request",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/validators", baseURL, val.GetAddress().String()),
- false,
- &types.QueryDelegatorValidatorsResponse{},
- &types.QueryDelegatorValidatorsResponse{
- Validators: []string{val.GetValAddress().String()},
- },
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequest(tc.url)
-
- s.Run(tc.name, func() {
- if tc.expErr {
- s.Require().Error(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- } else {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- s.Require().Equal(tc.expected.String(), tc.respType.String())
- }
- })
- }
-}
-
-func (s *GRPCQueryTestSuite) TestQueryWithdrawAddressGRPC() {
- val := s.network.GetValidators()[0]
- baseURL := val.GetAPIAddress()
-
- testCases := []struct {
- name string
- url string
- expErr bool
- respType proto.Message
- expected proto.Message
- }{
- {
- "empty delegator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/withdraw_address", baseURL, ""),
- true,
- &types.QueryDelegatorWithdrawAddressResponse{},
- nil,
- },
- {
- "wrong delegator address",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/withdraw_address", baseURL, "wrongDelegatorAddress"),
- true,
- &types.QueryDelegatorWithdrawAddressResponse{},
- nil,
- },
- {
- "valid request",
- fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/withdraw_address", baseURL, val.GetAddress().String()),
- false,
- &types.QueryDelegatorWithdrawAddressResponse{},
- &types.QueryDelegatorWithdrawAddressResponse{
- WithdrawAddress: val.GetAddress().String(),
- },
- },
- }
-
- for _, tc := range testCases {
-
- resp, err := sdktestutil.GetRequest(tc.url)
-
- s.Run(tc.name, func() {
- if tc.expErr {
- s.Require().Error(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- } else {
- s.Require().NoError(err)
- s.Require().NoError(val.GetClientCtx().Codec.UnmarshalJSON(resp, tc.respType))
- s.Require().Equal(tc.expected.String(), tc.respType.String())
- }
- })
- }
-}
diff --git a/tests/e2e/distribution/withdraw_all_suite.go b/tests/e2e/distribution/withdraw_all_suite.go
deleted file mode 100644
index 9dd1888c0468..000000000000
--- a/tests/e2e/distribution/withdraw_all_suite.go
+++ /dev/null
@@ -1,139 +0,0 @@
-package distribution
-
-import (
- "fmt"
- "strings"
-
- "github.com/stretchr/testify/suite"
-
- "cosmossdk.io/math"
- "cosmossdk.io/simapp"
- banktypes "cosmossdk.io/x/bank/types"
- "cosmossdk.io/x/distribution/client/cli"
- stakingtypes "cosmossdk.io/x/staking/types"
-
- "github.com/cosmos/cosmos-sdk/client/flags"
- "github.com/cosmos/cosmos-sdk/crypto/hd"
- "github.com/cosmos/cosmos-sdk/crypto/keyring"
- clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
- "github.com/cosmos/cosmos-sdk/testutil/network"
- sdk "github.com/cosmos/cosmos-sdk/types"
-)
-
-type WithdrawAllTestSuite struct {
- suite.Suite
-
- cfg network.Config
- network network.NetworkI
-}
-
-func (s *WithdrawAllTestSuite) SetupSuite() {
- cfg := network.DefaultConfig(simapp.NewTestNetworkFixture)
- cfg.NumValidators = 2
- s.cfg = cfg
-
- s.T().Log("setting up e2e test suite")
- network, err := network.New(s.T(), s.T().TempDir(), s.cfg)
- s.Require().NoError(err)
- s.network = network
-
- s.Require().NoError(s.network.WaitForNextBlock())
-}
-
-// TearDownSuite cleans up the current test network after _each_ test.
-func (s *WithdrawAllTestSuite) TearDownSuite() {
- s.T().Log("tearing down e2e test suite")
- s.network.Cleanup()
-}
-
-// This test requires multiple validators, if I add this test to `E2ETestSuite` by increasing
-// `NumValidators` the existing tests are leading to non-determnism so created new suite for this test.
-func (s *WithdrawAllTestSuite) TestNewWithdrawAllRewardsGenerateOnly() {
- require := s.Require()
- val := s.network.GetValidators()[0]
- val1 := s.network.GetValidators()[1]
- clientCtx := val.GetClientCtx()
-
- info, _, err := val.GetClientCtx().Keyring.NewMnemonic("newAccount", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1)
- require.NoError(err)
-
- pubkey, err := info.GetPubKey()
- require.NoError(err)
-
- newAddr := sdk.AccAddress(pubkey.Address())
-
- msgSend := &banktypes.MsgSend{
- FromAddress: val.GetAddress().String(),
- ToAddress: newAddr.String(),
- Amount: sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(2000))),
- }
- _, err = clitestutil.SubmitTestTx(
- val.GetClientCtx(),
- msgSend,
- val.GetAddress(),
- clitestutil.TestTxConfig{},
- )
-
- require.NoError(err)
- require.NoError(s.network.WaitForNextBlock())
-
- // delegate 500 tokens to validator1
- msg := &stakingtypes.MsgDelegate{
- DelegatorAddress: newAddr.String(),
- ValidatorAddress: val.GetValAddress().String(),
- Amount: sdk.NewCoin("stake", math.NewInt(500)),
- }
-
- _, err = clitestutil.SubmitTestTx(val.GetClientCtx(), msg, newAddr, clitestutil.TestTxConfig{})
- require.NoError(err)
- require.NoError(s.network.WaitForNextBlock())
-
- // delegate 500 tokens to validator2
- msg2 := &stakingtypes.MsgDelegate{
- DelegatorAddress: newAddr.String(),
- ValidatorAddress: val1.GetValAddress().String(),
- Amount: sdk.NewCoin("stake", math.NewInt(500)),
- }
-
- _, err = clitestutil.SubmitTestTx(val.GetClientCtx(), msg2, newAddr, clitestutil.TestTxConfig{})
- require.NoError(err)
- require.NoError(s.network.WaitForNextBlock())
-
- err = s.network.RetryForBlocks(func() error {
- args := []string{
- fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()),
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
- fmt.Sprintf("--%s=1", cli.FlagMaxMessagesPerTx),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10))).String()),
- }
- cmd := cli.NewWithdrawAllRewardsCmd()
- out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
- if err != nil {
- return err
- }
-
- // expect 2 transactions in the generated file when --max-msgs in a tx set 1.
- txLen := len(strings.Split(strings.Trim(out.String(), "\n"), "\n"))
- if txLen != 2 {
- return fmt.Errorf("expected 2 transactions in the generated file, got %d", txLen)
- }
- return nil
- }, 3)
- require.NoError(err)
-
- args := []string{
- fmt.Sprintf("--%s=%s", flags.FlagFrom, newAddr.String()),
- fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
- fmt.Sprintf("--%s=true", flags.FlagGenerateOnly),
- fmt.Sprintf("--%s=2", cli.FlagMaxMessagesPerTx),
- fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
- fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10))).String()),
- }
- cmd := cli.NewWithdrawAllRewardsCmd()
- out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
- require.NoError(err)
- // expect 1 transaction in the generated file when --max-msgs in a tx set 2, since there are only delegations.
- s.Require().Equal(1, len(strings.Split(strings.Trim(out.String(), "\n"), "\n")))
-}
diff --git a/tests/e2e/genutil/export_test.go b/tests/e2e/genutil/export_test.go
index 0a98ef6b4e85..798885c0900f 100644
--- a/tests/e2e/genutil/export_test.go
+++ b/tests/e2e/genutil/export_test.go
@@ -31,6 +31,7 @@ import (
"github.com/cosmos/cosmos-sdk/server/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
gentestutil "github.com/cosmos/cosmos-sdk/testutil/x/genutil"
+ sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
@@ -184,7 +185,7 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, ge
ChainID: "theChainId",
AppState: stateBytes,
Consensus: &genutiltypes.ConsensusGenesis{
- Validators: nil,
+ Validators: []sdk.GenesisValidator{},
},
}
diff --git a/tests/go.mod b/tests/go.mod
index bbc2a3c3e485..540cb84fd733 100644
--- a/tests/go.mod
+++ b/tests/go.mod
@@ -26,7 +26,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
pgregory.net/rapid v1.1.0
)
@@ -55,8 +55,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.8.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
@@ -174,7 +174,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -206,15 +206,15 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/api v0.192.0 // indirect
diff --git a/tests/go.sum b/tests/go.sum
index b2cfe1aa475e..474e0a602b10 100644
--- a/tests/go.sum
+++ b/tests/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -712,8 +712,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -851,8 +851,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1071,13 +1071,13 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1088,8 +1088,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1382,8 +1382,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/tests/integration/rapidgen/rapidgen.go b/tests/integration/rapidgen/rapidgen.go
index 0060ca1976ce..2d2f5ab48630 100644
--- a/tests/integration/rapidgen/rapidgen.go
+++ b/tests/integration/rapidgen/rapidgen.go
@@ -259,9 +259,7 @@ var (
GenType(&slashingtypes.Params{}, &slashingapi.Params{}, GenOpts.WithDisallowNil()),
- // JSON ordering of one of fields to be fixed in https://github.com/cosmos/cosmos-sdk/pull/21782
- // TODO uncomment once merged
- // GenType(&stakingtypes.StakeAuthorization{}, &stakingapi.StakeAuthorization{}, GenOpts),
+ GenType(&stakingtypes.StakeAuthorization{}, &stakingapi.StakeAuthorization{}, GenOpts),
GenType(&upgradetypes.CancelSoftwareUpgradeProposal{}, &upgradeapi.CancelSoftwareUpgradeProposal{}, GenOpts), //nolint:staticcheck // testing legacy code path
GenType(&upgradetypes.SoftwareUpgradeProposal{}, &upgradeapi.SoftwareUpgradeProposal{}, GenOpts.WithDisallowNil()), //nolint:staticcheck // testing legacy code path
diff --git a/tests/integration/tx/aminojson/aminojson_test.go b/tests/integration/tx/aminojson/aminojson_test.go
index cf9695b4b451..38aecaa9b30f 100644
--- a/tests/integration/tx/aminojson/aminojson_test.go
+++ b/tests/integration/tx/aminojson/aminojson_test.go
@@ -258,6 +258,11 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
"gov/v1_msg_submit_proposal": {
gogo: &gov_v1_types.MsgSubmitProposal{},
},
+ "gov/v1_params": {
+ gogo: &gov_v1_types.Params{
+ Quorum: math.LegacyMustNewDecFromStr("0.33").String(),
+ },
+ },
"slashing/params/dec": {
gogo: &slashingtypes.Params{
DowntimeJailDuration: 1e9 + 7,
@@ -311,9 +316,6 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
},
AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE,
},
- // to be fixed in https://github.com/cosmos/cosmos-sdk/pull/21782
- // TODO remove once merged
- fails: true,
},
"vesting/base_account_empty": {
gogo: &vestingtypes.BaseVestingAccount{BaseAccount: &authtypes.BaseAccount{}},
diff --git a/tests/systemtests/auth_test.go b/tests/systemtests/auth_test.go
new file mode 100644
index 000000000000..c45652f3cf8a
--- /dev/null
+++ b/tests/systemtests/auth_test.go
@@ -0,0 +1,508 @@
+//go:build system_test
+
+package systemtests
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+ "github.com/tidwall/gjson"
+ "github.com/tidwall/sjson"
+)
+
+const (
+ authTestDenom = "stake"
+)
+
+func TestAuthSignAndBroadcastTxCmd(t *testing.T) {
+ // scenario: test auth sign and broadcast commands
+ // given a running chain
+
+ sut.ResetChain(t)
+ require.GreaterOrEqual(t, sut.NodesCount(), 2)
+
+ cli := NewCLIWrapper(t, sut, verbose)
+
+ // get validator addresses
+ val1Addr := cli.GetKeyAddr("node0")
+ require.NotEmpty(t, val1Addr)
+
+ val2Addr := cli.GetKeyAddr("node1")
+ require.NotEmpty(t, val2Addr)
+
+ sut.StartChain(t)
+
+ var transferAmount, feeAmount int64 = 1000, 1
+
+ // test sign tx command
+
+ // run bank tx send with --generate-only flag
+ sendTx := generateBankSendTx(t, cli, val1Addr, val2Addr, transferAmount, feeAmount, "")
+ txFile := StoreTempFile(t, []byte(fmt.Sprintf("%s\n", sendTx)))
+
+ // query node0 account details
+ signTxCmd := []string{"tx", "sign", txFile.Name(), "--from=" + val1Addr, "--chain-id=" + cli.chainID}
+ testSignTxBroadcast(t, cli, signTxCmd, "sign tx", val1Addr, val2Addr, transferAmount, feeAmount)
+
+ // test broadcast with empty public key in signed tx
+ rsp := cli.RunCommandWithArgs(cli.withTXFlags("tx", "sign", txFile.Name(), "--from="+val1Addr)...)
+ updated, err := sjson.Set(rsp, "auth_info.signer_infos.0.public_key", nil)
+ require.NoError(t, err)
+ newSignFile := StoreTempFile(t, []byte(updated))
+
+ broadcastCmd := []string{"tx", "broadcast", newSignFile.Name()}
+ rsp = cli.RunCommandWithArgs(cli.withTXFlags(broadcastCmd...)...)
+ RequireTxFailure(t, rsp)
+
+ // test sign-batch tx command
+
+ // generate another bank send tx with less amount
+ newAmount := int64(100)
+ sendTx2 := generateBankSendTx(t, cli, val1Addr, val2Addr, newAmount, feeAmount, "")
+ tx2File := StoreTempFile(t, []byte(fmt.Sprintf("%s\n", sendTx2)))
+
+ signBatchCmd := []string{"tx", "sign-batch", txFile.Name(), tx2File.Name(), "--from=" + val1Addr, "--chain-id=" + cli.chainID}
+ sendAmount := transferAmount + newAmount
+ fees := feeAmount * 2
+
+ // TODO: remove below block code once v2 supports multi messages
+ // ref: https://github.com/cosmos/cosmos-sdk/issues/22215
+ if isV2() {
+ sendAmount = transferAmount
+ fees = feeAmount
+ }
+
+ testSignTxBroadcast(t, cli, signBatchCmd, "sign-batch tx", val1Addr, val2Addr, sendAmount, fees)
+}
+
+func testSignTxBroadcast(t *testing.T, cli *CLIWrapper, txCmd []string, prefix, fromAddr, toAddr string, amount, fees int64) {
+ t.Helper()
+
+ fromAddrBal := cli.QueryBalance(fromAddr, authTestDenom)
+ toAddrBal := cli.QueryBalance(toAddr, authTestDenom)
+
+ // query from account details
+ rsp := cli.CustomQuery("q", "auth", "accounts")
+ details := gjson.Get(rsp, fmt.Sprintf("accounts.#(value.address==%s).value", fromAddr)).String()
+ accSeq := gjson.Get(details, "sequence").Int()
+ accNum := gjson.Get(details, "account_number").Int()
+
+ testCases := []struct {
+ name string
+ extraArgs []string
+ }{
+ {
+ "valid tx sign with offline mode",
+ []string{
+ "--offline",
+ fmt.Sprintf("--account-number=%d", accNum),
+ fmt.Sprintf("--sequence=%d", accSeq),
+ },
+ },
+ {
+ "valid tx sign",
+ []string{},
+ },
+ {
+ "valid tx sign with sign-mode",
+ []string{"--sign-mode=amino-json"},
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(prefix+"-"+tc.name, func(t *testing.T) {
+ cmd := append(txCmd, tc.extraArgs...)
+
+ // run tx sign command and verify signatures count
+ rsp = cli.RunCommandWithArgs(cli.withKeyringFlags(cmd...)...)
+
+ signatures := gjson.Get(rsp, "signatures").Array()
+ require.Len(t, signatures, 1)
+
+ signFile := StoreTempFile(t, []byte(rsp))
+
+ // validate signature
+ rsp = cli.RunCommandWithArgs(cli.withKeyringFlags("tx", "validate-signatures", signFile.Name(), "--from="+fromAddr, "--chain-id="+cli.chainID)...)
+ require.Contains(t, rsp, "[OK]")
+
+ // run broadcast tx command
+ broadcastCmd := []string{"tx", "broadcast", signFile.Name()}
+ rsp = cli.RunAndWait(broadcastCmd...)
+ RequireTxSuccess(t, rsp)
+
+ // query balance and confirm transaction
+ expVal1Bal := fromAddrBal - amount - fees
+ fromAddrBal = cli.QueryBalance(fromAddr, authTestDenom)
+ require.Equal(t, expVal1Bal, fromAddrBal)
+
+ expVal2Bal := toAddrBal + amount
+ toAddrBal = cli.QueryBalance(toAddr, authTestDenom)
+ require.Equal(t, expVal2Bal, toAddrBal)
+ })
+ }
+}
+
+func TestAuthQueryTxCmds(t *testing.T) {
+ // scenario: test query tx and txs commands
+ // given a running chain
+
+ sut.ResetChain(t)
+ require.GreaterOrEqual(t, sut.NodesCount(), 2)
+
+ cli := NewCLIWrapper(t, sut, verbose)
+
+ // get validator addresses
+ val1Addr := cli.GetKeyAddr("node0")
+ require.NotEmpty(t, val1Addr)
+
+ val2Addr := cli.GetKeyAddr("node1")
+ require.NotEmpty(t, val2Addr)
+
+ sut.StartChain(t)
+
+ // do a bank transfer and use it for query txs
+ feeAmount := "2stake"
+ rsp := cli.RunAndWait("tx", "bank", "send", val1Addr, val2Addr, "10000stake", "--fees="+feeAmount)
+ RequireTxSuccess(t, rsp)
+
+ // parse values from above tx
+ height := gjson.Get(rsp, "height").String()
+ txHash := gjson.Get(rsp, "txhash").String()
+ accSeq := fmt.Sprintf("%s/%d", val1Addr, gjson.Get(rsp, "tx.auth_info.signer_infos.0.sequence").Int())
+ signature := gjson.Get(rsp, "tx.signatures.0").String()
+
+ // test query tx command
+ testCases := []struct {
+ name string
+ args []string
+ }{
+ {
+ "valid query with txhash",
+ []string{txHash},
+ },
+ {
+ "valid query with addr+seq filter",
+ []string{"--type=acc_seq", accSeq},
+ },
+ {
+ "valid query with signature filter",
+ []string{"--type=signature", signature},
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ cmd := []string{"q", "tx"}
+ rsp = cli.CustomQuery(append(cmd, tc.args...)...)
+ txHeight := gjson.Get(rsp, "height").String()
+ require.Equal(t, height, txHeight)
+ })
+ }
+
+ // test query txs command
+ txsTestCases := []struct {
+ name string
+ query string
+ expLen int
+ }{
+ {
+ "fee event happy case",
+ fmt.Sprintf("--query=tx.fee='%s'", feeAmount),
+ 1,
+ },
+ {
+ "no matching fee event",
+ "--query=tx.fee='120stake'",
+ 0,
+ },
+ {
+ "query with tx height",
+ fmt.Sprintf("--query=tx.height='%s'", height),
+ 1,
+ },
+ }
+
+ for _, tc := range txsTestCases {
+ t.Run(tc.name, func(t *testing.T) {
+ cmd := []string{"q", "txs", tc.query}
+ rsp = cli.CustomQuery(cmd...)
+ txs := gjson.Get(rsp, "txs").Array()
+ require.Equal(t, tc.expLen, len(txs))
+ })
+ }
+}
+
+func TestAuthMultisigTxCmds(t *testing.T) {
+ // scenario: test auth multisig related tx commands
+ // given a running chain
+
+ sut.ResetChain(t)
+ cli := NewCLIWrapper(t, sut, verbose)
+
+ // get validator address
+ valAddr := cli.GetKeyAddr("node0")
+ require.NotEmpty(t, valAddr)
+
+ // add new keys for multisig
+ acc1Addr := cli.AddKey("acc1")
+ require.NotEmpty(t, acc1Addr)
+
+ acc2Addr := cli.AddKey("acc2")
+ require.NotEqual(t, acc1Addr, acc2Addr)
+
+ acc3Addr := cli.AddKey("acc3")
+ require.NotEqual(t, acc1Addr, acc3Addr)
+
+ out := cli.RunCommandWithArgs(cli.withKeyringFlags("keys", "add", "multi", "--multisig=acc1,acc2,acc3", "--multisig-threshold=2")...)
+ multiAddr := gjson.Get(out, "address").String()
+ require.NotEmpty(t, multiAddr)
+
+ sut.StartChain(t)
+
+ // fund multisig address some amount
+ var initialAmount, transferAmount, feeAmount int64 = 10000, 100, 1
+ _ = cli.FundAddress(multiAddr, fmt.Sprintf("%d%s", initialAmount, authTestDenom))
+
+ multiAddrBal := cli.QueryBalance(multiAddr, authTestDenom)
+ require.Equal(t, initialAmount, multiAddrBal)
+
+ // test multisign tx command
+
+ // run bank tx send with --generate-only flag
+ sendTx := generateBankSendTx(t, cli, multiAddr, valAddr, transferAmount, feeAmount, "")
+ txFile := StoreTempFile(t, []byte(sendTx))
+
+ signTxCmd := cli.withKeyringFlags("tx", "sign", txFile.Name(), "--multisig="+multiAddr, "--chain-id="+cli.chainID)
+ multiSignTxCmd := cli.withKeyringFlags("tx", "multisign", txFile.Name(), "multi", "--chain-id="+cli.chainID)
+
+ testMultisigTxBroadcast(t, cli, multiSigTxInput{
+ "multisign",
+ multiAddr,
+ valAddr,
+ acc1Addr,
+ acc2Addr,
+ acc3Addr,
+ signTxCmd,
+ multiSignTxCmd,
+ transferAmount,
+ feeAmount,
+ })
+
+ // test multisign-batch tx command
+
+ // generate two send transactions in single file
+ multiSendTx := fmt.Sprintf("%s\n%s", sendTx, sendTx)
+ multiTxFile := StoreTempFile(t, []byte(multiSendTx))
+
+ signBatchTxCmd := cli.withKeyringFlags("tx", "sign-batch", multiTxFile.Name(), "--multisig="+multiAddr, "--signature-only", "--chain-id="+cli.chainID)
+ multiSignBatchTxCmd := cli.withKeyringFlags("tx", "multisign-batch", multiTxFile.Name(), "multi", "--chain-id="+cli.chainID)
+
+ // as we done couple of bank transactions as batch,
+ // transferred amount will be twice
+ sendAmount := transferAmount * 2
+ fees := feeAmount * 2
+
+ // TODO: remove below block code once v2 supports multi messages
+ // ref: https://github.com/cosmos/cosmos-sdk/issues/22215
+ if isV2() {
+ sendAmount = transferAmount
+ fees = feeAmount
+ }
+
+ testMultisigTxBroadcast(t, cli, multiSigTxInput{
+ "multisign-batch",
+ multiAddr,
+ valAddr,
+ acc1Addr,
+ acc2Addr,
+ acc3Addr,
+ signBatchTxCmd,
+ multiSignBatchTxCmd,
+ sendAmount,
+ fees,
+ })
+}
+
+func generateBankSendTx(t *testing.T, cli *CLIWrapper, fromAddr, toAddr string, amount, fees int64, memo string) string {
+ t.Helper()
+
+ bankSendGenCmd := []string{
+ "tx", "bank", "send", fromAddr, toAddr,
+ fmt.Sprintf("%d%s", amount, authTestDenom),
+ fmt.Sprintf("--fees=%d%s", fees, authTestDenom),
+ "--generate-only",
+ "--note=" + memo,
+ }
+
+ return cli.RunCommandWithArgs(cli.withTXFlags(bankSendGenCmd...)...)
+}
+
+type multiSigTxInput struct {
+ prefix string
+ multiAddr string
+ toAddr string
+ acc1Addr string
+ acc2Addr string
+ acc3Addr string
+ signCmd []string
+ multiSignCmd []string
+ transferAmount int64
+ feeAmount int64
+}
+
+func testMultisigTxBroadcast(t *testing.T, cli *CLIWrapper, i multiSigTxInput) {
+ t.Helper()
+
+ multiAddrBal := cli.QueryBalance(i.multiAddr, authTestDenom)
+ toAddrBal := cli.QueryBalance(i.toAddr, authTestDenom)
+
+ testCases := []struct {
+ name string
+ signingAccs []string
+ expErrMsg string
+ }{
+ {
+ "minimum threshold not reached",
+ []string{i.acc1Addr},
+ "signature size is incorrect",
+ },
+ {
+ "valid tx with two signers",
+ []string{i.acc1Addr, i.acc2Addr},
+ "",
+ },
+ {
+ "valid tx with three signed files",
+ []string{i.acc1Addr, i.acc2Addr, i.acc3Addr},
+ "",
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(i.prefix+"-"+tc.name, func(t *testing.T) {
+ // append signed files to multisign command
+ cmd := i.multiSignCmd
+ for _, acc := range tc.signingAccs {
+ rsp := cli.RunCommandWithArgs(append(i.signCmd, "--from="+acc)...)
+ signFile := StoreTempFile(t, []byte(rsp))
+ cmd = append(cmd, signFile.Name())
+ }
+ rsp := cli.RunCommandWithArgs(cmd...)
+ multiSignFile := StoreTempFile(t, []byte(rsp))
+
+ // run broadcast tx command
+ broadcastCmd := []string{"tx", "broadcast", multiSignFile.Name()}
+ if tc.expErrMsg != "" {
+ rsp = cli.RunCommandWithArgs(cli.withTXFlags(broadcastCmd...)...)
+ RequireTxFailure(t, rsp)
+ require.Contains(t, rsp, tc.expErrMsg)
+ return
+ }
+
+ rsp = cli.RunAndWait(broadcastCmd...)
+ RequireTxSuccess(t, rsp)
+
+ // query balance and confirm transaction
+ expMultiBal := multiAddrBal - i.transferAmount - i.feeAmount
+ multiAddrBal = cli.QueryBalance(i.multiAddr, authTestDenom)
+ require.Equal(t, expMultiBal, multiAddrBal)
+
+ expVal2Bal := toAddrBal + i.transferAmount
+ toAddrBal = cli.QueryBalance(i.toAddr, authTestDenom)
+ require.Equal(t, expVal2Bal, toAddrBal)
+ })
+ }
+}
+
+func TestAuxSigner(t *testing.T) {
+ // scenario: test tx with direct aux sign mode
+ // given a running chain
+
+ sut.ResetChain(t)
+ require.GreaterOrEqual(t, sut.NodesCount(), 2)
+
+ cli := NewCLIWrapper(t, sut, verbose)
+
+ // get validator addresses
+ val1Addr := cli.GetKeyAddr("node0")
+ require.NotEmpty(t, val1Addr)
+
+ val2Addr := cli.GetKeyAddr("node1")
+ require.NotEmpty(t, val2Addr)
+
+ sut.StartChain(t)
+
+ bankSendCmd := []string{"tx", "bank", "send", val1Addr, val2Addr, "10000stake", "--from=" + val1Addr}
+
+ testCases := []struct {
+ name string
+ args []string
+ expErrMsg string
+ }{
+ {
+ "error with SIGN_MODE_DIRECT_AUX and --aux unset",
+ []string{
+ "--sign-mode=direct-aux",
+ },
+ "cannot sign with SIGN_MODE_DIRECT_AUX",
+ },
+ {
+ "no error with SIGN_MDOE_DIRECT_AUX mode and generate-only set (ignores generate-only)",
+ []string{
+ "--sign-mode=direct-aux",
+ "--generate-only",
+ },
+ "",
+ },
+ {
+ "no error with SIGN_MDOE_DIRECT_AUX mode and generate-only, tip flag set",
+ []string{
+ "--sign-mode=direct-aux",
+ "--generate-only",
+ "--tip=10stake",
+ },
+ "",
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ cmd := append(bankSendCmd, tc.args...)
+ assertTxOutput := func(_ assert.TestingT, gotErr error, gotOutputs ...interface{}) bool {
+ require.Len(t, gotOutputs, 1)
+ output := gotOutputs[0].(string)
+ if tc.expErrMsg != "" {
+ require.Contains(t, output, tc.expErrMsg)
+ } else {
+ require.Len(t, gjson.Get(output, "body.messages").Array(), 1)
+ }
+ return false
+ }
+
+ _ = cli.WithRunErrorMatcher(assertTxOutput).Run(cli.withTXFlags(cmd...)...)
+ })
+ }
+}
+
+func TestTxEncodeandDecode(t *testing.T) {
+ // scenario: test tx encode and decode commands
+
+ cli := NewCLIWrapper(t, sut, verbose)
+
+ // get validator address
+ val1Addr := cli.GetKeyAddr("node0")
+ require.NotEmpty(t, val1Addr)
+
+ memoText := "testmemo"
+ sendTx := generateBankSendTx(t, cli, val1Addr, val1Addr, 100, 1, memoText)
+ txFile := StoreTempFile(t, []byte(sendTx))
+
+ // run encode command
+ encodedText := cli.RunCommandWithArgs("tx", "encode", txFile.Name())
+
+ // check transaction decodes as expected
+ decodedTx := cli.RunCommandWithArgs("tx", "decode", encodedText)
+ require.Equal(t, gjson.Get(decodedTx, "body.memo").String(), memoText)
+}
diff --git a/tests/systemtests/authz_test.go b/tests/systemtests/authz_test.go
index da66aef5d267..f3e0ec748c8b 100644
--- a/tests/systemtests/authz_test.go
+++ b/tests/systemtests/authz_test.go
@@ -607,7 +607,7 @@ func TestAuthzExecRedelegateAuthorization(t *testing.T) {
msgRedelegateTypeURL, granterAddr, val1Addr, val2Addr, testDenom, redelegationAmount)
execMsg := WriteToTempJSONFile(t, redelegateTx)
- redelegateCmd := []string{"tx", "authz", "exec", execMsg.Name(), "--from=" + granteeAddr, "--gas=auto"}
+ redelegateCmd := []string{"tx", "authz", "exec", execMsg.Name(), "--from=" + granteeAddr, "--gas=500000", "--fees=10stake"}
rsp = cli.RunAndWait(redelegateCmd...)
RequireTxSuccess(t, rsp)
diff --git a/tests/systemtests/cli.go b/tests/systemtests/cli.go
index d7ac2368ae79..6c8dffc4bbd5 100644
--- a/tests/systemtests/cli.go
+++ b/tests/systemtests/cli.go
@@ -1,8 +1,6 @@
package systemtests
import (
- "bufio"
- "bytes"
"fmt"
"io"
"os"
@@ -243,26 +241,10 @@ func (c CLIWrapper) runWithInput(args []string, input io.Reader) (output string,
cmd.Stdin = input
return cmd.CombinedOutput()
}()
- gotOut = filterProtoNoise(gotOut)
ok = c.assertErrorFn(c.t, gotErr, string(gotOut))
return strings.TrimSpace(string(gotOut)), ok
}
-func filterProtoNoise(in []byte) []byte {
- // temporary hack to get rid of all the noise on the stderr
- var out bytes.Buffer
- scanner := bufio.NewScanner(bytes.NewReader(in))
- for scanner.Scan() {
- if !strings.Contains(scanner.Text(), " proto: duplicate proto type registered") {
- _, _ = out.Write(scanner.Bytes())
- }
- }
- if err := scanner.Err(); err != nil {
- panic(err)
- }
- return out.Bytes()
-}
-
func (c CLIWrapper) withQueryFlags(args ...string) []string {
args = append(args, "--output", "json")
return c.withChainFlags(args...)
diff --git a/tests/systemtests/cometbft_client_test.go b/tests/systemtests/cometbft_client_test.go
index 0c9fd62bb5bd..cee97baa0c61 100644
--- a/tests/systemtests/cometbft_client_test.go
+++ b/tests/systemtests/cometbft_client_test.go
@@ -5,6 +5,7 @@ package systemtests
import (
"context"
"fmt"
+ "net/http"
"net/url"
"testing"
"time"
@@ -82,6 +83,10 @@ func TestQueryBlockByHeight(t *testing.T) {
}
func TestQueryLatestValidatorSet(t *testing.T) {
+ if sut.NodesCount() < 2 {
+ t.Skip("not enough nodes")
+ return
+ }
baseurl := fmt.Sprintf("http://localhost:%d", apiPortStart)
sut.ResetChain(t)
sut.StartChain(t)
@@ -103,7 +108,7 @@ func TestQueryLatestValidatorSet(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, len(res.Validators), 2)
- restRes := GetRequest(t, mustV(url.JoinPath(baseurl, "/cosmos/base/tendermint/v1beta1/validatorsets/latest?pagination.offset=0&pagination.limit=2")))
+ restRes := GetRequest(t, fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/latest?pagination.offset=%d&pagination.limit=%d", baseurl, 0, 2))
assert.Equal(t, len(gjson.GetBytes(restRes, "validators").Array()), 2)
}
@@ -161,13 +166,14 @@ func TestLatestValidatorSet_GRPCGateway(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- rsp := GetRequest(t, mustV(url.JoinPath(baseurl, tc.url)))
if tc.expErr {
+ rsp := GetRequestWithHeaders(t, baseurl+tc.url, nil, http.StatusBadRequest)
errMsg := gjson.GetBytes(rsp, "message").String()
assert.Contains(t, errMsg, tc.expErrMsg)
- } else {
- assert.Equal(t, len(vals), int(gjson.GetBytes(rsp, "pagination.total").Int()))
+ return
}
+ rsp := GetRequest(t, baseurl+tc.url)
+ assert.Equal(t, len(vals), int(gjson.GetBytes(rsp, "pagination.total").Int()))
})
}
}
@@ -204,41 +210,40 @@ func TestValidatorSetByHeight(t *testing.T) {
}
}
-func TestValidatorSetByHeight_GRPCGateway(t *testing.T) {
+func TestValidatorSetByHeight_GRPCRestGateway(t *testing.T) {
sut.ResetChain(t)
sut.StartChain(t)
vals := sut.RPCClient(t).Validators()
- baseurl := fmt.Sprintf("http://localhost:%d", apiPortStart)
-
+ baseurl := sut.APIAddress()
block := sut.AwaitNextBlock(t, time.Second*3)
testCases := []struct {
- name string
- url string
- expErr bool
- expErrMsg string
+ name string
+ url string
+ expErr bool
+ expErrMsg string
+ expHttpCode int
}{
- {"invalid height", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d", baseurl, -1), true, "height must be greater than 0"},
- {"no pagination", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d", baseurl, block), false, ""},
- {"pagination invalid fields", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d?pagination.offset=-1&pagination.limit=-2", baseurl, block), true, "strconv.ParseUint"},
- {"with pagination", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d?pagination.limit=2", baseurl, 1), false, ""},
+ {"invalid height", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d", baseurl, -1), true, "height must be greater than 0", http.StatusInternalServerError},
+ {"no pagination", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d", baseurl, block), false, "", http.StatusOK},
+ {"pagination invalid fields", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d?pagination.offset=-1&pagination.limit=-2", baseurl, block), true, "strconv.ParseUint", http.StatusBadRequest},
+ {"with pagination", fmt.Sprintf("%s/cosmos/base/tendermint/v1beta1/validatorsets/%d?pagination.limit=2", baseurl, 1), false, "", http.StatusOK},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
- rsp := GetRequest(t, tc.url)
+ rsp := GetRequestWithHeaders(t, tc.url, nil, tc.expHttpCode)
if tc.expErr {
errMsg := gjson.GetBytes(rsp, "message").String()
assert.Contains(t, errMsg, tc.expErrMsg)
- } else {
- assert.Equal(t, len(vals), int(gjson.GetBytes(rsp, "pagination.total").Int()))
+ return
}
+ assert.Equal(t, len(vals), int(gjson.GetBytes(rsp, "pagination.total").Int()))
})
}
}
func TestABCIQuery(t *testing.T) {
- sut.ResetChain(t)
sut.StartChain(t)
qc := cmtservice.NewServiceClient(sut.RPCClient(t))
@@ -312,7 +317,7 @@ func TestABCIQuery(t *testing.T) {
} else {
assert.NoError(t, err)
assert.NotNil(t, res)
- assert.Equal(t, res.Code, tc.expectedCode)
+ assert.Equal(t, tc.expectedCode, res.Code)
}
if tc.validQuery {
diff --git a/tests/systemtests/distribution_test.go b/tests/systemtests/distribution_test.go
new file mode 100644
index 000000000000..e074b89e7cf3
--- /dev/null
+++ b/tests/systemtests/distribution_test.go
@@ -0,0 +1,301 @@
+//go:build system_test
+
+package systemtests
+
+import (
+ "fmt"
+ "net/http"
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+ "github.com/tidwall/gjson"
+ "github.com/tidwall/sjson"
+)
+
+const (
+ distrTestDenom = "stake"
+)
+
+func TestWithdrawAllRewardsCmd(t *testing.T) {
+ // scenario: test distribution withdraw all rewards command
+ // given a running chain
+
+ sut.ResetChain(t)
+ cli := NewCLIWrapper(t, sut, verbose)
+
+ newAddr := cli.AddKey("newAddr")
+ require.NotEmpty(t, newAddr)
+
+ var initialAmount int64 = 10000000
+ initialBalance := fmt.Sprintf("%d%s", initialAmount, distrTestDenom)
+ sut.ModifyGenesisCLI(t,
+ []string{"genesis", "add-genesis-account", newAddr, initialBalance},
+ )
+ sut.StartChain(t)
+
+ // query balance
+ newAddrBal := cli.QueryBalance(newAddr, distrTestDenom)
+ require.Equal(t, initialAmount, newAddrBal)
+
+ // query validator operator address
+ rsp := cli.CustomQuery("q", "staking", "validators")
+ validators := gjson.Get(rsp, "validators.#.operator_address").Array()
+ require.GreaterOrEqual(t, len(validators), 2)
+ val1Addr := validators[0].String()
+ val2Addr := validators[1].String()
+
+ var delegationAmount int64 = 100000
+ delegation := fmt.Sprintf("%d%s", delegationAmount, distrTestDenom)
+
+ // delegate tokens to validator1
+ rsp = cli.RunAndWait("tx", "staking", "delegate", val1Addr, delegation, "--from="+newAddr, "--fees=1"+distrTestDenom)
+ RequireTxSuccess(t, rsp)
+
+ // delegate tokens to validator2
+ rsp = cli.RunAndWait("tx", "staking", "delegate", val2Addr, delegation, "--from="+newAddr, "--fees=1"+distrTestDenom)
+ RequireTxSuccess(t, rsp)
+
+ // check updated balance: newAddrBal - delegatedBal - fees
+ expBal := newAddrBal - (delegationAmount * 2) - 2
+ newAddrBal = cli.QueryBalance(newAddr, distrTestDenom)
+ require.Equal(t, expBal, newAddrBal)
+
+ withdrawCmdArgs := []string{"tx", "distribution", "withdraw-all-rewards", "--from=" + newAddr, "--fees=1" + distrTestDenom}
+
+ // test with --max-msgs
+ testCases := []struct {
+ name string
+ maxMsgs int
+ expTxLen int
+ }{
+ {
+ "--max-msgs value is 1",
+ 1,
+ 2,
+ },
+ {
+ "--max-msgs value is 2",
+ 2,
+ 1,
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ assertGenOnlyOutput := func(_ assert.TestingT, gotErr error, gotOutputs ...interface{}) bool {
+ require.Len(t, gotOutputs, 1)
+ // split txs with new line
+ splitOutput := strings.Split(strings.Trim(gotOutputs[0].(string), "\n"), "\n")
+ require.Len(t, splitOutput, tc.expTxLen)
+ return false
+ }
+ cmd := append(withdrawCmdArgs, fmt.Sprintf("--max-msgs=%d", tc.maxMsgs), "--generate-only")
+ _ = cli.WithRunErrorMatcher(assertGenOnlyOutput).Run(cmd...)
+ })
+ }
+
+ // test withdraw-all-rewards transaction
+ rsp = cli.RunAndWait(withdrawCmdArgs...)
+ RequireTxSuccess(t, rsp)
+}
+
+func TestDistrValidatorGRPCQueries(t *testing.T) {
+ // scenario: test distribution validator grpc gateway queries
+ // given a running chain
+
+ sut.ResetChain(t)
+ cli := NewCLIWrapper(t, sut, verbose)
+ // get validator address
+ valAddr := cli.GetKeyAddr("node0")
+ require.NotEmpty(t, valAddr)
+ valOperAddr := cli.GetKeyAddrPrefix("node0", "val")
+ require.NotEmpty(t, valOperAddr)
+
+ sut.StartChain(t)
+
+ sut.AwaitNBlocks(t, 3)
+
+ baseurl := sut.APIAddress()
+ expectedAmountOutput := fmt.Sprintf(`{"denom":"%s","amount":"203.105000000000000000"}`, distrTestDenom)
+
+ // test params grpc endpoint
+ paramsURL := baseurl + "/cosmos/distribution/v1beta1/params"
+
+ paramsTestCases := []RestTestCase{
+ {
+ "gRPC request params",
+ paramsURL,
+ http.StatusOK,
+ `{"params":{"community_tax":"0.020000000000000000","base_proposer_reward":"0.000000000000000000","bonus_proposer_reward":"0.000000000000000000","withdraw_addr_enabled":true}}`,
+ },
+ }
+ RunRestQueries(t, paramsTestCases)
+
+ // test validator distribution info grpc endpoint
+ validatorsURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s`
+ validatorsOutput := fmt.Sprintf(`{"operator_address":"%s","self_bond_rewards":[],"commission":[%s]}`, valAddr, expectedAmountOutput)
+
+ validatorsTestCases := []RestTestCase{
+ {
+ "gRPC request validator with valid validator address",
+ fmt.Sprintf(validatorsURL, valOperAddr),
+ http.StatusOK,
+ validatorsOutput,
+ },
+ }
+ TestRestQueryIgnoreNumbers(t, validatorsTestCases)
+
+ // test outstanding rewards grpc endpoint
+ outstandingRewardsURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s/outstanding_rewards`
+
+ rewardsTestCases := []RestTestCase{
+ {
+ "gRPC request outstanding rewards with valid validator address",
+ fmt.Sprintf(outstandingRewardsURL, valOperAddr),
+ http.StatusOK,
+ fmt.Sprintf(`{"rewards":{"rewards":[%s]}}`, expectedAmountOutput),
+ },
+ }
+ TestRestQueryIgnoreNumbers(t, rewardsTestCases)
+
+ // test validator commission grpc endpoint
+ commissionURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s/commission`
+
+ commissionTestCases := []RestTestCase{
+ {
+ "gRPC request commission with valid validator address",
+ fmt.Sprintf(commissionURL, valOperAddr),
+ http.StatusOK,
+ fmt.Sprintf(`{"commission":{"commission":[%s]}}`, expectedAmountOutput),
+ },
+ }
+ TestRestQueryIgnoreNumbers(t, commissionTestCases)
+
+ // test validator slashes grpc endpoint
+ slashURL := baseurl + `/cosmos/distribution/v1beta1/validators/%s/slashes`
+ invalidHeightOutput := `{"code":3, "message":"strconv.ParseUint: parsing \"-3\": invalid syntax", "details":[]}`
+
+ slashTestCases := []RestTestCase{
+ {
+ "invalid start height",
+ fmt.Sprintf(slashURL+`?starting_height=%s&ending_height=%s`, valOperAddr, "-3", "3"),
+ http.StatusBadRequest,
+ invalidHeightOutput,
+ },
+ {
+ "invalid end height",
+ fmt.Sprintf(slashURL+`?starting_height=%s&ending_height=%s`, valOperAddr, "1", "-3"),
+ http.StatusBadRequest,
+ invalidHeightOutput,
+ },
+ {
+ "valid request get slashes",
+ fmt.Sprintf(slashURL+`?starting_height=%s&ending_height=%s`, valOperAddr, "1", "3"),
+ http.StatusOK,
+ `{"slashes":[],"pagination":{"next_key":null,"total":"0"}}`,
+ },
+ }
+ RunRestQueries(t, slashTestCases)
+}
+
+func TestDistrDelegatorGRPCQueries(t *testing.T) {
+ // scenario: test distribution validator gsrpc gateway queries
+ // given a running chain
+
+ sut.ResetChain(t)
+ cli := NewCLIWrapper(t, sut, verbose)
+
+ // get validator address
+ valAddr := cli.GetKeyAddr("node0")
+ require.NotEmpty(t, valAddr)
+ valOperAddr := cli.GetKeyAddrPrefix("node0", "val")
+ require.NotEmpty(t, valOperAddr)
+
+ // update commission rate of node0 validator
+ // generate new gentx and copy it to genesis.json before starting network
+ rsp := cli.RunCommandWithArgs("genesis", "gentx", "node0", "100000000"+distrTestDenom, "--chain-id="+cli.chainID, "--commission-rate=0.01", "--home", sut.nodePath(0), "--keyring-backend=test")
+ // extract gentx path from above command output
+ re := regexp.MustCompile(`"(.*?\.json)"`)
+ match := re.FindStringSubmatch(rsp)
+ require.GreaterOrEqual(t, len(match), 1)
+
+ updatedGentx := filepath.Join(WorkDir, match[1])
+ updatedGentxBz, err := os.ReadFile(updatedGentx) // #nosec G304
+ require.NoError(t, err)
+
+ sut.ModifyGenesisJSON(t, func(genesis []byte) []byte {
+ state, err := sjson.SetRawBytes(genesis, "app_state.genutil.gen_txs.0", updatedGentxBz)
+ require.NoError(t, err)
+ return state
+ })
+
+ // create new address which will be used as delegator address
+ delAddr := cli.AddKey("delAddr")
+ require.NotEmpty(t, delAddr)
+
+ var initialAmount int64 = 1000000000
+ initialBalance := fmt.Sprintf("%d%s", initialAmount, distrTestDenom)
+ sut.ModifyGenesisCLI(t,
+ []string{"genesis", "add-genesis-account", delAddr, initialBalance},
+ )
+
+ sut.StartChain(t)
+
+ // delegate some tokens to valOperAddr
+ rsp = cli.RunAndWait("tx", "staking", "delegate", valOperAddr, "100000000"+distrTestDenom, "--from="+delAddr)
+ RequireTxSuccess(t, rsp)
+
+ sut.AwaitNBlocks(t, 5)
+
+ baseurl := sut.APIAddress()
+
+ // test delegator rewards grpc endpoint
+ delegatorRewardsURL := baseurl + `/cosmos/distribution/v1beta1/delegators/%s/rewards`
+ expectedAmountOutput := `{"denom":"stake","amount":"0.121275000000000000"}`
+ rewardsOutput := fmt.Sprintf(`{"rewards":[{"validator_address":"%s","reward":[%s]}],"total":[%s]}`, valOperAddr, expectedAmountOutput, expectedAmountOutput)
+
+ delegatorRewardsTestCases := []RestTestCase{
+ {
+ "valid rewards request with valid delegator address",
+ fmt.Sprintf(delegatorRewardsURL, delAddr),
+ http.StatusOK,
+ rewardsOutput,
+ },
+ {
+ "valid request(specific validator rewards)",
+ fmt.Sprintf(delegatorRewardsURL+`/%s`, delAddr, valOperAddr),
+ http.StatusOK,
+ fmt.Sprintf(`{"rewards":[%s]}`, expectedAmountOutput),
+ },
+ }
+ TestRestQueryIgnoreNumbers(t, delegatorRewardsTestCases)
+
+ // test delegator validators grpc endpoint
+ delegatorValsURL := baseurl + `/cosmos/distribution/v1beta1/delegators/%s/validators`
+ valsTestCases := []RestTestCase{
+ {
+ "gRPC request delegator validators with valid delegator address",
+ fmt.Sprintf(delegatorValsURL, delAddr),
+ http.StatusOK,
+ fmt.Sprintf(`{"validators":["%s"]}`, valOperAddr),
+ },
+ }
+ RunRestQueries(t, valsTestCases)
+
+ // test withdraw address grpc endpoint
+ withdrawAddrURL := baseurl + `/cosmos/distribution/v1beta1/delegators/%s/withdraw_address`
+ withdrawAddrTestCases := []RestTestCase{
+ {
+ "gRPC request withdraw address with valid delegator address",
+ fmt.Sprintf(withdrawAddrURL, delAddr),
+ http.StatusOK,
+ fmt.Sprintf(`{"withdraw_address":"%s"}`, delAddr),
+ },
+ }
+ RunRestQueries(t, withdrawAddrTestCases)
+}
diff --git a/tests/systemtests/genesis_io.go b/tests/systemtests/genesis_io.go
index df2081ba0924..f3a61e54a2dd 100644
--- a/tests/systemtests/genesis_io.go
+++ b/tests/systemtests/genesis_io.go
@@ -33,6 +33,15 @@ func SetGovVotingPeriod(t *testing.T, period time.Duration) GenesisMutator {
}
}
+func SetGovExpeditedVotingPeriod(t *testing.T, period time.Duration) GenesisMutator {
+ t.Helper()
+ return func(genesis []byte) []byte {
+ state, err := sjson.SetRawBytes(genesis, "app_state.gov.params.expedited_voting_period", []byte(fmt.Sprintf("%q", period.String())))
+ require.NoError(t, err)
+ return state
+ }
+}
+
// GetGenesisBalance return the balance amount for an address from the given genesis json
func GetGenesisBalance(rawGenesis []byte, addr string) sdk.Coins {
var r []sdk.Coin
diff --git a/tests/systemtests/go.mod b/tests/systemtests/go.mod
index 6203d6d05d05..cc8b27c8bea0 100644
--- a/tests/systemtests/go.mod
+++ b/tests/systemtests/go.mod
@@ -13,7 +13,7 @@ require (
github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
@@ -146,16 +146,16 @@ require (
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/tests/systemtests/go.sum b/tests/systemtests/go.sum
index 746009230523..dab25bbfe8ae 100644
--- a/tests/systemtests/go.sum
+++ b/tests/systemtests/go.sum
@@ -601,8 +601,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -769,8 +769,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
@@ -887,20 +887,20 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -984,8 +984,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/tests/systemtests/gov_test.go b/tests/systemtests/gov_test.go
index 092773dc2053..b3270275b454 100644
--- a/tests/systemtests/gov_test.go
+++ b/tests/systemtests/gov_test.go
@@ -375,6 +375,13 @@ func TestQueryDeposit(t *testing.T) {
sut.ResetChain(t)
cli := NewCLIWrapper(t, sut, verbose)
+ // short voting period
+ // update expedited voting period to avoid validation error
+ sut.ModifyGenesisJSON(
+ t,
+ SetGovVotingPeriod(t, time.Second*8),
+ SetGovExpeditedVotingPeriod(t, time.Second*7),
+ )
// get validator address
valAddr := gjson.Get(cli.Keys("keys", "list"), "0.address").String()
diff --git a/tests/systemtests/rest_cli.go b/tests/systemtests/rest_cli.go
index 2ae879e1a242..3ad1e30dda68 100644
--- a/tests/systemtests/rest_cli.go
+++ b/tests/systemtests/rest_cli.go
@@ -3,9 +3,12 @@ package systemtests
import (
"io"
"net/http"
+ "regexp"
"testing"
"github.com/stretchr/testify/require"
+
+ "github.com/cosmos/cosmos-sdk/testutil"
)
type RestTestCase struct {
@@ -28,6 +31,34 @@ func RunRestQueries(t *testing.T, testCases []RestTestCase) {
}
}
+// TestRestQueryIgnoreNumbers runs given rest testcases by making requests and
+// checking response with expected output ignoring number values
+// This method is used when number values in response are non-deterministic
+func TestRestQueryIgnoreNumbers(t *testing.T, testCases []RestTestCase) {
+ t.Helper()
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ resp, err := testutil.GetRequest(tc.url)
+ require.NoError(t, err)
+
+ // regular expression pattern to match any numeric value in the JSON
+ numberRegexPattern := `"\d+(\.\d+)?"`
+
+ // compile the regex
+ r, err := regexp.Compile(numberRegexPattern)
+ require.NoError(t, err)
+
+ // replace all numeric values in the above JSONs with `NUMBER` text
+ expectedJSON := r.ReplaceAllString(tc.expOut, `"NUMBER"`)
+ actualJSON := r.ReplaceAllString(string(resp), `"NUMBER"`)
+
+ // compare two jsons
+ require.JSONEq(t, expectedJSON, actualJSON)
+ })
+ }
+}
+
func GetRequest(t *testing.T, url string) []byte {
t.Helper()
return GetRequestWithHeaders(t, url, nil, http.StatusOK)
@@ -48,9 +79,9 @@ func GetRequestWithHeaders(t *testing.T, url string, headers map[string]string,
defer func() {
_ = res.Body.Close()
}()
- require.Equal(t, expCode, res.StatusCode, "status code should be %d, got: %d", expCode, res.StatusCode)
-
body, err := io.ReadAll(res.Body)
require.NoError(t, err)
+ require.Equal(t, expCode, res.StatusCode, "status code should be %d, got: %d, %s", expCode, res.StatusCode, body)
+
return body
}
diff --git a/tests/systemtests/snapshots_test.go b/tests/systemtests/snapshots_test.go
index d80eb530f413..c4d6b257fc93 100644
--- a/tests/systemtests/snapshots_test.go
+++ b/tests/systemtests/snapshots_test.go
@@ -89,7 +89,7 @@ func TestPrune(t *testing.T) {
// prune
var command []string
if isV2() {
- command = []string{"store", "prune", "--keep-recent=1"}
+ command = []string{"store", "prune", "--store.keep-recent=1"}
} else {
command = []string{"prune", "everything"}
}
diff --git a/tests/systemtests/system.go b/tests/systemtests/system.go
index 7aa00f7cfbf3..adaa6da91d77 100644
--- a/tests/systemtests/system.go
+++ b/tests/systemtests/system.go
@@ -132,12 +132,7 @@ func (s *SystemUnderTest) SetupChain() {
genesisBz, err = sjson.SetRawBytes(genesisBz, "consensus.params.block.max_gas", []byte(fmt.Sprintf(`"%d"`, 10_000_000)))
if err != nil {
- panic(fmt.Sprintf("failed set block max gas: %s", err))
- }
- // Short period for gov
- genesisBz, err = sjson.SetRawBytes(genesisBz, "app_state.gov.params.voting_period", []byte(fmt.Sprintf(`"%s"`, "8s")))
- if err != nil {
- panic(fmt.Sprintf("failed set block max gas: %s", err))
+ panic(fmt.Sprintf("failed to set block max gas: %s", err))
}
s.withEachNodeHome(func(i int, home string) {
if err := saveGenesis(home, genesisBz); err != nil {
@@ -761,6 +756,11 @@ func (s *SystemUnderTest) CurrentHeight() int64 {
return s.currentHeight.Load()
}
+// NodesCount returns the number of node instances used
+func (s *SystemUnderTest) NodesCount() int {
+ return s.nodesCount
+}
+
type Node struct {
ID string
IP string
diff --git a/tests/systemtests/testnet_init.go b/tests/systemtests/testnet_init.go
index bdb2a85d25da..9033c283e43a 100644
--- a/tests/systemtests/testnet_init.go
+++ b/tests/systemtests/testnet_init.go
@@ -51,6 +51,20 @@ func NewSingleHostTestnetCmdInitializer(
}
}
+// InitializerWithBinary creates new SingleHostTestnetCmdInitializer from sut with given binary
+func InitializerWithBinary(binary string, sut *SystemUnderTest) TestnetInitializer {
+ return NewSingleHostTestnetCmdInitializer(
+ binary,
+ WorkDir,
+ sut.chainID,
+ sut.outputDir,
+ sut.initialNodesCount,
+ sut.minGasPrice,
+ sut.CommitTimeout(),
+ sut.Log,
+ )
+}
+
func (s SingleHostTestnetCmdInitializer) Initialize() {
args := []string{
"testnet",
diff --git a/tests/systemtests/upgrade_test.go b/tests/systemtests/upgrade_test.go
index bd719d1e7962..c7de9e6dfa99 100644
--- a/tests/systemtests/upgrade_test.go
+++ b/tests/systemtests/upgrade_test.go
@@ -17,25 +17,28 @@ import (
)
func TestChainUpgrade(t *testing.T) {
+ // err> panic: failed to load latest version: failed to load store: initial version set to 22, but found earlier version 1 [cosmossdk.io/store@v1.1.1/rootmulti/store.go:256]
+ t.Skip("Skipped until any v052 artifact is available AND main branch handles the store upgrade proper")
+
// Scenario:
// start a legacy chain with some state
// when a chain upgrade proposal is executed
// then the chain upgrades successfully
sut.StopChain()
- legacyBinary := FetchExecutable(t, "v0.50")
+ legacyBinary := FetchExecutable(t, "v0.52")
t.Logf("+++ legacy binary: %s\n", legacyBinary)
currentBranchBinary := sut.execBinary
currentInitializer := sut.testnetInitializer
sut.SetExecBinary(legacyBinary)
- sut.SetTestnetInitializer(NewModifyConfigYamlInitializer(legacyBinary, sut))
+ sut.SetTestnetInitializer(InitializerWithBinary(legacyBinary, sut))
sut.SetupChain()
votingPeriod := 5 * time.Second // enough time to vote
sut.ModifyGenesisJSON(t, SetGovVotingPeriod(t, votingPeriod))
const (
upgradeHeight int64 = 22
- upgradeName = "v050-to-v051"
+ upgradeName = "v052-to-v054" // must match UpgradeName in simapp/upgrades.go
)
sut.StartChain(t, fmt.Sprintf("--halt-height=%d", upgradeHeight+1))
diff --git a/testutil/x/counter/depinject.go b/testutil/x/counter/depinject.go
index b529d7f54297..3f05c7659f31 100644
--- a/testutil/x/counter/depinject.go
+++ b/testutil/x/counter/depinject.go
@@ -1,6 +1,10 @@
package counter
import (
+ "fmt"
+ "maps"
+ "slices"
+
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"cosmossdk.io/depinject/appconfig"
@@ -18,6 +22,7 @@ func init() {
appconfig.RegisterModule(
&types.Module{},
appconfig.Provide(ProvideModule),
+ appconfig.Invoke(InvokeSetHooks),
)
}
@@ -31,7 +36,7 @@ type ModuleInputs struct {
type ModuleOutputs struct {
depinject.Out
- Keeper keeper.Keeper
+ Keeper *keeper.Keeper
Module appmodule.AppModule
}
@@ -44,3 +49,27 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
Module: m,
}
}
+
+func InvokeSetHooks(keeper *keeper.Keeper, counterHooks map[string]types.CounterHooksWrapper) error {
+ if keeper == nil {
+ return fmt.Errorf("keeper is nil")
+ }
+ if counterHooks == nil {
+ return fmt.Errorf("counterHooks is nil")
+ }
+
+ // Default ordering is lexical by module name.
+ // Explicit ordering can be added to the module config if required.
+ modNames := slices.Sorted(maps.Keys(counterHooks))
+ var multiHooks types.MultiCounterHooks
+ for _, modName := range modNames {
+ hook, ok := counterHooks[modName]
+ if !ok {
+ return fmt.Errorf("can't find hooks for module %s", modName)
+ }
+ multiHooks = append(multiHooks, hook)
+ }
+
+ keeper.SetHooks(multiHooks)
+ return nil
+}
diff --git a/testutil/x/counter/keeper/hooks.go b/testutil/x/counter/keeper/hooks.go
new file mode 100644
index 000000000000..5b847bf95c6b
--- /dev/null
+++ b/testutil/x/counter/keeper/hooks.go
@@ -0,0 +1,14 @@
+package keeper
+
+import (
+ "context"
+)
+
+type Hooks struct {
+ AfterCounterIncreased bool
+}
+
+func (h *Hooks) AfterIncreaseCount(ctx context.Context, n int64) error {
+ h.AfterCounterIncreased = true
+ return nil
+}
diff --git a/testutil/x/counter/keeper/keeper.go b/testutil/x/counter/keeper/keeper.go
index e3389089dad8..8890f801fb47 100644
--- a/testutil/x/counter/keeper/keeper.go
+++ b/testutil/x/counter/keeper/keeper.go
@@ -21,11 +21,13 @@ type Keeper struct {
appmodule.Environment
CountStore collections.Item[int64]
+
+ hooks types.CounterHooks
}
-func NewKeeper(env appmodule.Environment) Keeper {
+func NewKeeper(env appmodule.Environment) *Keeper {
sb := collections.NewSchemaBuilder(env.KVStoreService)
- return Keeper{
+ return &Keeper{
Environment: env,
CountStore: collections.NewItem(sb, collections.NewPrefix(0), "count", collections.Int64Value),
}
@@ -67,6 +69,10 @@ func (k Keeper) IncreaseCount(ctx context.Context, msg *types.MsgIncreaseCounter
return nil, err
}
+ if err := k.Hooks().AfterIncreaseCount(ctx, num+msg.Count); err != nil {
+ return nil, err
+ }
+
if err := k.EventService.EventManager(ctx).EmitKV(
"increase_counter",
event.NewAttribute("signer", msg.Signer),
@@ -78,3 +84,23 @@ func (k Keeper) IncreaseCount(ctx context.Context, msg *types.MsgIncreaseCounter
NewCount: num + msg.Count,
}, nil
}
+
+// Hooks gets the hooks for counter Keeper
+func (k *Keeper) Hooks() types.CounterHooks {
+ if k.hooks == nil {
+ // return a no-op implementation if no hooks are set
+ return types.MultiCounterHooks{}
+ }
+
+ return k.hooks
+}
+
+// SetHooks sets the hooks for counter
+func (k *Keeper) SetHooks(gh types.CounterHooks) *Keeper {
+ if k.hooks != nil {
+ panic("cannot set governance hooks twice")
+ }
+
+ k.hooks = gh
+ return k
+}
diff --git a/testutil/x/counter/module.go b/testutil/x/counter/module.go
index 39f18857d8a5..455b6a6e8bc4 100644
--- a/testutil/x/counter/module.go
+++ b/testutil/x/counter/module.go
@@ -17,7 +17,7 @@ var (
// AppModule implements an application module
type AppModule struct {
- keeper keeper.Keeper
+ keeper *keeper.Keeper
}
// IsAppModule implements the appmodule.AppModule interface.
@@ -31,7 +31,7 @@ func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error {
}
// NewAppModule creates a new AppModule object
-func NewAppModule(keeper keeper.Keeper) AppModule {
+func NewAppModule(keeper *keeper.Keeper) AppModule {
return AppModule{
keeper: keeper,
}
diff --git a/testutil/x/counter/types/expected_keepers.go b/testutil/x/counter/types/expected_keepers.go
new file mode 100644
index 000000000000..d4bc4e5dc218
--- /dev/null
+++ b/testutil/x/counter/types/expected_keepers.go
@@ -0,0 +1,12 @@
+package types
+
+import "context"
+
+type CounterHooks interface {
+ AfterIncreaseCount(ctx context.Context, newCount int64) error
+}
+
+type CounterHooksWrapper struct{ CounterHooks }
+
+// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
+func (CounterHooksWrapper) IsOnePerModuleType() {}
diff --git a/testutil/x/counter/types/hooks.go b/testutil/x/counter/types/hooks.go
new file mode 100644
index 000000000000..5d5e475188c3
--- /dev/null
+++ b/testutil/x/counter/types/hooks.go
@@ -0,0 +1,26 @@
+package types
+
+import (
+ "context"
+ "errors"
+)
+
+var _ CounterHooks = MultiCounterHooks{}
+
+// MultiCounterHooks is a slice of hooks to be called in sequence.
+type MultiCounterHooks []CounterHooks
+
+// NewMultiCounterHooks returns a MultiCounterHooks from a list of CounterHooks
+func NewMultiCounterHooks(hooks ...CounterHooks) MultiCounterHooks {
+ return hooks
+}
+
+// AfterIncreaseCount calls AfterIncreaseCount on all hooks and collects the errors if any.
+func (ch MultiCounterHooks) AfterIncreaseCount(ctx context.Context, newCount int64) error {
+ var errs error
+ for i := range ch {
+ errs = errors.Join(errs, ch[i].AfterIncreaseCount(ctx, newCount))
+ }
+
+ return errs
+}
diff --git a/tools/confix/data/v2-app.toml b/tools/confix/data/v2-app.toml
index c4f19348ce52..8a35d32f543b 100644
--- a/tools/confix/data/v2-app.toml
+++ b/tools/confix/data/v2-app.toml
@@ -21,6 +21,14 @@ standalone = false
# max-txs defines the maximum number of transactions that can be in the mempool. A value of 0 indicates an unbounded mempool, a negative value disables the app-side mempool.
max-txs = -1
+# indexer defines the configuration for the SDK built-in indexer implementation.
+[comet.indexer]
+# Buffer size of the channels used for buffering data sent to indexer go routines.
+channel_buffer_size = 1024
+
+# Target is a map of named indexer targets to their configuration.
+[comet.indexer.target]
+
[grpc]
# Enable defines if the gRPC server should be enabled.
enable = true
@@ -42,7 +50,7 @@ minimum-gas-prices = '0stake'
app-db-backend = 'goleveldb'
[store.options]
-# SState storage database type. Currently we support: "sqlite", "pebble" and "rocksdb"
+# State storage database type. Currently we support: "sqlite", "pebble" and "rocksdb"
ss-type = 'sqlite'
# State commitment database type. Currently we support: "iavl" and "iavl-v2"
sc-type = 'iavl'
@@ -71,7 +79,7 @@ skip-fast-storage-upgrade = true
# Enable enables the application telemetry functionality. When enabled, an in-memory sink is also enabled by default. Operators may also enabled other sinks such as Prometheus.
enable = true
# Address defines the metrics server address to bind to.
-address = 'localhost:1338'
+address = 'localhost:1318'
# Prefixed with keys to separate services.
service-name = ''
# Enable prefixing gauge values with hostname.
diff --git a/tools/confix/go.mod b/tools/confix/go.mod
index e6800c66e46b..f537f956c81d 100644
--- a/tools/confix/go.mod
+++ b/tools/confix/go.mod
@@ -115,7 +115,7 @@ require (
github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -139,18 +139,18 @@ require (
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/grpc v1.67.1 // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
diff --git a/tools/confix/go.sum b/tools/confix/go.sum
index 32242dcba2a9..b3decd704e23 100644
--- a/tools/confix/go.sum
+++ b/tools/confix/go.sum
@@ -602,8 +602,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -763,8 +763,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
@@ -883,20 +883,20 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -981,8 +981,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/tools/cosmovisor/CHANGELOG.md b/tools/cosmovisor/CHANGELOG.md
index 3db3e4ea9954..3dd65d805595 100644
--- a/tools/cosmovisor/CHANGELOG.md
+++ b/tools/cosmovisor/CHANGELOG.md
@@ -38,10 +38,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features
+* [#21790](https://github.com/cosmos/cosmos-sdk/pull/21790) Add `add-batch-upgrade` command.
* [#21972](https://github.com/cosmos/cosmos-sdk/pull/21972) Add `prepare-upgrade` command
### Improvements
+* [#21891](https://github.com/cosmos/cosmos-sdk/pull/21891) create `current` symlink as relative
* [#21462](https://github.com/cosmos/cosmos-sdk/pull/21462) Pass `stdin` to binary.
### Features
diff --git a/tools/cosmovisor/args.go b/tools/cosmovisor/args.go
index 6c6b5b7b0572..733f561faf1a 100644
--- a/tools/cosmovisor/args.go
+++ b/tools/cosmovisor/args.go
@@ -111,16 +111,26 @@ func (cfg *Config) UpgradeInfoFilePath() string {
return filepath.Join(cfg.Home, "data", upgradetypes.UpgradeInfoFilename)
}
+// UpgradeInfoBatchFilePath is the same as UpgradeInfoFilePath but with a batch suffix.
+func (cfg *Config) UpgradeInfoBatchFilePath() string {
+ return cfg.UpgradeInfoFilePath() + ".batch"
+}
+
// SymLinkToGenesis creates a symbolic link from "./current" to the genesis directory.
func (cfg *Config) SymLinkToGenesis() (string, error) {
- genesis := filepath.Join(cfg.Root(), genesisDir)
- link := filepath.Join(cfg.Root(), currentLink)
+ // workdir is set to cosmovisor directory so relative
+ // symlinks are getting resolved correctly
+ if err := os.Symlink(genesisDir, currentLink); err != nil {
+ return "", err
+ }
- if err := os.Symlink(genesis, link); err != nil {
+ res, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ if err != nil {
return "", err
}
+
// and return the genesis binary
- return cfg.GenesisBin(), nil
+ return res, nil
}
// WaitRestartDelay will block and wait until the RestartDelay has elapsed.
@@ -134,27 +144,24 @@ func (cfg *Config) WaitRestartDelay() {
// This will resolve the symlink to the underlying directory to make it easier to debug
func (cfg *Config) CurrentBin() (string, error) {
cur := filepath.Join(cfg.Root(), currentLink)
+
// if nothing here, fallback to genesis
- info, err := os.Lstat(cur)
- if err != nil {
- // Create symlink to the genesis
- return cfg.SymLinkToGenesis()
- }
// if it is there, ensure it is a symlink
- if info.Mode()&os.ModeSymlink == 0 {
+ info, err := os.Lstat(cur)
+ if err != nil || (info.Mode()&os.ModeSymlink == 0) {
// Create symlink to the genesis
return cfg.SymLinkToGenesis()
}
- // resolve it
- dest, err := os.Readlink(cur)
+ res, err := filepath.EvalSymlinks(cur)
if err != nil {
// Create symlink to the genesis
return cfg.SymLinkToGenesis()
}
// and return the binary
- binpath := filepath.Join(dest, "bin", cfg.Name)
+ binpath := filepath.Join(res, "bin", cfg.Name)
+
return binpath, nil
}
@@ -385,24 +392,23 @@ func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) (rerr error) {
}
// set a symbolic link
- link := filepath.Join(cfg.Root(), currentLink)
safeName := url.PathEscape(u.Name)
- upgrade := filepath.Join(cfg.Root(), upgradesDir, safeName)
+ upgrade := filepath.Join(upgradesDir, safeName)
// remove link if it exists
- if _, err := os.Stat(link); err == nil {
- if err := os.Remove(link); err != nil {
+ if _, err := os.Stat(currentLink); err == nil {
+ if err := os.Remove(currentLink); err != nil {
return fmt.Errorf("failed to remove existing link: %w", err)
}
}
// point to the new directory
- if err := os.Symlink(upgrade, link); err != nil {
+ if err := os.Symlink(upgrade, currentLink); err != nil {
return fmt.Errorf("creating current symlink: %w", err)
}
cfg.currentUpgrade = u
- f, err := os.Create(filepath.Join(upgrade, upgradetypes.UpgradeInfoFilename))
+ f, err := os.Create(filepath.Join(cfg.Root(), upgrade, upgradetypes.UpgradeInfoFilename))
if err != nil {
return err
}
diff --git a/tools/cosmovisor/args_test.go b/tools/cosmovisor/args_test.go
index f121a3989d9f..12c28b8e7952 100644
--- a/tools/cosmovisor/args_test.go
+++ b/tools/cosmovisor/args_test.go
@@ -454,6 +454,7 @@ var newConfig = func(
skipBackup bool,
dataBackupPath string,
interval, preupgradeMaxRetries int,
+ grpcAddress string,
disableLogs, colorLogs bool,
timeFormatLogs string,
customPreUpgrade string,
@@ -470,6 +471,7 @@ var newConfig = func(
PollInterval: time.Millisecond * time.Duration(interval),
UnsafeSkipBackup: skipBackup,
DataBackupPath: dataBackupPath,
+ GRPCAddress: grpcAddress,
PreUpgradeMaxRetries: preupgradeMaxRetries,
DisableLogs: disableLogs,
ColorLogs: colorLogs,
@@ -518,7 +520,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "all good",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "false", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "true", "10s"},
- expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", true, 10000000000),
+ expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", true, 10000000000),
expectedErrCount: 0,
},
{
@@ -538,25 +540,25 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "download bin not set",
envVals: cosmovisorEnv{absPath, "testname", "", "true", "false", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, true, absPath, 303, 1, false, true, time.Kitchen, "", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "", false, 0),
expectedErrCount: 0,
},
{
name: "download bin true",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "false", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "download bin false",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "download ensure checksum true",
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "false", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, false, false, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, false, false, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -568,19 +570,19 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "restart upgrade not set",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, true, true, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, true, true, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "restart upgrade true",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "true", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, true, true, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, true, true, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "restart upgrade true",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "false", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -592,19 +594,19 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "skip unsafe backups not set",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "false", "600ms", "", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, true, false, 600, false, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, true, false, 600, false, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "skip unsafe backups true",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "false", "600ms", "true", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, true, false, 600, true, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "skip unsafe backups false",
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "false", "600ms", "false", "", "303ms", "1", "false", "true", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", true, true, false, 600, false, absPath, 303, 1, false, true, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", true, true, false, 600, false, absPath, 303, 1, "localhost:9090", false, true, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -622,7 +624,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "poll interval not set",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "", "1", "false", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 300, 1, false, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 300, 1, "localhost:9090", false, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -634,7 +636,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "poll interval 1s",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "1s", "1", "false", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 1000, 1, false, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 1000, 1, "localhost:9090", false, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -658,7 +660,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "restart delay not set",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "", "false", "", "303ms", "1", "false", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 0, false, absPath, 303, 1, false, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 0, false, absPath, 303, 1, "localhost:9090", false, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -670,7 +672,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "restart delay 1s",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "1s", "false", "", "303ms", "1", "false", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 1000, false, absPath, 303, 1, false, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 1000, false, absPath, 303, 1, "localhost:9090", false, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -688,19 +690,19 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "prepupgrade max retries 0",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "0", "false", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, false, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", false, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "prepupgrade max retries not set",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "", "false", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, false, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", false, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "prepupgrade max retries 5",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "5", "false", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 5, false, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 5, "localhost:9090", false, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -712,7 +714,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "disable logs good",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "", "true", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, true, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", true, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -724,19 +726,19 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "disable logs color good",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "", "true", "false", "kitchen", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, true, false, time.Kitchen, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", true, false, time.Kitchen, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "disable logs timestamp",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "", "true", "false", "", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, true, false, "", "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", true, false, "", "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
name: "enable rf3339 logs timestamp",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "", "true", "true", "rfc3339", "preupgrade.sh", "", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, true, true, time.RFC3339, "preupgrade.sh", false, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", true, true, time.RFC3339, "preupgrade.sh", false, 0),
expectedErrCount: 0,
},
{
@@ -748,7 +750,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "disable recase good",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "", "true", "true", "rfc3339", "preupgrade.sh", "true", ""},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, true, true, time.RFC3339, "preupgrade.sh", true, 0),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", true, true, time.RFC3339, "preupgrade.sh", true, 0),
expectedErrCount: 0,
},
{
@@ -759,7 +761,7 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
{
name: "shutdown grace good",
envVals: cosmovisorEnv{absPath, "testname", "false", "true", "false", "600ms", "false", "", "406ms", "", "true", "true", "rfc3339", "preupgrade.sh", "true", "15s"},
- expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, true, true, time.RFC3339, "preupgrade.sh", true, 15000000000),
+ expectedCfg: newConfig(absPath, "testname", false, true, false, 600, false, absPath, 406, 0, "localhost:9090", true, true, time.RFC3339, "preupgrade.sh", true, 15000000000),
expectedErrCount: 0,
},
}
@@ -794,7 +796,7 @@ func (s *argsTestSuite) setUpDir() string {
func (s *argsTestSuite) setupConfig(home string) string {
s.T().Helper()
- cfg := newConfig(home, "test", true, true, true, 406, false, home, 8, 0, false, true, "kitchen", "", true, 10000000000)
+ cfg := newConfig(home, "test", true, true, true, 406, false, home, 8, 0, "localhost:9090", false, true, "kitchen", "", true, 10000000000)
path := filepath.Join(home, rootName, "config.toml")
f, err := os.Create(path)
s.Require().NoError(err)
@@ -824,7 +826,7 @@ func (s *argsTestSuite) TestConfigFromFile() {
{
name: "valid config",
expectedCfg: func() *Config {
- return newConfig(home, "test", true, true, true, 406, false, home, 8, 0, false, true, time.Kitchen, "", true, 10000000000)
+ return newConfig(home, "test", true, true, true, 406, false, home, 8, 0, "localhost:9090", false, true, time.Kitchen, "", true, 10000000000)
},
filePath: cfgFilePath,
expectedError: "",
@@ -839,13 +841,13 @@ func (s *argsTestSuite) TestConfigFromFile() {
os.Setenv(EnvName, "env-name")
},
expectedCfg: func() *Config {
- return newConfig(home, "env-name", true, true, true, 406, false, home, 8, 0, false, true, time.Kitchen, "", true, 10000000000)
+ return newConfig(home, "env-name", true, true, true, 406, false, home, 8, 0, "localhost:9090", false, true, time.Kitchen, "", true, 10000000000)
},
},
{
name: "empty config file path will load config from ENV variables",
expectedCfg: func() *Config {
- return newConfig(home, "test", true, true, true, 406, false, home, 8, 0, false, true, time.Kitchen, "", true, 10000000000)
+ return newConfig(home, "test", true, true, true, 406, false, home, 8, 0, "localhost:9090", false, true, time.Kitchen, "", true, 10000000000)
},
filePath: "",
expectedError: "",
diff --git a/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go b/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go
index a197f33bc1dc..3832efa05e81 100644
--- a/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go
+++ b/tools/cosmovisor/cmd/cosmovisor/add_upgrade.go
@@ -19,7 +19,7 @@ func NewAddUpgradeCmd() *cobra.Command {
Short: "Add APP upgrade binary to cosmovisor",
SilenceUsage: true,
Args: cobra.ExactArgs(2),
- RunE: AddUpgrade,
+ RunE: addUpgradeCmd,
}
addUpgrade.Flags().Bool(cosmovisor.FlagForce, false, "overwrite existing upgrade binary / upgrade-info.json file")
@@ -28,26 +28,14 @@ func NewAddUpgradeCmd() *cobra.Command {
return addUpgrade
}
-// AddUpgrade adds upgrade info to manifest
-func AddUpgrade(cmd *cobra.Command, args []string) error {
- configPath, err := cmd.Flags().GetString(cosmovisor.FlagCosmovisorConfig)
- if err != nil {
- return fmt.Errorf("failed to get config flag: %w", err)
- }
-
- cfg, err := cosmovisor.GetConfigFromFile(configPath)
- if err != nil {
- return err
- }
-
+// addUpgrade adds upgrade info to manifest
+func addUpgrade(cfg *cosmovisor.Config, force bool, upgradeHeight int64, upgradeName, executablePath, upgradeInfoPath string) error {
logger := cfg.Logger(os.Stdout)
- upgradeName := args[0]
if !cfg.DisableRecase {
- upgradeName = strings.ToLower(args[0])
+ upgradeName = strings.ToLower(upgradeName)
}
- executablePath := args[1]
if _, err := os.Stat(executablePath); err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("invalid executable path: %w", err)
@@ -68,11 +56,6 @@ func AddUpgrade(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to read binary: %w", err)
}
- force, err := cmd.Flags().GetBool(cosmovisor.FlagForce)
- if err != nil {
- return fmt.Errorf("failed to get force flag: %w", err)
- }
-
if err := saveOrAbort(cfg.UpgradeBin(upgradeName), executableData, force); err != nil {
return err
}
@@ -80,9 +63,7 @@ func AddUpgrade(cmd *cobra.Command, args []string) error {
logger.Info(fmt.Sprintf("Using %s for %s upgrade", executablePath, upgradeName))
logger.Info(fmt.Sprintf("Upgrade binary located at %s", cfg.UpgradeBin(upgradeName)))
- if upgradeHeight, err := cmd.Flags().GetInt64(cosmovisor.FlagUpgradeHeight); err != nil {
- return fmt.Errorf("failed to get upgrade-height flag: %w", err)
- } else if upgradeHeight > 0 {
+ if upgradeHeight > 0 {
plan := upgradetypes.Plan{Name: upgradeName, Height: upgradeHeight}
if err := plan.ValidateBasic(); err != nil {
panic(fmt.Errorf("something is wrong with cosmovisor: %w", err))
@@ -94,16 +75,52 @@ func AddUpgrade(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to marshal upgrade plan: %w", err)
}
- if err := saveOrAbort(cfg.UpgradeInfoFilePath(), planData, force); err != nil {
+ if err := saveOrAbort(upgradeInfoPath, planData, force); err != nil {
return err
}
- logger.Info(fmt.Sprintf("%s created, %s upgrade binary will switch at height %d", cfg.UpgradeInfoFilePath(), upgradeName, upgradeHeight))
+ logger.Info(fmt.Sprintf("%s created, %s upgrade binary will switch at height %d", upgradeInfoPath, upgradeName, upgradeHeight))
}
return nil
}
+// GetConfig returns a Config using passed-in flag
+func getConfigFromCmd(cmd *cobra.Command) (*cosmovisor.Config, error) {
+ configPath, err := cmd.Flags().GetString(cosmovisor.FlagCosmovisorConfig)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get config flag: %w", err)
+ }
+
+ cfg, err := cosmovisor.GetConfigFromFile(configPath)
+ if err != nil {
+ return nil, err
+ }
+ return cfg, nil
+}
+
+// addUpgradeCmd parses input flags and adds upgrade info to manifest
+func addUpgradeCmd(cmd *cobra.Command, args []string) error {
+ cfg, err := getConfigFromCmd(cmd)
+ if err != nil {
+ return err
+ }
+
+ upgradeName, executablePath := args[0], args[1]
+
+ force, err := cmd.Flags().GetBool(cosmovisor.FlagForce)
+ if err != nil {
+ return fmt.Errorf("failed to get force flag: %w", err)
+ }
+
+ upgradeHeight, err := cmd.Flags().GetInt64(cosmovisor.FlagUpgradeHeight)
+ if err != nil {
+ return fmt.Errorf("failed to get upgrade-height flag: %w", err)
+ }
+
+ return addUpgrade(cfg, force, upgradeHeight, upgradeName, executablePath, cfg.UpgradeInfoFilePath())
+}
+
// saveOrAbort saves data to path or aborts if file exists and force is false
func saveOrAbort(path string, data []byte, force bool) error {
if _, err := os.Stat(path); err == nil {
diff --git a/tools/cosmovisor/cmd/cosmovisor/batch_upgrade.go b/tools/cosmovisor/cmd/cosmovisor/batch_upgrade.go
new file mode 100644
index 000000000000..a66f65b406ab
--- /dev/null
+++ b/tools/cosmovisor/cmd/cosmovisor/batch_upgrade.go
@@ -0,0 +1,143 @@
+package main
+
+import (
+ "encoding/csv"
+ "encoding/json"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+
+ "github.com/spf13/cobra"
+
+ "cosmossdk.io/tools/cosmovisor"
+)
+
+func NewBatchAddUpgradeCmd() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "add-batch-upgrade [flags]",
+ Short: "Add multiple upgrade binaries at specified heights to cosmovisor",
+ Long: `This command allows you to specify multiple upgrades at once at specific heights, copying or creating a batch upgrade file that's actively watched during 'cosmovisor run'.
+You can provide upgrades in two ways:
+
+1. Using --upgrade-file: Specify a path to a headerless CSV batch upgrade file in the format:
+ upgrade-name,path-to-exec,upgrade-height
+
+2. Using --upgrade-list: Provide a comma-separated list of upgrades.
+ Each upgrade is defined by three colon-separated values:
+ a. upgrade-name: A unique identifier for the upgrade
+ b. path-to-exec: The file path to the upgrade's executable binary
+ c. upgrade-height: The block height at which the upgrade should occur
+ This creates a batch upgrade JSON file with the upgrade-info objects in the upgrade directory.
+
+Note: You must provide either --upgrade-file or --upgrade-list.`,
+ Example: `cosmovisor add-batch-upgrade --upgrade-list upgrade_v2:/path/to/v2/binary:1000000,upgrade_v3:/path/to/v3/binary:2000000
+
+cosmovisor add-batch-upgrade --upgrade-file /path/to/batch_upgrade.csv`,
+ SilenceUsage: true,
+ Args: cobra.NoArgs,
+ RunE: addBatchUpgrade,
+ }
+
+ cmd.Flags().String("upgrade-file", "", "Path to a batch upgrade file which is a JSON array of upgrade-info objects")
+ cmd.Flags().StringSlice("upgrade-list", []string{}, "List of comma-separated upgrades in the format 'name:path/to/binary:height'")
+ cmd.MarkFlagsMutuallyExclusive("upgrade-file", "upgrade-list")
+
+ return cmd
+}
+
+// addBatchUpgrade takes in multiple specified upgrades and creates a single
+// batch upgrade file out of them
+func addBatchUpgrade(cmd *cobra.Command, args []string) error {
+ cfg, err := getConfigFromCmd(cmd)
+ if err != nil {
+ return err
+ }
+ upgradeFile, err := cmd.Flags().GetString("upgrade-file")
+ if err == nil && upgradeFile != "" {
+ return processUpgradeFile(cfg, upgradeFile)
+ }
+ upgradeList, err := cmd.Flags().GetStringSlice("upgrade-list")
+ if err != nil || len(upgradeList) == 0 {
+ return fmt.Errorf("either --upgrade-file or --upgrade-list must be provided")
+ }
+ var splitUpgrades [][]string
+ for _, upgrade := range upgradeList {
+ splitUpgrades = append(splitUpgrades, strings.Split(upgrade, ":"))
+ }
+ return processUpgradeList(cfg, splitUpgrades)
+}
+
+// processUpgradeList takes in a list of upgrades and creates a batch upgrade file
+func processUpgradeList(cfg *cosmovisor.Config, upgradeList [][]string) error {
+ upgradeInfoPaths := []string{}
+ for i, upgrade := range upgradeList {
+ if len(upgrade) != 3 {
+ return fmt.Errorf("argument at position %d (%s) is invalid", i, upgrade)
+ }
+ upgradeName := filepath.Base(upgrade[0])
+ upgradePath := upgrade[1]
+ upgradeHeight, err := strconv.ParseInt(upgrade[2], 10, 64)
+ if err != nil {
+ return fmt.Errorf("upgrade height at position %d (%s) is invalid", i, upgrade[2])
+ }
+ upgradeInfoPath := cfg.UpgradeInfoFilePath() + "." + upgradeName
+ upgradeInfoPaths = append(upgradeInfoPaths, upgradeInfoPath)
+ if err := addUpgrade(cfg, true, upgradeHeight, upgradeName, upgradePath, upgradeInfoPath); err != nil {
+ return err
+ }
+ }
+
+ var allData []json.RawMessage
+ for _, uip := range upgradeInfoPaths {
+ fileData, err := os.ReadFile(uip)
+ if err != nil {
+ return fmt.Errorf("error reading file %s: %w", uip, err)
+ }
+
+ // Verify it's valid JSON
+ var jsonData json.RawMessage
+ if err := json.Unmarshal(fileData, &jsonData); err != nil {
+ return fmt.Errorf("error parsing JSON from file %s: %w", uip, err)
+ }
+
+ // Add to our slice
+ allData = append(allData, jsonData)
+ }
+
+ // Marshal the combined data
+ batchData, err := json.MarshalIndent(allData, "", " ")
+ if err != nil {
+ return fmt.Errorf("error marshaling combined JSON: %w", err)
+ }
+
+ // Write to output file
+ err = os.WriteFile(cfg.UpgradeInfoBatchFilePath(), batchData, 0o600)
+ if err != nil {
+ return fmt.Errorf("error writing combined JSON to file: %w", err)
+ }
+
+ return nil
+}
+
+// processUpgradeFile takes in a CSV batch upgrade file, parses it and calls processUpgradeList
+func processUpgradeFile(cfg *cosmovisor.Config, upgradeFile string) error {
+ file, err := os.Open(upgradeFile)
+ if err != nil {
+ return fmt.Errorf("error opening upgrade CSV file %s: %w", upgradeFile, err)
+ }
+ defer file.Close()
+
+ r := csv.NewReader(file)
+ r.FieldsPerRecord = 3
+ r.TrimLeadingSpace = true
+ records, err := r.ReadAll()
+ if err != nil {
+ return fmt.Errorf("error parsing upgrade CSV file %s: %w", upgradeFile, err)
+ }
+ if err := processUpgradeList(cfg, records); err != nil {
+ return err
+ }
+ return nil
+}
diff --git a/tools/cosmovisor/cmd/cosmovisor/init.go b/tools/cosmovisor/cmd/cosmovisor/init.go
index 5f78e2845c02..90a35ca286fa 100644
--- a/tools/cosmovisor/cmd/cosmovisor/init.go
+++ b/tools/cosmovisor/cmd/cosmovisor/init.go
@@ -14,7 +14,7 @@ import (
"cosmossdk.io/x/upgrade/plan"
)
-func NewIntCmd() *cobra.Command {
+func NewInitCmd() *cobra.Command {
initCmd := &cobra.Command{
Use: "init ",
Short: "Initialize a cosmovisor daemon home directory.",
@@ -93,6 +93,12 @@ func InitializeCosmovisor(logger log.Logger, args []string) error {
return err
}
+ // set current working directory to $DAEMON_NAME/cosmosvisor
+ // to allow current symlink to be relative
+ if err = os.Chdir(cfg.Root()); err != nil {
+ return fmt.Errorf("failed to change directory to %s: %w", cfg.Root(), err)
+ }
+
logger.Info("checking on the current symlink and creating it if needed")
cur, curErr := cfg.CurrentBin()
if curErr != nil {
diff --git a/tools/cosmovisor/cmd/cosmovisor/init_test.go b/tools/cosmovisor/cmd/cosmovisor/init_test.go
index 97a082db729b..35a73348cc39 100644
--- a/tools/cosmovisor/cmd/cosmovisor/init_test.go
+++ b/tools/cosmovisor/cmd/cosmovisor/init_test.go
@@ -138,8 +138,8 @@ func (s *InitTestSuite) readStdInpFromFile(data []byte) {
}
var (
- _ io.Reader = BufferedPipe{}
- _ io.Writer = BufferedPipe{}
+ _ io.Reader = &BufferedPipe{}
+ _ io.Writer = &BufferedPipe{}
)
// BufferedPipe contains a connected read/write pair of files (a pipe),
@@ -167,8 +167,8 @@ type BufferedPipe struct {
// NewBufferedPipe creates a new BufferedPipe with the given name.
// Files must be closed once you are done with them (e.g. with .Close()).
// Once ready, buffering must be started using .Start(). See also StartNewBufferedPipe.
-func NewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error) {
- p := BufferedPipe{Name: name}
+func NewBufferedPipe(name string, replicateTo ...io.Writer) (*BufferedPipe, error) {
+ p := &BufferedPipe{Name: name}
p.Reader, p.Writer, p.Error = os.Pipe()
if p.Error != nil {
return p, p.Error
@@ -184,7 +184,7 @@ func NewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error
//
// p, _ := NewBufferedPipe(name, replicateTo...)
// p.Start()
-func StartNewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error) {
+func StartNewBufferedPipe(name string, replicateTo ...io.Writer) (*BufferedPipe, error) {
p, err := NewBufferedPipe(name, replicateTo...)
if err != nil {
return p, err
@@ -214,6 +214,7 @@ func (p *BufferedPipe) Start() {
if _, p.Error = io.Copy(&b, p.BufferReader); p.Error != nil {
b.WriteString("buffer error: " + p.Error.Error())
}
+
p.buffer <- b.Bytes()
}()
p.started = true
@@ -238,6 +239,7 @@ func (p *BufferedPipe) Collect() []byte {
panic("buffered pipe " + p.Name + " has not been started: cannot collect")
}
_ = p.Writer.Close()
+
if p.buffer == nil {
return []byte{}
}
@@ -247,12 +249,12 @@ func (p *BufferedPipe) Collect() []byte {
}
// Read implements the io.Reader interface on this BufferedPipe.
-func (p BufferedPipe) Read(bz []byte) (n int, err error) {
+func (p *BufferedPipe) Read(bz []byte) (n int, err error) {
return p.Reader.Read(bz)
}
// Write implements the io.Writer interface on this BufferedPipe.
-func (p BufferedPipe) Write(bz []byte) (n int, err error) {
+func (p *BufferedPipe) Write(bz []byte) (n int, err error) {
return p.Writer.Write(bz)
}
@@ -274,7 +276,7 @@ func (s *InitTestSuite) NewCapturingLogger() (*BufferedPipe, log.Logger) {
bufferedStdOut, err := StartNewBufferedPipe("stdout", os.Stdout)
s.Require().NoError(err, "creating stdout buffered pipe")
logger := log.NewLogger(bufferedStdOut, log.ColorOption(false), log.TimeFormatOption(time.RFC3339Nano)).With(log.ModuleKey, cosmovisorDirName)
- return &bufferedStdOut, logger
+ return bufferedStdOut, logger
}
// CreateHelloWorld creates a shell script that outputs HELLO WORLD.
@@ -443,15 +445,13 @@ func (s *InitTestSuite) TestInitializeCosmovisorInvalidExisting() {
rootDir := filepath.Join(env.Home, cosmovisorDirName)
require.NoError(t, os.MkdirAll(rootDir, 0o755))
curLn := filepath.Join(rootDir, "current")
- genDir := filepath.Join(rootDir, "genesis")
require.NoError(t, copyFile(hwExe, curLn))
- expErr := fmt.Sprintf("symlink %s %s: file exists", genDir, curLn)
s.setEnv(t, env)
buffer, logger := s.NewCapturingLogger()
logger.Info(fmt.Sprintf("Calling InitializeCosmovisor: %s", t.Name()))
err := InitializeCosmovisor(logger, []string{hwExe})
- require.EqualError(t, err, expErr, "calling InitializeCosmovisor")
+ require.EqualError(t, err, "symlink genesis current: file exists", "calling InitializeCosmovisor")
bufferBz := buffer.Collect()
bufferStr := string(bufferBz)
assert.Contains(t, bufferStr, "checking on the current symlink and creating it if needed")
@@ -484,37 +484,43 @@ func (s *InitTestSuite) TestInitializeCosmovisorValid() {
hwExe := s.CreateHelloWorld(0o755)
s.T().Run("starting with blank slate", func(t *testing.T) {
- testDir := s.T().TempDir()
- env := &cosmovisorInitEnv{
- Home: filepath.Join(testDir, "home"),
+ env := s.prepareConfig(s.T(), cosmovisorInitEnv{
Name: "blank",
- }
+ })
+
curLn := filepath.Join(env.Home, cosmovisorDirName, "current")
- genBinDir := filepath.Join(env.Home, cosmovisorDirName, "genesis", "bin")
- genBinExe := filepath.Join(genBinDir, env.Name)
+
+ s.setEnv(s.T(), env)
+ buffer, logger := s.NewCapturingLogger()
+ logger.Info(fmt.Sprintf("Calling InitializeCosmovisor: %s", t.Name()))
+ err := InitializeCosmovisor(logger, []string{hwNonExe})
+ require.NoError(t, err, "calling InitializeCosmovisor")
+
+ genDir := filepath.Join(env.Home, cosmovisorDirName, "genesis", "bin")
+ genBinExe := filepath.Join(genDir, env.Name)
+
+ genBinDirEval, err := filepath.EvalSymlinks(genDir)
+ require.NoError(t, err)
+
+ genBinEvalExe := filepath.Join(genBinDirEval, env.Name)
+
expInLog := []string{
"checking on the genesis/bin directory",
- fmt.Sprintf("creating directory (and any parents): %q", genBinDir),
+ fmt.Sprintf("creating directory (and any parents): %q", genDir),
"checking on the genesis/bin executable",
fmt.Sprintf("copying executable into place: %q", genBinExe),
fmt.Sprintf("making sure %q is executable", genBinExe),
"checking on the current symlink and creating it if needed",
- fmt.Sprintf("the current symlink points to: %q", genBinExe),
+ fmt.Sprintf("the current symlink points to: %q", genBinEvalExe),
fmt.Sprintf("cosmovisor config.toml created at: %s", filepath.Join(env.Home, cosmovisorDirName, cfgFileWithExt)),
}
- s.setEnv(s.T(), env)
- buffer, logger := s.NewCapturingLogger()
- logger.Info(fmt.Sprintf("Calling InitializeCosmovisor: %s", t.Name()))
- err := InitializeCosmovisor(logger, []string{hwNonExe})
- require.NoError(t, err, "calling InitializeCosmovisor")
-
- _, err = os.Stat(genBinDir)
- assert.NoErrorf(t, err, "statting the genesis bin dir: %q", genBinDir)
+ _, err = os.Stat(genBinDirEval)
+ assert.NoErrorf(t, err, "statting the genesis bin dir: %q", genBinDirEval)
_, err = os.Stat(curLn)
assert.NoError(t, err, "statting the current link: %q", curLn)
- exeInfo, exeErr := os.Stat(genBinExe)
- if assert.NoError(t, exeErr, "statting the executable: %q", genBinExe) {
+ exeInfo, exeErr := os.Stat(genBinEvalExe)
+ if assert.NoError(t, exeErr, "statting the executable: %q", genBinEvalExe) {
assert.True(t, exeInfo.Mode().IsRegular(), "executable is regular file")
// Check if the world-executable bit is set.
exePermMask := exeInfo.Mode().Perm() & 0o001
@@ -534,10 +540,18 @@ func (s *InitTestSuite) TestInitializeCosmovisorValid() {
Name: "nocur",
}
rootDir := filepath.Join(env.Home, cosmovisorDirName)
+
genBinDir := filepath.Join(rootDir, "genesis", "bin")
genBinDirExe := filepath.Join(genBinDir, env.Name)
+
require.NoError(t, os.MkdirAll(genBinDir, 0o755), "making genesis bin dir")
require.NoError(t, copyFile(hwExe, genBinDirExe), "copying executable to genesis")
+
+ genBinDirEval, err := filepath.EvalSymlinks(genBinDir)
+ require.NoError(t, err)
+
+ genBinEvalExe := filepath.Join(genBinDirEval, env.Name)
+
upgradesDir := filepath.Join(rootDir, "upgrades")
for i := 1; i <= 5; i++ {
upgradeBinDir := filepath.Join(upgradesDir, fmt.Sprintf("upgrade-%02d", i), "bin")
@@ -552,14 +566,14 @@ func (s *InitTestSuite) TestInitializeCosmovisorValid() {
"checking on the genesis/bin executable",
fmt.Sprintf("the %q file already exists", genBinDirExe),
fmt.Sprintf("making sure %q is executable", genBinDirExe),
- fmt.Sprintf("the current symlink points to: %q", genBinDirExe),
+ fmt.Sprintf("the current symlink points to: %q", genBinEvalExe),
fmt.Sprintf("cosmovisor config.toml created at: %s", filepath.Join(env.Home, cosmovisorDirName, cfgFileWithExt)),
}
s.setEnv(t, env)
buffer, logger := s.NewCapturingLogger()
logger.Info(fmt.Sprintf("Calling InitializeCosmovisor: %s", t.Name()))
- err := InitializeCosmovisor(logger, []string{hwExe})
+ err = InitializeCosmovisor(logger, []string{hwExe})
require.NoError(t, err, "calling InitializeCosmovisor")
bufferBz := buffer.Collect()
bufferStr := string(bufferBz)
@@ -579,21 +593,27 @@ func (s *InitTestSuite) TestInitializeCosmovisorValid() {
genBinExe := filepath.Join(genBinDir, env.Name)
require.NoError(t, os.MkdirAll(genBinDir, 0o755), "making genesis bin dir")
+ s.setEnv(t, env)
+ buffer, logger := s.NewCapturingLogger()
+ logger.Info(fmt.Sprintf("Calling InitializeCosmovisor: %s", t.Name()))
+ err := InitializeCosmovisor(logger, []string{hwExe})
+ require.NoError(t, err, "calling InitializeCosmovisor")
+
+ genBinDirEval, err := filepath.EvalSymlinks(genBinDir)
+ require.NoError(t, err)
+
+ genBinEvalExe := filepath.Join(genBinDirEval, env.Name)
+
expInLog := []string{
"checking on the genesis/bin directory",
fmt.Sprintf("the %q directory already exists", genBinDir),
"checking on the genesis/bin executable",
fmt.Sprintf("copying executable into place: %q", genBinExe),
fmt.Sprintf("making sure %q is executable", genBinExe),
- fmt.Sprintf("the current symlink points to: %q", genBinExe),
+ fmt.Sprintf("the current symlink points to: %q", genBinEvalExe),
fmt.Sprintf("cosmovisor config.toml created at: %s", filepath.Join(env.Home, cosmovisorDirName, cfgFileWithExt)),
}
- s.setEnv(t, env)
- buffer, logger := s.NewCapturingLogger()
- logger.Info(fmt.Sprintf("Calling InitializeCosmovisor: %s", t.Name()))
- err := InitializeCosmovisor(logger, []string{hwExe})
- require.NoError(t, err, "calling InitializeCosmovisor")
bufferBz := buffer.Collect()
bufferStr := string(bufferBz)
for _, exp := range expInLog {
@@ -693,7 +713,9 @@ func (s *InitTestSuite) TestInitializeCosmovisorWithOverrideCfg() {
// read the config file
cfgFile, err := os.Open(tc.cfg.DefaultCfgPath())
require.NoError(t, err)
- defer cfgFile.Close()
+ defer func() {
+ _ = cfgFile.Close()
+ }()
err = toml.NewDecoder(cfgFile).Decode(cfg)
require.NoError(t, err)
@@ -708,3 +730,14 @@ func (s *InitTestSuite) TestInitializeCosmovisorWithOverrideCfg() {
})
}
}
+
+func (s *InitTestSuite) prepareConfig(t *testing.T, config cosmovisorInitEnv) *cosmovisorInitEnv {
+ t.Helper()
+
+ config.Home = s.T().TempDir()
+
+ err := os.Chdir(config.Home)
+ require.NoError(t, err)
+
+ return &config
+}
diff --git a/tools/cosmovisor/cmd/cosmovisor/root.go b/tools/cosmovisor/cmd/cosmovisor/root.go
index 5cd31f8aea5b..92b1af2e11cf 100644
--- a/tools/cosmovisor/cmd/cosmovisor/root.go
+++ b/tools/cosmovisor/cmd/cosmovisor/root.go
@@ -14,12 +14,13 @@ func NewRootCmd() *cobra.Command {
}
rootCmd.AddCommand(
- NewIntCmd(),
+ NewInitCmd(),
runCmd,
configCmd,
NewVersionCmd(),
NewAddUpgradeCmd(),
NewShowUpgradeInfoCmd(),
+ NewBatchAddUpgradeCmd(),
NewPrepareUpgradeCmd(),
)
diff --git a/tools/cosmovisor/cmd/cosmovisor/run.go b/tools/cosmovisor/cmd/cosmovisor/run.go
index f835b59e5280..4da2ac24d846 100644
--- a/tools/cosmovisor/cmd/cosmovisor/run.go
+++ b/tools/cosmovisor/cmd/cosmovisor/run.go
@@ -2,6 +2,7 @@ package main
import (
"fmt"
+ "os"
"strings"
"github.com/spf13/cobra"
@@ -39,6 +40,12 @@ func run(cfgPath string, args []string, options ...RunOption) error {
opt(&runCfg)
}
+ // set current working directory to $DAEMON_NAME/cosmosvisor
+ // to allow current symlink to be relative
+ if err = os.Chdir(cfg.Root()); err != nil {
+ return err
+ }
+
logger := cfg.Logger(runCfg.StdOut)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
if err != nil {
diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod
index d4b7d5328069..7cde5f87512e 100644
--- a/tools/cosmovisor/go.mod
+++ b/tools/cosmovisor/go.mod
@@ -5,6 +5,8 @@ go 1.23
require (
cosmossdk.io/log v1.4.1
cosmossdk.io/x/upgrade v0.1.4
+ github.com/cosmos/cosmos-sdk v0.50.10
+ github.com/fsnotify/fsnotify v1.7.0
github.com/otiai10/copy v1.14.0
github.com/pelletier/go-toml/v2 v2.2.3
github.com/spf13/cobra v1.8.1
@@ -22,12 +24,12 @@ require (
cloud.google.com/go/storage v1.43.0 // indirect
cosmossdk.io/api v0.7.6 // indirect
cosmossdk.io/collections v0.4.0 // indirect
- cosmossdk.io/core v0.11.0 // indirect
+ cosmossdk.io/core v0.11.1 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
- cosmossdk.io/store v1.1.0 // indirect
- cosmossdk.io/x/tx v0.13.3 // indirect
+ cosmossdk.io/store v1.1.1 // indirect
+ cosmossdk.io/x/tx v0.13.5 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
@@ -38,20 +40,20 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.2.0 // indirect
- github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
+ github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
+ github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
- github.com/cockroachdb/pebble v1.1.0 // indirect
+ github.com/cockroachdb/pebble v1.1.1 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
- github.com/cometbft/cometbft v0.38.9 // indirect
+ github.com/cometbft/cometbft v0.38.12 // indirect
github.com/cometbft/cometbft-db v0.12.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
- github.com/cosmos/cosmos-sdk v0.50.7 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.7.0 // indirect
@@ -69,7 +71,6 @@ require (
github.com/emicklei/dot v1.6.2 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
- github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/getsentry/sentry-go v0.28.0 // indirect
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
@@ -92,7 +93,7 @@ require (
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
- github.com/gorilla/websocket v1.5.1 // indirect
+ github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
@@ -118,7 +119,6 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
- github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.9.3 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
@@ -133,13 +133,13 @@ require (
github.com/petermattis/goid v0.0.0-20240503122002-4b96552b8156 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
- github.com/rs/cors v1.11.0 // indirect
+ github.com/rs/cors v1.11.1 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
@@ -163,20 +163,20 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/api v0.192.0 // indirect
google.golang.org/genproto v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum
index 0fdc70f990e7..2e3f95e6f163 100644
--- a/tools/cosmovisor/go.sum
+++ b/tools/cosmovisor/go.sum
@@ -192,8 +192,8 @@ cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY=
cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
-cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo=
-cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w=
+cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA=
+cosmossdk.io/core v0.11.1/go.mod h1:OJzxcdC+RPrgGF8NJZR2uoQr56tc7gfBKhiKeDO7hH0=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
@@ -202,10 +202,10 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
-cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk=
-cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng=
-cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g=
-cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys=
+cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y=
+cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
+cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw=
+cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
cosmossdk.io/x/upgrade v0.1.4 h1:/BWJim24QHoXde8Bc64/2BSEB6W4eTydq0X/2f8+g38=
cosmossdk.io/x/upgrade v0.1.4/go.mod h1:9v0Aj+fs97O+Ztw+tG3/tp5JSlrmT7IcFhAebQHmOPo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
@@ -261,10 +261,10 @@ github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE5
github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c=
github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
-github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0=
-github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
-github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ=
-github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0=
+github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
+github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
+github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c=
+github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY=
@@ -303,17 +303,19 @@ github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaY
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I=
github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8=
+github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4=
+github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
-github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4=
-github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E=
+github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw=
+github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU=
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
-github.com/cometbft/cometbft v0.38.9 h1:cJBJBG0mPKz+sqelCi/hlfZjadZQGdDNnu6YQ1ZsUHQ=
-github.com/cometbft/cometbft v0.38.9/go.mod h1:xOoGZrtUT+A5izWfHSJgl0gYZUE7lu7Z2XIS1vWG/QQ=
+github.com/cometbft/cometbft v0.38.12 h1:OWsLZN2KcSSFe8bet9xCn07VwhBnavPea3VyPnNq1bg=
+github.com/cometbft/cometbft v0.38.12/go.mod h1:GPHp3/pehPqgX1930HmK1BpBLZPxB75v/dZg8Viwy+o=
github.com/cometbft/cometbft-db v0.12.0 h1:v77/z0VyfSU7k682IzZeZPFZrQAKiQwkqGN0QzAjMi0=
github.com/cometbft/cometbft-db v0.12.0/go.mod h1:aX2NbCrjNVd2ZajYxt1BsiFf/Z+TQ2MN0VxdicheYuw=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@@ -326,8 +328,8 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK
github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
-github.com/cosmos/cosmos-sdk v0.50.7 h1:LsBGKxifENR/DN4E1RZaitsyL93HU44x0p8EnMHp4V4=
-github.com/cosmos/cosmos-sdk v0.50.7/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s=
+github.com/cosmos/cosmos-sdk v0.50.10 h1:zXfeu/z653tWZARr/jESzAEiCUYjgJwwG4ytnYWMoDM=
+github.com/cosmos/cosmos-sdk v0.50.10/go.mod h1:6Eesrx3ZE7vxBZWpK++30H+Uc7Q4ahQWCL7JKU/LEdU=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
@@ -585,8 +587,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
-github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
+github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
+github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
@@ -706,8 +708,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
-github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
-github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/linxGnu/grocksdb v1.9.3 h1:s1cbPcOd0cU2SKXRG1nEqCOWYAELQjdqg3RVI2MH9ik=
@@ -838,8 +838,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -874,8 +874,8 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
-github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
-github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
+github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
+github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
@@ -1015,8 +1015,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1251,13 +1251,13 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1268,8 +1268,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1577,8 +1577,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/tools/cosmovisor/process.go b/tools/cosmovisor/process.go
index ac759bde39f4..4e9fad8be81f 100644
--- a/tools/cosmovisor/process.go
+++ b/tools/cosmovisor/process.go
@@ -1,6 +1,7 @@
package cosmovisor
import (
+ "context"
"encoding/json"
"errors"
"fmt"
@@ -9,16 +10,23 @@ import (
"os/exec"
"os/signal"
"path/filepath"
+ "sort"
"strconv"
"strings"
+ "sync"
"syscall"
"time"
+ "github.com/fsnotify/fsnotify"
"github.com/otiai10/copy"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
"cosmossdk.io/log"
"cosmossdk.io/x/upgrade/plan"
upgradetypes "cosmossdk.io/x/upgrade/types"
+
+ cmtservice "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
)
type Launcher struct {
@@ -36,6 +44,144 @@ func NewLauncher(logger log.Logger, cfg *Config) (Launcher, error) {
return Launcher{logger: logger, cfg: cfg, fw: fw}, nil
}
+// loadBatchUpgradeFile loads the batch upgrade file into memory, sorted by
+// their upgrade heights
+func loadBatchUpgradeFile(cfg *Config) ([]upgradetypes.Plan, error) {
+ var uInfos []upgradetypes.Plan
+ upgradeInfoFile, err := os.ReadFile(cfg.UpgradeInfoBatchFilePath())
+ if os.IsNotExist(err) {
+ return uInfos, nil
+ } else if err != nil {
+ return nil, fmt.Errorf("error while reading %s: %w", cfg.UpgradeInfoBatchFilePath(), err)
+ }
+
+ if err = json.Unmarshal(upgradeInfoFile, &uInfos); err != nil {
+ return nil, err
+ }
+ sort.Slice(uInfos, func(i, j int) bool {
+ return uInfos[i].Height < uInfos[j].Height
+ })
+ return uInfos, nil
+}
+
+// BatchUpgradeWatcher starts a watcher loop that swaps upgrade manifests at the correct
+// height, given the batch upgrade file. It watches the current state of the chain
+// via the websocket API.
+func BatchUpgradeWatcher(ctx context.Context, cfg *Config, logger log.Logger) {
+ // load batch file in memory
+ uInfos, err := loadBatchUpgradeFile(cfg)
+ if err != nil {
+ logger.Warn("failed to load batch upgrade file", "error", err)
+ uInfos = []upgradetypes.Plan{}
+ }
+
+ watcher, err := fsnotify.NewWatcher()
+ if err != nil {
+ logger.Warn("failed to init watcher", "error", err)
+ return
+ }
+ defer watcher.Close()
+ err = watcher.Add(filepath.Dir(cfg.UpgradeInfoBatchFilePath()))
+ if err != nil {
+ logger.Warn("watcher failed to add upgrade directory", "error", err)
+ return
+ }
+
+ var conn *grpc.ClientConn
+ var grpcErr error
+
+ defer func() {
+ if conn != nil {
+ if err := conn.Close(); err != nil {
+ logger.Warn("couldn't stop gRPC client", "error", err)
+ }
+ }
+ }()
+
+ // Wait for the chain process to be ready
+pollLoop:
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ default:
+ conn, grpcErr = grpc.NewClient(cfg.GRPCAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
+ if grpcErr == nil {
+ break pollLoop
+ }
+ time.Sleep(time.Second)
+ }
+ }
+
+ client := cmtservice.NewServiceClient(conn)
+
+ var prevUpgradeHeight int64 = -1
+
+ logger.Info("starting the batch watcher loop")
+ for {
+ select {
+ case event := <-watcher.Events:
+ if event.Op&(fsnotify.Write|fsnotify.Create) != 0 {
+ uInfos, err = loadBatchUpgradeFile(cfg)
+ if err != nil {
+ logger.Warn("failed to load batch upgrade file", "error", err)
+ continue
+ }
+ }
+ case <-ctx.Done():
+ return
+ default:
+ if len(uInfos) == 0 {
+ // prevent spending extra CPU cycles
+ time.Sleep(time.Second)
+ continue
+ }
+ resp, err := client.GetLatestBlock(ctx, &cmtservice.GetLatestBlockRequest{})
+ if err != nil {
+ logger.Warn("error getting latest block", "error", err)
+ time.Sleep(time.Second)
+ continue
+ }
+
+ h := resp.SdkBlock.Header.Height
+ upcomingUpgrade := uInfos[0].Height
+ // replace upgrade-info and upgrade-info batch file
+ if h > prevUpgradeHeight && h < upcomingUpgrade {
+ jsonBytes, err := json.Marshal(uInfos[0])
+ if err != nil {
+ logger.Warn("error marshaling JSON for upgrade-info.json", "error", err, "upgrade", uInfos[0])
+ continue
+ }
+ if err := os.WriteFile(cfg.UpgradeInfoFilePath(), jsonBytes, 0o600); err != nil {
+ logger.Warn("error writing upgrade-info.json", "error", err)
+ continue
+ }
+ uInfos = uInfos[1:]
+
+ jsonBytes, err = json.Marshal(uInfos)
+ if err != nil {
+ logger.Warn("error marshaling JSON for upgrade-info.json.batch", "error", err, "upgrades", uInfos)
+ continue
+ }
+ if err := os.WriteFile(cfg.UpgradeInfoBatchFilePath(), jsonBytes, 0o600); err != nil {
+ logger.Warn("error writing upgrade-info.json.batch", "error", err)
+ // remove the upgrade-info.json.batch file to avoid non-deterministic behavior
+ err := os.Remove(cfg.UpgradeInfoBatchFilePath())
+ if err != nil && !os.IsNotExist(err) {
+ logger.Warn("error removing upgrade-info.json.batch", "error", err)
+ return
+ }
+ continue
+ }
+ prevUpgradeHeight = upcomingUpgrade
+ }
+
+ // Add a small delay to avoid hammering the gRPC endpoint
+ time.Sleep(time.Second)
+ }
+ }
+}
+
// Run launches the app in a subprocess and returns when the subprocess (app)
// exits (either when it dies, or *after* a successful upgrade.) and upgrade finished.
// Returns true if the upgrade request was detected and the upgrade process started.
@@ -58,10 +204,20 @@ func (l Launcher) Run(args []string, stdin io.Reader, stdout, stderr io.Writer)
return false, fmt.Errorf("launching process %s %s failed: %w", bin, strings.Join(args, " "), err)
}
+ ctx, cancel := context.WithCancel(context.Background())
+ var wg sync.WaitGroup
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ BatchUpgradeWatcher(ctx, l.cfg, l.logger)
+ }()
+
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGQUIT, syscall.SIGTERM)
go func() {
sig := <-sigs
+ cancel()
+ wg.Wait()
if err := cmd.Process.Signal(sig); err != nil {
l.logger.Error("terminated", "error", err, "bin", bin)
os.Exit(1)
@@ -94,6 +250,9 @@ func (l Launcher) Run(args []string, stdin io.Reader, stdout, stderr io.Writer)
return true, nil
}
+ cancel()
+ wg.Wait()
+
return false, nil
}
diff --git a/tools/cosmovisor/process_test.go b/tools/cosmovisor/process_test.go
index 988bcf0a8074..26ef82900fe6 100644
--- a/tools/cosmovisor/process_test.go
+++ b/tools/cosmovisor/process_test.go
@@ -1,5 +1,4 @@
-//go:build linux
-// +build linux
+//go:build linux || darwin
package cosmovisor_test
@@ -20,12 +19,26 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"
)
+var workDir string
+
+func init() {
+ workDir, _ = os.Getwd()
+}
+
// TestLaunchProcess will try running the script a few times and watch upgrades work properly
// and args are passed through
func TestLaunchProcess(t *testing.T) {
// binaries from testdata/validate directory
- home := copyTestData(t, "validate")
- cfg := &cosmovisor.Config{Home: home, Name: "dummyd", PollInterval: 15, UnsafeSkipBackup: true}
+ cfg := prepareConfig(
+ t,
+ fmt.Sprintf("%s/%s", workDir, "testdata/validate"),
+ cosmovisor.Config{
+ Name: "dummyd",
+ PollInterval: 15,
+ UnsafeSkipBackup: true,
+ },
+ )
+
logger := log.NewTestLogger(t).With(log.ModuleKey, "cosmosvisor")
// should run the genesis binary and produce expected output
@@ -33,7 +46,11 @@ func TestLaunchProcess(t *testing.T) {
stdout, stderr := newBuffer(), newBuffer()
currentBin, err := cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.GenesisBin(), currentBin)
+
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ require.NoError(t, err)
+
+ require.Equal(t, rPath, currentBin)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
require.NoError(t, err)
@@ -51,7 +68,10 @@ func TestLaunchProcess(t *testing.T) {
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain2"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain2"))
+ require.NoError(t, err)
+
+ require.Equal(t, rPath, currentBin)
args = []string{"second", "run", "--verbose"}
stdout.Reset()
stderr.Reset()
@@ -63,14 +83,26 @@ func TestLaunchProcess(t *testing.T) {
require.Equal(t, "Chain 2 is live!\nArgs: second run --verbose\nFinished successfully\n", stdout.String())
// ended without other upgrade
- require.Equal(t, cfg.UpgradeBin("chain2"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain2"))
+ require.NoError(t, err)
+
+ require.Equal(t, rPath, currentBin)
}
// TestPlanDisableRecase will test upgrades without lower case plan names
func TestPlanDisableRecase(t *testing.T) {
// binaries from testdata/validate directory
- home := copyTestData(t, "norecase")
- cfg := &cosmovisor.Config{Home: home, Name: "dummyd", PollInterval: 20, UnsafeSkipBackup: true, DisableRecase: true}
+ cfg := prepareConfig(
+ t,
+ fmt.Sprintf("%s/%s", workDir, "testdata/norecase"),
+ cosmovisor.Config{
+ Name: "dummyd",
+ PollInterval: 20,
+ UnsafeSkipBackup: true,
+ DisableRecase: true,
+ },
+ )
+
logger := log.NewTestLogger(t).With(log.ModuleKey, "cosmosvisor")
// should run the genesis binary and produce expected output
@@ -78,7 +110,11 @@ func TestPlanDisableRecase(t *testing.T) {
stdout, stderr := newBuffer(), newBuffer()
currentBin, err := cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.GenesisBin(), currentBin)
+
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ require.NoError(t, err)
+
+ require.Equal(t, rPath, currentBin)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
require.NoError(t, err)
@@ -96,7 +132,9 @@ func TestPlanDisableRecase(t *testing.T) {
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("Chain2"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("Chain2"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
args = []string{"second", "run", "--verbose"}
stdout.Reset()
stderr.Reset()
@@ -108,13 +146,24 @@ func TestPlanDisableRecase(t *testing.T) {
require.Equal(t, "Chain 2 is live!\nArgs: second run --verbose\nFinished successfully\n", stdout.String())
// ended without other upgrade
- require.Equal(t, cfg.UpgradeBin("Chain2"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("Chain2"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
}
func TestLaunchProcessWithRestartDelay(t *testing.T) {
// binaries from testdata/validate directory
- home := copyTestData(t, "validate")
- cfg := &cosmovisor.Config{Home: home, Name: "dummyd", RestartDelay: 5 * time.Second, PollInterval: 20, UnsafeSkipBackup: true}
+ cfg := prepareConfig(
+ t,
+ fmt.Sprintf("%s/%s", workDir, "testdata/validate"),
+ cosmovisor.Config{
+ Name: "dummyd",
+ RestartDelay: 5 * time.Second,
+ PollInterval: 20,
+ UnsafeSkipBackup: true,
+ },
+ )
+
logger := log.NewTestLogger(t).With(log.ModuleKey, "cosmosvisor")
// should run the genesis binary and produce expected output
@@ -122,7 +171,10 @@ func TestLaunchProcessWithRestartDelay(t *testing.T) {
stdout, stderr := newBuffer(), newBuffer()
currentBin, err := cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.GenesisBin(), currentBin)
+
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
require.NoError(t, err)
@@ -144,8 +196,17 @@ func TestLaunchProcessWithRestartDelay(t *testing.T) {
// TestPlanShutdownGrace will test upgrades without lower case plan names
func TestPlanShutdownGrace(t *testing.T) {
// binaries from testdata/validate directory
- home := copyTestData(t, "dontdie")
- cfg := &cosmovisor.Config{Home: home, Name: "dummyd", PollInterval: 15, UnsafeSkipBackup: true, ShutdownGrace: 2 * time.Second}
+ cfg := prepareConfig(
+ t,
+ fmt.Sprintf("%s/%s", workDir, "testdata/dontdie"),
+ cosmovisor.Config{
+ Name: "dummyd",
+ PollInterval: 15,
+ UnsafeSkipBackup: true,
+ ShutdownGrace: 2 * time.Second,
+ },
+ )
+
logger := log.NewTestLogger(t).With(log.ModuleKey, "cosmosvisor")
// should run the genesis binary and produce expected output
@@ -153,7 +214,9 @@ func TestPlanShutdownGrace(t *testing.T) {
stdout, stderr := newBuffer(), newBuffer()
currentBin, err := cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.GenesisBin(), currentBin)
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
require.NoError(t, err)
@@ -171,7 +234,9 @@ func TestPlanShutdownGrace(t *testing.T) {
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain2"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain2"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
args = []string{"second", "run", "--verbose"}
stdout.Reset()
stderr.Reset()
@@ -183,7 +248,9 @@ func TestPlanShutdownGrace(t *testing.T) {
require.Equal(t, "Chain 2 is live!\nArgs: second run --verbose\nFinished successfully\n", stdout.String())
// ended without other upgrade
- require.Equal(t, cfg.UpgradeBin("chain2"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain2"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
}
// TestLaunchProcess will try running the script a few times and watch upgrades work properly
@@ -193,15 +260,26 @@ func TestLaunchProcessWithDownloads(t *testing.T) {
// genesis -> chain2-zip_bin
// chain2-zip_bin -> ref_to_chain3-zip_dir.json = (json for the next download instructions) -> chain3-zip_dir
// chain3-zip_dir - doesn't upgrade
- home := copyTestData(t, "download")
- cfg := &cosmovisor.Config{Home: home, Name: "autod", AllowDownloadBinaries: true, PollInterval: 100, UnsafeSkipBackup: true}
+ cfg := prepareConfig(
+ t,
+ fmt.Sprintf("%s/%s", workDir, "testdata/download"),
+ cosmovisor.Config{
+ Name: "autod",
+ AllowDownloadBinaries: true,
+ PollInterval: 100,
+ UnsafeSkipBackup: true,
+ },
+ )
+
logger := log.NewTestLogger(t).With(log.ModuleKey, "cosmovisor")
upgradeFilename := cfg.UpgradeInfoFilePath()
// should run the genesis binary and produce expected output
currentBin, err := cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.GenesisBin(), currentBin)
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
require.NoError(t, err)
@@ -216,7 +294,10 @@ func TestLaunchProcessWithDownloads(t *testing.T) {
require.Equal(t, "Genesis autod. Args: some args "+upgradeFilename+"\n"+`ERROR: UPGRADE "chain2" NEEDED at height: 49: zip_binary`+"\n", stdout.String())
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain2"), currentBin)
+
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain2"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
// start chain2
stdout.Reset()
@@ -231,7 +312,9 @@ func TestLaunchProcessWithDownloads(t *testing.T) {
require.True(t, doUpgrade)
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain3"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain3"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
// run the last chain
args = []string{"end", "--halt", upgradeFilename}
@@ -246,7 +329,9 @@ func TestLaunchProcessWithDownloads(t *testing.T) {
// and this doesn't upgrade
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain3"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain3"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
}
// TestLaunchProcessWithDownloadsAndMissingPreupgrade will try running the script a few times and watch upgrades work properly
@@ -256,22 +341,28 @@ func TestLaunchProcessWithDownloadsAndMissingPreupgrade(t *testing.T) {
// genesis -> chain2-zip_bin
// chain2-zip_bin -> ref_to_chain3-zip_dir.json = (json for the next download instructions) -> chain3-zip_dir
// chain3-zip_dir - doesn't upgrade
- home := copyTestData(t, "download")
- cfg := &cosmovisor.Config{
- Home: home,
- Name: "autod",
- AllowDownloadBinaries: true,
- PollInterval: 100,
- UnsafeSkipBackup: true,
- CustomPreUpgrade: "missing.sh",
- }
+ cfg := prepareConfig(
+ t,
+ fmt.Sprintf("%s/%s", workDir, "testdata/download"),
+ cosmovisor.Config{
+ Name: "autod",
+ AllowDownloadBinaries: true,
+ PollInterval: 100,
+ UnsafeSkipBackup: true,
+ CustomPreUpgrade: "missing.sh",
+ },
+ )
+
logger := log.NewTestLogger(t).With(log.ModuleKey, "cosmovisor")
upgradeFilename := cfg.UpgradeInfoFilePath()
// should run the genesis binary and produce expected output
currentBin, err := cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.GenesisBin(), currentBin)
+
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
require.NoError(t, err)
@@ -292,15 +383,18 @@ func TestLaunchProcessWithDownloadsAndPreupgrade(t *testing.T) {
// genesis -> chain2-zip_bin
// chain2-zip_bin -> ref_to_chain3-zip_dir.json = (json for the next download instructions) -> chain3-zip_dir
// chain3-zip_dir - doesn't upgrade
- home := copyTestData(t, "download")
- cfg := &cosmovisor.Config{
- Home: home,
- Name: "autod",
- AllowDownloadBinaries: true,
- PollInterval: 100,
- UnsafeSkipBackup: true,
- CustomPreUpgrade: "preupgrade.sh",
- }
+ cfg := prepareConfig(
+ t,
+ fmt.Sprintf("%s/%s", workDir, "testdata/download"),
+ cosmovisor.Config{
+ Name: "autod",
+ AllowDownloadBinaries: true,
+ PollInterval: 100,
+ UnsafeSkipBackup: true,
+ CustomPreUpgrade: "preupgrade.sh",
+ },
+ )
+
buf := newBuffer() // inspect output using buf.String()
logger := log.NewLogger(buf).With(log.ModuleKey, "cosmovisor")
upgradeFilename := cfg.UpgradeInfoFilePath()
@@ -308,7 +402,9 @@ func TestLaunchProcessWithDownloadsAndPreupgrade(t *testing.T) {
// should run the genesis binary and produce expected output
currentBin, err := cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.GenesisBin(), currentBin)
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
launcher, err := cosmovisor.NewLauncher(logger, cfg)
require.NoError(t, err)
@@ -323,10 +419,13 @@ func TestLaunchProcessWithDownloadsAndPreupgrade(t *testing.T) {
require.Equal(t, "Genesis autod. Args: some args "+upgradeFilename+"\n"+`ERROR: UPGRADE "chain2" NEEDED at height: 49: zip_binary`+"\n", stdout.String())
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain2"), currentBin)
+
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain2"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
// should have preupgrade.sh results
- require.FileExists(t, filepath.Join(home, "upgrade_name_chain2_height_49"))
+ require.FileExists(t, filepath.Join(cfg.Home, "upgrade_name_chain2_height_49"))
// start chain2
stdout.Reset()
@@ -341,10 +440,12 @@ func TestLaunchProcessWithDownloadsAndPreupgrade(t *testing.T) {
require.True(t, doUpgrade)
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain3"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain3"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
// should have preupgrade.sh results
- require.FileExists(t, filepath.Join(home, "upgrade_name_chain3_height_936"))
+ require.FileExists(t, filepath.Join(cfg.Home, "upgrade_name_chain3_height_936"))
// run the last chain
args = []string{"end", "--halt", upgradeFilename}
@@ -359,7 +460,9 @@ func TestLaunchProcessWithDownloadsAndPreupgrade(t *testing.T) {
// and this doesn't upgrade
currentBin, err = cfg.CurrentBin()
require.NoError(t, err)
- require.Equal(t, cfg.UpgradeBin("chain3"), currentBin)
+ rPath, err = filepath.EvalSymlinks(cfg.UpgradeBin("chain3"))
+ require.NoError(t, err)
+ require.Equal(t, rPath, currentBin)
}
// TestSkipUpgrade tests heights that are identified to be skipped and return if upgrade height matches the skip heights
diff --git a/tools/cosmovisor/upgrade_test.go b/tools/cosmovisor/upgrade_test.go
index 5c8d867e2ca6..be79a0170f2e 100644
--- a/tools/cosmovisor/upgrade_test.go
+++ b/tools/cosmovisor/upgrade_test.go
@@ -1,5 +1,4 @@
-//go:build linux
-// +build linux
+//go:build darwin || linux
package cosmovisor_test
@@ -7,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "slices"
"strings"
"testing"
@@ -28,13 +28,21 @@ func TestUpgradeTestSuite(t *testing.T) {
}
func (s *upgradeTestSuite) TestCurrentBin() {
- home := copyTestData(s.T(), "validate")
- cfg := cosmovisor.Config{Home: home, Name: "dummyd"}
+ cfg := prepareConfig(
+ s.T(),
+ fmt.Sprintf("%s/%s", workDir, "testdata/validate"),
+ cosmovisor.Config{
+ Name: "dummyd",
+ },
+ )
currentBin, err := cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(cfg.GenesisBin(), currentBin)
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ s.Require().NoError(err)
+
+ s.Require().Equal(rPath, currentBin)
// ensure we cannot set this to an invalid value
for _, name := range []string{"missing", "nobin"} {
@@ -43,7 +51,10 @@ func (s *upgradeTestSuite) TestCurrentBin() {
currentBin, err := cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(cfg.GenesisBin(), currentBin, name)
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ s.Require().NoError(err)
+
+ s.Require().Equal(rPath, currentBin, name)
}
// try a few times to make sure this can be reproduced
@@ -55,29 +66,46 @@ func (s *upgradeTestSuite) TestCurrentBin() {
currentBin, err := cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(cfg.UpgradeBin(name), currentBin)
+ rPath, err := filepath.EvalSymlinks(cfg.UpgradeBin(name))
+ s.Require().NoError(err)
+
+ s.Require().Equal(rPath, currentBin)
}
}
func (s *upgradeTestSuite) TestCurrentAlwaysSymlinkToDirectory() {
- home := copyTestData(s.T(), "validate")
- cfg := cosmovisor.Config{Home: home, Name: "dummyd"}
+ cfg := prepareConfig(
+ s.T(),
+ fmt.Sprintf("%s/%s", workDir, "testdata/validate"),
+ cosmovisor.Config{
+ Name: "dummyd",
+ },
+ )
currentBin, err := cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(cfg.GenesisBin(), currentBin)
+
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ s.Require().NoError(err)
+
+ s.Require().Equal(rPath, currentBin)
s.assertCurrentLink(cfg, "genesis")
err = cfg.SetCurrentUpgrade(upgradetypes.Plan{Name: "chain2"})
s.Require().NoError(err)
currentBin, err = cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(cfg.UpgradeBin("chain2"), currentBin)
+
+ eval, err := filepath.EvalSymlinks(cfg.UpgradeBin("chain2"))
+ s.Require().NoError(err)
+
+ s.Require().Equal(eval, currentBin)
s.assertCurrentLink(cfg, filepath.Join("upgrades", "chain2"))
}
-func (s *upgradeTestSuite) assertCurrentLink(cfg cosmovisor.Config, target string) {
+func (s *upgradeTestSuite) assertCurrentLink(cfg *cosmovisor.Config, target string) {
link := filepath.Join(cfg.Root(), "current")
+
// ensure this is a symlink
info, err := os.Lstat(link)
s.Require().NoError(err)
@@ -85,20 +113,29 @@ func (s *upgradeTestSuite) assertCurrentLink(cfg cosmovisor.Config, target strin
dest, err := os.Readlink(link)
s.Require().NoError(err)
- expected := filepath.Join(cfg.Root(), target)
- s.Require().Equal(expected, dest)
+ s.Require().Equal(target, dest)
}
// TODO: test with download (and test all download functions)
func (s *upgradeTestSuite) TestUpgradeBinaryNoDownloadUrl() {
- home := copyTestData(s.T(), "validate")
- cfg := &cosmovisor.Config{Home: home, Name: "dummyd", AllowDownloadBinaries: true}
+ cfg := prepareConfig(
+ s.T(),
+ fmt.Sprintf("%s/%s", workDir, "testdata/validate"),
+ cosmovisor.Config{
+ Name: "dummyd",
+ AllowDownloadBinaries: true,
+ },
+ )
+
logger := log.NewLogger(os.Stdout).With(log.ModuleKey, "cosmovisor")
currentBin, err := cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(cfg.GenesisBin(), currentBin)
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ s.Require().NoError(err)
+
+ s.Require().Equal(rPath, currentBin)
// do upgrade ignores bad files
for _, name := range []string{"missing", "nobin"} {
@@ -107,7 +144,11 @@ func (s *upgradeTestSuite) TestUpgradeBinaryNoDownloadUrl() {
s.Require().Error(err, name)
currentBin, err := cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(cfg.GenesisBin(), currentBin, name)
+
+ rPath, err := filepath.EvalSymlinks(cfg.GenesisBin())
+ s.Require().NoError(err)
+
+ s.Require().Equal(rPath, currentBin, name)
}
// make sure it updates a few times
@@ -121,7 +162,10 @@ func (s *upgradeTestSuite) TestUpgradeBinaryNoDownloadUrl() {
currentBin, err := cfg.CurrentBin()
s.Require().NoError(err)
- s.Require().Equal(upgradeBin, currentBin)
+ rPath, err := filepath.EvalSymlinks(upgradeBin)
+ s.Require().NoError(err)
+
+ s.Require().Equal(rPath, currentBin)
}
}
@@ -135,26 +179,25 @@ func (s *upgradeTestSuite) TestUpgradeBinary() {
}{
"get raw binary with checksum": {
// sha256sum ./testdata/repo/raw_binary/autod
- url: "./testdata/repo/raw_binary/autod?checksum=sha256:e6bc7851600a2a9917f7bf88eb7bdee1ec162c671101485690b4deb089077b0d",
+ url: workDir + "/testdata/repo/raw_binary/autod?checksum=sha256:e6bc7851600a2a9917f7bf88eb7bdee1ec162c671101485690b4deb089077b0d",
canDownload: true,
validBinary: true,
},
"get raw binary with invalid checksum": {
- url: "./testdata/repo/raw_binary/autod?checksum=sha256:73e2bd6cbb99261733caf137015d5cc58e3f96248d8b01da68be8564989dd906",
+ url: workDir + "/testdata/repo/raw_binary/autod?checksum=sha256:73e2bd6cbb99261733caf137015d5cc58e3f96248d8b01da68be8564989dd906",
canDownload: false,
},
"get zipped directory with valid checksum": {
- // sha256sum ./testdata/repo/chain3-zip_dir/autod.zip
- url: "./testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:8951f52a0aea8617de0ae459a20daf704c29d259c425e60d520e363df0f166b4",
+ url: workDir + "/testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:8951f52a0aea8617de0ae459a20daf704c29d259c425e60d520e363df0f166b4",
canDownload: true,
validBinary: true,
},
"get zipped directory with invalid checksum": {
- url: "./testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:73e2bd6cbb99261733caf137015d5cc58e3f96248d8b01da68be8564989dd906",
+ url: workDir + "/testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:73e2bd6cbb99261733caf137015d5cc58e3f96248d8b01da68be8564989dd906",
canDownload: false,
},
"invalid url": {
- url: "./testdata/repo/bad_dir/autod?checksum=sha256:73e2bd6cbb99261733caf137015d5cc58e3f96248d8b01da68be8564989dd906",
+ url: workDir + "/testdata/repo/bad_dir/autod?checksum=sha256:73e2bd6cbb99261733caf137015d5cc58e3f96248d8b01da68be8564989dd906",
canDownload: false,
},
"valid remote": {
@@ -167,14 +210,14 @@ func (s *upgradeTestSuite) TestUpgradeBinary() {
for label, tc := range cases {
s.Run(label, func() {
var err error
- // make temp dir
- home := copyTestData(s.T(), "download")
-
- cfg := &cosmovisor.Config{
- Home: home,
- Name: "autod",
- AllowDownloadBinaries: true,
- }
+ cfg := prepareConfig(
+ s.T(),
+ fmt.Sprintf("%s/%s", workDir, "testdata/download"),
+ cosmovisor.Config{
+ Name: "autod",
+ AllowDownloadBinaries: true,
+ },
+ )
url := tc.url
if strings.HasPrefix(url, "./") {
@@ -198,17 +241,37 @@ func (s *upgradeTestSuite) TestUpgradeBinary() {
}
func (s *upgradeTestSuite) TestOsArch() {
- // all download tests will fail if we are not on linux...
- s.Require().Equal("linux/amd64", cosmovisor.OSArch())
+ // all download tests will fail if we are not on linux or darwin...
+ hosts := []string{
+ "linux/arm64",
+ "linux/amd64",
+ "darwin/amd64",
+ "darwin/arm64",
+ }
+
+ s.Require().True(slices.Contains(hosts, cosmovisor.OSArch()))
}
// copyTestData will make a tempdir and then
// "cp -r" a subdirectory under testdata there
// returns the directory (which can now be used as Config.Home) and modified safely
-func copyTestData(t *testing.T, subdir string) string {
+func copyTestData(t *testing.T, testData string) string {
t.Helper()
tmpdir := t.TempDir()
- require.NoError(t, copy.Copy(filepath.Join("testdata", subdir), tmpdir))
+ require.NoError(t, copy.Copy(testData, tmpdir))
return tmpdir
}
+
+func prepareConfig(t *testing.T, testData string, config cosmovisor.Config) *cosmovisor.Config {
+ t.Helper()
+
+ tmpdir := copyTestData(t, testData)
+
+ config.Home = tmpdir
+
+ err := os.Chdir(config.Root())
+ require.NoError(t, err)
+
+ return &config
+}
diff --git a/tools/hubl/go.mod b/tools/hubl/go.mod
index 2c59b55e2b52..2247020a8d30 100644
--- a/tools/hubl/go.mod
+++ b/tools/hubl/go.mod
@@ -12,7 +12,7 @@ require (
github.com/pelletier/go-toml/v2 v2.2.3
github.com/spf13/cobra v1.8.1
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
@@ -115,7 +115,7 @@ require (
github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -140,13 +140,13 @@ require (
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/tools/hubl/go.sum b/tools/hubl/go.sum
index f91c80296998..3c80625ba480 100644
--- a/tools/hubl/go.sum
+++ b/tools/hubl/go.sum
@@ -602,8 +602,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -762,8 +762,8 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
@@ -880,20 +880,20 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -977,8 +977,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/tools/hubl/internal/registry.go b/tools/hubl/internal/registry.go
index a3eea12391e4..945e0ff4296c 100644
--- a/tools/hubl/internal/registry.go
+++ b/tools/hubl/internal/registry.go
@@ -26,12 +26,15 @@ func GetChainRegistryEntry(chain string) (*ChainRegistryEntry, error) {
if err != nil {
return nil, err
}
-
bz, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
+ if err = res.Body.Close(); err != nil {
+ return nil, err
+ }
+
data := &ChainRegistryEntry{}
if err = json.Unmarshal(bz, data); err != nil {
return nil, err
diff --git a/types/genesis.go b/types/genesis.go
deleted file mode 100644
index f250ac600014..000000000000
--- a/types/genesis.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package types
-
-import cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
-
-type GenesisValidator struct {
- Address ConsAddress
- PubKey cryptotypes.PubKey
- Power int64
- Name string
-}
diff --git a/types/staking.go b/types/staking.go
index f8cdb325038c..b33e32ae9d04 100644
--- a/types/staking.go
+++ b/types/staking.go
@@ -3,6 +3,7 @@ package types
import (
"cosmossdk.io/math"
+ cryptokeys "github.com/cosmos/cosmos-sdk/crypto/keys"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)
@@ -98,3 +99,11 @@ type ValidatorI interface {
SharesFromTokens(amt math.Int) (math.LegacyDec, error) // shares worth of delegator's bond
SharesFromTokensTruncated(amt math.Int) (math.LegacyDec, error) // truncated shares worth of delegator's bond
}
+
+// GenesisValidator is an initial validator.
+type GenesisValidator struct {
+ Address ConsAddress `json:"address"`
+ PubKey cryptokeys.JSONPubkey `json:"pub_key"`
+ Power int64 `json:"power"`
+ Name string `json:"name"`
+}
diff --git a/x/accounts/README.md b/x/accounts/README.md
index 6be5a541eaeb..a7490a9fcc65 100644
--- a/x/accounts/README.md
+++ b/x/accounts/README.md
@@ -1,8 +1,356 @@
-# x/accounts Module
+# x/accounts
The x/accounts module enhances the Cosmos SDK by providing tools and infrastructure for creating advanced smart accounts.
-# The Authentication Interface
+## Basics
+
+An account can be thought of as a simplified cosmos-sdk module that supports multiple deployments. This means:
+
+1. A single account implementation can be deployed to multiple addresses, similar to how CosmWasm allows multiple contract instances from one WASM upload.
+
+2. Each account address is mapped to its corresponding account code.
+
+3. Accounts maintain their own state partition, similar to modules.
+
+4. Accounts can define both message and query handlers.
+
+This design allows for flexible and reusable account structures within the ecosystem.
+
+### Example account creation
+
+#### Basic
+
+Defining an account begins with creating a struct that encapsulates the account's state. If the account has no state, the
+struct is empty `type Account struct{}`.
+
+By default, accounts utilize collections to manage their state.
+
+##### State Isolation
+
+It's crucial to understand that an account's state is isolated. This means:
+
+1. States are not shared between accounts of different types.
+2. States are not shared even between accounts of the same type.
+
+For example, consider two accounts of type Counter:
+
+- One located at address "cosmos123"
+- Another at address "cosmos456"
+
+These accounts do not share the same collections.Item instance. Instead, each maintains its own separate state.
+
+```go
+type Account struct {
+ // We will define that the account contains in its state a counter, it's an item.
+ // It could also be a map or whatever!
+ Counter collections.Item[uint64]
+}
+```
+
+#### Init
+
+Creating an account begins with defining its init message. This message is processed when an account is created, similar to:
+
+- The `instantiate` method in a CosmWasm contract
+- The `constructor` in an EVM contract
+
+For an account to be a valid `x/account` implementer, it must define both:
+
+1. An `Init` method
+2. An init message
+
+We start by defining the `MsgInit` and its corresponding `MsgInitResponse` as protobuf messages:
+
+```protobuf
+message MsgInit {
+ uint64 counter = 1;
+}
+
+message MsgInitResponse {}
+```
+
+Next, we implement the Init method, which sets the initial counter. We also implement a method of the `Account` interface. This method:
+
+Signals to the x/accounts runtime what the Init entrypoint is
+Performs some generic operations to maintain type safety in the system
+
+Here's the Go implementation:
+
+```go
+package counter
+
+import (
+ "context"
+ "cosmossdk.io/x/accounts/accountstd"
+)
+
+type Account struct {
+ Counter collections.Item[uint64]
+}
+
+func (a Account) Init(ctx context.Context, msg *MsgInit) (*MsgInitResponse, error) {
+ err := a.Counter.Set(ctx, msg.Counter)
+ if err != nil {
+ return nil, err
+ }
+
+ return &MsgInitResponse{}, nil
+}
+
+func (a Account) RegisterInitHandler(builder *accountstd.InitBuilder) {
+ accountstd.RegisterInitHandler(builder, a.Init)
+}
+```
+
+#### Execute Handlers
+
+Execute handlers are methods that an account can execute, defined as messages. These executions can be triggered:
+
+- During block execution (not queries) through transactions
+- During begin or end block
+
+To define an execute handler, we start by creating its proto message:
+
+```protobuf
+message MsgIncreaseCounter {
+ uint64 amount = 1;
+}
+
+message MsgIncreaseCounterResponse {
+ uint64 new_value = 1;
+}
+```
+
+Next, we implement the handling code for this message and register it using the `RegisterExecuteHandlers` method:
+
+```go
+package counter
+
+import (
+ "context"
+ "cosmossdk.io/x/accounts/accountstd"
+)
+
+type Account struct {
+ Counter collections.Item[uint64]
+}
+
+func (a Account) Init(ctx context.Context, msg *MsgInit) (*MsgInitResponse, error) {
+ err := a.Counter.Set(ctx, msg.Counter)
+ if err != nil {
+ return nil, err
+ }
+ return &MsgInitResponse{}, nil
+}
+
+// Handler for MsgIncreaseCounter
+func (a Account) IncreaseCounter(ctx context.Context, msg *MsgIncreaseCounter) (*MsgIncreaseCounterResponse, error) {
+ counter, err := a.Counter.Get(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ newValue := counter + msg.Amount
+ err = a.Counter.Set(ctx, newValue)
+ if err != nil {
+ return nil, err
+ }
+
+ return &MsgIncreaseCounterResponse{NewValue: newValue}, nil
+}
+
+// Registration of the handler in the runtime
+func (a Account) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) {
+ accountstd.RegisterExecuteHandler(builder, a.IncreaseCounter)
+}
+
+func (a Account) RegisterInitHandler(builder *accountstd.InitBuilder) {
+ accountstd.RegisterInitHandler(builder, a.Init)
+}
+```
+
+This implementation defines an IncreaseCounter method that handles the MsgIncreaseCounter message, updating the counter
+value and returning the new value in the response.
+
+#### Query Handlers
+
+Query Handlers are read-only methods implemented by an account to expose information about itself. This information can be accessed by:
+
+- External clients (e.g., CLI, wallets)
+- Other modules and accounts within the system
+
+Query handlers can be invoked:
+
+1. By external clients
+2. During block execution
+
+To define a query handler, we follow a similar process to execute handlers:
+
+1. Define the request and response proto messages:
+
+```protobuf
+message QueryCounter {}
+
+message QueryCounterResponse {
+ uint64 value = 1;
+}
+```
+
+2. Implement and register the query handler:
+
+```go
+package counter
+
+import (
+ "context"
+ "cosmossdk.io/x/accounts/accountstd"
+)
+
+func (a Account) QueryCounter(ctx context.Context, _ *QueryCounterRequest) (*QueryCounterResponse, error) {
+ counter, err := a.Counter.Get(ctx)
+ if err != nil {
+ return nil, err
+ }
+ return &QueryCounterResponse{
+ Value: counter,
+ }, nil
+}
+
+func (a Account) RegisterQueryHandlers(builder *accountstd.QueryBuilder) {
+ accountstd.RegisterQueryHandler(builder, a.QueryCounter)
+}
+```
+
+This implementation defines a `QueryCounter` method that retrieves the current counter value and returns it in the response.
+The `RegisterQueryHandlers` method registers this query handler with the system.
+
+#### The Account Constructor
+
+After creating our basic counter account, we implement the account constructor function:
+
+```go
+package counter
+
+import (
+ "cosmossdk.io/collections"
+ "cosmossdk.io/x/accounts/accountstd"
+)
+
+func NewAccount(deps accountstd.Dependencies) (Account, error) {
+ return Account{
+ Counter: collections.NewItem(deps.SchemaBuilder, CounterPrefix, "counter", collections.Uint64Value),
+ }, nil
+}
+
+type Account struct {
+ Counter collections.Item[uint64]
+}
+
+// Rest of the Account implementation...
+```
+
+The `accountstd.Dependencies` type provides an environment with essential components:
+
+1. `AddressCodec`: For encoding and decoding addresses
+2. `SchemaBuilder`: For schema construction (handled by the accounts module)
+3. `HeaderService`: For accessing block header information
+4. Other useful services and utilities
+
+These dependencies allow the account to interact with the blockchain system.
+
+## App Wiring
+
+Note: This assumes you've already wired the `x/accounts` module in your application. If not, refer to the Simapp example.
+
+After creating our basic account, we wire it to the `x/accounts` module.
+
+### Depinject Method
+
+Define the depinject constructor:
+
+```go
+package counterdepinject
+
+func ProvideAccount() accountstd.DepinjectAccount {
+ return accountstd.DIAccount("counter", counter.NewAccount)
+}
+```
+
+Add this to the application:
+
+```go
+package app
+
+func NewApp() *App {
+ // ...
+ appConfig = depinject.Configs(
+ AppConfig(),
+ depinject.Supply(
+ appOpts,
+ logger,
+ ),
+ depinject.Provide(
+ counterdepinject.ProvideAccount,
+ ),
+ )
+ // ...
+}
+```
+
+### Manual Method
+
+Add the account to the x/accounts Keeper:
+
+```go
+accountsKeeper, err := accounts.NewKeeper(
+ appCodec,
+ runtime.NewEnvironment(/* ... */),
+ signingCtx.AddressCodec(),
+ appCodec.InterfaceRegistry(),
+
+ accountstd.AddAccount("counter", counter.NewAccount), // Add account here
+ // Add more accounts if needed
+)
+```
+
+Choose the method that best fits your application structure.
+
+### The accountsstd Package
+
+The `accountsstd` package provides utility functions for use within account init, execution, or query handlers. Key functions include:
+
+1. `Whoami()`: Retrieves the address of the current account.
+2. `Sender()`: Gets the address of the transaction sender (not available in queries).
+3. `Funds()`: Retrieves funds provided by the sender during Init or Execution.
+4. `ExecModule()`: Allows the account to execute a module message.
+ Note: Impersonation is prevented. An account can't send messages on behalf of others.
+5. `QueryModule()`: Enables querying a module.
+
+These functions, along with others, facilitate account operations and interactions within the system.
+For a comprehensive list of available utilities, refer to the Go documentation.
+
+### Interfaces via Messages and Queries
+
+Accounts can handle various messages and queries, allowing for flexible interface definitions:
+
+1. Multiple account types can handle the same message or query.
+2. Different accounts (even with the same type but different addresses) can process identical messages or queries.
+
+This flexibility enables defining interfaces as common sets of messages and/or queries that accounts can handle.
+
+Example: Transaction Authentication
+
+- We define a `MsgAuthenticate` message.
+- Any account capable of handling `MsgAuthenticate` is considered to implement the `Authentication` interface.
+- This approach allows for standardized interaction patterns across different account types.
+
+(Note: More details on the `Authentication` interface will be provided later.)
+
+### Full Examples
+
+Some examples can be found in the [defaults](./defaults) package.
+
+## The Authentication Interface
x/accounts introduces the `Authentication` interface, allowing for flexible transaction (TX) authentication beyond traditional public key cryptography.
@@ -14,21 +362,21 @@ The key message type for authentication is `MsgAuthenticate`, which is defined i
[interfaces/account_abstraction/v1/interface.proto](./proto/cosmos/accounts/interfaces/account_abstraction/v1/interface.proto)
-## Authentication Mechanism
+### Authentication Mechanism
-### AnteHandler in the SDK
+#### AnteHandler in the SDK
The Cosmos SDK utilizes an `AnteHandler` to verify transaction (TX) integrity. Its primary function is to ensure that the messages within a transaction are correctly signed by the purported sender.
-### Authentication Flow for x/accounts Module
+#### Authentication Flow for x/accounts Module
When the `AnteHandler` identifies that a message sender (and transaction signer) belongs to the x/accounts module, it delegates the authentication process to that module.
-#### Authentication Interface Requirement
+##### Authentication Interface Requirement
For successful authentication, the account must implement the `Authentication` interface. If an account fails to implement this interface, it's considered non-externally owned, resulting in transaction rejection.
-##### Sequence Diagram
+###### Sequence Diagram
```mermaid
graph TD
@@ -43,8 +391,7 @@ graph TD
H --> I
```
-
-## Implementing the Authentication Interface
+### Implementing the Authentication Interface
To implement the Authentication interface, an account must handle the execution of `MsgAuthenticate`. Here's an example of how to do this:
@@ -80,33 +427,32 @@ func (a Account) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) {
}
```
-### Key Implementation Points
+#### Key Implementation Points
1. **Sender Verification**: Always verify that the sender is the x/accounts module. This prevents unauthorized accounts from triggering authentication.
2. **Authentication Safety**: Ensure your authentication mechanism is secure:
- Prevent replay attacks by making it impossible to reuse the same action with the same signature.
-
-#### Implementation example
+##### Implementation example
Please find an example [here](./defaults/base/account.go).
-# Supporting Custom Accounts in the x/auth gRPC Server
+## Supporting Custom Accounts in the x/auth gRPC Server
-## Overview
+### Overview
The x/auth module provides a mechanism for custom account types to be exposed via its `Account` and `AccountInfo` gRPC
-queries. This feature is particularly useful for ensuring compatibility with existing wallets that have not yet integrated
+queries. This feature is particularly useful for ensuring compatibility with existing wallets that have not yet integrated
with x/accounts but still need to parse account information post-migration.
-## Implementation
+### Implementation
To support this feature, your custom account type needs to implement the `auth.QueryLegacyAccount` handler. Here are some important points to consider:
1. **Selective Implementation**: This implementation is not required for every account type. It's only necessary for accounts you want to expose through the x/auth gRPC `Account` and `AccountInfo` methods.
2. **Flexible Response**: The `info` field in the `QueryLegacyAccountResponse` is optional. If your custom account cannot be represented as a `BaseAccount`, you can leave this field empty.
-## Example Implementation
+### Example Implementation
A concrete example of implementation can be found in `defaults/base/account.go`. Here's a simplified version:
@@ -143,23 +489,23 @@ func (a Account) AuthRetroCompatibility(ctx context.Context, _ *authtypes.QueryL
}
```
-## Usage Notes
+### Usage Notes
-* Implement this handler only for account types you want to expose via x/auth gRPC methods.
-* The `info` field in the response can be nil if your account doesn't fit the `BaseAccount` structure.
+- Implement this handler only for account types you want to expose via x/auth gRPC methods.
+- The `info` field in the response can be nil if your account doesn't fit the `BaseAccount` structure.
-# Genesis
+## Genesis
-## Creating accounts on genesis
+### Creating accounts on genesis
In order to create accounts at genesis, the `x/accounts` module allows developers to provide
a list of genesis `MsgInit` messages that will be executed in the `x/accounts` genesis flow.
The init messages are generated offline. You can also use the following CLI command to generate the
-json messages: `simd accounts tx init [account type] [msg] --from me --genesis`. This will generate
+json messages: `simd accounts tx init [account type] [msg] --from me --genesis`. This will generate
a jsonified init message wrapped in an x/accounts `MsgInit`.
-This follows the same initialization flow and rules that would happen if the chain is running.
+This follows the same initialization flow and rules that would happen if the chain is running.
The only concrete difference is that this is happening at the genesis block.
For example, given the following `genesis.json` file:
diff --git a/x/accounts/defaults/base/go.mod b/x/accounts/defaults/base/go.mod
index ea0ef43187dc..bc28cb2f289e 100644
--- a/x/accounts/defaults/base/go.mod
+++ b/x/accounts/defaults/base/go.mod
@@ -13,12 +13,12 @@ require (
github.com/cosmos/gogoproto v1.7.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/stretchr/testify v1.9.0
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
@@ -118,7 +118,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -147,14 +147,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
diff --git a/x/accounts/defaults/base/go.sum b/x/accounts/defaults/base/go.sum
index 25dd6bf3bb3f..a5f02361cc93 100644
--- a/x/accounts/defaults/base/go.sum
+++ b/x/accounts/defaults/base/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -402,8 +402,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -510,8 +510,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -590,19 +590,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -661,8 +661,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/accounts/defaults/lockup/TUTORIAL.md b/x/accounts/defaults/lockup/TUTORIAL.md
new file mode 100644
index 000000000000..1a308cbcea7c
--- /dev/null
+++ b/x/accounts/defaults/lockup/TUTORIAL.md
@@ -0,0 +1,243 @@
+# Using lockup account on Cosmos sdk
+
+* [Setup](#setup)
+* [Init](#init)
+* [Execution](#execution)
+ * [Delegate](#delegate)
+ * [Undelegate](#undelegate)
+ * [Withdraw reward](#withdraw-reward)
+ * [Withdraw unlocked token](#withdraw-unlocked-token)
+ * [Send coins](#send-coins)
+* [Query](#query)
+ * [Query account info](#query-account-info)
+ * [Query periodic lockup account locking periods](#query-periodic-lockup-account-locking-periods)
+
+To learn more about lockup account, please also check out [readme](./README.md)
+
+## Setup
+
+To create a lockup account we need 2 wallets (newly created or use any of the existing wallet that you have) one for the creator and one for the owner of the lockup account.
+
+```bash
+simd keys add creator
+simd keys add owner
+```
+
+## Init
+
+Normally the creator must have enough token to grant to the lockup account during the lockup account init process. The owner wallet should be associated with the individual that the creator want to grant the fund to.
+
+Now, the creator can craft the lockup account init messages. This message depend on what type of lockup account the creator want to create.
+For continous, delayed, permanent locking account:
+
+```json
+{
+ "owner": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "end_time": 1495793860
+ "start_time": 1465793854
+}
+```
+
+:::info
+`start_time` is only needed for continous locking account init process. For the other two, you dont have to set it in. Error will returned if `start_time` is not provided when creating continous locking account*
+:::
+
+For periodic locking account:
+
+```json
+ {
+ "owner": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "locking_periods": [
+ {
+ "length": 84600
+ "amount": {
+ "denom": "stake",
+ "amount": 2000
+ }
+ },
+ {
+ "length": 84600
+ "amount": {
+ "denom": "stake",
+ "amount": 1500
+ }
+ }
+ ]
+ "start_time": 1465793854
+ }
+```
+
+Periodic locking account locking duration is the combines of all the period length from `locking_periods`.
+
+The `owner` field takes a string while `start_time` and `end_time` takes a timestamp as value. `locking_periods` are an array of `period`s which consist of 2 field: `length` for the duration of that period and the `amount` that will be release after such duration.
+
+To initialize the account, we have to run the accounts init command passing the account type and the json string for the init message.
+
+```bash
+initcontents=$(cat init.json)
+simd tx accounts init $initcontents --from creator
+```
+
+Whereas the available `lockup_type` options are:
+
+* continuous-locking-account
+
+* delayed-locking-account
+
+* periodic-locking-account
+
+* permanent-locking-account
+
+If success, we'll check the tx result for the lockup account address. You can send token to it like a normal account.
+
+## Execution
+
+To execute a message, we can use the command below:
+
+```bash
+msgcontents=$(cat msg.json)
+simd tx accounts execute $msgcontents --from owner
+```
+
+Whereas `execute-msg-type-url` and `msgcontents` corresponds to lockup account available executions, which are:
+
+### Delegate
+
+The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgDelegate`.
+
+Example of json file:
+
+```json
+{
+ "sender": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "validator_address": "cosmosvaloper1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "amount": {
+ "amount": 100
+ "denom": "stake"
+ }
+}
+```
+
+:::warning
+The `sender` field are the address of the owner of the lockup account. If the sender is not the owner an error will be returned.
+:::
+
+### Undelegate
+
+The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgUndelegate`.
+
+Example of json file:
+
+```json
+{
+ "sender": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "validator_address": "cosmosvaloper1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "amount": {
+ "amount": 100
+ "denom": "stake"
+ }
+}
+```
+
+:::warning
+The `sender` field are the address of the owner of the lockup account. If the sender is not the owner an error will be returned.
+:::
+
+### Withdraw reward
+
+The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgWithdrawReward`.
+
+Example of json file:
+
+```json
+{
+ "sender": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "validator_address": "cosmosvaloper1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+}
+```
+
+:::warning
+The `sender` field are the address of the owner of the lockup account. If the sender is not the owner an error will be returned.
+:::
+
+### Withdraw unlocked token
+
+The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgWithdraw`.
+
+Example of json file:
+
+```json
+{
+ // lockup account owner address
+ "withdrawer": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx46",
+ // withdraw to an account of choice
+ "to_address": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx47",
+ "denoms": ["stake"]
+}
+```
+
+:::warning
+The `withdrawer` field are the address of the owner of the lockup account. If the sender is not the owner an error will be returned.
+:::
+
+### Send coins
+
+The execute message type url for this execution is `cosmos.accounts.defaults.lockup.MsgSend`.
+
+Example of json file:
+
+```json
+{
+ "sender": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx45",
+ "to_address": "cosmos1vaqh39cdex9sgr69ef0tdln5cn0hdyd3s0lx46",
+ "amount": {
+ "amount": 100
+ "denom": "stake"
+ }
+}
+```
+
+:::warning
+The `sender` field are the address of the owner of the lockup account. If the sender is not the owner an error will be returned.
+:::
+
+## Query
+
+To query a lockup account state, we can use the command below:
+
+```bash
+querycontents=$(cat query.json)
+simd tx accounts query $querycontents --from owner
+```
+
+### Query account info
+
+The query request type url for this query is `cosmos.accounts.defaults.lockup.QueryLockupAccountInfoRequest`. And query json file can be an empty object since `QueryLockupAccountInfoRequest` does not required an input.
+
+Account informations including:
+
+* original locked amount
+
+* delegated amount that are locked
+
+* delegated amount that are free
+
+* start and end time
+
+* owner address
+
+* current locked and unlocked amount
+
+### Query periodic lockup account locking periods
+
+:::info
+Note, can only be queried from a periodic lockup account
+:::
+
+The query request type url for this query is `cosmos.accounts.defaults.lockup.QueryLockingPeriodsRequest`. And query json file can be an empty object since `QueryLockingPeriodsRequest` does not required an input.
+
+Locking periods including:
+
+* List of period with its duration and amount
+
+
diff --git a/x/accounts/defaults/lockup/go.mod b/x/accounts/defaults/lockup/go.mod
index 2f66fafe70f0..315965d73c53 100644
--- a/x/accounts/defaults/lockup/go.mod
+++ b/x/accounts/defaults/lockup/go.mod
@@ -14,8 +14,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/api v0.7.6 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
@@ -96,7 +96,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -125,18 +125,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
google.golang.org/grpc v1.67.1 // indirect
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/x/accounts/defaults/lockup/go.sum b/x/accounts/defaults/lockup/go.sum
index 3609dca29bfb..05748373dd70 100644
--- a/x/accounts/defaults/lockup/go.sum
+++ b/x/accounts/defaults/lockup/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -349,8 +349,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -449,8 +449,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -516,18 +516,18 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -576,8 +576,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/accounts/defaults/multisig/go.mod b/x/accounts/defaults/multisig/go.mod
index 3d2600c39a02..265aa5b79be7 100644
--- a/x/accounts/defaults/multisig/go.mod
+++ b/x/accounts/defaults/multisig/go.mod
@@ -12,12 +12,12 @@ require (
github.com/cosmos/cosmos-sdk v0.53.0
github.com/cosmos/gogoproto v1.7.0
github.com/stretchr/testify v1.9.0
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/api v0.7.6 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/depinject v1.0.0 // indirect
@@ -118,7 +118,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -147,14 +147,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
diff --git a/x/accounts/defaults/multisig/go.sum b/x/accounts/defaults/multisig/go.sum
index 25dd6bf3bb3f..a5f02361cc93 100644
--- a/x/accounts/defaults/multisig/go.sum
+++ b/x/accounts/defaults/multisig/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -402,8 +402,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -510,8 +510,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -590,19 +590,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -661,8 +661,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/accounts/go.mod b/x/accounts/go.mod
index 3232de28c027..ec9e3a68f871 100644
--- a/x/accounts/go.mod
+++ b/x/accounts/go.mod
@@ -15,7 +15,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
@@ -26,8 +26,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/math v1.3.0
@@ -123,7 +123,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -151,14 +151,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
diff --git a/x/accounts/go.sum b/x/accounts/go.sum
index 7588b565a0d7..58d4121c9e48 100644
--- a/x/accounts/go.sum
+++ b/x/accounts/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -402,8 +402,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -511,8 +511,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -593,19 +593,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -665,8 +665,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/accounts/internal/prefixstore/prefixstore.go b/x/accounts/internal/prefixstore/prefixstore.go
index 3121691a25df..ef84b70703d0 100644
--- a/x/accounts/internal/prefixstore/prefixstore.go
+++ b/x/accounts/internal/prefixstore/prefixstore.go
@@ -21,7 +21,7 @@ func New(store store.KVStore, prefix []byte) store.KVStore {
var _ store.KVStore = Store{}
-// Store is similar with cometbft/cometbft/libs/db/prefix_db
+// Store is similar with cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
// both gives access only to the limited subset of the store
// for convenience or safety
type Store struct {
@@ -63,7 +63,7 @@ func (s Store) Set(key, value []byte) error {
func (s Store) Delete(key []byte) error { return s.parent.Delete(s.key(key)) }
// Implements KVStore
-// Check https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db.go#L106
+// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L109
func (s Store) Iterator(start, end []byte) (store.Iterator, error) {
newstart := cloneAppend(s.prefix, start)
@@ -83,7 +83,7 @@ func (s Store) Iterator(start, end []byte) (store.Iterator, error) {
}
// ReverseIterator implements KVStore
-// Check https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db.go#L129
+// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L132
func (s Store) ReverseIterator(start, end []byte) (store.Iterator, error) {
newstart := cloneAppend(s.prefix, start)
@@ -180,7 +180,7 @@ func (pi *prefixIterator) Error() error {
return nil
}
-// copied from github.com/cometbft/cometbft/libs/db/prefix_db.go
+// copied from github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
func stripPrefix(key, prefix []byte) []byte {
if len(key) < len(prefix) || !bytes.Equal(key[:len(prefix)], prefix) {
panic("should not happen")
diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go
index 07d8f5330f41..bf0fb453d102 100644
--- a/x/auth/client/cli/tx_sign.go
+++ b/x/auth/client/cli/tx_sign.go
@@ -98,12 +98,16 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error {
return err
}
- if !clientCtx.Offline && multisigKey == "" {
+ if !clientCtx.Offline {
from, err := cmd.Flags().GetString(flags.FlagFrom)
if err != nil {
return err
}
+ if multisigKey != "" {
+ from = multisigKey
+ }
+
fromAddr, _, _, err := client.GetFromFields(clientCtx, txFactory.Keybase(), from)
if err != nil {
return err
@@ -267,7 +271,7 @@ func multisigSign(clientCtx client.Context, txBuilder client.TxBuilder, txFactor
multisigAddr,
clientCtx.FromName,
txBuilder,
- clientCtx.Offline,
+ true,
true,
); err != nil {
return err
diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go
index 423bca3a0870..2b1c866e8e0a 100644
--- a/x/auth/tx/builder.go
+++ b/x/auth/tx/builder.go
@@ -112,7 +112,7 @@ var marshalOption = proto.MarshalOptions{
func (w *builder) getTx() (*gogoTxWrapper, error) {
anyMsgs, err := msgsV1toAnyV2(w.msgs)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("unable to convert messages: %w", err)
}
body := &txv1beta1.TxBody{
Messages: anyMsgs,
@@ -136,12 +136,12 @@ func (w *builder) getTx() (*gogoTxWrapper, error) {
bodyBytes, err := marshalOption.Marshal(body)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("unable to marshal body: %w", err)
}
authInfoBytes, err := marshalOption.Marshal(authInfo)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("unable to marshal auth info: %w", err)
}
txRawBytes, err := marshalOption.Marshal(&txv1beta1.TxRaw{
@@ -150,12 +150,12 @@ func (w *builder) getTx() (*gogoTxWrapper, error) {
Signatures: w.signatures,
})
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("unable to marshal tx raw: %w", err)
}
decodedTx, err := w.decoder.Decode(txRawBytes)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("unable to decode tx: %w", err)
}
return newWrapperFromDecodedTx(w.addressCodec, w.codec, decodedTx)
diff --git a/x/authz/go.mod b/x/authz/go.mod
index a40b44423b98..f110c68a5794 100644
--- a/x/authz/go.mod
+++ b/x/authz/go.mod
@@ -23,12 +23,12 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@@ -117,7 +117,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -145,14 +145,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/x/authz/go.sum b/x/authz/go.sum
index 7588b565a0d7..58d4121c9e48 100644
--- a/x/authz/go.sum
+++ b/x/authz/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -402,8 +402,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -511,8 +511,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -593,19 +593,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -665,8 +665,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/bank/depinject.go b/x/bank/depinject.go
index b17a0cbf7557..22ec40422bcc 100644
--- a/x/bank/depinject.go
+++ b/x/bank/depinject.go
@@ -7,6 +7,7 @@ import (
"sort"
modulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
+ "cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"cosmossdk.io/depinject/appconfig"
@@ -33,9 +34,10 @@ func init() {
type ModuleInputs struct {
depinject.In
- Config *modulev1.Module
- Cdc codec.Codec
- Environment appmodule.Environment
+ Config *modulev1.Module
+ Cdc codec.Codec
+ Environment appmodule.Environment
+ AddressCodec address.Codec
AccountKeeper types.AccountKeeper
}
@@ -55,7 +57,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
blockedAddresses := make(map[string]bool)
if len(in.Config.BlockedModuleAccountsOverride) > 0 {
for _, moduleName := range in.Config.BlockedModuleAccountsOverride {
- addrStr, err := in.AccountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(moduleName))
+ addrStr, err := in.AddressCodec.BytesToString(authtypes.NewModuleAddress(moduleName))
if err != nil {
panic(err)
}
@@ -63,7 +65,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
}
} else {
for _, permission := range in.AccountKeeper.GetModulePermissions() {
- addrStr, err := in.AccountKeeper.AddressCodec().BytesToString(permission.GetAddress())
+ addrStr, err := in.AddressCodec.BytesToString(permission.GetAddress())
if err != nil {
panic(err)
}
@@ -77,7 +79,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
- authStr, err := in.AccountKeeper.AddressCodec().BytesToString(authority)
+ authStr, err := in.AddressCodec.BytesToString(authority)
if err != nil {
panic(err)
}
diff --git a/x/bank/go.mod b/x/bank/go.mod
index 53fd49dabcd2..d0e6c97912b2 100644
--- a/x/bank/go.mod
+++ b/x/bank/go.mod
@@ -28,8 +28,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
@@ -115,7 +115,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -143,18 +143,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
pgregory.net/rapid v1.1.0 // indirect
diff --git a/x/bank/go.sum b/x/bank/go.sum
index 7588b565a0d7..58d4121c9e48 100644
--- a/x/bank/go.sum
+++ b/x/bank/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -402,8 +402,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -511,8 +511,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -593,19 +593,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -665,8 +665,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/bank/keeper/collections_test.go b/x/bank/keeper/collections_test.go
index 3e6d470b380a..f18fe08f434a 100644
--- a/x/bank/keeper/collections_test.go
+++ b/x/bank/keeper/collections_test.go
@@ -16,7 +16,6 @@ import (
banktestutil "cosmossdk.io/x/bank/testutil"
banktypes "cosmossdk.io/x/bank/types"
- "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@@ -32,13 +31,13 @@ func TestBankStateCompatibility(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{})
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
+ ac := codectestutil.CodecOptions{}.GetAddressCodec()
// gomock initializations
ctrl := gomock.NewController(t)
authKeeper := banktestutil.NewMockAccountKeeper(ctrl)
- authKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes()
+ authKeeper.EXPECT().AddressCodec().Return(ac).AnyTimes()
- ac := codectestutil.CodecOptions{}.GetAddressCodec()
addr, err := ac.BytesToString(accAddrs[4])
require.NoError(t, err)
authority, err := ac.BytesToString(authtypes.NewModuleAddress(banktypes.GovModuleName))
diff --git a/x/bank/keeper/genesis.go b/x/bank/keeper/genesis.go
index 8e422e5f420c..2f6facc9ab80 100644
--- a/x/bank/keeper/genesis.go
+++ b/x/bank/keeper/genesis.go
@@ -23,14 +23,14 @@ func (k BaseKeeper) InitGenesis(ctx context.Context, genState *types.GenesisStat
}
totalSupplyMap := sdk.NewMapCoins(sdk.Coins{})
- genState.Balances, err = types.SanitizeGenesisBalances(genState.Balances, k.ak.AddressCodec())
+ genState.Balances, err = types.SanitizeGenesisBalances(genState.Balances, k.addrCdc)
if err != nil {
return err
}
for _, balance := range genState.Balances {
addr := balance.GetAddress()
- bz, err := k.ak.AddressCodec().StringToBytes(addr)
+ bz, err := k.addrCdc.StringToBytes(addr)
if err != nil {
return err
}
diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go
index 42f6221092cf..c8c7b58c2c81 100644
--- a/x/bank/keeper/genesis_test.go
+++ b/x/bank/keeper/genesis_test.go
@@ -21,7 +21,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() {
for i := range []int{1, 2} {
suite.bankKeeper.SetDenomMetaData(ctx, expectedMetadata[i])
- accAddr, err1 := suite.authKeeper.AddressCodec().StringToBytes(expectedBalances[i].Address)
+ accAddr, err1 := suite.addrCdc.StringToBytes(expectedBalances[i].Address)
if err1 != nil {
panic(err1)
}
diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go
index c6d499143d83..909efe3a9d38 100644
--- a/x/bank/keeper/grpc_query.go
+++ b/x/bank/keeper/grpc_query.go
@@ -37,7 +37,7 @@ func (k BaseKeeper) Balance(ctx context.Context, req *types.QueryBalanceRequest)
return nil, status.Error(codes.InvalidArgument, err.Error())
}
- address, err := k.ak.AddressCodec().StringToBytes(req.Address)
+ address, err := k.addrCdc.StringToBytes(req.Address)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error())
}
@@ -53,7 +53,7 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances
return nil, status.Error(codes.InvalidArgument, "empty request")
}
- addr, err := k.ak.AddressCodec().StringToBytes(req.Address)
+ addr, err := k.addrCdc.StringToBytes(req.Address)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error())
}
@@ -86,7 +86,7 @@ func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpend
return nil, status.Error(codes.InvalidArgument, "empty request")
}
- addr, err := k.ak.AddressCodec().StringToBytes(req.Address)
+ addr, err := k.addrCdc.StringToBytes(req.Address)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error())
}
@@ -120,7 +120,7 @@ func (k BaseKeeper) SpendableBalanceByDenom(ctx context.Context, req *types.Quer
return nil, status.Error(codes.InvalidArgument, "empty request")
}
- addr, err := k.ak.AddressCodec().StringToBytes(req.Address)
+ addr, err := k.addrCdc.StringToBytes(req.Address)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error())
}
@@ -295,7 +295,7 @@ func (k BaseKeeper) DenomOwners(
if err != nil {
return nil, err
}
- addr, err := k.ak.AddressCodec().BytesToString(key.K2())
+ addr, err := k.addrCdc.BytesToString(key.K2())
if err != nil {
return nil, err
}
diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go
index 6de9321d404c..4878bf24ce50 100644
--- a/x/bank/keeper/grpc_query_test.go
+++ b/x/bank/keeper/grpc_query_test.go
@@ -21,7 +21,7 @@ func (suite *KeeperTestSuite) TestQueryBalance() {
ctx, queryClient := suite.ctx, suite.queryClient
_, _, addr := testdata.KeyTestPubAddr()
- addrStr, err := suite.authKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := suite.addrCdc.BytesToString(addr)
suite.Require().NoError(err)
origCoins := sdk.NewCoins(newBarCoin(30))
@@ -105,7 +105,7 @@ func (suite *KeeperTestSuite) TestQueryAllBalances() {
_, err := queryClient.AllBalances(gocontext.Background(), &types.QueryAllBalancesRequest{})
suite.Require().Error(err)
- addrStr, err := suite.authKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := suite.addrCdc.BytesToString(addr)
suite.Require().NoError(err)
pageReq := &query.PageRequest{
@@ -178,7 +178,7 @@ func (suite *KeeperTestSuite) TestQueryAllBalances() {
func (suite *KeeperTestSuite) TestSpendableBalances() {
_, _, addr := testdata.KeyTestPubAddr()
- addrStr, err := suite.authKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := suite.addrCdc.BytesToString(addr)
suite.Require().NoError(err)
ctx := sdk.UnwrapSDKContext(suite.ctx)
@@ -241,7 +241,7 @@ func (suite *KeeperTestSuite) TestSpendableBalanceByDenom() {
_, err := queryClient.SpendableBalanceByDenom(ctx, &types.QuerySpendableBalanceByDenomRequest{})
suite.Require().Error(err)
- addrStr, err := suite.authKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := suite.addrCdc.BytesToString(addr)
suite.Require().NoError(err)
req := types.NewQuerySpendableBalanceByDenomRequest(addrStr, fooDenom)
diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go
index 9b1d79c1091b..f8e8aab22974 100644
--- a/x/bank/keeper/keeper.go
+++ b/x/bank/keeper/keeper.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
+ "cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/event"
errorsmod "cosmossdk.io/errors"
@@ -60,6 +61,7 @@ type BaseKeeper struct {
ak types.AccountKeeper
cdc codec.BinaryCodec
mintCoinsRestrictionFn types.MintingRestrictionFn
+ addrCdc address.Codec
}
// GetPaginatedTotalSupply queries for the supply, ignoring 0 coins, with a given pagination
@@ -87,7 +89,8 @@ func NewBaseKeeper(
blockedAddrs map[string]bool,
authority string,
) BaseKeeper {
- if _, err := ak.AddressCodec().StringToBytes(authority); err != nil {
+ addrCdc := ak.AddressCodec()
+ if _, err := addrCdc.StringToBytes(authority); err != nil {
panic(fmt.Errorf("invalid bank authority address: %w", err))
}
@@ -97,6 +100,7 @@ func NewBaseKeeper(
ak: ak,
cdc: cdc,
mintCoinsRestrictionFn: types.NoOpMintingRestrictionFn,
+ addrCdc: addrCdc,
}
}
@@ -146,7 +150,7 @@ func (k BaseKeeper) DelegateCoins(ctx context.Context, delegatorAddr, moduleAccA
return errorsmod.Wrap(err, "failed to track delegation")
}
// emit coin spent event
- delAddrStr, err := k.ak.AddressCodec().BytesToString(delegatorAddr)
+ delAddrStr, err := k.addrCdc.BytesToString(delegatorAddr)
if err != nil {
return err
}
@@ -362,7 +366,7 @@ func (k BaseKeeper) MintCoins(ctx context.Context, moduleName string, amounts sd
k.Logger.Debug("minted coins from module account", "amount", amounts.String(), "from", moduleName)
- addrStr, err := k.ak.AddressCodec().BytesToString(acc.GetAddress())
+ addrStr, err := k.addrCdc.BytesToString(acc.GetAddress())
if err != nil {
return err
}
@@ -403,7 +407,7 @@ func (k BaseKeeper) BurnCoins(ctx context.Context, address []byte, amounts sdk.C
k.setSupply(ctx, supply)
}
- addrStr, err := k.ak.AddressCodec().BytesToString(acc.GetAddress())
+ addrStr, err := k.addrCdc.BytesToString(acc.GetAddress())
if err != nil {
return err
}
diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go
index 4fe765039638..1e984109008b 100644
--- a/x/bank/keeper/keeper_test.go
+++ b/x/bank/keeper/keeper_test.go
@@ -13,6 +13,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
+ "cosmossdk.io/core/address"
coreevent "cosmossdk.io/core/event"
"cosmossdk.io/core/header"
coretesting "cosmossdk.io/core/testing"
@@ -24,7 +25,6 @@ import (
banktypes "cosmossdk.io/x/bank/types"
"github.com/cosmos/cosmos-sdk/baseapp"
- "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil"
@@ -114,6 +114,7 @@ type KeeperTestSuite struct {
ctx context.Context
bankKeeper keeper.BaseKeeper
+ addrCdc address.Codec
authKeeper *banktestutil.MockAccountKeeper
queryClient banktypes.QueryClient
@@ -143,9 +144,10 @@ func (suite *KeeperTestSuite) SetupTest() {
// gomock initializations
ctrl := gomock.NewController(suite.T())
authKeeper := banktestutil.NewMockAccountKeeper(ctrl)
- authKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes()
+ authKeeper.EXPECT().AddressCodec().Return(ac).AnyTimes()
suite.ctx = ctx
suite.authKeeper = authKeeper
+ suite.addrCdc = ac
suite.bankKeeper = keeper.NewBaseKeeper(
env,
encCfg.Codec,
@@ -320,9 +322,9 @@ func (suite *KeeperTestSuite) TestGetAuthority() {
authority,
)
}
- govAddr, err := suite.authKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(banktypes.GovModuleName))
+ govAddr, err := suite.addrCdc.BytesToString(authtypes.NewModuleAddress(banktypes.GovModuleName))
suite.Require().NoError(err)
- modAddr, err := suite.authKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress(banktypes.MintModuleName))
+ modAddr, err := suite.addrCdc.BytesToString(authtypes.NewModuleAddress(banktypes.MintModuleName))
suite.Require().NoError(err)
tests := map[string]string{
@@ -647,9 +649,9 @@ func (suite *KeeperTestSuite) TestInputOutputNewAccount() {
require.Empty(suite.bankKeeper.GetAllBalances(ctx, accAddrs[1]))
- acc0StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[0])
+ acc0StrAddr, err := suite.addrCdc.BytesToString(accAddrs[0])
suite.Require().NoError(err)
- acc1StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[1])
+ acc1StrAddr, err := suite.addrCdc.BytesToString(accAddrs[1])
suite.Require().NoError(err)
suite.mockInputOutputCoins([]sdk.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]})
@@ -674,11 +676,11 @@ func (suite *KeeperTestSuite) TestInputOutputCoins() {
acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0])
- acc0StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[0])
+ acc0StrAddr, err := suite.addrCdc.BytesToString(accAddrs[0])
suite.Require().NoError(err)
- acc1StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[1])
+ acc1StrAddr, err := suite.addrCdc.BytesToString(accAddrs[1])
suite.Require().NoError(err)
- acc2StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[2])
+ acc2StrAddr, err := suite.addrCdc.BytesToString(accAddrs[2])
suite.Require().NoError(err)
input := banktypes.Input{
@@ -786,16 +788,16 @@ func (suite *KeeperTestSuite) TestInputOutputCoinsWithRestrictions() {
setupCtx := suite.ctx
balances := sdk.NewCoins(newFooCoin(1000), newBarCoin(500))
fromAddr := accAddrs[0]
- fromStrAddr, err := suite.authKeeper.AddressCodec().BytesToString(fromAddr)
+ fromStrAddr, err := suite.addrCdc.BytesToString(fromAddr)
suite.Require().NoError(err)
fromAcc := authtypes.NewBaseAccountWithAddress(fromAddr)
inputAccs := []sdk.AccountI{fromAcc}
suite.authKeeper.EXPECT().GetAccount(suite.ctx, inputAccs[0].GetAddress()).Return(inputAccs[0]).AnyTimes()
toAddr1 := accAddrs[1]
- toAddr1Str, err := suite.authKeeper.AddressCodec().BytesToString(toAddr1)
+ toAddr1Str, err := suite.addrCdc.BytesToString(toAddr1)
suite.Require().NoError(err)
toAddr2 := accAddrs[2]
- toAddr2Str, err := suite.authKeeper.AddressCodec().BytesToString(toAddr2)
+ toAddr2Str, err := suite.addrCdc.BytesToString(toAddr2)
suite.Require().NoError(err)
suite.mockFundAccount(accAddrs[0])
@@ -1365,9 +1367,9 @@ func (suite *KeeperTestSuite) TestMsgSendEvents() {
acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0])
- acc0StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[0])
+ acc0StrAddr, err := suite.addrCdc.BytesToString(accAddrs[0])
suite.Require().NoError(err)
- acc1StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[1])
+ acc1StrAddr, err := suite.addrCdc.BytesToString(accAddrs[1])
suite.Require().NoError(err)
newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))
@@ -1407,11 +1409,11 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() {
require.NoError(suite.bankKeeper.SetParams(ctx, banktypes.DefaultParams()))
- acc0StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[0])
+ acc0StrAddr, err := suite.addrCdc.BytesToString(accAddrs[0])
suite.Require().NoError(err)
- acc2StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[2])
+ acc2StrAddr, err := suite.addrCdc.BytesToString(accAddrs[2])
suite.Require().NoError(err)
- acc3StrAddr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[3])
+ acc3StrAddr, err := suite.addrCdc.BytesToString(accAddrs[3])
suite.Require().NoError(err)
coins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100))
@@ -1932,7 +1934,7 @@ func (suite *KeeperTestSuite) TestBalanceTrackingEvents() {
case banktypes.EventTypeCoinSpent:
coinsSpent, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value)
require.NoError(err)
- _, err = suite.authKeeper.AddressCodec().StringToBytes(e.Attributes[0].Value)
+ _, err = suite.addrCdc.StringToBytes(e.Attributes[0].Value)
require.NoError(err)
balances[e.Attributes[0].Value] = balances[e.Attributes[0].Value].Sub(coinsSpent...)
@@ -1940,7 +1942,7 @@ func (suite *KeeperTestSuite) TestBalanceTrackingEvents() {
case banktypes.EventTypeCoinReceived:
coinsRecv, err := sdk.ParseCoinsNormalized(e.Attributes[1].Value)
require.NoError(err)
- _, err = suite.authKeeper.AddressCodec().StringToBytes(e.Attributes[0].Value)
+ _, err = suite.addrCdc.StringToBytes(e.Attributes[0].Value)
require.NoError(err)
balances[e.Attributes[0].Value] = balances[e.Attributes[0].Value].Add(coinsRecv...)
}
@@ -1958,7 +1960,7 @@ func (suite *KeeperTestSuite) TestBalanceTrackingEvents() {
return false
}
- addr, err := suite.authKeeper.AddressCodec().BytesToString(address)
+ addr, err := suite.addrCdc.BytesToString(address)
suite.Require().NoError(err)
balance, exists := balances[addr]
diff --git a/x/bank/keeper/msg_server.go b/x/bank/keeper/msg_server.go
index 81d4d2321476..893191ce4805 100644
--- a/x/bank/keeper/msg_server.go
+++ b/x/bank/keeper/msg_server.go
@@ -29,11 +29,11 @@ func (k msgServer) Send(ctx context.Context, msg *types.MsgSend) (*types.MsgSend
)
if base, ok := k.Keeper.(BaseKeeper); ok {
- from, err = base.ak.AddressCodec().StringToBytes(msg.FromAddress)
+ from, err = base.addrCdc.StringToBytes(msg.FromAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid from address: %s", err)
}
- to, err = base.ak.AddressCodec().StringToBytes(msg.ToAddress)
+ to, err = base.addrCdc.StringToBytes(msg.ToAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid to address: %s", err)
}
@@ -91,7 +91,7 @@ func (k msgServer) MultiSend(ctx context.Context, msg *types.MsgMultiSend) (*typ
for _, out := range msg.Outputs {
if base, ok := k.Keeper.(BaseKeeper); ok {
- accAddr, err := base.ak.AddressCodec().StringToBytes(out.Address)
+ accAddr, err := base.addrCdc.StringToBytes(out.Address)
if err != nil {
return nil, err
}
@@ -174,7 +174,7 @@ func (k msgServer) Burn(ctx context.Context, msg *types.MsgBurn) (*types.MsgBurn
}
if base, ok := k.Keeper.(BaseKeeper); ok {
- from, err = base.ak.AddressCodec().StringToBytes(msg.FromAddress)
+ from, err = base.addrCdc.StringToBytes(msg.FromAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid from address: %s", err)
}
diff --git a/x/bank/keeper/msg_server_test.go b/x/bank/keeper/msg_server_test.go
index c02f6943b90a..475116389593 100644
--- a/x/bank/keeper/msg_server_test.go
+++ b/x/bank/keeper/msg_server_test.go
@@ -71,9 +71,9 @@ func (suite *KeeperTestSuite) TestMsgSend() {
atom0 := sdk.NewCoins(sdk.NewInt64Coin("atom", 0))
atom123eth0 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 0)}
- acc4Addr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[4])
+ acc4Addr, err := suite.addrCdc.BytesToString(accAddrs[4])
suite.Require().NoError(err)
- minterAccAddr, err := suite.authKeeper.AddressCodec().BytesToString(minterAcc.GetAddress())
+ minterAccAddr, err := suite.addrCdc.BytesToString(minterAcc.GetAddress())
suite.Require().NoError(err)
testCases := []struct {
@@ -168,13 +168,13 @@ func (suite *KeeperTestSuite) TestMsgMultiSend() {
sendCoins := sdk.NewCoins(sdk.NewInt64Coin(origDenom, 50))
suite.bankKeeper.SetSendEnabled(suite.ctx, origDenom, true)
- acc0Addr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[0])
+ acc0Addr, err := suite.addrCdc.BytesToString(accAddrs[0])
suite.Require().NoError(err)
- acc1Addr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[1])
+ acc1Addr, err := suite.addrCdc.BytesToString(accAddrs[1])
suite.Require().NoError(err)
- acc4Addr, err := suite.authKeeper.AddressCodec().BytesToString(accAddrs[4])
+ acc4Addr, err := suite.addrCdc.BytesToString(accAddrs[4])
suite.Require().NoError(err)
- minterAccAddr, err := suite.authKeeper.AddressCodec().BytesToString(minterAcc.GetAddress())
+ minterAccAddr, err := suite.addrCdc.BytesToString(minterAcc.GetAddress())
suite.Require().NoError(err)
testCases := []struct {
@@ -269,7 +269,7 @@ func (suite *KeeperTestSuite) TestMsgMultiSend() {
}
func (suite *KeeperTestSuite) TestMsgSetSendEnabled() {
- govAccAddr, err := suite.authKeeper.AddressCodec().BytesToString(govAcc.GetAddress())
+ govAccAddr, err := suite.addrCdc.BytesToString(govAcc.GetAddress())
suite.Require().NoError(err)
testCases := []struct {
name string
@@ -380,7 +380,7 @@ func (suite *KeeperTestSuite) TestMsgBurn() {
origCoins := sdk.NewInt64Coin("eth", 100)
atom0 := sdk.NewInt64Coin("atom", 0)
- multiPermAccAddr, err := suite.authKeeper.AddressCodec().BytesToString(multiPermAcc.GetAddress())
+ multiPermAccAddr, err := suite.addrCdc.BytesToString(multiPermAcc.GetAddress())
suite.Require().NoError(err)
testCases := []struct {
diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go
index 929ff2e50285..6afa29b9f21c 100644
--- a/x/bank/keeper/send.go
+++ b/x/bank/keeper/send.go
@@ -143,7 +143,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input,
return err
}
- inAddress, err := k.ak.AddressCodec().StringToBytes(input.Address)
+ inAddress, err := k.addrCdc.StringToBytes(input.Address)
if err != nil {
return err
}
@@ -156,7 +156,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input,
}
sending := make([]toSend, 0)
for _, out := range outputs {
- outAddress, err := k.ak.AddressCodec().StringToBytes(out.Address)
+ outAddress, err := k.addrCdc.StringToBytes(out.Address)
if err != nil {
return err
}
@@ -218,11 +218,11 @@ func (k BaseSendKeeper) SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccA
return err
}
- fromAddrString, err := k.ak.AddressCodec().BytesToString(fromAddr)
+ fromAddrString, err := k.addrCdc.BytesToString(fromAddr)
if err != nil {
return err
}
- toAddrString, err := k.ak.AddressCodec().BytesToString(toAddr)
+ toAddrString, err := k.addrCdc.BytesToString(toAddr)
if err != nil {
return err
}
@@ -275,7 +275,7 @@ func (k BaseSendKeeper) subUnlockedCoins(ctx context.Context, addr sdk.AccAddres
}
}
- addrStr, err := k.ak.AddressCodec().BytesToString(addr)
+ addrStr, err := k.addrCdc.BytesToString(addr)
if err != nil {
return err
}
@@ -303,7 +303,7 @@ func (k BaseSendKeeper) addCoins(ctx context.Context, addr sdk.AccAddress, amt s
}
}
- addrStr, err := k.ak.AddressCodec().BytesToString(addr)
+ addrStr, err := k.addrCdc.BytesToString(addr)
if err != nil {
return err
}
@@ -359,7 +359,7 @@ func (k BaseSendKeeper) IsSendEnabledCoin(ctx context.Context, coin sdk.Coin) bo
// BlockedAddr checks if a given address is restricted from
// receiving funds.
func (k BaseSendKeeper) BlockedAddr(addr sdk.AccAddress) bool {
- addrStr, err := k.ak.AddressCodec().BytesToString(addr)
+ addrStr, err := k.addrCdc.BytesToString(addr)
if err != nil {
panic(err)
}
diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go
index 54236a60aa07..496e907de8ca 100644
--- a/x/bank/keeper/view.go
+++ b/x/bank/keeper/view.go
@@ -6,6 +6,7 @@ import (
"cosmossdk.io/collections"
"cosmossdk.io/collections/indexes"
+ "cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
@@ -57,8 +58,9 @@ func (b BalancesIndexes) IndexesList() []collections.Index[collections.Pair[sdk.
type BaseViewKeeper struct {
appmodule.Environment
- cdc codec.BinaryCodec
- ak types.AccountKeeper
+ cdc codec.BinaryCodec
+ ak types.AccountKeeper
+ addrCdc address.Codec
Schema collections.Schema
Supply collections.Map[string, math.Int]
@@ -75,6 +77,7 @@ func NewBaseViewKeeper(env appmodule.Environment, cdc codec.BinaryCodec, ak type
Environment: env,
cdc: cdc,
ak: ak,
+ addrCdc: ak.AddressCodec(),
Supply: collections.NewMap(sb, types.SupplyKey, "supply", collections.StringKey, sdk.IntValue),
DenomMetadata: collections.NewMap(sb, types.DenomMetadataPrefix, "denom_metadata", collections.StringKey, codec.CollValue[types.Metadata](cdc)),
SendEnabled: collections.NewMap(sb, types.SendEnabledPrefix, "send_enabled", collections.StringKey, codec.BoolValue), // NOTE: we use a bool value which uses protobuf to retain state backwards compat
@@ -112,7 +115,7 @@ func (k BaseViewKeeper) GetAccountsBalances(ctx context.Context) []types.Balance
mapAddressToBalancesIdx := make(map[string]int)
k.IterateAllBalances(ctx, func(addr sdk.AccAddress, balance sdk.Coin) bool {
- addrStr, err := k.ak.AddressCodec().BytesToString(addr)
+ addrStr, err := k.addrCdc.BytesToString(addr)
if err != nil {
panic(err)
}
diff --git a/x/bank/testutil/expected_keepers_mocks.go b/x/bank/testutil/expected_keepers_mocks.go
index aeddace241f3..4b420c3b5c4b 100644
--- a/x/bank/testutil/expected_keepers_mocks.go
+++ b/x/bank/testutil/expected_keepers_mocks.go
@@ -79,21 +79,6 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interf
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAccount), ctx, moduleName)
}
-// GetModuleAccountAndPermissions mocks base method.
-func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (types.ModuleAccountI, []string) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetModuleAccountAndPermissions", ctx, moduleName)
- ret0, _ := ret[0].(types.ModuleAccountI)
- ret1, _ := ret[1].([]string)
- return ret0, ret1
-}
-
-// GetModuleAccountAndPermissions indicates an expected call of GetModuleAccountAndPermissions.
-func (mr *MockAccountKeeperMockRecorder) GetModuleAccountAndPermissions(ctx, moduleName interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAccountAndPermissions", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAccountAndPermissions), ctx, moduleName)
-}
-
// GetModuleAddress mocks base method.
func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types.AccAddress {
m.ctrl.T.Helper()
@@ -108,21 +93,6 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), moduleName)
}
-// GetModuleAddressAndPermissions mocks base method.
-func (m *MockAccountKeeper) GetModuleAddressAndPermissions(moduleName string) (types.AccAddress, []string) {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetModuleAddressAndPermissions", moduleName)
- ret0, _ := ret[0].(types.AccAddress)
- ret1, _ := ret[1].([]string)
- return ret0, ret1
-}
-
-// GetModuleAddressAndPermissions indicates an expected call of GetModuleAddressAndPermissions.
-func (mr *MockAccountKeeperMockRecorder) GetModuleAddressAndPermissions(moduleName interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddressAndPermissions", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddressAndPermissions), moduleName)
-}
-
// GetModulePermissions mocks base method.
func (m *MockAccountKeeper) GetModulePermissions() map[string]types0.PermissionsForAddress {
m.ctrl.T.Helper()
@@ -151,34 +121,6 @@ func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomo
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasAccount", reflect.TypeOf((*MockAccountKeeper)(nil).HasAccount), ctx, addr)
}
-// NewAccount mocks base method.
-func (m *MockAccountKeeper) NewAccount(arg0 context.Context, arg1 types.AccountI) types.AccountI {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "NewAccount", arg0, arg1)
- ret0, _ := ret[0].(types.AccountI)
- return ret0
-}
-
-// NewAccount indicates an expected call of NewAccount.
-func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewAccount", reflect.TypeOf((*MockAccountKeeper)(nil).NewAccount), arg0, arg1)
-}
-
-// NewAccountWithAddress mocks base method.
-func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr)
- ret0, _ := ret[0].(types.AccountI)
- return ret0
-}
-
-// NewAccountWithAddress indicates an expected call of NewAccountWithAddress.
-func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewAccountWithAddress", reflect.TypeOf((*MockAccountKeeper)(nil).NewAccountWithAddress), ctx, addr)
-}
-
// SetAccount mocks base method.
func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
m.ctrl.T.Helper()
@@ -190,29 +132,3 @@ func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomoc
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetAccount), ctx, acc)
}
-
-// SetModuleAccount mocks base method.
-func (m *MockAccountKeeper) SetModuleAccount(ctx context.Context, macc types.ModuleAccountI) {
- m.ctrl.T.Helper()
- m.ctrl.Call(m, "SetModuleAccount", ctx, macc)
-}
-
-// SetModuleAccount indicates an expected call of SetModuleAccount.
-func (mr *MockAccountKeeperMockRecorder) SetModuleAccount(ctx, macc interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetModuleAccount), ctx, macc)
-}
-
-// ValidatePermissions mocks base method.
-func (m *MockAccountKeeper) ValidatePermissions(macc types.ModuleAccountI) error {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "ValidatePermissions", macc)
- ret0, _ := ret[0].(error)
- return ret0
-}
-
-// ValidatePermissions indicates an expected call of ValidatePermissions.
-func (mr *MockAccountKeeperMockRecorder) ValidatePermissions(macc interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatePermissions", reflect.TypeOf((*MockAccountKeeper)(nil).ValidatePermissions), macc)
-}
diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go
index 013530f8116e..288d64a8f17d 100644
--- a/x/bank/types/expected_keepers.go
+++ b/x/bank/types/expected_keepers.go
@@ -14,18 +14,11 @@ import (
type AccountKeeper interface {
AddressCodec() address.Codec
- NewAccount(context.Context, sdk.AccountI) sdk.AccountI
- NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
-
GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
HasAccount(ctx context.Context, addr sdk.AccAddress) bool
SetAccount(ctx context.Context, acc sdk.AccountI)
- ValidatePermissions(macc sdk.ModuleAccountI) error
GetModuleAddress(moduleName string) sdk.AccAddress
- GetModuleAddressAndPermissions(moduleName string) (addr sdk.AccAddress, permissions []string)
- GetModuleAccountAndPermissions(ctx context.Context, moduleName string) (sdk.ModuleAccountI, []string)
GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI
- SetModuleAccount(ctx context.Context, macc sdk.ModuleAccountI)
GetModulePermissions() map[string]types.PermissionsForAddress
}
diff --git a/x/circuit/go.mod b/x/circuit/go.mod
index 57801be443d0..2ba978365c0c 100644
--- a/x/circuit/go.mod
+++ b/x/circuit/go.mod
@@ -20,8 +20,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
@@ -119,7 +119,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -148,18 +148,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/x/circuit/go.sum b/x/circuit/go.sum
index c9df997e10ec..8fd99b8608ea 100644
--- a/x/circuit/go.sum
+++ b/x/circuit/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -404,8 +404,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -513,8 +513,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -595,19 +595,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -667,8 +667,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/consensus/README.md b/x/consensus/README.md
index 2af97a6a32db..83add3f0bc95 100644
--- a/x/consensus/README.md
+++ b/x/consensus/README.md
@@ -10,33 +10,53 @@ Functionality to modify CometBFT's ABCI consensus params.
## Contents
+* [Abstract](#abstract)
+* [Contents](#contents)
* [State](#state)
* [Params](#params)
-* [Keepers](#keepers)
+* [Keeper](#keeper)
* [Messages](#messages)
-* [Consensus Messages](#consensus-messages)
+ * [UpdateParams](#updateparams)
* [Events](#events)
- * [Message Events](#message-events)
-
## State
-The `x/consensus` module keeps state of the consensus params from cometbft.:
+The `x/consensus` module keeps state of the consensus params from CometBFT.
## Params
-The consensus module stores it's params in state with the prefix of `0x05`,
+The consensus module stores its params in state with the prefix of `0x05`,
it can be updated with governance or the address with authority.
* Params: `0x05 | ProtocolBuffer(cometbft.ConsensusParams)`
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/consensus/proto/cosmos/consensus/v1/consensus.proto#L9-L15
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/consensus/proto/cosmos/consensus/v1/query.proto#L21-L27
+```
+
+```protobuf reference
+https://github.com/cometbft/cometbft/blob/v0.34.35/proto/tendermint/types/params.proto#L11-L18
```
-## Keepers
+## Keeper
+
+The Keeper of the `x/consensus` module provides the following functions:
+
+* `Params`: Retrieves the current consensus parameters.
+
+* `UpdateParams`: Updates the consensus parameters. Only the authority can perform this operation.
+
+* `BlockParams`: Returns the maximum gas and bytes allowed in a block.
+
+* `ValidatorPubKeyTypes`: Provides the list of public key types allowed for validators.
+
+* `EvidenceParams`: Returns the evidence parameters, including maximum age and bytes.
+
+* `AppVersion`: Returns the current application version.
+
+
+Note: It is recommended to use the `x/consensus` module keeper to get consensus params instead of accessing them through the context.
-The consensus module provides methods to Set and Get consensus params. It is recommended to use the `x/consensus` module keeper to get consensus params instead of accessing them through the context.
## Messages
@@ -45,7 +65,7 @@ The consensus module provides methods to Set and Get consensus params. It is rec
Update consensus params.
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/consensus/proto/cosmos/consensus/v1/tx.proto#L23-L44
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/consensus/proto/cosmos/consensus/v1/tx.proto#L24-L44
```
The message will fail under the following conditions:
diff --git a/x/consensus/go.mod b/x/consensus/go.mod
index cee2372dc92d..40ca70da36a7 100644
--- a/x/consensus/go.mod
+++ b/x/consensus/go.mod
@@ -22,8 +22,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
@@ -118,7 +118,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -147,18 +147,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/x/consensus/go.sum b/x/consensus/go.sum
index 6a6b2df0b205..a856f6d1b923 100644
--- a/x/consensus/go.sum
+++ b/x/consensus/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -404,8 +404,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -512,8 +512,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -592,19 +592,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -663,8 +663,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/distribution/README.md b/x/distribution/README.md
index d49b309f50fe..8cd03dc5e459 100644
--- a/x/distribution/README.md
+++ b/x/distribution/README.md
@@ -74,7 +74,7 @@ which is considered computationally expensive.
In conclusion, we can only have Atom commission and unbonded atoms
provisions or bonded atom provisions with no Atom commission, and we elect to
-implement the former. Stakeholders wishing to rebond their provisions may elect
+implement the former. Stakeholders wishing to rebond their provisions, may elect
to set up a script to periodically withdraw and rebond rewards.
## Contents
@@ -99,7 +99,7 @@ In Proof of Stake (PoS) blockchains, rewards gained from transaction fees are pa
Rewards are calculated per period. The period is updated each time a validator's delegation changes, for example, when the validator receives a new delegation.
The rewards for a single validator can then be calculated by taking the total rewards for the period before the delegation started, minus the current total rewards.
-To learn more, see the [F1 Fee Distribution paper](https://github.com/cosmos/cosmos-sdk/tree/main/docs/spec/fee_distribution/f1_fee_distr.pdf).
+To learn more, see the [F1 Fee Distribution paper](https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/docs/spec/fee_distribution/f1_fee_distr.pdf).
The commission to the validator is paid when the validator is removed or when the validator requests a withdrawal.
The commission is calculated and incremented at every `BeginBlock` operation to update accumulated fee amounts.
@@ -438,8 +438,6 @@ The distribution module emits the following events:
| Type | Attribute Key | Attribute Value |
|-----------------|---------------|--------------------|
-| proposer_reward | validator | {validatorAddress} |
-| proposer_reward | reward | {proposerReward} |
| commission | amount | {commissionAmount} |
| commission | validator | {validatorAddress} |
| rewards | amount | {rewardAmount} |
diff --git a/x/distribution/go.mod b/x/distribution/go.mod
index dac4ae3041e6..b2e2e9213568 100644
--- a/x/distribution/go.mod
+++ b/x/distribution/go.mod
@@ -26,8 +26,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
@@ -120,7 +120,7 @@ require (
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -148,18 +148,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/x/distribution/go.sum b/x/distribution/go.sum
index 7588b565a0d7..58d4121c9e48 100644
--- a/x/distribution/go.sum
+++ b/x/distribution/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -402,8 +402,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -511,8 +511,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -593,19 +593,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -665,8 +665,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go
index 703840f15e1b..c0b5d1304009 100644
--- a/x/distribution/keeper/allocation_test.go
+++ b/x/distribution/keeper/allocation_test.go
@@ -57,6 +57,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {
valCodec := address.NewBech32Codec("cosmosvaloper")
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
+ accountKeeper.EXPECT().AddressCodec().Return(cdcOpts.GetAddressCodec())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(valCodec).AnyTimes()
authorityAddr, err := cdcOpts.GetAddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
@@ -120,6 +121,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
feeCollectorAcc := authtypes.NewEmptyModuleAccount("fee_collector")
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), "fee_collector").Return(feeCollectorAcc)
+ accountKeeper.EXPECT().AddressCodec().Return(cdcOpts.GetAddressCodec())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec("cosmosvaloper")).AnyTimes()
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
@@ -258,6 +260,7 @@ func TestAllocateTokensTruncation(t *testing.T) {
feeCollectorAcc := authtypes.NewEmptyModuleAccount("fee_collector")
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
accountKeeper.EXPECT().GetModuleAccount(gomock.Any(), "fee_collector").Return(feeCollectorAcc)
+ accountKeeper.EXPECT().AddressCodec().Return(cdcOpts.GetAddressCodec())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec("cosmosvaloper")).AnyTimes()
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
@@ -391,8 +394,10 @@ func TestAllocateTokensToValidatorWithoutCommission(t *testing.T) {
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
valCodec := address.NewBech32Codec("cosmosvaloper")
+ addrCdc := address.NewBech32Codec("cosmos")
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(valCodec).AnyTimes()
authorityAddr, err := cdcOpts.GetAddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
@@ -460,6 +465,7 @@ func TestAllocateTokensWithZeroTokens(t *testing.T) {
valCodec := address.NewBech32Codec("cosmosvaloper")
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
+ accountKeeper.EXPECT().AddressCodec().Return(cdcOpts.GetAddressCodec())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(valCodec).AnyTimes()
authorityAddr, err := cdcOpts.GetAddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go
index 7bf2091edb89..b261c2e64a48 100644
--- a/x/distribution/keeper/delegation.go
+++ b/x/distribution/keeper/delegation.go
@@ -46,7 +46,7 @@ func (k Keeper) initializeDelegation(ctx context.Context, val sdk.ValAddress, de
return k.DelegatorStartingInfo.Set(ctx, collections.Join(val, del), types.NewDelegatorStartingInfo(previousPeriod, stake, uint64(headerinfo.Height)))
}
-// calculate the rewards accrued by a delegation between two periods
+// calculateDelegationRewardsBetween calculates the rewards accrued by a delegation between two periods
func (k Keeper) calculateDelegationRewardsBetween(ctx context.Context, val sdk.ValidatorI,
startingPeriod, endingPeriod uint64, stake math.LegacyDec,
) (sdk.DecCoins, error) {
@@ -85,9 +85,9 @@ func (k Keeper) calculateDelegationRewardsBetween(ctx context.Context, val sdk.V
return rewards, nil
}
-// calculate the total rewards accrued by a delegation
+// CalculateDelegationRewards calculate the total rewards accrued by a delegation
func (k Keeper) CalculateDelegationRewards(ctx context.Context, val sdk.ValidatorI, del sdk.DelegationI, endingPeriod uint64) (rewards sdk.DecCoins, err error) {
- addrCodec := k.authKeeper.AddressCodec()
+ addrCodec := k.addrCdc
delAddr, err := addrCodec.StringToBytes(del.GetDelegatorAddr())
if err != nil {
return sdk.DecCoins{}, err
@@ -200,8 +200,9 @@ func (k Keeper) CalculateDelegationRewards(ctx context.Context, val sdk.Validato
return rewards, nil
}
+// withdrawDelegationRewards withdraws the rewards accrued by a delegation.
func (k Keeper) withdrawDelegationRewards(ctx context.Context, val sdk.ValidatorI, del sdk.DelegationI) (sdk.Coins, error) {
- addrCodec := k.authKeeper.AddressCodec()
+ addrCodec := k.addrCdc
delAddr, err := addrCodec.StringToBytes(del.GetDelegatorAddr())
if err != nil {
return nil, err
diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go
index 8ee03d5f3f3b..f7f5cff97a3e 100644
--- a/x/distribution/keeper/delegation_test.go
+++ b/x/distribution/keeper/delegation_test.go
@@ -32,6 +32,7 @@ func TestCalculateRewardsBasic(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
@@ -39,11 +40,11 @@ func TestCalculateRewardsBasic(t *testing.T) {
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -70,7 +71,7 @@ func TestCalculateRewardsBasic(t *testing.T) {
require.NoError(t, err)
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -144,18 +145,18 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl)
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
-
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -184,7 +185,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
require.NoError(t, err)
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -259,18 +260,19 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl)
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -299,7 +301,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
require.NoError(t, err)
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -395,6 +397,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
@@ -402,11 +405,11 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -432,7 +435,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
val, err := distrtestutil.CreateValidator(valConsPk0, operatorAddr, math.NewInt(100))
require.NoError(t, err)
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr0)
+ addrStr, err := addrCdc.BytesToString(addr0)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -459,7 +462,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
// second delegation
addr1 := sdk.AccAddress(valConsAddr1)
- _, del1, err := distrtestutil.Delegate(ctx, distrKeeper, addr1, &val, math.NewInt(100), nil, stakingKeeper, accountKeeper.AddressCodec())
+ _, del1, err := distrtestutil.Delegate(ctx, distrKeeper, addr1, &val, math.NewInt(100), nil, stakingKeeper, addrCdc)
require.NoError(t, err)
stakingKeeper.EXPECT().Delegation(gomock.Any(), addr1, valAddr).Return(del1, nil)
@@ -504,6 +507,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
@@ -511,11 +515,11 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -543,7 +547,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -591,6 +595,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
@@ -598,11 +603,11 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -630,7 +635,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -719,6 +724,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
@@ -726,11 +732,11 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -759,7 +765,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
require.NoError(t, err)
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -809,7 +815,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),
nil,
stakingKeeper,
- accountKeeper.AddressCodec(),
+ addrCdc,
)
require.NoError(t, err)
@@ -875,14 +881,15 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl)
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -909,7 +916,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
require.NoError(t, err)
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
@@ -944,7 +951,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
math.NewInt(100),
nil,
stakingKeeper,
- accountKeeper.AddressCodec(),
+ addrCdc,
)
require.NoError(t, err)
@@ -1083,19 +1090,20 @@ func Test100PercentCommissionReward(t *testing.T) {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, distribution.AppModule{})
ctx := testCtx.Ctx.WithHeaderInfo(header.Info{Height: 1})
+ addrCdc := address.NewBech32Codec(sdk.Bech32MainPrefix)
bankKeeper := distrtestutil.NewMockBankKeeper(ctrl)
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl)
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
+ accountKeeper.EXPECT().AddressCodec().Return(addrCdc)
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec(sdk.Bech32PrefixValAddr)).AnyTimes()
stakingKeeper.EXPECT().BondDenom(gomock.Any()).Return("stake", nil).AnyTimes()
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec(sdk.Bech32MainPrefix)).AnyTimes()
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- authorityAddr, err := accountKeeper.AddressCodec().BytesToString(authtypes.NewModuleAddress("gov"))
+ authorityAddr, err := addrCdc.BytesToString(authtypes.NewModuleAddress("gov"))
require.NoError(t, err)
distrKeeper := keeper.NewKeeper(
@@ -1122,7 +1130,7 @@ func Test100PercentCommissionReward(t *testing.T) {
require.NoError(t, err)
val.Commission = stakingtypes.NewCommission(math.LegacyNewDecWithPrec(10, 1), math.LegacyNewDecWithPrec(10, 1), math.LegacyNewDec(0))
- addrStr, err := accountKeeper.AddressCodec().BytesToString(addr)
+ addrStr, err := addrCdc.BytesToString(addr)
require.NoError(t, err)
valAddrStr, err := stakingKeeper.ValidatorAddressCodec().BytesToString(valAddr)
require.NoError(t, err)
diff --git a/x/distribution/keeper/genesis.go b/x/distribution/keeper/genesis.go
index b6fa562268e4..41f8a715c163 100644
--- a/x/distribution/keeper/genesis.go
+++ b/x/distribution/keeper/genesis.go
@@ -23,11 +23,11 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) error
}
for _, dwi := range data.DelegatorWithdrawInfos {
- delegatorAddress, err := k.authKeeper.AddressCodec().StringToBytes(dwi.DelegatorAddress)
+ delegatorAddress, err := k.addrCdc.StringToBytes(dwi.DelegatorAddress)
if err != nil {
return err
}
- withdrawAddress, err := k.authKeeper.AddressCodec().StringToBytes(dwi.WithdrawAddress)
+ withdrawAddress, err := k.addrCdc.StringToBytes(dwi.WithdrawAddress)
if err != nil {
return err
}
@@ -83,7 +83,7 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) error
if err != nil {
return err
}
- delegatorAddress, err := k.authKeeper.AddressCodec().StringToBytes(del.DelegatorAddress)
+ delegatorAddress, err := k.addrCdc.StringToBytes(del.DelegatorAddress)
if err != nil {
return err
}
@@ -123,9 +123,6 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) error
}
balances := k.bankKeeper.GetAllBalances(ctx, moduleAcc.GetAddress())
- if balances.IsZero() {
- k.authKeeper.SetModuleAccount(ctx, moduleAcc)
- }
if !balances.Equal(moduleHoldingsInt) {
return fmt.Errorf("distribution module balance does not match the module holdings: %s <-> %s", balances, moduleHoldingsInt)
}
@@ -146,11 +143,11 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error)
var dwi []types.DelegatorWithdrawInfo
err = k.DelegatorsWithdrawAddress.Walk(ctx, nil, func(key, value sdk.AccAddress) (stop bool, err error) {
- keyAddr, err := k.authKeeper.AddressCodec().BytesToString(key)
+ keyAddr, err := k.addrCdc.BytesToString(key)
if err != nil {
return true, err
}
- valueAddr, err := k.authKeeper.AddressCodec().BytesToString(value)
+ valueAddr, err := k.addrCdc.BytesToString(value)
if err != nil {
return true, err
}
@@ -241,7 +238,7 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error)
dels := make([]types.DelegatorStartingInfoRecord, 0)
err = k.DelegatorStartingInfo.Walk(ctx, nil, func(key collections.Pair[sdk.ValAddress, sdk.AccAddress], value types.DelegatorStartingInfo) (stop bool, err error) {
- delAddr, err := k.authKeeper.AddressCodec().BytesToString(key.K2())
+ delAddr, err := k.addrCdc.BytesToString(key.K2())
if err != nil {
return true, err
}
diff --git a/x/distribution/keeper/grpc_query.go b/x/distribution/keeper/grpc_query.go
index 5337ec58c342..3af717a16ca5 100644
--- a/x/distribution/keeper/grpc_query.go
+++ b/x/distribution/keeper/grpc_query.go
@@ -86,7 +86,7 @@ func (k Querier) ValidatorDistributionInfo(ctx context.Context, req *types.Query
return nil, err
}
- operatorAddr, err := k.authKeeper.AddressCodec().BytesToString(delAdr)
+ operatorAddr, err := k.addrCdc.BytesToString(delAdr)
if err != nil {
return nil, err
}
@@ -225,7 +225,7 @@ func (k Querier) DelegationRewards(ctx context.Context, req *types.QueryDelegati
return nil, errors.Wrap(types.ErrNoValidatorExists, req.ValidatorAddress)
}
- delAdr, err := k.authKeeper.AddressCodec().StringToBytes(req.DelegatorAddress)
+ delAdr, err := k.addrCdc.StringToBytes(req.DelegatorAddress)
if err != nil {
return nil, err
}
@@ -264,7 +264,7 @@ func (k Querier) DelegationTotalRewards(ctx context.Context, req *types.QueryDel
total := sdk.DecCoins{}
var delRewards []types.DelegationDelegatorReward
- delAdr, err := k.authKeeper.AddressCodec().StringToBytes(req.DelegatorAddress)
+ delAdr, err := k.addrCdc.StringToBytes(req.DelegatorAddress)
if err != nil {
return nil, err
}
@@ -322,7 +322,7 @@ func (k Querier) DelegatorValidators(ctx context.Context, req *types.QueryDelega
return nil, status.Error(codes.InvalidArgument, "empty delegator address")
}
- delAdr, err := k.authKeeper.AddressCodec().StringToBytes(req.DelegatorAddress)
+ delAdr, err := k.addrCdc.StringToBytes(req.DelegatorAddress)
if err != nil {
return nil, err
}
@@ -351,7 +351,7 @@ func (k Querier) DelegatorWithdrawAddress(ctx context.Context, req *types.QueryD
if req.DelegatorAddress == "" {
return nil, status.Error(codes.InvalidArgument, "empty delegator address")
}
- delAdr, err := k.authKeeper.AddressCodec().StringToBytes(req.DelegatorAddress)
+ delAdr, err := k.addrCdc.StringToBytes(req.DelegatorAddress)
if err != nil {
return nil, err
}
@@ -361,7 +361,7 @@ func (k Querier) DelegatorWithdrawAddress(ctx context.Context, req *types.QueryD
return nil, err
}
- addr, err := k.authKeeper.AddressCodec().BytesToString(withdrawAddr)
+ addr, err := k.addrCdc.BytesToString(withdrawAddr)
if err != nil {
return nil, err
}
diff --git a/x/distribution/keeper/hooks.go b/x/distribution/keeper/hooks.go
index 46605690c26f..47a21d32dec4 100644
--- a/x/distribution/keeper/hooks.go
+++ b/x/distribution/keeper/hooks.go
@@ -20,12 +20,12 @@ type Hooks struct {
var _ stakingtypes.StakingHooks = Hooks{}
-// Create new distribution hooks
+// Hooks creates new distribution hooks
func (k Keeper) Hooks() Hooks {
return Hooks{k}
}
-// initialize validator distribution record
+// AfterValidatorCreated initialize validator distribution record
func (h Hooks) AfterValidatorCreated(ctx context.Context, valAddr sdk.ValAddress) error {
val, err := h.k.stakingKeeper.Validator(ctx, valAddr)
if err != nil {
@@ -129,8 +129,8 @@ func (h Hooks) AfterValidatorRemoved(ctx context.Context, _ sdk.ConsAddress, val
return nil
}
-// increment period
-func (h Hooks) BeforeDelegationCreated(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
+// BeforeDelegationCreated increment period
+func (h Hooks) BeforeDelegationCreated(ctx context.Context, _ sdk.AccAddress, valAddr sdk.ValAddress) error {
val, err := h.k.stakingKeeper.Validator(ctx, valAddr)
if err != nil {
return err
@@ -140,7 +140,7 @@ func (h Hooks) BeforeDelegationCreated(ctx context.Context, delAddr sdk.AccAddre
return err
}
-// withdraw delegation rewards (which also increments period)
+// BeforeDelegationSharesModified withdraws delegation rewards (which also increments period)
func (h Hooks) BeforeDelegationSharesModified(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
val, err := h.k.stakingKeeper.Validator(ctx, valAddr)
if err != nil {
@@ -159,12 +159,12 @@ func (h Hooks) BeforeDelegationSharesModified(ctx context.Context, delAddr sdk.A
return nil
}
-// create new delegation period record
+// AfterDelegationModified create new delegation period record
func (h Hooks) AfterDelegationModified(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
return h.k.initializeDelegation(ctx, valAddr, delAddr)
}
-// record the slash event
+// BeforeValidatorSlashed record the slash event
func (h Hooks) BeforeValidatorSlashed(ctx context.Context, valAddr sdk.ValAddress, fraction sdkmath.LegacyDec) error {
return h.k.updateValidatorSlashFraction(ctx, valAddr, fraction)
}
diff --git a/x/distribution/keeper/invariants.go b/x/distribution/keeper/invariants.go
index 04f3294320a0..bf01b4cf644d 100644
--- a/x/distribution/keeper/invariants.go
+++ b/x/distribution/keeper/invariants.go
@@ -80,7 +80,7 @@ func CanWithdrawInvariant(k Keeper) sdk.Invariant {
}
for _, del := range allDelegations {
- delAddr, err := k.authKeeper.AddressCodec().StringToBytes(del.GetDelegatorAddr())
+ delAddr, err := k.addrCdc.StringToBytes(del.GetDelegatorAddr())
if err != nil {
panic(err)
}
diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go
index 0ded047e93d6..a44285055dd4 100644
--- a/x/distribution/keeper/keeper.go
+++ b/x/distribution/keeper/keeper.go
@@ -7,6 +7,7 @@ import (
"cosmossdk.io/collections"
collcodec "cosmossdk.io/collections/codec"
+ "cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/event"
@@ -25,6 +26,7 @@ type Keeper struct {
cometService comet.Service
cdc codec.BinaryCodec
+ addrCdc address.Codec
authKeeper types.AccountKeeper
bankKeeper types.BankKeeper
stakingKeeper types.StakingKeeper
@@ -76,6 +78,7 @@ func NewKeeper(
Environment: env,
cometService: cometService,
cdc: cdc,
+ addrCdc: ak.AddressCodec(),
authKeeper: ak,
bankKeeper: bk,
stakingKeeper: sk,
@@ -163,7 +166,7 @@ func (k Keeper) SetWithdrawAddr(ctx context.Context, delegatorAddr, withdrawAddr
return types.ErrSetWithdrawAddrDisabled
}
- addr, err := k.authKeeper.AddressCodec().BytesToString(withdrawAddr)
+ addr, err := k.addrCdc.BytesToString(withdrawAddr)
if err != nil {
return err
}
@@ -178,7 +181,7 @@ func (k Keeper) SetWithdrawAddr(ctx context.Context, delegatorAddr, withdrawAddr
return k.DelegatorsWithdrawAddress.Set(ctx, delegatorAddr, withdrawAddr)
}
-// withdraw rewards from a delegation
+// WithdrawDelegationRewards withdraw rewards from a delegation
func (k Keeper) WithdrawDelegationRewards(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) {
val, err := k.stakingKeeper.Validator(ctx, valAddr)
if err != nil {
@@ -212,7 +215,7 @@ func (k Keeper) WithdrawDelegationRewards(ctx context.Context, delAddr sdk.AccAd
return rewards, nil
}
-// withdraw validator commission
+// WithdrawValidatorCommission withdraw validator commission
func (k Keeper) WithdrawValidatorCommission(ctx context.Context, valAddr sdk.ValAddress) (sdk.Coins, error) {
// fetch validator accumulated commission
accumCommission, err := k.ValidatorsAccumulatedCommission.Get(ctx, valAddr)
diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go
index 589b738a0b57..0d57217a407f 100644
--- a/x/distribution/keeper/keeper_test.go
+++ b/x/distribution/keeper/keeper_test.go
@@ -47,8 +47,8 @@ func initFixture(t *testing.T) (sdk.Context, []sdk.AccAddress, keeper.Keeper, de
stakingKeeper := distrtestutil.NewMockStakingKeeper(ctrl)
accountKeeper := distrtestutil.NewMockAccountKeeper(ctrl)
+ accountKeeper.EXPECT().AddressCodec().Return(cdcOpts.GetAddressCodec()).AnyTimes()
accountKeeper.EXPECT().GetModuleAddress("distribution").Return(distrAcc.GetAddress())
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes()
stakingKeeper.EXPECT().ValidatorAddressCodec().Return(address.NewBech32Codec("cosmosvaloper")).AnyTimes()
diff --git a/x/distribution/keeper/msg_server.go b/x/distribution/keeper/msg_server.go
index 5d1fbdcba553..370529b95be2 100644
--- a/x/distribution/keeper/msg_server.go
+++ b/x/distribution/keeper/msg_server.go
@@ -24,12 +24,12 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
}
func (k msgServer) SetWithdrawAddress(ctx context.Context, msg *types.MsgSetWithdrawAddress) (*types.MsgSetWithdrawAddressResponse, error) {
- delegatorAddress, err := k.authKeeper.AddressCodec().StringToBytes(msg.DelegatorAddress)
+ delegatorAddress, err := k.addrCdc.StringToBytes(msg.DelegatorAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid delegator address: %s", err)
}
- withdrawAddress, err := k.authKeeper.AddressCodec().StringToBytes(msg.WithdrawAddress)
+ withdrawAddress, err := k.addrCdc.StringToBytes(msg.WithdrawAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid withdraw address: %s", err)
}
@@ -48,7 +48,7 @@ func (k msgServer) WithdrawDelegatorReward(ctx context.Context, msg *types.MsgWi
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err)
}
- delegatorAddress, err := k.authKeeper.AddressCodec().StringToBytes(msg.DelegatorAddress)
+ delegatorAddress, err := k.addrCdc.StringToBytes(msg.DelegatorAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid delegator address: %s", err)
}
@@ -78,7 +78,7 @@ func (k msgServer) WithdrawValidatorCommission(ctx context.Context, msg *types.M
// Deprecated: DO NOT USE
// This method uses deprecated message request. Use FundCommunityPool from x/protocolpool module instead.
func (k msgServer) FundCommunityPool(ctx context.Context, msg *types.MsgFundCommunityPool) (*types.MsgFundCommunityPoolResponse, error) {
- depositor, err := k.authKeeper.AddressCodec().StringToBytes(msg.Depositor)
+ depositor, err := k.addrCdc.StringToBytes(msg.Depositor)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid depositor address: %s", err)
}
@@ -126,7 +126,7 @@ func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni
return nil, err
}
- recipient, err := k.authKeeper.AddressCodec().StringToBytes(msg.Recipient)
+ recipient, err := k.addrCdc.StringToBytes(msg.Recipient)
if err != nil {
return nil, fmt.Errorf("invalid recipient address: %w", err)
}
@@ -141,7 +141,7 @@ func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni
}
func (k msgServer) DepositValidatorRewardsPool(ctx context.Context, msg *types.MsgDepositValidatorRewardsPool) (*types.MsgDepositValidatorRewardsPoolResponse, error) {
- depositor, err := k.authKeeper.AddressCodec().StringToBytes(msg.Depositor)
+ depositor, err := k.addrCdc.StringToBytes(msg.Depositor)
if err != nil {
return nil, fmt.Errorf("invalid depositor address: %w", err)
}
@@ -183,7 +183,7 @@ func (k msgServer) DepositValidatorRewardsPool(ctx context.Context, msg *types.M
}
func (k *Keeper) validateAuthority(authority string) error {
- if _, err := k.authKeeper.AddressCodec().StringToBytes(authority); err != nil {
+ if _, err := k.addrCdc.StringToBytes(authority); err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err)
}
diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go
index e30590d865e9..d702ed78a61a 100644
--- a/x/distribution/testutil/expected_keepers_mocks.go
+++ b/x/distribution/testutil/expected_keepers_mocks.go
@@ -51,20 +51,6 @@ func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddressCodec", reflect.TypeOf((*MockAccountKeeper)(nil).AddressCodec))
}
-// GetAccount mocks base method.
-func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types0.AccAddress) types0.AccountI {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
- ret0, _ := ret[0].(types0.AccountI)
- return ret0
-}
-
-// GetAccount indicates an expected call of GetAccount.
-func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr)
-}
-
// GetModuleAccount mocks base method.
func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, name string) types0.ModuleAccountI {
m.ctrl.T.Helper()
@@ -93,18 +79,6 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), name)
}
-// SetModuleAccount mocks base method.
-func (m *MockAccountKeeper) SetModuleAccount(arg0 context.Context, arg1 types0.ModuleAccountI) {
- m.ctrl.T.Helper()
- m.ctrl.Call(m, "SetModuleAccount", arg0, arg1)
-}
-
-// SetModuleAccount indicates an expected call of SetModuleAccount.
-func (mr *MockAccountKeeperMockRecorder) SetModuleAccount(arg0, arg1 interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetModuleAccount), arg0, arg1)
-}
-
// MockBankKeeper is a mock of BankKeeper interface.
type MockBankKeeper struct {
ctrl *gomock.Controller
diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go
index 8288f2206280..e7ec583b9de5 100644
--- a/x/distribution/types/expected_keepers.go
+++ b/x/distribution/types/expected_keepers.go
@@ -12,11 +12,8 @@ import (
// AccountKeeper defines the expected account keeper used for simulations (noalias)
type AccountKeeper interface {
AddressCodec() address.Codec
- GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
GetModuleAddress(name string) sdk.AccAddress
GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI
- // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
- SetModuleAccount(context.Context, sdk.ModuleAccountI)
}
// BankKeeper defines the expected interface needed to retrieve account balances.
diff --git a/x/epochs/go.mod b/x/epochs/go.mod
index b8262cba4f35..cfa18e12f8e1 100644
--- a/x/epochs/go.mod
+++ b/x/epochs/go.mod
@@ -23,8 +23,8 @@ require (
require cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
@@ -117,7 +117,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -146,18 +146,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/x/epochs/go.sum b/x/epochs/go.sum
index 6a6b2df0b205..a856f6d1b923 100644
--- a/x/epochs/go.sum
+++ b/x/epochs/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -404,8 +404,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -512,8 +512,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -592,19 +592,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -663,8 +663,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go
index c655dac54845..f743227ed5bd 100644
--- a/x/epochs/keeper/epoch.go
+++ b/x/epochs/keeper/epoch.go
@@ -5,12 +5,10 @@ import (
"fmt"
"cosmossdk.io/x/epochs/types"
-
- sdk "github.com/cosmos/cosmos-sdk/types"
)
// GetEpochInfo returns epoch info by identifier.
-func (k Keeper) GetEpochInfo(ctx sdk.Context, identifier string) (types.EpochInfo, error) {
+func (k Keeper) GetEpochInfo(ctx context.Context, identifier string) (types.EpochInfo, error) {
return k.EpochInfo.Get(ctx, identifier)
}
diff --git a/x/evidence/go.mod b/x/evidence/go.mod
index 94af124c0a3d..d18950503bd5 100644
--- a/x/evidence/go.mod
+++ b/x/evidence/go.mod
@@ -21,12 +21,12 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
@@ -121,7 +121,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -149,14 +149,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/x/evidence/go.sum b/x/evidence/go.sum
index c9df997e10ec..8fd99b8608ea 100644
--- a/x/evidence/go.sum
+++ b/x/evidence/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -404,8 +404,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -513,8 +513,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -595,19 +595,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -667,8 +667,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/feegrant/CHANGELOG.md b/x/feegrant/CHANGELOG.md
index 9f565f739cb0..a3a9d036f5c3 100644
--- a/x/feegrant/CHANGELOG.md
+++ b/x/feegrant/CHANGELOG.md
@@ -31,6 +31,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### API Breaking Changes
+* [#21651](https://github.com/cosmos/cosmos-sdk/pull/21651) NewKeeper receives an address.Codec instead of an x/auth keeper.
* [#21377](https://github.com/cosmos/cosmos-sdk/pull/21377) Simulation API breaking changes:
* `SimulateMsgGrantAllowance` and `SimulateMsgRevokeAllowance` no longer require a `ProtoCodec` parameter.
* `WeightedOperations` functions no longer require `ProtoCodec`, `JSONCodec`, or `address.Codec` parameters.
diff --git a/x/feegrant/README.md b/x/feegrant/README.md
index f60720a51ff4..63e563d2efb8 100644
--- a/x/feegrant/README.md
+++ b/x/feegrant/README.md
@@ -35,13 +35,13 @@ This module allows accounts to grant fee allowances and to use fees from their a
`Grant` is stored in the KVStore to record a grant with full context. Every grant will contain `granter`, `grantee` and what kind of `allowance` is granted. `granter` is an account address who is giving permission to `grantee` (the beneficiary account address) to pay for some or all of `grantee`'s transaction fees. `allowance` defines what kind of fee allowance (`BasicAllowance` or `PeriodicAllowance`, see below) is granted to `grantee`. `allowance` accepts an interface which implements `FeeAllowanceI`, encoded as `Any` type. There can be only one existing fee grant allowed for a `grantee` and `granter`, self grants are not allowed.
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L86-L96
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L86-L96
```
`FeeAllowanceI` looks like:
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/fees.go#L10-L34
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/fees.go#L10-L34
```
### Fee Allowance types
@@ -57,7 +57,7 @@ There are two types of fee allowances present at the moment:
`BasicAllowance` is permission for `grantee` to use fee from a `granter`'s account. If any of the `spend_limit` or `expiration` reaches its limit, the grant will be removed from the state.
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L15-L33
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L15-L33
```
* `spend_limit` is the limit of coins that are allowed to be used from the `granter` account. If it is empty, it assumes there's no spend limit, `grantee` can use any number of available coins from `granter` account address before the expiration.
@@ -71,7 +71,7 @@ https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmo
`PeriodicAllowance` is a repeating fee allowance for the mentioned period, we can mention when the grant can expire as well as when a period can reset. We can also define the maximum number of coins that can be used in a mentioned period of time.
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L35-L71
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L35-L71
```
* `basic` is the instance of `BasicAllowance` which is optional for periodic fee allowance. If empty, the grant will have no `expiration` and no `spend_limit`.
@@ -89,7 +89,7 @@ https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmo
`AllowedMsgAllowance` is a fee allowance, it can be any of `BasicFeeAllowance`, `PeriodicAllowance` but restricted only to the allowed messages mentioned by the granter.
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L73-L84
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/proto/cosmos/feegrant/v1beta1/feegrant.proto#L73-L84
```
* `allowance` is either `BasicAllowance` or `PeriodicAllowance`.
@@ -101,19 +101,19 @@ https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmo
`feegrant` module introduces a `FeeGranter` flag for CLI for the sake of executing transactions with fee granter. When this flag is set, `clientCtx` will append the granter account address for transactions generated through CLI.
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/client/cmd.go#L256-L267
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/client/cmd.go#L269-L280
```
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/client/tx/tx.go#L129-L131
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/client/tx/tx.go#L129-L131
```
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/auth/tx/builder.go#L208
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/auth/tx/builder.go#L208
```
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/proto/cosmos/tx/v1beta1/tx.proto#L216-L243
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/proto/cosmos/tx/v1beta1/tx.proto#L216-L243
```
Example cmd:
@@ -147,7 +147,7 @@ Fee allowance grants are stored in the state as follows:
* Grant: `0x00 | grantee_addr_len (1 byte) | grantee_addr_bytes | granter_addr_len (1 byte) | granter_addr_bytes -> ProtocolBuffer(Grant)`
```go reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/feegrant.pb.go#L222-L230
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/feegrant.pb.go#L222-L230
```
### FeeAllowanceQueue
@@ -165,7 +165,7 @@ Fee allowance queue keys are stored in the state as follows:
A fee allowance grant will be created with the `MsgGrantAllowance` message.
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmos/feegrant/v1beta1/tx.proto#L30-L44
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/proto/cosmos/feegrant/v1beta1/tx.proto#L30-L44
```
### Msg/RevokeAllowance
@@ -173,7 +173,7 @@ https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmo
An allowed grant fee allowance can be removed with the `MsgRevokeAllowance` message.
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/feegrant/proto/cosmos/feegrant/v1beta1/tx.proto#L49-L62
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/feegrant/proto/cosmos/feegrant/v1beta1/tx.proto#L49-L62
```
## Events
diff --git a/x/feegrant/expected_keepers.go b/x/feegrant/expected_keepers.go
index ce6a2d0a5698..9f0591ad3ffc 100644
--- a/x/feegrant/expected_keepers.go
+++ b/x/feegrant/expected_keepers.go
@@ -3,23 +3,9 @@ package feegrant
import (
"context"
- "cosmossdk.io/core/address"
-
sdk "github.com/cosmos/cosmos-sdk/types"
)
-// AccountKeeper defines the expected auth Account Keeper (noalias)
-type AccountKeeper interface {
- AddressCodec() address.Codec
-
- GetModuleAddress(moduleName string) sdk.AccAddress
- GetModuleAccount(ctx context.Context, moduleName string) sdk.ModuleAccountI
-
- NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
- GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
- SetAccount(ctx context.Context, acc sdk.AccountI)
-}
-
// BankKeeper defines the expected supply Keeper (noalias)
type BankKeeper interface {
SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins
diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod
index 56310d95579a..14350cae8f6b 100644
--- a/x/feegrant/go.mod
+++ b/x/feegrant/go.mod
@@ -24,7 +24,7 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
)
@@ -34,8 +34,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 // indirect
@@ -129,7 +129,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -157,14 +157,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum
index 8e11511b6d57..696a6ef7d845 100644
--- a/x/feegrant/go.sum
+++ b/x/feegrant/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -412,8 +412,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -521,8 +521,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -605,19 +605,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -677,8 +677,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/feegrant/keeper/genesis_test.go b/x/feegrant/keeper/genesis_test.go
index dd2a1eb27bfc..68edd5915808 100644
--- a/x/feegrant/keeper/genesis_test.go
+++ b/x/feegrant/keeper/genesis_test.go
@@ -4,18 +4,17 @@ import (
"errors"
"testing"
- "github.com/golang/mock/gomock"
"gotest.tools/v3/assert"
+ address "cosmossdk.io/core/address"
coretesting "cosmossdk.io/core/testing"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/feegrant/keeper"
"cosmossdk.io/x/feegrant/module"
- feegranttestutil "cosmossdk.io/x/feegrant/testutil"
- "github.com/cosmos/cosmos-sdk/codec/address"
+ addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
@@ -24,7 +23,6 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
var (
@@ -37,7 +35,7 @@ var (
type genesisFixture struct {
ctx sdk.Context
feegrantKeeper keeper.Keeper
- accountKeeper *feegranttestutil.MockAccountKeeper
+ addrCdc address.Codec
}
func initFixture(t *testing.T) *genesisFixture {
@@ -46,22 +44,18 @@ func initFixture(t *testing.T) *genesisFixture {
testCtx := testutil.DefaultContextWithDB(t, key, storetypes.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
- ctrl := gomock.NewController(t)
- accountKeeper := feegranttestutil.NewMockAccountKeeper(ctrl)
- accountKeeper.EXPECT().AddressCodec().Return(address.NewBech32Codec("cosmos")).AnyTimes()
+ addrCdc := addresscodec.NewBech32Codec(sdk.Bech32MainPrefix)
return &genesisFixture{
ctx: testCtx.Ctx,
- feegrantKeeper: keeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger()), encCfg.Codec, accountKeeper),
- accountKeeper: accountKeeper,
+ feegrantKeeper: keeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger()), encCfg.Codec, addrCdc),
+ addrCdc: addrCdc,
}
}
func TestImportExportGenesis(t *testing.T) {
f := initFixture(t)
- f.accountKeeper.EXPECT().GetAccount(gomock.Any(), granteeAddr).Return(authtypes.NewBaseAccountWithAddress(granteeAddr)).AnyTimes()
-
coins := sdk.NewCoins(sdk.NewCoin("foo", math.NewInt(1_000)))
now := f.ctx.HeaderInfo().Time
oneYear := now.AddDate(1, 0, 0)
@@ -74,9 +68,9 @@ func TestImportExportGenesis(t *testing.T) {
genesis, err := f.feegrantKeeper.ExportGenesis(f.ctx)
assert.NilError(t, err)
- granter, err := f.accountKeeper.AddressCodec().BytesToString(granterAddr.Bytes())
+ granter, err := f.addrCdc.BytesToString(granterAddr.Bytes())
assert.NilError(t, err)
- grantee, err := f.accountKeeper.AddressCodec().BytesToString(granteeAddr.Bytes())
+ grantee, err := f.addrCdc.BytesToString(granteeAddr.Bytes())
assert.NilError(t, err)
// revoke fee allowance
@@ -98,7 +92,7 @@ func TestInitGenesis(t *testing.T) {
any, err := codectypes.NewAnyWithValue(&testdata.Dog{})
assert.NilError(t, err)
- ac := address.NewBech32Codec("cosmos")
+ ac := addresscodec.NewBech32Codec("cosmos")
granter, err := ac.BytesToString(granterAddr.Bytes())
assert.NilError(t, err)
diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go
index f5ff7df04370..09c21cf88c58 100644
--- a/x/feegrant/keeper/grpc_query.go
+++ b/x/feegrant/keeper/grpc_query.go
@@ -23,12 +23,12 @@ func (q Keeper) Allowance(ctx context.Context, req *feegrant.QueryAllowanceReque
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
- granterAddr, err := q.authKeeper.AddressCodec().StringToBytes(req.Granter)
+ granterAddr, err := q.addrCdc.StringToBytes(req.Granter)
if err != nil {
return nil, err
}
- granteeAddr, err := q.authKeeper.AddressCodec().StringToBytes(req.Grantee)
+ granteeAddr, err := q.addrCdc.StringToBytes(req.Grantee)
if err != nil {
return nil, err
}
@@ -63,7 +63,7 @@ func (q Keeper) Allowances(c context.Context, req *feegrant.QueryAllowancesReque
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
- granteeAddr, err := q.authKeeper.AddressCodec().StringToBytes(req.Grantee)
+ granteeAddr, err := q.addrCdc.StringToBytes(req.Grantee)
if err != nil {
return nil, err
}
@@ -91,7 +91,7 @@ func (q Keeper) AllowancesByGranter(c context.Context, req *feegrant.QueryAllowa
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
- granterAddr, err := q.authKeeper.AddressCodec().StringToBytes(req.Granter)
+ granterAddr, err := q.addrCdc.StringToBytes(req.Granter)
if err != nil {
return nil, err
}
diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go
index 30e47ae36086..6db74f1022d5 100644
--- a/x/feegrant/keeper/keeper.go
+++ b/x/feegrant/keeper/keeper.go
@@ -5,6 +5,7 @@ import (
"time"
"cosmossdk.io/collections"
+ "cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
corecontext "cosmossdk.io/core/context"
"cosmossdk.io/core/event"
@@ -22,9 +23,9 @@ import (
type Keeper struct {
appmodule.Environment
- cdc codec.BinaryCodec
- authKeeper feegrant.AccountKeeper
- Schema collections.Schema
+ cdc codec.BinaryCodec
+ addrCdc address.Codec
+ Schema collections.Schema
// FeeAllowance key: grantee+granter | value: Grant
FeeAllowance collections.Map[collections.Pair[sdk.AccAddress, sdk.AccAddress], feegrant.Grant]
// FeeAllowanceQueue key: expiration time+grantee+granter | value: bool
@@ -34,13 +35,13 @@ type Keeper struct {
var _ ante.FeegrantKeeper = &Keeper{}
// NewKeeper creates a feegrant Keeper
-func NewKeeper(env appmodule.Environment, cdc codec.BinaryCodec, ak feegrant.AccountKeeper) Keeper {
+func NewKeeper(env appmodule.Environment, cdc codec.BinaryCodec, addrCdc address.Codec) Keeper {
sb := collections.NewSchemaBuilder(env.KVStoreService)
return Keeper{
Environment: env,
cdc: cdc,
- authKeeper: ak,
+ addrCdc: addrCdc,
FeeAllowance: collections.NewMap(
sb,
feegrant.FeeAllowanceKeyPrefix,
@@ -85,11 +86,11 @@ func (k Keeper) GrantAllowance(ctx context.Context, granter, grantee sdk.AccAddr
}
}
- granterStr, err := k.authKeeper.AddressCodec().BytesToString(granter)
+ granterStr, err := k.addrCdc.BytesToString(granter)
if err != nil {
return err
}
- granteeStr, err := k.authKeeper.AddressCodec().BytesToString(grantee)
+ granteeStr, err := k.addrCdc.BytesToString(grantee)
if err != nil {
return err
}
@@ -126,11 +127,11 @@ func (k Keeper) UpdateAllowance(ctx context.Context, granter, grantee sdk.AccAdd
return err
}
- granterStr, err := k.authKeeper.AddressCodec().BytesToString(granter)
+ granterStr, err := k.addrCdc.BytesToString(granter)
if err != nil {
return err
}
- granteeStr, err := k.authKeeper.AddressCodec().BytesToString(grantee)
+ granteeStr, err := k.addrCdc.BytesToString(grantee)
if err != nil {
return err
}
@@ -173,11 +174,11 @@ func (k Keeper) revokeAllowance(ctx context.Context, granter, grantee sdk.AccAdd
}
}
- granterStr, err := k.authKeeper.AddressCodec().BytesToString(granter)
+ granterStr, err := k.addrCdc.BytesToString(granter)
if err != nil {
return err
}
- granteeStr, err := k.authKeeper.AddressCodec().BytesToString(grantee)
+ granteeStr, err := k.addrCdc.BytesToString(grantee)
if err != nil {
return err
}
@@ -217,11 +218,11 @@ func (k Keeper) UseGrantedFees(ctx context.Context, granter, grantee sdk.AccAddr
return err
}
- granterStr, err := k.authKeeper.AddressCodec().BytesToString(granter)
+ granterStr, err := k.addrCdc.BytesToString(granter)
if err != nil {
return err
}
- granteeStr, err := k.authKeeper.AddressCodec().BytesToString(grantee)
+ granteeStr, err := k.addrCdc.BytesToString(grantee)
if err != nil {
return err
}
@@ -255,11 +256,11 @@ func (k *Keeper) emitUseGrantEvent(ctx context.Context, granter, grantee string)
// InitGenesis will initialize the keeper from a *previously validated* GenesisState
func (k Keeper) InitGenesis(ctx context.Context, data *feegrant.GenesisState) error {
for _, f := range data.Allowances {
- granter, err := k.authKeeper.AddressCodec().StringToBytes(f.Granter)
+ granter, err := k.addrCdc.StringToBytes(f.Granter)
if err != nil {
return err
}
- grantee, err := k.authKeeper.AddressCodec().StringToBytes(f.Grantee)
+ grantee, err := k.addrCdc.StringToBytes(f.Grantee)
if err != nil {
return err
}
diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go
index af5cde5dc663..7b9ed26b5d50 100644
--- a/x/feegrant/keeper/keeper_test.go
+++ b/x/feegrant/keeper/keeper_test.go
@@ -3,7 +3,6 @@ package keeper_test
import (
"testing"
- "github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"
"cosmossdk.io/core/header"
@@ -13,7 +12,6 @@ import (
"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/feegrant/keeper"
"cosmossdk.io/x/feegrant/module"
- feegranttestutil "cosmossdk.io/x/feegrant/testutil"
codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
@@ -22,7 +20,6 @@ import (
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
type KeeperTestSuite struct {
@@ -34,7 +31,6 @@ type KeeperTestSuite struct {
msgSrvr feegrant.MsgServer
atom sdk.Coins
feegrantKeeper keeper.Keeper
- accountKeeper *feegranttestutil.MockAccountKeeper
}
func TestKeeperTestSuite(t *testing.T) {
@@ -48,21 +44,14 @@ func (suite *KeeperTestSuite) SetupTest() {
encCfg := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}, module.AppModule{})
// setup gomock and initialize some globally expected executions
- ctrl := gomock.NewController(suite.T())
- suite.accountKeeper = feegranttestutil.NewMockAccountKeeper(ctrl)
- for i := 0; i < len(suite.addrs); i++ {
- suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), suite.addrs[i]).Return(authtypes.NewBaseAccountWithAddress(suite.addrs[i])).AnyTimes()
- }
-
ac := codecaddress.NewBech32Codec("cosmos")
- suite.accountKeeper.EXPECT().AddressCodec().Return(ac).AnyTimes()
for _, addr := range suite.addrs {
str, err := ac.BytesToString(addr)
suite.Require().NoError(err)
suite.encodedAddrs = append(suite.encodedAddrs, str)
}
- suite.feegrantKeeper = keeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger()), encCfg.Codec, suite.accountKeeper)
+ suite.feegrantKeeper = keeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger()), encCfg.Codec, ac)
suite.ctx = testCtx.Ctx
suite.msgSrvr = keeper.NewMsgServerImpl(suite.feegrantKeeper)
suite.atom = sdk.NewCoins(sdk.NewCoin("atom", sdkmath.NewInt(555)))
@@ -181,7 +170,6 @@ func (suite *KeeperTestSuite) TestKeeperCrud() {
address := "cosmos1rxr4mq58w3gtnx5tsc438mwjjafv3mja7k5pnu"
accAddr, err := codecaddress.NewBech32Codec("cosmos").StringToBytes(address)
suite.Require().NoError(err)
- suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), accAddr).Return(authtypes.NewBaseAccountWithAddress(accAddr)).AnyTimes()
// let's grant and revoke authorization to non existing account
err = suite.feegrantKeeper.GrantAllowance(suite.ctx, suite.addrs[3], accAddr, basic2)
diff --git a/x/feegrant/keeper/msg_server.go b/x/feegrant/keeper/msg_server.go
index 79e4405ccfb9..e18a1f8f3dce 100644
--- a/x/feegrant/keeper/msg_server.go
+++ b/x/feegrant/keeper/msg_server.go
@@ -31,12 +31,12 @@ func (k msgServer) GrantAllowance(ctx context.Context, msg *feegrant.MsgGrantAll
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "cannot self-grant fee authorization")
}
- grantee, err := k.authKeeper.AddressCodec().StringToBytes(msg.Grantee)
+ grantee, err := k.addrCdc.StringToBytes(msg.Grantee)
if err != nil {
return nil, err
}
- granter, err := k.authKeeper.AddressCodec().StringToBytes(msg.Granter)
+ granter, err := k.addrCdc.StringToBytes(msg.Granter)
if err != nil {
return nil, err
}
@@ -68,12 +68,12 @@ func (k msgServer) RevokeAllowance(ctx context.Context, msg *feegrant.MsgRevokeA
return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "addresses must be different")
}
- grantee, err := k.authKeeper.AddressCodec().StringToBytes(msg.Grantee)
+ grantee, err := k.addrCdc.StringToBytes(msg.Grantee)
if err != nil {
return nil, err
}
- granter, err := k.authKeeper.AddressCodec().StringToBytes(msg.Granter)
+ granter, err := k.addrCdc.StringToBytes(msg.Granter)
if err != nil {
return nil, err
}
diff --git a/x/feegrant/keeper/msg_server_test.go b/x/feegrant/keeper/msg_server_test.go
index 2e4e8f405c80..62fa1aa65079 100644
--- a/x/feegrant/keeper/msg_server_test.go
+++ b/x/feegrant/keeper/msg_server_test.go
@@ -3,16 +3,12 @@ package keeper_test
import (
"time"
- "github.com/golang/mock/gomock"
-
"cosmossdk.io/collections"
"cosmossdk.io/core/header"
"cosmossdk.io/x/feegrant"
- codecaddress "github.com/cosmos/cosmos-sdk/codec/address"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/types"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
func (suite *KeeperTestSuite) TestGrantAllowance() {
@@ -20,8 +16,6 @@ func (suite *KeeperTestSuite) TestGrantAllowance() {
oneYear := ctx.HeaderInfo().Time.AddDate(1, 0, 0)
yesterday := ctx.HeaderInfo().Time.AddDate(0, 0, -1)
- addressCodec := codecaddress.NewBech32Codec("cosmos")
-
testCases := []struct {
name string
req func() *feegrant.MsgGrantAllowance
@@ -62,22 +56,12 @@ func (suite *KeeperTestSuite) TestGrantAllowance() {
name: "valid: grantee account doesn't exist",
req: func() *feegrant.MsgGrantAllowance {
grantee := "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5"
- granteeAccAddr, err := addressCodec.StringToBytes(grantee)
- suite.Require().NoError(err)
any, err := codectypes.NewAnyWithValue(&feegrant.BasicAllowance{
SpendLimit: suite.atom,
Expiration: &oneYear,
})
suite.Require().NoError(err)
- suite.accountKeeper.EXPECT().GetAccount(gomock.Any(), granteeAccAddr).Return(nil).AnyTimes()
-
- acc := authtypes.NewBaseAccountWithAddress(granteeAccAddr)
- add, err := addressCodec.StringToBytes(grantee)
- suite.Require().NoError(err)
-
- suite.accountKeeper.EXPECT().NewAccountWithAddress(gomock.Any(), add).Return(acc).AnyTimes()
-
suite.Require().NoError(err)
return &feegrant.MsgGrantAllowance{
Granter: suite.encodedAddrs[0],
diff --git a/x/feegrant/module/abci_test.go b/x/feegrant/module/abci_test.go
index 12f65c24c89f..0faa384493c8 100644
--- a/x/feegrant/module/abci_test.go
+++ b/x/feegrant/module/abci_test.go
@@ -3,7 +3,6 @@ package module_test
import (
"testing"
- "github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"cosmossdk.io/core/header"
@@ -13,7 +12,6 @@ import (
"cosmossdk.io/x/feegrant"
"cosmossdk.io/x/feegrant/keeper"
"cosmossdk.io/x/feegrant/module"
- feegranttestutil "cosmossdk.io/x/feegrant/testutil"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/address"
@@ -23,7 +21,6 @@ import (
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
- authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)
func TestFeegrantPruning(t *testing.T) {
@@ -40,18 +37,11 @@ func TestFeegrantPruning(t *testing.T) {
now := testCtx.Ctx.HeaderInfo().Time
oneDay := now.AddDate(0, 0, 1)
- ctrl := gomock.NewController(t)
- accountKeeper := feegranttestutil.NewMockAccountKeeper(ctrl)
- accountKeeper.EXPECT().GetAccount(gomock.Any(), grantee).Return(authtypes.NewBaseAccountWithAddress(grantee)).AnyTimes()
- accountKeeper.EXPECT().GetAccount(gomock.Any(), granter1).Return(authtypes.NewBaseAccountWithAddress(granter1)).AnyTimes()
- accountKeeper.EXPECT().GetAccount(gomock.Any(), granter2).Return(authtypes.NewBaseAccountWithAddress(granter2)).AnyTimes()
- accountKeeper.EXPECT().GetAccount(gomock.Any(), granter3).Return(authtypes.NewBaseAccountWithAddress(granter3)).AnyTimes()
ac := address.NewBech32Codec("cosmos")
- accountKeeper.EXPECT().AddressCodec().Return(ac).AnyTimes()
env := runtime.NewEnvironment(runtime.NewKVStoreService(key), coretesting.NewNopLogger())
- feegrantKeeper := keeper.NewKeeper(env, encCfg.Codec, accountKeeper)
+ feegrantKeeper := keeper.NewKeeper(env, encCfg.Codec, ac)
err := feegrantKeeper.GrantAllowance(
testCtx.Ctx,
diff --git a/x/feegrant/module/depinject.go b/x/feegrant/module/depinject.go
index 613d51a14743..85b7508468c5 100644
--- a/x/feegrant/module/depinject.go
+++ b/x/feegrant/module/depinject.go
@@ -2,6 +2,7 @@ package module
import (
modulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
+ "cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"cosmossdk.io/depinject/appconfig"
@@ -30,15 +31,15 @@ func init() {
type FeegrantInputs struct {
depinject.In
- Environment appmodule.Environment
- Cdc codec.Codec
- AccountKeeper feegrant.AccountKeeper
- BankKeeper feegrant.BankKeeper
- Registry cdctypes.InterfaceRegistry
+ Environment appmodule.Environment
+ Cdc codec.Codec
+ AddressCodec address.Codec
+ BankKeeper feegrant.BankKeeper
+ Registry cdctypes.InterfaceRegistry
}
func ProvideModule(in FeegrantInputs) (keeper.Keeper, appmodule.AppModule) {
- k := keeper.NewKeeper(in.Environment, in.Cdc, in.AccountKeeper)
+ k := keeper.NewKeeper(in.Environment, in.Cdc, in.AddressCodec)
m := NewAppModule(in.Cdc, k, in.Registry)
return k, m
}
diff --git a/x/feegrant/testutil/expected_keepers_mocks.go b/x/feegrant/testutil/expected_keepers_mocks.go
index d7567b8266d3..d1149afa8503 100644
--- a/x/feegrant/testutil/expected_keepers_mocks.go
+++ b/x/feegrant/testutil/expected_keepers_mocks.go
@@ -8,116 +8,10 @@ import (
context "context"
reflect "reflect"
- address "cosmossdk.io/core/address"
types "github.com/cosmos/cosmos-sdk/types"
gomock "github.com/golang/mock/gomock"
)
-// MockAccountKeeper is a mock of AccountKeeper interface.
-type MockAccountKeeper struct {
- ctrl *gomock.Controller
- recorder *MockAccountKeeperMockRecorder
-}
-
-// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper.
-type MockAccountKeeperMockRecorder struct {
- mock *MockAccountKeeper
-}
-
-// NewMockAccountKeeper creates a new mock instance.
-func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper {
- mock := &MockAccountKeeper{ctrl: ctrl}
- mock.recorder = &MockAccountKeeperMockRecorder{mock}
- return mock
-}
-
-// EXPECT returns an object that allows the caller to indicate expected use.
-func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder {
- return m.recorder
-}
-
-// AddressCodec mocks base method.
-func (m *MockAccountKeeper) AddressCodec() address.Codec {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "AddressCodec")
- ret0, _ := ret[0].(address.Codec)
- return ret0
-}
-
-// AddressCodec indicates an expected call of AddressCodec.
-func (mr *MockAccountKeeperMockRecorder) AddressCodec() *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddressCodec", reflect.TypeOf((*MockAccountKeeper)(nil).AddressCodec))
-}
-
-// GetAccount mocks base method.
-func (m *MockAccountKeeper) GetAccount(ctx context.Context, addr types.AccAddress) types.AccountI {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetAccount", ctx, addr)
- ret0, _ := ret[0].(types.AccountI)
- return ret0
-}
-
-// GetAccount indicates an expected call of GetAccount.
-func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr)
-}
-
-// GetModuleAccount mocks base method.
-func (m *MockAccountKeeper) GetModuleAccount(ctx context.Context, moduleName string) types.ModuleAccountI {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName)
- ret0, _ := ret[0].(types.ModuleAccountI)
- return ret0
-}
-
-// GetModuleAccount indicates an expected call of GetModuleAccount.
-func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAccount), ctx, moduleName)
-}
-
-// GetModuleAddress mocks base method.
-func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types.AccAddress {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "GetModuleAddress", moduleName)
- ret0, _ := ret[0].(types.AccAddress)
- return ret0
-}
-
-// GetModuleAddress indicates an expected call of GetModuleAddress.
-func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), moduleName)
-}
-
-// NewAccountWithAddress mocks base method.
-func (m *MockAccountKeeper) NewAccountWithAddress(ctx context.Context, addr types.AccAddress) types.AccountI {
- m.ctrl.T.Helper()
- ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr)
- ret0, _ := ret[0].(types.AccountI)
- return ret0
-}
-
-// NewAccountWithAddress indicates an expected call of NewAccountWithAddress.
-func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewAccountWithAddress", reflect.TypeOf((*MockAccountKeeper)(nil).NewAccountWithAddress), ctx, addr)
-}
-
-// SetAccount mocks base method.
-func (m *MockAccountKeeper) SetAccount(ctx context.Context, acc types.AccountI) {
- m.ctrl.T.Helper()
- m.ctrl.Call(m, "SetAccount", ctx, acc)
-}
-
-// SetAccount indicates an expected call of SetAccount.
-func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomock.Call {
- mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetAccount), ctx, acc)
-}
-
// MockBankKeeper is a mock of BankKeeper interface.
type MockBankKeeper struct {
ctrl *gomock.Controller
diff --git a/x/genutil/client/cli/migrate.go b/x/genutil/client/cli/migrate.go
index 2b2a1c856b74..912aae4600f8 100644
--- a/x/genutil/client/cli/migrate.go
+++ b/x/genutil/client/cli/migrate.go
@@ -13,13 +13,19 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
+ v052 "github.com/cosmos/cosmos-sdk/x/genutil/migration/v052"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
)
-const flagGenesisTime = "genesis-time"
+const (
+ flagGenesisTime = "genesis-time"
+ v52 = "v0.52"
+)
// MigrationMap is a map of SDK versions to their respective genesis migration functions.
-var MigrationMap = types.MigrationMap{}
+var MigrationMap = types.MigrationMap{
+ v52: v052.Migrate,
+}
// MigrateGenesisCmd returns a command to execute genesis state migration.
// Applications should pass their own migration map to this function.
@@ -56,7 +62,17 @@ func MigrateHandler(cmd *cobra.Command, args []string, migrations types.Migratio
}
importGenesis := args[1]
- appGenesis, err := types.AppGenesisFromFile(importGenesis)
+ outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
+
+ // for v52 we need to migrate the consensus validator address from hex bytes to
+ // sdk consensus address.
+ var appGenesis *types.AppGenesis
+ var err error
+ if target == v52 {
+ appGenesis, err = v052.MigrateGenesisFile(importGenesis)
+ } else {
+ appGenesis, err = types.AppGenesisFromFile(importGenesis)
+ }
if err != nil {
return err
}
@@ -110,7 +126,6 @@ func MigrateHandler(cmd *cobra.Command, args []string, migrations types.Migratio
return fmt.Errorf("failed to marshal app genesis: %w", err)
}
- outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument)
if outputDocument == "" {
cmd.Println(string(bz))
return nil
diff --git a/x/genutil/migration/v052/migrate.go b/x/genutil/migration/v052/migrate.go
new file mode 100644
index 000000000000..350240850cff
--- /dev/null
+++ b/x/genutil/migration/v052/migrate.go
@@ -0,0 +1,173 @@
+package migrate
+
+import (
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "time"
+
+ cmtjson "github.com/cometbft/cometbft/libs/json"
+ cmttypes "github.com/cometbft/cometbft/types"
+
+ "github.com/cosmos/cosmos-sdk/client"
+ cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ "github.com/cosmos/cosmos-sdk/version"
+ "github.com/cosmos/cosmos-sdk/x/genutil/types"
+)
+
+type legacyAppGenesis struct {
+ AppName string `json:"app_name"`
+ AppVersion string `json:"app_version"`
+ GenesisTime time.Time `json:"genesis_time"`
+ ChainID string `json:"chain_id"`
+ InitialHeight int64 `json:"initial_height"`
+ AppHash []byte `json:"app_hash"`
+ AppState json.RawMessage `json:"app_state,omitempty"`
+ Consensus *legacyConsensusGenesis `json:"consensus,omitempty"`
+}
+
+type legacyConsensusGenesis struct {
+ Validators []cmttypes.GenesisValidator `json:"validators,omitempty"`
+ Params *cmttypes.ConsensusParams `json:"params,omitempty"`
+}
+
+func MigrateGenesisFile(oldGenFile string) (*types.AppGenesis, error) {
+ file, err := os.Open(filepath.Clean(oldGenFile))
+ if err != nil {
+ return nil, err
+ }
+ defer file.Close()
+
+ appGenesis, err := migrateGenesisValidator(file)
+ if err != nil {
+ return nil, fmt.Errorf("failed to read genesis from file %s: %w", oldGenFile, err)
+ }
+
+ return appGenesis, nil
+}
+
+// migrateGenesisValidator migrate current genesis file genesis validator to match of the
+// new genesis validator type.
+func migrateGenesisValidator(r io.Reader) (*types.AppGenesis, error) {
+ var newAg types.AppGenesis
+ var ag legacyAppGenesis
+ var err error
+
+ if rs, ok := r.(io.ReadSeeker); ok {
+ err = json.NewDecoder(rs).Decode(&ag)
+ if err == nil {
+ vals, err := convertValidators(ag.Consensus.Validators)
+ if err != nil {
+ return nil, err
+ }
+ newAg = types.AppGenesis{
+ AppName: ag.AppName,
+ AppVersion: ag.AppVersion,
+ GenesisTime: ag.GenesisTime,
+ ChainID: ag.ChainID,
+ InitialHeight: ag.InitialHeight,
+ AppHash: ag.AppHash,
+ AppState: ag.AppState,
+ Consensus: &types.ConsensusGenesis{
+ Validators: vals,
+ Params: ag.Consensus.Params,
+ },
+ }
+
+ return &newAg, nil
+ }
+
+ err = fmt.Errorf("error unmarshalling legacy AppGenesis: %w", err)
+ if _, serr := rs.Seek(0, io.SeekStart); serr != nil {
+ err = errors.Join(err, fmt.Errorf("error seeking back to the front: %w", serr))
+ return nil, err
+ }
+ }
+
+ jsonBlob, ioerr := io.ReadAll(r)
+ if ioerr != nil {
+ err = errors.Join(err, fmt.Errorf("failed to read file completely: %w", ioerr))
+ return nil, err
+ }
+
+ // fallback to comet genesis parsing
+ var ctmGenesis cmttypes.GenesisDoc
+ if uerr := cmtjson.Unmarshal(jsonBlob, &ctmGenesis); uerr != nil {
+ err = errors.Join(err, fmt.Errorf("failed fallback to CometBFT GenDoc: %w", uerr))
+ return nil, err
+ }
+
+ vals, err := convertValidators(ctmGenesis.Validators)
+ if err != nil {
+ return nil, err
+ }
+ newAg = types.AppGenesis{
+ AppName: version.AppName,
+ GenesisTime: ctmGenesis.GenesisTime,
+ ChainID: ctmGenesis.ChainID,
+ InitialHeight: ctmGenesis.InitialHeight,
+ AppHash: ctmGenesis.AppHash,
+ AppState: ctmGenesis.AppState,
+ Consensus: &types.ConsensusGenesis{
+ Validators: vals,
+ Params: ctmGenesis.ConsensusParams,
+ },
+ }
+
+ return &newAg, nil
+}
+
+func convertValidators(cmtVals []cmttypes.GenesisValidator) ([]sdk.GenesisValidator, error) {
+ vals := make([]sdk.GenesisValidator, len(cmtVals))
+ for i, cmtVal := range cmtVals {
+ pk, err := cryptocodec.FromCmtPubKeyInterface(cmtVal.PubKey)
+ if err != nil {
+ return nil, err
+ }
+ jsonPk, err := cryptocodec.PubKeyFromProto(pk)
+ if err != nil {
+ return nil, err
+ }
+ vals[i] = sdk.GenesisValidator{
+ Address: cmtVal.Address.Bytes(),
+ PubKey: jsonPk,
+ Power: cmtVal.Power,
+ Name: cmtVal.Name,
+ }
+ }
+ return vals, nil
+}
+
+// CometBFT Genesis Handling for JSON,
+// this is necessary for json unmarshaling of legacyConsensusGenesis
+func (cs *legacyConsensusGenesis) MarshalJSON() ([]byte, error) {
+ type Alias legacyConsensusGenesis
+ return cmtjson.Marshal(&Alias{
+ Validators: cs.Validators,
+ Params: cs.Params,
+ })
+}
+
+func (cs *legacyConsensusGenesis) UnmarshalJSON(b []byte) error {
+ type Alias legacyConsensusGenesis
+
+ result := Alias{}
+ if err := cmtjson.Unmarshal(b, &result); err != nil {
+ return err
+ }
+
+ cs.Params = result.Params
+ cs.Validators = result.Validators
+
+ return nil
+}
+
+// since we only need migrate the consensus validators content so there is no
+// exported state migration.
+func Migrate(appState types.AppMap, _ client.Context) (types.AppMap, error) {
+ return appState, nil
+}
diff --git a/x/genutil/migration/v052/migrate_test.go b/x/genutil/migration/v052/migrate_test.go
new file mode 100644
index 000000000000..5c38bb3401fa
--- /dev/null
+++ b/x/genutil/migration/v052/migrate_test.go
@@ -0,0 +1,51 @@
+package migrate
+
+import (
+ "bytes"
+ "encoding/json"
+ "os"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/cosmos/cosmos-sdk/x/genutil/types"
+)
+
+var oldGenFilePath = "./testdata/old_app_genesis.json"
+
+func TestMigration(t *testing.T) {
+ tempDir := t.TempDir()
+
+ // clean all content on this directory
+ err := os.RemoveAll(tempDir)
+ require.NoError(t, err)
+
+ // should not be able to get app genesis from new genesis file
+ // since validators address are still in hex string and not cons address
+ _, err = types.AppGenesisFromFile(oldGenFilePath)
+ require.ErrorContains(t, err, "error unmarshalling AppGenesis: decoding bech32 failed")
+
+ newAppGenesis, err := MigrateGenesisFile(oldGenFilePath)
+ require.NoError(t, err)
+ // save the new app genesis to new temp dir
+ err = newAppGenesis.SaveAs(tempDir)
+ require.NoError(t, err)
+
+ // read the old app genesis to compare with the new app genesis
+ var oldAppGenesis legacyAppGenesis
+ r, err := os.Open(oldGenFilePath)
+ require.NoError(t, err)
+ err = json.NewDecoder(r).Decode(&oldAppGenesis)
+ require.NoError(t, err)
+
+ // should be able to get app genesis from new genesis file
+ newAppGenesis, err = types.AppGenesisFromFile(tempDir)
+ require.NotNil(t, newAppGenesis)
+ require.NotNil(t, newAppGenesis.Consensus)
+ require.True(t, bytes.Equal(oldAppGenesis.AppHash, newAppGenesis.AppHash))
+ require.True(t, bytes.Equal(oldAppGenesis.Consensus.Validators[0].Address.Bytes(), newAppGenesis.Consensus.Validators[0].Address.Bytes()))
+ require.True(t, bytes.Equal(oldAppGenesis.Consensus.Validators[0].PubKey.Bytes(), newAppGenesis.Consensus.Validators[0].PubKey.Bytes()))
+ require.Equal(t, len(oldAppGenesis.Consensus.Validators), len(newAppGenesis.Consensus.Validators), "Number of validators should remain the same after migration")
+
+ require.NoError(t, err)
+}
diff --git a/x/genutil/migration/v052/testdata/old_app_genesis.json b/x/genutil/migration/v052/testdata/old_app_genesis.json
new file mode 100644
index 000000000000..57ca37536b6d
--- /dev/null
+++ b/x/genutil/migration/v052/testdata/old_app_genesis.json
@@ -0,0 +1 @@
+{"app_name":"\u003cappd\u003e","app_version":"","genesis_time":"2023-02-20T11:08:30.588307671Z","chain_id":"demo","initial_height":48,"app_hash":"","app_state":{"auth":{"accounts":[{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"1","address":"cosmos1qmkksxlxqdslq6kkca25m4jn344nx29lytq8f9","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"8","address":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"4","address":"cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh","pub_key":null,"sequence":"0"},"name":"bonded_tokens_pool","permissions":["burner","staking"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"5","address":"cosmos1tygms3xhhs3yv487phx3dw4a95jn7t7lpm470r","pub_key":null,"sequence":"0"},"name":"not_bonded_tokens_pool","permissions":["burner","staking"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"6","address":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","pub_key":null,"sequence":"0"},"name":"gov","permissions":["burner"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"3","address":"cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl","pub_key":null,"sequence":"0"},"name":"distribution","permissions":[]},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"0","address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","pub_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A3uyZdXedyvYx9VCL6xRjkxtcFpgxjhXFIz9b2mWz+aV"},"sequence":"4"},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"7","address":"cosmos1m3h30wlvsf8llruxtpukdvsy0km2kum8g38c8q","pub_key":null,"sequence":"0"},"name":"mint","permissions":["minter"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"2","address":"cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta","pub_key":null,"sequence":"0"},"name":"fee_collector","permissions":[]}],"params":{"max_memo_characters":"256","sig_verify_cost_ed25519":"590","sig_verify_cost_secp256k1":"1000","tx_sig_limit":"7","tx_size_cost_per_byte":"10"}},"authz":{"authorization":[]},"bank":{"balances":[{"address":"cosmos1qmkksxlxqdslq6kkca25m4jn344nx29lytq8f9","coins":[{"amount":"5000000000","denom":"stake"}]},{"address":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8","coins":[{"amount":"1000","denom":"stake"}]},{"address":"cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh","coins":[{"amount":"1000000","denom":"stake"}]},{"address":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","coins":[{"amount":"10010000","denom":"stake"}]},{"address":"cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl","coins":[{"amount":"9635","denom":"stake"}]},{"address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","coins":[{"amount":"4988989000","denom":"stake"}]}],"denom_metadata":[],"params":{"default_send_enabled":true,"send_enabled":[]},"send_enabled":[],"supply":[{"amount":"10000009635","denom":"stake"}]},"consensus":null,"crisis":{"constant_fee":{"amount":"1000","denom":"stake"}},"distribution":{"delegator_starting_infos":[{"delegator_address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","starting_info":{"height":"0","previous_period":"1","stake":"1000000.000000000000000000"},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"delegator_withdraw_infos":[],"fee_pool":{"community_pool":[{"amount":"192.700000000000000000","denom":"stake"}]},"outstanding_rewards":[{"outstanding_rewards":[{"amount":"9442.300000000000000000","denom":"stake"}],"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"params":{"base_proposer_reward":"0.000000000000000000","bonus_proposer_reward":"0.000000000000000000","community_tax":"0.020000000000000000","withdraw_addr_enabled":true},"previous_proposer":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","validator_accumulated_commissions":[{"accumulated":{"commission":[{"amount":"944.230000000000000000","denom":"stake"}]},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_current_rewards":[{"rewards":{"period":"2","rewards":[{"amount":"8498.070000000000000000","denom":"stake"}]},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_historical_rewards":[{"period":"1","rewards":{"cumulative_reward_ratio":[],"reference_count":2},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_slash_events":[]},"evidence":{"evidence":[]},"feegrant":{"allowances":[]},"genutil":{"gen_txs":[]},"gov":{"deposit_params":null,"deposits":[{"amount":[{"amount":"10010000","denom":"stake"}],"depositor":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","proposal_id":"1"}],"params":{"expedited_min_deposit":[{"amount":"50000000","denom":"stake"}],"expedited_threshold":"0.667000000000000000","expedited_voting_period":"86400s","max_deposit_period":"172800s","min_deposit":[{"amount":"10000000","denom":"stake"}],"min_initial_deposit_ratio":"0.000000000000000000","proposal_cancel_dest":"","proposal_cancel_ratio":"0.500000000000000000","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","voting_period":"172800s"},"proposals":[{"deposit_end_time":"2023-02-22T11:11:52.776167376Z","expedited":false,"final_tally_result":{"abstain_count":"0","no_count":"0","no_with_veto_count":"0","yes_count":"0"},"id":"1","messages":[{"@type":"/cosmos.distribution.v1beta1.MsgCommunityPoolSpend","amount":[],"authority":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","recipient":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8"}],"metadata":"ipfs://CID","proposer":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","status":"PROPOSAL_STATUS_VOTING_PERIOD","submit_time":"2023-02-20T11:11:52.776167376Z","summary":"test proposal","title":"test proposal","total_deposit":[{"amount":"10010000","denom":"stake"}],"voting_end_time":"2023-02-22T11:12:07.801161984Z","voting_start_time":"2023-02-20T11:12:07.801161984Z"}],"starting_proposal_id":"2","tally_params":null,"votes":[],"voting_params":null},"group":{"group_members":[],"group_policies":[],"group_policy_seq":"0","group_seq":"0","groups":[],"proposal_seq":"0","proposals":[],"votes":[]},"mint":{"minter":{"annual_provisions":"1300010905.175073197786747950","inflation":"0.130000967926594565"},"params":{"blocks_per_year":"6311520","goal_bonded":"0.670000000000000000","inflation_max":"0.200000000000000000","inflation_min":"0.070000000000000000","inflation_rate_change":"0.130000000000000000","mint_denom":"stake"}},"nft":{"classes":[],"entries":[]},"params":null,"slashing":{"missed_blocks":[{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","missed_blocks":[]}],"params":{"downtime_jail_duration":"600s","min_signed_per_window":"0.500000000000000000","signed_blocks_window":"100","slash_fraction_double_sign":"0.050000000000000000","slash_fraction_downtime":"0.010000000000000000"},"signing_infos":[{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","validator_signing_info":{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","index_offset":"46","jailed_until":"1970-01-01T00:00:00Z","missed_blocks_counter":"0","start_height":"0","tombstoned":false}}]},"staking":{"delegations":[{"delegator_address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","shares":"1000000.000000000000000000","validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"exported":true,"last_total_power":"1","last_validator_powers":[{"address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp","power":"1"}],"params":{"bond_denom":"stake","historical_entries":10000,"max_entries":7,"max_validators":100,"min_commission_rate":"0.000000000000000000","unbonding_time":"1814400s"},"redelegations":[],"unbonding_delegations":[],"validators":[{"commission":{"commission_rates":{"max_change_rate":"0.010000000000000000","max_rate":"0.200000000000000000","rate":"0.100000000000000000"},"update_time":"2023-02-20T11:08:30.588307671Z"},"consensus_pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"tMZonPQYoooG/xbFVhHg95pTLxx7aO43/qgHFxDagWM="},"delegator_shares":"1000000.000000000000000000","description":{"details":"","identity":"","moniker":"test","security_contact":"","website":""},"jailed":false,"min_self_delegation":"1","operator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp","status":"BOND_STATUS_BONDED","tokens":"1000000","unbonding_height":"0","unbonding_ids":[],"unbonding_on_hold_ref_count":"0","unbonding_time":"1970-01-01T00:00:00Z"}]},"upgrade":{},"vesting":{}},"consensus":{"validators":[{"address":"D336F99AA5CF77503CDD8366E68A0DFE89B4124B","pub_key":{"type":"tendermint/PubKeyEd25519","value":"tMZonPQYoooG/xbFVhHg95pTLxx7aO43/qgHFxDagWM="},"power":"1","name":"test"}],"params":{"block":{"max_bytes":"22020096","max_gas":"-1"},"evidence":{"max_age_num_blocks":"100000","max_age_duration":"172800000000000","max_bytes":"1048576"},"validator":{"pub_key_types":["ed25519"]},"version":{"app":"0"},"synchrony":{"precision":"0","message_delay":"0"},"feature":{"vote_extensions_enable_height":"0","pbts_enable_height":"0"}}}}
\ No newline at end of file
diff --git a/x/genutil/types/genesis.go b/x/genutil/types/genesis.go
index 1566c0affaac..023abfba082c 100644
--- a/x/genutil/types/genesis.go
+++ b/x/genutil/types/genesis.go
@@ -14,6 +14,8 @@ import (
cmtjson "github.com/cometbft/cometbft/libs/json"
cmttypes "github.com/cometbft/cometbft/types"
+ cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
+ sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
)
@@ -118,6 +120,26 @@ func AppGenesisFromReader(reader io.Reader) (*AppGenesis, error) {
return nil, err
}
+ vals := []sdk.GenesisValidator{}
+ for _, cmtVal := range ctmGenesis.Validators {
+ pk, err := cryptocodec.FromCmtPubKeyInterface(cmtVal.PubKey)
+ if err != nil {
+ return nil, err
+ }
+ jsonPk, err := cryptocodec.PubKeyFromProto(pk)
+ if err != nil {
+ return nil, err
+ }
+ val := sdk.GenesisValidator{
+ Address: cmtVal.Address.Bytes(),
+ PubKey: jsonPk,
+ Power: cmtVal.Power,
+ Name: cmtVal.Name,
+ }
+
+ vals = append(vals, val)
+ }
+
ag = AppGenesis{
AppName: version.AppName,
// AppVersion is not filled as we do not know it from a CometBFT genesis
@@ -127,7 +149,7 @@ func AppGenesisFromReader(reader io.Reader) (*AppGenesis, error) {
AppHash: ctmGenesis.AppHash,
AppState: ctmGenesis.AppState,
Consensus: &ConsensusGenesis{
- Validators: ctmGenesis.Validators,
+ Validators: vals,
Params: ctmGenesis.ConsensusParams,
},
}
@@ -160,13 +182,36 @@ func AppGenesisFromFile(genFile string) (*AppGenesis, error) {
// ToGenesisDoc converts the AppGenesis to a CometBFT GenesisDoc.
func (ag *AppGenesis) ToGenesisDoc() (*cmttypes.GenesisDoc, error) {
+ cmtValidators := []cmttypes.GenesisValidator{}
+ for _, val := range ag.Consensus.Validators {
+ pk, err := cryptocodec.PubKeyToProto(val.PubKey)
+ if err != nil {
+ return nil, err
+ }
+ cmtPk, err := cryptocodec.ToCmtPubKeyInterface(pk)
+ if err != nil {
+ return nil, err
+ }
+ cmtVal := cmttypes.GenesisValidator{
+ Address: val.Address.Bytes(),
+ PubKey: cmtPk,
+ Power: val.Power,
+ Name: val.Name,
+ }
+
+ cmtValidators = append(cmtValidators, cmtVal)
+ }
+ // assert nil value for empty validators set
+ if len(cmtValidators) == 0 {
+ cmtValidators = nil
+ }
return &cmttypes.GenesisDoc{
GenesisTime: ag.GenesisTime,
ChainID: ag.ChainID,
InitialHeight: ag.InitialHeight,
AppHash: ag.AppHash,
AppState: ag.AppState,
- Validators: ag.Consensus.Validators,
+ Validators: cmtValidators,
ConsensusParams: ag.Consensus.Params,
}, nil
}
@@ -174,13 +219,13 @@ func (ag *AppGenesis) ToGenesisDoc() (*cmttypes.GenesisDoc, error) {
// ConsensusGenesis defines the consensus layer's genesis.
// TODO(@julienrbrt) eventually abstract from CometBFT types
type ConsensusGenesis struct {
- Validators []cmttypes.GenesisValidator `json:"validators,omitempty"`
- Params *cmttypes.ConsensusParams `json:"params,omitempty"`
+ Validators []sdk.GenesisValidator `json:"validators,omitempty"`
+ Params *cmttypes.ConsensusParams `json:"params,omitempty"`
}
// NewConsensusGenesis returns a ConsensusGenesis with given values.
// It takes a proto consensus params so it can called from server export command.
-func NewConsensusGenesis(params cmtproto.ConsensusParams, validators []cmttypes.GenesisValidator) *ConsensusGenesis {
+func NewConsensusGenesis(params cmtproto.ConsensusParams, validators []sdk.GenesisValidator) *ConsensusGenesis {
return &ConsensusGenesis{
Params: &cmttypes.ConsensusParams{
Block: cmttypes.BlockParams{
@@ -211,7 +256,7 @@ func (cs *ConsensusGenesis) MarshalJSON() ([]byte, error) {
func (cs *ConsensusGenesis) UnmarshalJSON(b []byte) error {
type Alias ConsensusGenesis
- result := Alias{}
+ var result Alias
if err := cmtjson.Unmarshal(b, &result); err != nil {
return err
}
@@ -241,7 +286,7 @@ func (cs *ConsensusGenesis) ValidateAndComplete() error {
return fmt.Errorf("incorrect address for validator %v in the genesis file, should be %v", v, v.PubKey.Address())
}
if len(v.Address) == 0 {
- cs.Validators[i].Address = v.PubKey.Address()
+ cs.Validators[i].Address = v.PubKey.Address().Bytes()
}
}
diff --git a/x/genutil/types/testdata/app_genesis.json b/x/genutil/types/testdata/app_genesis.json
index 57ca37536b6d..20bca1589f76 100644
--- a/x/genutil/types/testdata/app_genesis.json
+++ b/x/genutil/types/testdata/app_genesis.json
@@ -1 +1 @@
-{"app_name":"\u003cappd\u003e","app_version":"","genesis_time":"2023-02-20T11:08:30.588307671Z","chain_id":"demo","initial_height":48,"app_hash":"","app_state":{"auth":{"accounts":[{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"1","address":"cosmos1qmkksxlxqdslq6kkca25m4jn344nx29lytq8f9","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"8","address":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"4","address":"cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh","pub_key":null,"sequence":"0"},"name":"bonded_tokens_pool","permissions":["burner","staking"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"5","address":"cosmos1tygms3xhhs3yv487phx3dw4a95jn7t7lpm470r","pub_key":null,"sequence":"0"},"name":"not_bonded_tokens_pool","permissions":["burner","staking"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"6","address":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","pub_key":null,"sequence":"0"},"name":"gov","permissions":["burner"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"3","address":"cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl","pub_key":null,"sequence":"0"},"name":"distribution","permissions":[]},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"0","address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","pub_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A3uyZdXedyvYx9VCL6xRjkxtcFpgxjhXFIz9b2mWz+aV"},"sequence":"4"},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"7","address":"cosmos1m3h30wlvsf8llruxtpukdvsy0km2kum8g38c8q","pub_key":null,"sequence":"0"},"name":"mint","permissions":["minter"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"2","address":"cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta","pub_key":null,"sequence":"0"},"name":"fee_collector","permissions":[]}],"params":{"max_memo_characters":"256","sig_verify_cost_ed25519":"590","sig_verify_cost_secp256k1":"1000","tx_sig_limit":"7","tx_size_cost_per_byte":"10"}},"authz":{"authorization":[]},"bank":{"balances":[{"address":"cosmos1qmkksxlxqdslq6kkca25m4jn344nx29lytq8f9","coins":[{"amount":"5000000000","denom":"stake"}]},{"address":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8","coins":[{"amount":"1000","denom":"stake"}]},{"address":"cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh","coins":[{"amount":"1000000","denom":"stake"}]},{"address":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","coins":[{"amount":"10010000","denom":"stake"}]},{"address":"cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl","coins":[{"amount":"9635","denom":"stake"}]},{"address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","coins":[{"amount":"4988989000","denom":"stake"}]}],"denom_metadata":[],"params":{"default_send_enabled":true,"send_enabled":[]},"send_enabled":[],"supply":[{"amount":"10000009635","denom":"stake"}]},"consensus":null,"crisis":{"constant_fee":{"amount":"1000","denom":"stake"}},"distribution":{"delegator_starting_infos":[{"delegator_address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","starting_info":{"height":"0","previous_period":"1","stake":"1000000.000000000000000000"},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"delegator_withdraw_infos":[],"fee_pool":{"community_pool":[{"amount":"192.700000000000000000","denom":"stake"}]},"outstanding_rewards":[{"outstanding_rewards":[{"amount":"9442.300000000000000000","denom":"stake"}],"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"params":{"base_proposer_reward":"0.000000000000000000","bonus_proposer_reward":"0.000000000000000000","community_tax":"0.020000000000000000","withdraw_addr_enabled":true},"previous_proposer":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","validator_accumulated_commissions":[{"accumulated":{"commission":[{"amount":"944.230000000000000000","denom":"stake"}]},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_current_rewards":[{"rewards":{"period":"2","rewards":[{"amount":"8498.070000000000000000","denom":"stake"}]},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_historical_rewards":[{"period":"1","rewards":{"cumulative_reward_ratio":[],"reference_count":2},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_slash_events":[]},"evidence":{"evidence":[]},"feegrant":{"allowances":[]},"genutil":{"gen_txs":[]},"gov":{"deposit_params":null,"deposits":[{"amount":[{"amount":"10010000","denom":"stake"}],"depositor":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","proposal_id":"1"}],"params":{"expedited_min_deposit":[{"amount":"50000000","denom":"stake"}],"expedited_threshold":"0.667000000000000000","expedited_voting_period":"86400s","max_deposit_period":"172800s","min_deposit":[{"amount":"10000000","denom":"stake"}],"min_initial_deposit_ratio":"0.000000000000000000","proposal_cancel_dest":"","proposal_cancel_ratio":"0.500000000000000000","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","voting_period":"172800s"},"proposals":[{"deposit_end_time":"2023-02-22T11:11:52.776167376Z","expedited":false,"final_tally_result":{"abstain_count":"0","no_count":"0","no_with_veto_count":"0","yes_count":"0"},"id":"1","messages":[{"@type":"/cosmos.distribution.v1beta1.MsgCommunityPoolSpend","amount":[],"authority":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","recipient":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8"}],"metadata":"ipfs://CID","proposer":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","status":"PROPOSAL_STATUS_VOTING_PERIOD","submit_time":"2023-02-20T11:11:52.776167376Z","summary":"test proposal","title":"test proposal","total_deposit":[{"amount":"10010000","denom":"stake"}],"voting_end_time":"2023-02-22T11:12:07.801161984Z","voting_start_time":"2023-02-20T11:12:07.801161984Z"}],"starting_proposal_id":"2","tally_params":null,"votes":[],"voting_params":null},"group":{"group_members":[],"group_policies":[],"group_policy_seq":"0","group_seq":"0","groups":[],"proposal_seq":"0","proposals":[],"votes":[]},"mint":{"minter":{"annual_provisions":"1300010905.175073197786747950","inflation":"0.130000967926594565"},"params":{"blocks_per_year":"6311520","goal_bonded":"0.670000000000000000","inflation_max":"0.200000000000000000","inflation_min":"0.070000000000000000","inflation_rate_change":"0.130000000000000000","mint_denom":"stake"}},"nft":{"classes":[],"entries":[]},"params":null,"slashing":{"missed_blocks":[{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","missed_blocks":[]}],"params":{"downtime_jail_duration":"600s","min_signed_per_window":"0.500000000000000000","signed_blocks_window":"100","slash_fraction_double_sign":"0.050000000000000000","slash_fraction_downtime":"0.010000000000000000"},"signing_infos":[{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","validator_signing_info":{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","index_offset":"46","jailed_until":"1970-01-01T00:00:00Z","missed_blocks_counter":"0","start_height":"0","tombstoned":false}}]},"staking":{"delegations":[{"delegator_address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","shares":"1000000.000000000000000000","validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"exported":true,"last_total_power":"1","last_validator_powers":[{"address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp","power":"1"}],"params":{"bond_denom":"stake","historical_entries":10000,"max_entries":7,"max_validators":100,"min_commission_rate":"0.000000000000000000","unbonding_time":"1814400s"},"redelegations":[],"unbonding_delegations":[],"validators":[{"commission":{"commission_rates":{"max_change_rate":"0.010000000000000000","max_rate":"0.200000000000000000","rate":"0.100000000000000000"},"update_time":"2023-02-20T11:08:30.588307671Z"},"consensus_pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"tMZonPQYoooG/xbFVhHg95pTLxx7aO43/qgHFxDagWM="},"delegator_shares":"1000000.000000000000000000","description":{"details":"","identity":"","moniker":"test","security_contact":"","website":""},"jailed":false,"min_self_delegation":"1","operator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp","status":"BOND_STATUS_BONDED","tokens":"1000000","unbonding_height":"0","unbonding_ids":[],"unbonding_on_hold_ref_count":"0","unbonding_time":"1970-01-01T00:00:00Z"}]},"upgrade":{},"vesting":{}},"consensus":{"validators":[{"address":"D336F99AA5CF77503CDD8366E68A0DFE89B4124B","pub_key":{"type":"tendermint/PubKeyEd25519","value":"tMZonPQYoooG/xbFVhHg95pTLxx7aO43/qgHFxDagWM="},"power":"1","name":"test"}],"params":{"block":{"max_bytes":"22020096","max_gas":"-1"},"evidence":{"max_age_num_blocks":"100000","max_age_duration":"172800000000000","max_bytes":"1048576"},"validator":{"pub_key_types":["ed25519"]},"version":{"app":"0"},"synchrony":{"precision":"0","message_delay":"0"},"feature":{"vote_extensions_enable_height":"0","pbts_enable_height":"0"}}}}
\ No newline at end of file
+{"app_name":"\u003cappd\u003e","app_version":"","genesis_time":"2023-02-20T11:08:30.588307671Z","chain_id":"demo","initial_height":48,"app_hash":"","app_state":{"auth":{"accounts":[{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"1","address":"cosmos1qmkksxlxqdslq6kkca25m4jn344nx29lytq8f9","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"8","address":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"4","address":"cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh","pub_key":null,"sequence":"0"},"name":"bonded_tokens_pool","permissions":["burner","staking"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"5","address":"cosmos1tygms3xhhs3yv487phx3dw4a95jn7t7lpm470r","pub_key":null,"sequence":"0"},"name":"not_bonded_tokens_pool","permissions":["burner","staking"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"6","address":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","pub_key":null,"sequence":"0"},"name":"gov","permissions":["burner"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"3","address":"cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl","pub_key":null,"sequence":"0"},"name":"distribution","permissions":[]},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"0","address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","pub_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A3uyZdXedyvYx9VCL6xRjkxtcFpgxjhXFIz9b2mWz+aV"},"sequence":"4"},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"7","address":"cosmos1m3h30wlvsf8llruxtpukdvsy0km2kum8g38c8q","pub_key":null,"sequence":"0"},"name":"mint","permissions":["minter"]},{"@type":"/cosmos.auth.v1beta1.ModuleAccount","base_account":{"account_number":"2","address":"cosmos17xpfvakm2amg962yls6f84z3kell8c5lserqta","pub_key":null,"sequence":"0"},"name":"fee_collector","permissions":[]}],"params":{"max_memo_characters":"256","sig_verify_cost_ed25519":"590","sig_verify_cost_secp256k1":"1000","tx_sig_limit":"7","tx_size_cost_per_byte":"10"}},"authz":{"authorization":[]},"bank":{"balances":[{"address":"cosmos1qmkksxlxqdslq6kkca25m4jn344nx29lytq8f9","coins":[{"amount":"5000000000","denom":"stake"}]},{"address":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8","coins":[{"amount":"1000","denom":"stake"}]},{"address":"cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh","coins":[{"amount":"1000000","denom":"stake"}]},{"address":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","coins":[{"amount":"10010000","denom":"stake"}]},{"address":"cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl","coins":[{"amount":"9635","denom":"stake"}]},{"address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","coins":[{"amount":"4988989000","denom":"stake"}]}],"denom_metadata":[],"params":{"default_send_enabled":true,"send_enabled":[]},"send_enabled":[],"supply":[{"amount":"10000009635","denom":"stake"}]},"consensus":null,"crisis":{"constant_fee":{"amount":"1000","denom":"stake"}},"distribution":{"delegator_starting_infos":[{"delegator_address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","starting_info":{"height":"0","previous_period":"1","stake":"1000000.000000000000000000"},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"delegator_withdraw_infos":[],"fee_pool":{"community_pool":[{"amount":"192.700000000000000000","denom":"stake"}]},"outstanding_rewards":[{"outstanding_rewards":[{"amount":"9442.300000000000000000","denom":"stake"}],"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"params":{"base_proposer_reward":"0.000000000000000000","bonus_proposer_reward":"0.000000000000000000","community_tax":"0.020000000000000000","withdraw_addr_enabled":true},"previous_proposer":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","validator_accumulated_commissions":[{"accumulated":{"commission":[{"amount":"944.230000000000000000","denom":"stake"}]},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_current_rewards":[{"rewards":{"period":"2","rewards":[{"amount":"8498.070000000000000000","denom":"stake"}]},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_historical_rewards":[{"period":"1","rewards":{"cumulative_reward_ratio":[],"reference_count":2},"validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"validator_slash_events":[]},"evidence":{"evidence":[]},"feegrant":{"allowances":[]},"genutil":{"gen_txs":[]},"gov":{"deposit_params":null,"deposits":[{"amount":[{"amount":"10010000","denom":"stake"}],"depositor":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","proposal_id":"1"}],"params":{"expedited_min_deposit":[{"amount":"50000000","denom":"stake"}],"expedited_threshold":"0.667000000000000000","expedited_voting_period":"86400s","max_deposit_period":"172800s","min_deposit":[{"amount":"10000000","denom":"stake"}],"min_initial_deposit_ratio":"0.000000000000000000","proposal_cancel_dest":"","proposal_cancel_ratio":"0.500000000000000000","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","voting_period":"172800s"},"proposals":[{"deposit_end_time":"2023-02-22T11:11:52.776167376Z","expedited":false,"final_tally_result":{"abstain_count":"0","no_count":"0","no_with_veto_count":"0","yes_count":"0"},"id":"1","messages":[{"@type":"/cosmos.distribution.v1beta1.MsgCommunityPoolSpend","amount":[],"authority":"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn","recipient":"cosmos1pnt5523etwtzv6mj7haryfw6w8h5tkcuhd99m8"}],"metadata":"ipfs://CID","proposer":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","status":"PROPOSAL_STATUS_VOTING_PERIOD","submit_time":"2023-02-20T11:11:52.776167376Z","summary":"test proposal","title":"test proposal","total_deposit":[{"amount":"10010000","denom":"stake"}],"voting_end_time":"2023-02-22T11:12:07.801161984Z","voting_start_time":"2023-02-20T11:12:07.801161984Z"}],"starting_proposal_id":"2","tally_params":null,"votes":[],"voting_params":null},"group":{"group_members":[],"group_policies":[],"group_policy_seq":"0","group_seq":"0","groups":[],"proposal_seq":"0","proposals":[],"votes":[]},"mint":{"minter":{"annual_provisions":"1300010905.175073197786747950","inflation":"0.130000967926594565"},"params":{"blocks_per_year":"6311520","goal_bonded":"0.670000000000000000","inflation_max":"0.200000000000000000","inflation_min":"0.070000000000000000","inflation_rate_change":"0.130000000000000000","mint_denom":"stake"}},"nft":{"classes":[],"entries":[]},"params":null,"slashing":{"missed_blocks":[{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","missed_blocks":[]}],"params":{"downtime_jail_duration":"600s","min_signed_per_window":"0.500000000000000000","signed_blocks_window":"100","slash_fraction_double_sign":"0.050000000000000000","slash_fraction_downtime":"0.010000000000000000"},"signing_infos":[{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","validator_signing_info":{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","index_offset":"46","jailed_until":"1970-01-01T00:00:00Z","missed_blocks_counter":"0","start_height":"0","tombstoned":false}}]},"staking":{"delegations":[{"delegator_address":"cosmos15jenkldw6348lpgdev3vjzw90zzknxa9a3vg0j","shares":"1000000.000000000000000000","validator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp"}],"exported":true,"last_total_power":"1","last_validator_powers":[{"address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp","power":"1"}],"params":{"bond_denom":"stake","historical_entries":10000,"max_entries":7,"max_validators":100,"min_commission_rate":"0.000000000000000000","unbonding_time":"1814400s"},"redelegations":[],"unbonding_delegations":[],"validators":[{"commission":{"commission_rates":{"max_change_rate":"0.010000000000000000","max_rate":"0.200000000000000000","rate":"0.100000000000000000"},"update_time":"2023-02-20T11:08:30.588307671Z"},"consensus_pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"tMZonPQYoooG/xbFVhHg95pTLxx7aO43/qgHFxDagWM="},"delegator_shares":"1000000.000000000000000000","description":{"details":"","identity":"","moniker":"test","security_contact":"","website":""},"jailed":false,"min_self_delegation":"1","operator_address":"cosmosvaloper15jenkldw6348lpgdev3vjzw90zzknxa9c9carp","status":"BOND_STATUS_BONDED","tokens":"1000000","unbonding_height":"0","unbonding_ids":[],"unbonding_on_hold_ref_count":"0","unbonding_time":"1970-01-01T00:00:00Z"}]},"upgrade":{},"vesting":{}},"consensus":{"validators":[{"address":"cosmosvalcons16vm0nx49eam4q0xasdnwdzsdl6ymgyjt757sgr","pub_key":{"type":"tendermint/PubKeyEd25519","value":"tMZonPQYoooG/xbFVhHg95pTLxx7aO43/qgHFxDagWM="},"power":"1","name":"test"}],"params":{"block":{"max_bytes":"22020096","max_gas":"-1"},"evidence":{"max_age_num_blocks":"100000","max_age_duration":"172800000000000","max_bytes":"1048576"},"validator":{"pub_key_types":["ed25519"]},"version":{"app":"0"},"synchrony":{"precision":"0","message_delay":"0"},"feature":{"vote_extensions_enable_height":"0","pbts_enable_height":"0"}}}}
\ No newline at end of file
diff --git a/x/genutil/utils.go b/x/genutil/utils.go
index b20b7bfa6ec8..ee7d11e39e80 100644
--- a/x/genutil/utils.go
+++ b/x/genutil/utils.go
@@ -14,11 +14,11 @@ import (
tmed25519 "github.com/cometbft/cometbft/crypto/ed25519"
"github.com/cometbft/cometbft/p2p"
"github.com/cometbft/cometbft/privval"
- cmttypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/go-bip39"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
+ sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
)
@@ -35,7 +35,7 @@ func ExportGenesisFile(genesis *types.AppGenesis, genFile string) error {
// ExportGenesisFileWithTime creates and writes the genesis configuration to disk.
// An error is returned if building or writing the configuration to file fails.
func ExportGenesisFileWithTime(
- genFile, chainID string, validators []cmttypes.GenesisValidator, appState json.RawMessage, genTime time.Time,
+ genFile, chainID string, validators []sdk.GenesisValidator, appState json.RawMessage, genTime time.Time,
) error {
appGenesis := types.NewAppGenesisWithVersion(chainID, appState)
appGenesis.GenesisTime = genTime
diff --git a/x/genutil/v2/cli/export.go b/x/genutil/v2/cli/export.go
index 318ad58d8a47..9b0d992bad0a 100644
--- a/x/genutil/v2/cli/export.go
+++ b/x/genutil/v2/cli/export.go
@@ -76,6 +76,7 @@ func ExportCmd(appExporter v2.AppExporter) *cobra.Command {
appGenesis.AppState = exported.AppState
appGenesis.InitialHeight = exported.Height
+ appGenesis.Consensus.Validators = exported.Validators
out, err := json.Marshal(appGenesis)
if err != nil {
diff --git a/x/genutil/v2/types.go b/x/genutil/v2/types.go
index 3199a5a5afb4..fbf288365a57 100644
--- a/x/genutil/v2/types.go
+++ b/x/genutil/v2/types.go
@@ -3,6 +3,8 @@ package v2
import (
"context"
"encoding/json"
+
+ sdk "github.com/cosmos/cosmos-sdk/types"
)
// AppExporter is a function that dumps all app state to
@@ -20,4 +22,6 @@ type ExportedApp struct {
AppState json.RawMessage
// Height is the app's latest block height.
Height int64
+ // Validators is the exported validator set.
+ Validators []sdk.GenesisValidator
}
diff --git a/x/gov/README.md b/x/gov/README.md
index cda1af118b6c..543639749f8a 100644
--- a/x/gov/README.md
+++ b/x/gov/README.md
@@ -37,8 +37,6 @@ staking token of the chain.
* [Parameters and base types](#parameters-and-base-types)
* [Deposit](#deposit-1)
* [ValidatorGovInfo](#validatorgovinfo)
- * [Stores](#stores)
- * [Proposal Processing Queue](#proposal-processing-queue)
* [Legacy Proposal](#legacy-proposal)
* [Messages](#messages)
* [Proposal Submission](#proposal-submission-1)
diff --git a/x/gov/go.mod b/x/gov/go.mod
index f86ae5dcf8c6..03f041b7968a 100644
--- a/x/gov/go.mod
+++ b/x/gov/go.mod
@@ -29,12 +29,12 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@@ -125,7 +125,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -152,14 +152,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/x/gov/go.sum b/x/gov/go.sum
index 46e0295dc4b6..a1587575f635 100644
--- a/x/gov/go.sum
+++ b/x/gov/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -410,8 +410,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -519,8 +519,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -603,19 +603,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -675,8 +675,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/group/client/cli/tx.go b/x/group/client/cli/tx.go
index 9054767ff142..ab7915feb865 100644
--- a/x/group/client/cli/tx.go
+++ b/x/group/client/cli/tx.go
@@ -534,7 +534,7 @@ metadata example:
},
}
- cmd.Flags().String(FlagExec, "", "Set to 1 to try to execute proposal immediately after creation (proposers signatures are considered as Yes votes)")
+ cmd.Flags().String(FlagExec, "", "Set to 1 or 'try' to try to execute proposal immediately after creation (proposers signatures are considered as Yes votes)")
flags.AddTxFlagsToCmd(cmd)
return cmd
diff --git a/x/group/client/cli/util.go b/x/group/client/cli/util.go
index 162a7addd310..53772e11ab46 100644
--- a/x/group/client/cli/util.go
+++ b/x/group/client/cli/util.go
@@ -55,7 +55,7 @@ func parseMembers(membersFile string) ([]group.MemberRequest, error) {
func execFromString(execStr string) group.Exec {
exec := group.Exec_EXEC_UNSPECIFIED
- if execStr == ExecTry {
+ if execStr == ExecTry || execStr == "1" {
exec = group.Exec_EXEC_TRY
}
diff --git a/x/group/go.mod b/x/group/go.mod
index 6f83519f4085..654c56b7d399 100644
--- a/x/group/go.mod
+++ b/x/group/go.mod
@@ -30,13 +30,13 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
pgregory.net/rapid v1.1.0
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 // indirect
@@ -131,7 +131,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -159,14 +159,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/x/group/go.sum b/x/group/go.sum
index dbc625fc5f52..43aac4657e87 100644
--- a/x/group/go.sum
+++ b/x/group/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -412,8 +412,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -521,8 +521,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -605,19 +605,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -677,8 +677,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/group/internal/orm/prefixstore/prefixstore.go b/x/group/internal/orm/prefixstore/prefixstore.go
index 5ac697756260..a121baf464d6 100644
--- a/x/group/internal/orm/prefixstore/prefixstore.go
+++ b/x/group/internal/orm/prefixstore/prefixstore.go
@@ -21,7 +21,7 @@ func New(store store.KVStore, prefix []byte) store.KVStore {
var _ store.KVStore = Store{}
-// Store is similar with cometbft/cometbft/libs/db/prefix_db
+// Store is similar with cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
// both gives access only to the limited subset of the store
// for convenience or safety
type Store struct {
@@ -63,7 +63,7 @@ func (s Store) Set(key, value []byte) error {
func (s Store) Delete(key []byte) error { return s.parent.Delete(s.key(key)) }
// Implements KVStore
-// Check https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db.go#L106
+// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L109
func (s Store) Iterator(start, end []byte) (store.Iterator, error) {
newstart := cloneAppend(s.prefix, start)
@@ -83,7 +83,7 @@ func (s Store) Iterator(start, end []byte) (store.Iterator, error) {
}
// ReverseIterator implements KVStore
-// Check https://github.com/cometbft/cometbft/blob/master/libs/db/prefix_db.go#L129
+// Check https://github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go#L132
func (s Store) ReverseIterator(start, end []byte) (store.Iterator, error) {
newstart := cloneAppend(s.prefix, start)
@@ -180,7 +180,7 @@ func (pi *prefixIterator) Error() error {
return nil
}
-// copied from github.com/cometbft/cometbft/libs/db/prefix_db.go
+// copied from github.com/cometbft/cometbft-db/blob/v1.0.1/prefixdb.go
func stripPrefix(key, prefix []byte) []byte {
if len(key) < len(prefix) || !bytes.Equal(key[:len(prefix)], prefix) {
panic("should not happen")
diff --git a/x/mint/README.md b/x/mint/README.md
index 5a885208eca1..db344931392c 100644
--- a/x/mint/README.md
+++ b/x/mint/README.md
@@ -8,20 +8,24 @@ sidebar_position: 1
* [Concepts](#concepts)
* [The Minting Mechanism](#the-minting-mechanism)
+ * [Inflation](#inflation)
* [Provisions](#provisions)
* [Relation to Inflation](#relation-to-inflation)
- * [Usage per Block](#usage-per-block)
+ * [Usage per Block](#usage-per-block-default-function)
* [Example](#example)
+ * [Bonding](#bonding)
* [State](#state)
* [Minter](#minter)
* [Params](#params)
-* [Epoch minting](#epoch-minting)
+* [Minting Methods](#minting-methods)
+ * [Epoch-based Minting](#epoch-based-minting)
+ * [Block-based Minting](#block-based-minting)
* [MintFn](#mintfn)
-* [Block based minting](#block-based-minting)
* [Default configuration](#default-configuration)
- * [NextInflationRate](#nextinflationrate)
- * [NextAnnualProvisions](#nextannualprovisions)
- * [BlockProvision](#blockprovision)
+ * [Calculations](#calculations)
+ * [NextInflationRate](#inflation-rate-calculation)
+ * [NextAnnualProvisions](#nextannualprovisions)
+ * [BlockProvision](#blockprovision)
* [Parameters](#parameters)
* [Events](#events)
* [BeginBlocker](#beginblocker)
@@ -34,26 +38,33 @@ sidebar_position: 1
### The Minting Mechanism
-The minting mechanism was designed to:
+The minting mechanism in the x/mint module has been redesigned to offer more flexibility. The `InflationCalculationFn` has been deprecated in favor of `MintFn`, that can be customized by the application developer. The `MintFn` function is passed to the `NewAppModule` function and is used to mint tokens on the configured epoch beginning. This change allows users to define their own minting logic and removes any assumptions on how tokens are minted.
-* allow for a flexible inflation rate determined by market demand targeting a particular bonded-stake ratio
-* effect a balance between market liquidity and staked supply
+Key features of the new minting mechanism:
-In order to best determine the appropriate market rate for inflation rewards, a
-moving change rate is used. The moving change rate mechanism ensures that if
-the % bonded is either over or under the goal %-bonded, the inflation rate will
-adjust to further incentivize or disincentivize being bonded, respectively. Setting the goal
-%-bonded at less than 100% encourages the network to maintain some non-staked tokens
-which should help provide some liquidity.
+1. **Customizable Minting Function**: The `MintFn` can be defined by the application to implement any desired minting logic.
+2. **Default Implementation**: If no custom function is provided, a default minting function is used.
+3. **Epoch-based or Block-based Minting**: The mechanism supports both epoch-based and block-based minting, depending on how the `MintFn` is implemented.
+4. **Flexible Inflation**: The inflation rate can be adjusted based on various parameters, not just the bonded ratio.
-It can be broken down in the following way:
+The default minting function, if no custom one is provided, is implemented in the `DefaultMintFn`.
+This function is called during the `BeginBlocker` and is responsible for minting new tokens, implementation details can be found [here](#default-configuration).
-* If the actual percentage of bonded tokens is below the goal %-bonded the inflation rate will
- increase until a maximum value is reached
-* If the goal % bonded (67% in Cosmos-Hub) is maintained, then the inflation
- rate will stay constant
-* If the actual percentage of bonded tokens is above the goal %-bonded the inflation rate will
- decrease until a minimum value is reached
+### Inflation
+
+Inflation is a key concept in the x/mint module, responsible for the creation of new tokens over time. The inflation rate determines how quickly the total supply of tokens increases.
+
+Key aspects of inflation in the x/mint module:
+
+1. **Dynamic Inflation**: The inflation rate can change over time based on various factors, primarily the bonded ratio.
+2. **Bounded Inflation**: The inflation rate is typically constrained between a minimum and maximum value to prevent extreme fluctuations.
+3. **Inflation Calculation**: The specific method of calculating inflation can be customized using the `MintFn`, allowing for flexible monetary policies.
+
+In the default implementation, inflation is calculated as follows:
+
+```plaintext
+Inflation = CurrentInflation + (1 - BondedRatio / GoalBonded) * (InflationRateChange / BlocksPerYear)
+```
### Provisions
@@ -63,7 +74,7 @@ Provisions are the number of tokens generated and distributed in each block. The
The inflation rate determines the percentage of the total supply of tokens that will be added as provisions over a year. These annual provisions are divided by the number of blocks in a year to obtain the provisions per block.
-#### Usage per Block
+#### Usage per Block (default function)
Each block uses a fraction of the annual provisions, calculated as:
@@ -74,7 +85,7 @@ Provisions per block = Annual provisions / Number of blocks per year
These provisions are distributed to validators and delegators as rewards for their participation in the network.
-#### Example
+##### Example
For example, if the total supply of tokens is 1,000,000 and the inflation rate is 10%, the annual provisions would be:
@@ -83,21 +94,17 @@ Annual provisions = 1,000,000 * 0.10 = 100,000 tokens
If there are 3,153,600 blocks per year (one block every 10 seconds), the provisions per block would be:
Provisions per block = 100,000 / 3,153,600 ≈ 0.0317 tokens per block.
-These provisions are then distributed to validators and delegators as rewards.
+These provisions are then passed to the fee collector.
-```mermaid
-flowchart TD
- A[Start] --> B[Get Total Supply]
- B --> C[Get Inflation Rate]
- C --> D[Calculate Annual Provisions]
- D --> E[Calculate Provisions per Block]
- E --> F[Distribute Provisions to Validators and Delegators]
-
- subgraph Calculation
- D --> |Annual Provisions = Total Supply * Inflation Rate| D
- E --> |Provisions per Block = Annual Provisions / Number of Blocks per Year| E
- end
-```
+### Bonding
+
+Bonding refers to the process of staking tokens in the network, which plays a crucial role in the Proof of Stake consensus mechanism and affects the minting process.
+
+Key aspects of bonding in relation to the x/mint module:
+
+1. **Bonded Ratio**: This is the proportion of the total token supply that is currently staked (bonded) in the network.
+2. **Goal Bonded Ratio**: A target percentage of tokens that should ideally be bonded, defined in the module parameters.
+3. **Inflation Adjustment**: The bonded ratio is used to adjust the inflation rate, encouraging or discouraging bonding as needed to maintain network security and token liquidity.
## State
@@ -109,7 +116,7 @@ related to minting (in the `data` field)
* Minter: `0x00 -> ProtocolBuffer(minter)`
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/mint/proto/cosmos/mint/v1beta1/mint.proto#L11-L29
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/mint/proto/cosmos/mint/v1beta1/mint.proto#L11-L29
```
### Params
@@ -122,23 +129,19 @@ A value of `0` indicates an unlimited supply.
* Params: `mint/params -> legacy_amino(params)`
```protobuf reference
-https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/mint/proto/cosmos/mint/v1beta1/mint.proto#L31-L73
+https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/x/mint/proto/cosmos/mint/v1beta1/mint.proto#L31-L73
```
-## Epoch minting
+## Minting Methods
-In the latest release of x/mint, the minting logic has been refactored to allow for more flexibility in the minting process. The `InflationCalculationFn` has been deprecated in favor of `MintFn`. The `MintFn` function is passed to the `NewAppModule` function and is used to mint tokens on the configured epoch beginning. This change allows users to define their own minting logic and removes any assumptions on how tokens are minted.
+### Epoch-based Minting
-```mermaid
-flowchart LR
- A[BeforeEpochStart] --> B[MintFn]
+Epoch-based minting allows for tokens to be minted at specific intervals or epochs, rather than on every block.
+To implement epoch-based minting, the `MintFn` should be designed to mint tokens only when a specific epoch ID is received. The epoch ID and number are passed as parameters to the `MintFn`.
- subgraph B["MintFn (user defined)"]
- direction LR
- C[Get x/staking info] --> D[Calculate Inflation]
- D --> E[Mint Tokens]
- end
-```
+### Block-based Minting
+
+In addition to minting based on epoch, minting based on block is also possible. This is achieved through calling the `MintFn` in `BeginBlock` with an epochID and epochNumber of `"block"` and `-1`, respectively.
### MintFn
@@ -154,16 +157,49 @@ How this function mints tokens is defined by the app developers, meaning they ca
Note that BeginBlock will keep calling the MintFn for every block, so it is important to ensure that MintFn returns early if the epoch ID does not match the expected one.
:::
+### Default configuration
-## Block based minting
+If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`.
-In addition to minting based on epoch, minting based on block is also possible. This is achieved through calling the `MintFn` in `BeginBlock` with an epochID and epochNumber of `"block"` and `-1`, respectively.
+The next diagram shows how the `DefaultMintFn` works:
-### Default configuration
+```mermaid
+flowchart TD
+ A[BeforeEpochStart] --> B[MintFn]
+ B --> C{epochId == 'block'?}
+ C -->|No| D[Return without minting]
+ C -->|Yes| E[Get StakingTokenSupply]
+ E --> F[Get BondedRatio]
+ F --> G[Get Parameters]
+ G --> H[Calculate Inflation]
+ H --> I[Calculate Annual Provisions]
+ I --> J[Calculate Block Provision]
+ J --> K{MaxSupply > 0?}
+ K -->|No| M[Mint coins]
+ K -->|Yes| L{TotalSupply + MintedCoins > MaxSupply?}
+ L -->|No| M
+ L -->|Yes| N[Adjust minting amount]
+ N --> O{Difference > 0?}
+ O -->|No| P[Do not mint]
+ O -->|Yes| M
+ M --> Q[Send minted coins to FeeCollector]
+ Q --> R[Emit events]
+ R --> S[End]
+
+ subgraph Calculations
+ H --> |Uses InflationCalculationFn| H
+ I --> |AnnualProvisions = TotalSupply * Inflation| I
+ J --> |BlockProvision = AnnualProvisions / BlocksPerYear| J
+ end
-If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`.
+ subgraph MaxSupply Adjustment
+ N --> |MintedCoins = MaxSupply - TotalSupply| N
+ end
+```
-### Inflation rate calculation
+### Calculations
+
+#### Inflation rate calculation
Inflation rate is calculated using an "inflation calculation function" that's
passed to the `NewAppModule` function. If no function is passed, then the SDK's
@@ -200,7 +236,7 @@ NextInflationRate(params Params, bondedRatio math.LegacyDec) (inflation math.Leg
}
```
-### NextAnnualProvisions
+#### NextAnnualProvisions
Calculate the annual provisions based on current total supply and inflation
rate. This parameter is calculated once per block.
@@ -208,9 +244,10 @@ rate. This parameter is calculated once per block.
```go
NextAnnualProvisions(params Params, totalSupply math.LegacyDec) (provisions math.LegacyDec) {
return Inflation * totalSupply
+}
```
-### BlockProvision
+#### BlockProvision
Calculate the provisions generated for each block based on current annual provisions. The provisions are then minted by the `mint` module's `ModuleMinterAccount` and then transferred to the `auth`'s `FeeCollector` `ModuleAccount`.
@@ -315,6 +352,12 @@ simd query mint params [flags]
Example:
+```shell
+simd query mint params
+```
+
+Example Output:
+
```yml
blocks_per_year: "4360000"
goal_bonded: "0.670000000000000000"
@@ -325,6 +368,28 @@ mint_denom: stake
max_supply: "0"
```
+#### Transactions
+
+The `tx` commands allow users to interact with the `mint` module.
+
+```shell
+simd tx mint --help
+```
+
+##### update-params-proposal
+
+The `update-params-proposal` command allows users to submit a proposal to update the mint module parameters (Note: the entire params must be provided).
+
+```shell
+simd tx mint update-params-proposal [flags]
+```
+
+Example:
+
+```shell
+simd tx mint update-params-proposal '{ "mint_denom": "stake" }'
+```
+
### gRPC
A user can query the `mint` module using gRPC endpoints.
diff --git a/x/mint/go.mod b/x/mint/go.mod
index b0343d16ef05..bd80104b5fc8 100644
--- a/x/mint/go.mod
+++ b/x/mint/go.mod
@@ -27,8 +27,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
@@ -117,7 +117,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -146,18 +146,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
pgregory.net/rapid v1.1.0 // indirect
diff --git a/x/mint/go.sum b/x/mint/go.sum
index c9df997e10ec..8fd99b8608ea 100644
--- a/x/mint/go.sum
+++ b/x/mint/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -404,8 +404,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -513,8 +513,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -595,19 +595,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -667,8 +667,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/nft/go.mod b/x/nft/go.mod
index baca50bed955..bf1eb272e33d 100644
--- a/x/nft/go.mod
+++ b/x/nft/go.mod
@@ -22,8 +22,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
@@ -119,7 +119,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -148,18 +148,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/x/nft/go.sum b/x/nft/go.sum
index c9df997e10ec..8fd99b8608ea 100644
--- a/x/nft/go.sum
+++ b/x/nft/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -404,8 +404,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -513,8 +513,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -595,19 +595,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -667,8 +667,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/params/go.mod b/x/params/go.mod
index f072f3b0256b..006af90f591d 100644
--- a/x/params/go.mod
+++ b/x/params/go.mod
@@ -26,8 +26,8 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
@@ -113,7 +113,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -140,18 +140,18 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
- google.golang.org/protobuf v1.34.2 // indirect
+ google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
diff --git a/x/params/go.sum b/x/params/go.sum
index 048c9a1067ea..bfa925d6aff0 100644
--- a/x/params/go.sum
+++ b/x/params/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -380,8 +380,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -487,8 +487,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -568,19 +568,19 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -640,8 +640,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod
index 5454bc67d0dd..dbbb158bb411 100644
--- a/x/protocolpool/go.mod
+++ b/x/protocolpool/go.mod
@@ -20,12 +20,12 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
@@ -120,7 +120,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -149,14 +149,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/x/protocolpool/go.sum b/x/protocolpool/go.sum
index c9df997e10ec..8fd99b8608ea 100644
--- a/x/protocolpool/go.sum
+++ b/x/protocolpool/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -404,8 +404,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -513,8 +513,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -595,19 +595,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -667,8 +667,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/slashing/go.mod b/x/slashing/go.mod
index c207b1c5317b..b5537caa655e 100644
--- a/x/slashing/go.mod
+++ b/x/slashing/go.mod
@@ -22,13 +22,13 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/log v1.4.1 // indirect
cosmossdk.io/schema v0.3.1-0.20240930054013-7c6e0388a3f9 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
@@ -122,7 +122,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -151,14 +151,14 @@ require (
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
diff --git a/x/slashing/go.sum b/x/slashing/go.sum
index 9600563cd537..9a22246ddee4 100644
--- a/x/slashing/go.sum
+++ b/x/slashing/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
@@ -406,8 +406,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -515,8 +515,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -597,19 +597,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -669,8 +669,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/staking/README.md b/x/staking/README.md
index 9e302bfba913..e09065481d86 100644
--- a/x/staking/README.md
+++ b/x/staking/README.md
@@ -69,20 +69,20 @@ Pool is used for tracking bonded and not-bonded token supply of the bond denomin
LastTotalPower tracks the total amounts of bonded tokens recorded during the previous end block.
Store entries prefixed with "Last" must remain unchanged until EndBlock.
-* LastTotalPower: `0x12 -> ProtocolBuffer(math.Int)`
+* LastTotalPower: `collections.NewPrefix(18)`
### UnbondingID
UnbondingID stores the ID of the latest unbonding operation. It enables creating unique IDs for unbonding operations, i.e., UnbondingID is incremented every time a new unbonding operation (validator unbonding, unbonding delegation, redelegation) is initiated.
-* UnbondingID: `0x37 -> uint64`
+* UnbondingID: `55`
### Params
The staking module stores its params in state with the prefix of `0x51`,
it can be updated with governance or the address with authority.
-* Params: `0x51 | ProtocolBuffer(Params)`
+* Params: `81`
```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/staking/proto/cosmos/staking/v1beta1/staking.proto#L300-L328
@@ -117,18 +117,18 @@ required lookups for slashing and validator-set updates. A third special index
throughout each block, unlike the first two indices which mirror the validator
records within a block.
-* Validators: `0x21 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(validator)`
-* ValidatorsByConsAddr: `0x22 | ConsAddrLen (1 byte) | ConsAddr -> OperatorAddr`
-* ValidatorsByPower: `0x23 | BigEndian(ConsensusPower) | OperatorAddrLen (1 byte) | OperatorAddr -> OperatorAddr`
-* LastValidatorsPower: `0x11 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(ConsensusPower)`
-* ValidatorsByUnbondingID: `0x38 | UnbondingID -> 0x21 | OperatorAddrLen (1 byte) | OperatorAddr`
+* Validators: `33 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(validator)`
+* ValidatorsByConsAddr: `34 | ConsAddrLen (1 byte) | ConsAddr -> OperatorAddr`
+* ValidatorsByPower: `23 | BigEndian(ConsensusPower) | OperatorAddrLen (1 byte) | OperatorAddr -> OperatorAddr`
+* LastValidatorsPower: `17 | OperatorAddrLen (1 byte) | OperatorAddr -> ProtocolBuffer(ConsensusPower)`
+* UnbondingIndex: `56 | UnbondingID -> 21 | OperatorAddrLen (1 byte) | OperatorAddr`
`Validators` is the primary index - it ensures that each operator can have only one
associated validator, where the public key of that validator can change in the
future. Delegators can refer to the immutable operator of the validator, without
concern for the changing public key.
-`ValidatorsByUnbondingID` is an additional index that enables lookups for
+`UnbondingIndex` is an additional index that enables lookups for
validators by the unbonding IDs corresponding to their current unbonding.
`ValidatorByConsAddr` is an additional index that enables lookups for slashing.
@@ -161,9 +161,9 @@ https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/staking/proto/cosmos
### Delegation
Delegations are identified by combining `DelegatorAddr` (the address of the delegator)
-with the `ValidatorAddr` Delegators are indexed in the store as follows:
+with the `ValidatorAddr`. Delegators are indexed in the store as follows:
-* Delegation: `0x31 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(delegation)`
+* Delegation: `49 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(delegation)`
Stake holders may delegate coins to validators; under this circumstance their
funds are held in a `Delegation` data structure. It is owned by one
@@ -183,7 +183,7 @@ validator and the number of shares issued so far:
`Shares per Token = validator.TotalShares() / validator.Tokens()`
Only the number of shares received is stored on the DelegationEntry. When a delegator then
-Undelegates, the token amount they receive is calculated from the number of shares they currently
+undelegates, the token amount they receive is calculated from the number of shares they currently
hold and the inverse exchange rate:
`Tokens per Share = validator.Tokens() / validatorShares()`
@@ -201,17 +201,17 @@ detected.
`UnbondingDelegation` are indexed in the store as:
-* UnbondingDelegation: `0x32 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(unbondingDelegation)`
-* UnbondingDelegationsFromValidator: `0x33 | ValidatorAddrLen (1 byte) | ValidatorAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
-* UnbondingDelegationByUnbondingId: `0x38 | UnbondingId -> 0x32 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr`
+* UnbondingDelegation: `50 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr -> ProtocolBuffer(unbondingDelegation)`
+* UnbondingDelegationByValIndex: `51 | ValidatorAddrLen (1 byte) | ValidatorAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
+* UnbondingIndex: `56 | UnbondingId -> 0x32 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorAddr`
`UnbondingDelegation` is used in queries, to lookup all unbonding delegations for
a given delegator.
-`UnbondingDelegationsFromValidator` is used in slashing, to lookup all
+`UnbondingDelegationByValIndex` is used in slashing, to lookup all
unbonding delegations associated with a given validator that need to be
slashed.
- `UnbondingDelegationByUnbondingId` is an additional index that enables
+ `UnbondingIndex` is an additional index that enables
lookups for unbonding delegations by the unbonding IDs of the containing
unbonding delegation entries.
@@ -232,23 +232,23 @@ committed by the source validator.
`Redelegation` are indexed in the store as:
-* Redelegations: `0x34 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddr -> ProtocolBuffer(redelegation)`
-* RedelegationsBySrc: `0x35 | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
-* RedelegationsByDst: `0x36 | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
-* RedelegationByUnbondingId: `0x38 | UnbondingId -> 0x34 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddr`
+* Redelegations: `52 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr -> ProtocolBuffer(redelegation)`
+* RedelegationsByValSrc: `53 | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
+* RedelegationsByValDst: `54 | ValidatorDstAddrLen (1 byte) | ValidatorDstAddr | ValidatorSrcAddrLen (1 byte) | ValidatorSrcAddr | DelegatorAddrLen (1 byte) | DelegatorAddr -> nil`
+* RedelegationByUnbondingId: `56 | UnbondingId -> 0x34 | DelegatorAddrLen (1 byte) | DelegatorAddr | ValidatorAddrLen (1 byte) | ValidatorSrcAddr | ValidatorDstAddr`
`Redelegations` is used for queries, to lookup all redelegations for a given
delegator.
- `RedelegationsBySrc` is used for slashing based on the `ValidatorSrcAddr`.
+ `RedelegationsByValSrc` is used for slashing based on the `ValidatorSrcAddr`.
- `RedelegationsByDst` is used for slashing based on the `ValidatorDstAddr`
+ `RedelegationsByValDst` is used for slashing based on the `ValidatorDstAddr`
The first map here is used for queries, to lookup all redelegations for a given
delegator. The second map is used for slashing based on the `ValidatorSrcAddr`,
while the third map is for slashing based on the `ValidatorDstAddr`.
-`RedelegationByUnbondingId` is an additional index that enables
+`UnbondingIndex` is an additional index that enables
lookups for redelegations by the unbonding IDs of the containing
redelegation entries.
@@ -317,7 +317,7 @@ element.
For the purpose of tracking progress of unbonding delegations the unbonding
delegations queue is kept.
-* UnbondingDelegation: `0x41 | format(time) -> []DVPair`
+* UnbondingQueue: `65 | format(time) -> []DVPair`
```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/staking/proto/cosmos/staking/v1beta1/staking.proto#L159-L173
@@ -328,7 +328,7 @@ https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/staking/proto/cosmos
For the purpose of tracking progress of redelegations the redelegation queue is
kept.
-* RedelegationQueue: `0x42 | format(time) -> []DVVTriplet`
+* RedelegationQueue: `66 | format(time) -> []DVVTriplet`
```protobuf reference
https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/staking/proto/cosmos/staking/v1beta1/staking.proto#L175-L191
@@ -339,7 +339,7 @@ https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/staking/proto/cosmos
For the purpose of tracking progress of unbonding validators the validator
queue is kept.
-* ValidatorQueueTime: `0x43 | format(time) -> []sdk.ValAddress`
+* ValidatorQueue: `67 | format(time) -> []sdk.ValAddress`
The stored object by each key is an array of validator operator addresses from
which the validator object can be accessed. Typically it is expected that only
@@ -348,7 +348,7 @@ that multiple validators exist in the queue at the same location.
#### ValidatorConsensusKeyRotationRecordQueueKey
-For the purpose of tracking progress or consensus pubkey rotations the `ValidatorConsensusKeyRotationRecordQueueKey` kept.
+For the purpose of tracking progress of consensus pubkey rotations, the `ValidatorConsensusKeyRotationRecordQueueKey` is kept.
* ValidatorConsensusKeyRotationRecordQueueKey: `103 | format(time) -> types.ValAddrsOfRotatedConsKeys`
@@ -361,9 +361,6 @@ the present store info and append the `ValAddress` to the array and set it back
https://github.com/cosmos/cosmos-sdk/blob/release/v0.52.x/x/staking/proto/cosmos/staking/v1beta1/staking.proto#L420-L424
```
-
-
-
## State Transitions
### Validators
@@ -401,7 +398,7 @@ When a validator begins the unbonding process the following operations occur:
#### Unbonding to Unbonded
A validator moves from unbonding to unbonded when the `ValidatorQueue` object
-moves from bonded to unbonded
+moves from bonded to unbonded.
* update the `Validator` object for this validator
* set `validator.Status` to `Unbonded`
@@ -423,7 +420,7 @@ Jailed validators are not present in any of the following stores:
#### Delegate
-When a delegation occurs both the validator and the delegation objects are affected
+When a delegation occurs both the validator and the delegation objects are affected.
* determine the delegators shares based on tokens delegated and the validator's exchange rate
* remove tokens from the sending account
@@ -894,10 +891,12 @@ following hooks can registered with staking:
* called when a delegation is created
* `BeforeDelegationSharesModified(Context, AccAddress, ValAddress) error`
* called when a delegation's shares are modified
-* `AfterDelegationModified(Context, AccAddress, ValAddress) error`
- * called when a delegation is created or modified
* `BeforeDelegationRemoved(Context, AccAddress, ValAddress) error`
* called when a delegation is removed
+* `AfterDelegationModified(Context, AccAddress, ValAddress) error`
+ * called when a delegation is created or modified
+* `BeforeValidatorSlashed(Context, sdk.ValAddress, math.LegacyDec) error`
+ * called when a validator is slashed
* `AfterUnbondingInitiated(Context, UnbondingID)`
* called when an unbonding operation (validator unbonding, unbonding delegation, redelegation) was initiated
* `AfterConsensusPubKeyUpdate(ctx Context, oldpubkey, newpubkey types.PubKey, fee sdk.Coin)`
@@ -916,11 +915,9 @@ The staking module emits the following events:
| complete_unbonding | validator | {validatorAddress} |
| complete_unbonding | delegator | {delegatorAddress} |
| complete_redelegation | amount | {totalRedelegationAmount} |
+| complete_redelegation | delegator | {delegatorAddress} |
| complete_redelegation | source_validator | {srcValidatorAddress} |
| complete_redelegation | destination_validator | {dstValidatorAddress} |
-| complete_redelegation | delegator | {delegatorAddress} |
-
-## Msg's
### MsgCreateValidator
@@ -947,7 +944,9 @@ The staking module emits the following events:
| Type | Attribute Key | Attribute Value |
| -------- | ------------- | ------------------ |
| delegate | validator | {validatorAddress} |
+| delegate | delegator | {delegatorAddress} |
| delegate | amount | {delegationAmount} |
+| delegate | new_shares | {newShares} |
| message | module | staking |
| message | action | delegate |
| message | sender | {senderAddress} |
@@ -957,6 +956,7 @@ The staking module emits the following events:
| Type | Attribute Key | Attribute Value |
| ------- | ------------------- | ------------------ |
| unbond | validator | {validatorAddress} |
+| unbond | delegator | {delegatorAddress} |
| unbond | amount | {unbondAmount} |
| unbond | completion_time [0] | {completionTime} |
| message | module | staking |
diff --git a/x/staking/genesis.go b/x/staking/genesis.go
index d09ada842f44..938dc4666569 100644
--- a/x/staking/genesis.go
+++ b/x/staking/genesis.go
@@ -9,23 +9,12 @@ import (
"cosmossdk.io/x/staking/keeper"
"cosmossdk.io/x/staking/types"
- cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
+ cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
-// TODO: move this to sdk types and use this instead of comet types GenesisValidator
-// then we can do pubkey conversion in ToGenesisDoc
-//
-// this is a temporary work around to avoid import comet directly in staking
-type GenesisValidator struct {
- Address sdk.ConsAddress
- PubKey cryptotypes.PubKey
- Power int64
- Name string
-}
-
// WriteValidators returns a slice of bonded genesis validators.
-func WriteValidators(ctx context.Context, keeper *keeper.Keeper) (vals []GenesisValidator, returnErr error) {
+func WriteValidators(ctx context.Context, keeper *keeper.Keeper) (vals []sdk.GenesisValidator, returnErr error) {
err := keeper.LastValidatorPower.Walk(ctx, nil, func(key []byte, _ gogotypes.Int64Value) (bool, error) {
validator, err := keeper.GetValidator(ctx, key)
if err != nil {
@@ -37,10 +26,14 @@ func WriteValidators(ctx context.Context, keeper *keeper.Keeper) (vals []Genesis
returnErr = err
return true, err
}
+ jsonPk, err := cryptocodec.PubKeyFromProto(pk)
+ if err != nil {
+ return true, err
+ }
- vals = append(vals, GenesisValidator{
- Address: sdk.ConsAddress(pk.Address()),
- PubKey: pk,
+ vals = append(vals, sdk.GenesisValidator{
+ Address: pk.Address().Bytes(),
+ PubKey: jsonPk,
Power: validator.GetConsensusPower(keeper.PowerReduction(ctx)),
Name: validator.GetMoniker(),
})
diff --git a/x/staking/go.mod b/x/staking/go.mod
index 9c4cdacb1257..44e95461200a 100644
--- a/x/staking/go.mod
+++ b/x/staking/go.mod
@@ -25,11 +25,11 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
@@ -109,7 +109,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -134,13 +134,13 @@ require (
gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect
go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f // indirect
@@ -151,7 +151,7 @@ require (
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
cosmossdk.io/log v1.4.1
github.com/cosmos/crypto v0.1.2 // indirect
github.com/dgraph-io/badger/v4 v4.3.0 // indirect
diff --git a/x/staking/go.sum b/x/staking/go.sum
index 7588b565a0d7..58d4121c9e48 100644
--- a/x/staking/go.sum
+++ b/x/staking/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
@@ -402,8 +402,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -511,8 +511,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg=
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
@@ -593,19 +593,19 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -665,8 +665,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/x/staking/types/params.go b/x/staking/types/params.go
index bd619ae2c0b2..72e6df6c910c 100644
--- a/x/staking/types/params.go
+++ b/x/staking/types/params.go
@@ -19,10 +19,11 @@ const (
// TODO: Justify our choice of default here.
DefaultUnbondingTime time.Duration = time.Hour * 24 * 7 * 3
- // Default maximum number of bonded validators
+ // DefaultMaxValidators is the default maximum number of bonded validators.
DefaultMaxValidators uint32 = 100
- // Default maximum entries in a UBD/RED pair
+ // DefaultMaxEntries is the default maximum number of entries
+ // in a UBD (Unbonding Delegation) or RED (Redelegation) pair.
DefaultMaxEntries uint32 = 7
)
@@ -63,7 +64,7 @@ func DefaultParams() Params {
)
}
-// unmarshal the current staking params value from store key or panic
+// MustUnmarshalParams unmarshal the current staking params value from store key or panic
func MustUnmarshalParams(cdc *codec.LegacyAmino, value []byte) Params {
params, err := UnmarshalParams(cdc, value)
if err != nil {
@@ -73,7 +74,7 @@ func MustUnmarshalParams(cdc *codec.LegacyAmino, value []byte) Params {
return params
}
-// unmarshal the current staking params value from store key
+// UnmarshalParams unmarshal the current staking params value from store key
func UnmarshalParams(cdc *codec.LegacyAmino, value []byte) (params Params, err error) {
err = cdc.Unmarshal(value, ¶ms)
if err != nil {
@@ -83,7 +84,7 @@ func UnmarshalParams(cdc *codec.LegacyAmino, value []byte) (params Params, err e
return
}
-// validate a set of params
+// Validate validates a set of params
func (p Params) Validate() error {
if err := validateUnbondingTime(p.UnbondingTime); err != nil {
return err
@@ -181,6 +182,7 @@ func validateBondDenom(i interface{}) error {
return nil
}
+// ValidatePowerReduction validates the PowerReduction parameter.
func ValidatePowerReduction(i interface{}) error {
v, ok := i.(math.Int)
if !ok {
diff --git a/x/tx/CHANGELOG.md b/x/tx/CHANGELOG.md
index 9fc07fac5acf..182c6dbfefb5 100644
--- a/x/tx/CHANGELOG.md
+++ b/x/tx/CHANGELOG.md
@@ -33,6 +33,7 @@ Since v0.13.0, x/tx follows Cosmos SDK semver: https://github.com/cosmos/cosmos-
## [Unreleased]
+* [#21782](https://github.com/cosmos/cosmos-sdk/pull/21782) Fix JSON attribute sort order on messages with oneof fields.
* [#21825](https://github.com/cosmos/cosmos-sdk/pull/21825) Fix decimal encoding and field ordering in Amino JSON encoder.
* [#21850](https://github.com/cosmos/cosmos-sdk/pull/21850) Support bytes field as signer.
diff --git a/x/tx/decode/decode.go b/x/tx/decode/decode.go
index 994d54cf488b..bf4f3a54f31f 100644
--- a/x/tx/decode/decode.go
+++ b/x/tx/decode/decode.go
@@ -84,7 +84,7 @@ func (d *Decoder) Decode(txBytes []byte) (*DecodedTx, error) {
err = proto.Unmarshal(txBytes, &raw)
if err != nil {
- return nil, err
+ return nil, errorsmod.Wrap(ErrTxDecode, err.Error())
}
var body v1beta1.TxBody
@@ -136,7 +136,7 @@ func (d *Decoder) Decode(txBytes []byte) (*DecodedTx, error) {
dynamicMsg := dynamicpb.NewMessageType(msgDesc.(protoreflect.MessageDescriptor)).New().Interface()
err = anyMsg.UnmarshalTo(dynamicMsg)
if err != nil {
- return nil, err
+ return nil, errorsmod.Wrap(ErrTxDecode, fmt.Sprintf("cannot unmarshal Any message: %v", err))
}
dynamicMsgs = append(dynamicMsgs, dynamicMsg)
@@ -148,7 +148,7 @@ func (d *Decoder) Decode(txBytes []byte) (*DecodedTx, error) {
msg := reflect.New(gogoType.Elem()).Interface().(gogoproto.Message)
err = d.codec.Unmarshal(anyMsg.Value, msg)
if err != nil {
- return nil, err
+ return nil, errorsmod.Wrap(ErrTxDecode, err.Error())
}
msgs = append(msgs, msg)
diff --git a/x/tx/go.mod b/x/tx/go.mod
index ed82d6892f5a..d430694f1dc7 100644
--- a/x/tx/go.mod
+++ b/x/tx/go.mod
@@ -15,7 +15,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
github.com/tendermint/go-amino v0.16.0
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
gotest.tools/v3 v3.5.1
pgregory.net/rapid v1.1.0
)
diff --git a/x/tx/go.sum b/x/tx/go.sum
index d92c41b50631..0a507668b549 100644
--- a/x/tx/go.sum
+++ b/x/tx/go.sum
@@ -59,8 +59,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20240930140551-af27646dc61f/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/x/tx/signing/aminojson/encoder.go b/x/tx/signing/aminojson/encoder.go
index d3e1e75c8bba..fa327d5c6503 100644
--- a/x/tx/signing/aminojson/encoder.go
+++ b/x/tx/signing/aminojson/encoder.go
@@ -43,7 +43,7 @@ func cosmosIntEncoder(_ *Encoder, v protoreflect.Value, w io.Writer) error {
}
}
-// cosmosDecEncoder provides legacy compatible encoding for cosmos.Dec and cosmos.Int types. These are sometimes
+// cosmosDecEncoder provides legacy compatible encoding for cosmos.Dec types. These are sometimes
// represented as strings in pulsar messages and sometimes as bytes. This encoder handles both cases.
func cosmosDecEncoder(_ *Encoder, v protoreflect.Value, w io.Writer) error {
switch val := v.Interface().(type) {
@@ -54,7 +54,7 @@ func cosmosDecEncoder(_ *Encoder, v protoreflect.Value, w io.Writer) error {
var dec math.LegacyDec
err := dec.Unmarshal([]byte(val))
if err != nil {
- return err
+ return fmt.Errorf("failed to unmarshal for Amino JSON encoding; string %q into Dec: %w", val, err)
}
return jsonMarshal(w, dec.String())
case []byte:
diff --git a/x/tx/signing/aminojson/json_marshal.go b/x/tx/signing/aminojson/json_marshal.go
index 52defcca6357..1e5d1b59af81 100644
--- a/x/tx/signing/aminojson/json_marshal.go
+++ b/x/tx/signing/aminojson/json_marshal.go
@@ -16,6 +16,8 @@ import (
"cosmossdk.io/x/tx/signing"
)
+const cosmosDecType = "cosmos.Dec"
+
// MessageEncoder is a function that can encode a protobuf protoreflect.Message to JSON.
type MessageEncoder func(*Encoder, protoreflect.Message, io.Writer) error
@@ -68,8 +70,8 @@ func NewEncoder(options EncoderOptions) Encoder {
}
enc := Encoder{
cosmosProtoScalarEncoders: map[string]FieldEncoder{
- "cosmos.Dec": cosmosDecEncoder,
- "cosmos.Int": cosmosIntEncoder,
+ cosmosDecType: cosmosDecEncoder,
+ "cosmos.Int": cosmosIntEncoder,
},
aminoMessageEncoders: map[string]MessageEncoder{
"key_field": keyFieldEncoder,
@@ -268,8 +270,11 @@ func (enc Encoder) marshal(value protoreflect.Value, fd protoreflect.FieldDescri
}
type nameAndIndex struct {
- i int
- name string
+ i int
+ name string
+ oneof protoreflect.OneofDescriptor
+ oneofFieldName string
+ oneofTypeName string
}
func (enc Encoder) marshalMessage(msg protoreflect.Message, writer io.Writer) error {
@@ -300,14 +305,37 @@ func (enc Encoder) marshalMessage(msg protoreflect.Message, writer io.Writer) er
indices := make([]*nameAndIndex, 0, fields.Len())
for i := 0; i < fields.Len(); i++ {
f := fields.Get(i)
- name := getAminoFieldName(f)
- indices = append(indices, &nameAndIndex{i: i, name: name})
+ entry := &nameAndIndex{
+ i: i,
+ name: getAminoFieldName(f),
+ oneof: f.ContainingOneof(),
+ }
+
+ if entry.oneof != nil {
+ var err error
+ entry.oneofFieldName, entry.oneofTypeName, err = getOneOfNames(f)
+ if err != nil {
+ return err
+ }
+ }
+
+ indices = append(indices, entry)
}
if shouldSortFields := !enc.doNotSortFields; shouldSortFields {
sort.Slice(indices, func(i, j int) bool {
ni, nj := indices[i], indices[j]
- return ni.name < nj.name
+ niName, njName := ni.name, nj.name
+
+ if indices[i].oneof != nil {
+ niName = indices[i].oneofFieldName
+ }
+
+ if indices[j].oneof != nil {
+ njName = indices[j].oneofFieldName
+ }
+
+ return niName < njName
})
}
@@ -316,22 +344,17 @@ func (enc Encoder) marshalMessage(msg protoreflect.Message, writer io.Writer) er
name := ni.name
f := fields.Get(i)
v := msg.Get(f)
- oneof := f.ContainingOneof()
- isOneOf := oneof != nil
- oneofFieldName, oneofTypeName, err := getOneOfNames(f)
- if err != nil && isOneOf {
- return err
- }
+ isOneOf := ni.oneof != nil
writeNil := false
if !msg.Has(f) {
// msg.WhichOneof(oneof) == nil: no field of the oneof has been set
// !emptyOneOfWritten: we haven't written a null for this oneof yet (only write one null per empty oneof)
switch {
- case isOneOf && msg.WhichOneof(oneof) == nil && !emptyOneOfWritten[oneofFieldName]:
- name = oneofFieldName
+ case isOneOf && msg.WhichOneof(ni.oneof) == nil && !emptyOneOfWritten[ni.oneofFieldName]:
+ name = ni.oneofFieldName
writeNil = true
- emptyOneOfWritten[oneofFieldName] = true
+ emptyOneOfWritten[ni.oneofFieldName] = true
case omitEmpty(f):
continue
case f.Kind() == protoreflect.MessageKind &&
@@ -349,7 +372,7 @@ func (enc Encoder) marshalMessage(msg protoreflect.Message, writer io.Writer) er
}
if isOneOf && !writeNil {
- _, err = fmt.Fprintf(writer, `"%s":{"type":"%s","value":{`, oneofFieldName, oneofTypeName)
+ _, err = fmt.Fprintf(writer, `"%s":{"type":"%s","value":{`, ni.oneofFieldName, ni.oneofTypeName)
if err != nil {
return err
}
@@ -366,7 +389,7 @@ func (enc Encoder) marshalMessage(msg protoreflect.Message, writer io.Writer) er
}
// encode value
- if encoder := enc.getFieldEncoding(f); encoder != nil {
+ if encoder := enc.getFieldEncoder(f); encoder != nil {
err = encoder(&enc, v, writer)
if err != nil {
return err
diff --git a/x/tx/signing/aminojson/options.go b/x/tx/signing/aminojson/options.go
index cf9110aef3ae..c5c9462ef106 100644
--- a/x/tx/signing/aminojson/options.go
+++ b/x/tx/signing/aminojson/options.go
@@ -2,11 +2,14 @@ package aminojson
import (
cosmos_proto "github.com/cosmos/cosmos-proto"
+ gogo "github.com/cosmos/gogoproto/gogoproto"
gogoproto "github.com/cosmos/gogoproto/proto"
"github.com/iancoleman/strcase"
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoimpl"
+ "google.golang.org/protobuf/types/descriptorpb"
"cosmossdk.io/api/amino"
)
@@ -100,7 +103,16 @@ func (enc Encoder) getMessageEncoder(message protoreflect.Message) MessageEncode
return nil
}
-func (enc Encoder) getFieldEncoding(field protoreflect.FieldDescriptor) FieldEncoder {
+var customTypeExtension = protoimpl.ExtensionInfo{
+ ExtendedType: (*descriptorpb.FieldOptions)(nil),
+ ExtensionType: gogo.E_Customtype.ExtensionType,
+ Field: gogo.E_Customtype.Field,
+ Name: gogo.E_Customtype.Name,
+ Tag: gogo.E_Customtype.Tag,
+ Filename: gogo.E_Customtype.Filename,
+}
+
+func (enc Encoder) getFieldEncoder(field protoreflect.FieldDescriptor) FieldEncoder {
opts := field.Options()
if proto.HasExtension(opts, amino.E_Encoding) {
encoding := proto.GetExtension(opts, amino.E_Encoding).(string)
@@ -110,6 +122,18 @@ func (enc Encoder) getFieldEncoding(field protoreflect.FieldDescriptor) FieldEnc
}
if proto.HasExtension(opts, cosmos_proto.E_Scalar) {
scalar := proto.GetExtension(opts, cosmos_proto.E_Scalar).(string)
+ // do not handle encoding of fields tagged only with scalar which are not backed by a
+ // LegacyDec custom type. This types are handled by the default encoding, as they are
+ // expected to already be encoded as their human readable string representation
+ // containing a radix, i.e. "1.2345".
+ // For example:
+ // https://github.com/cosmos/cosmos-sdk/blob/9076487d035e43d39fe54e8498da1ce31b9c845c/x/gov/proto/cosmos/gov/v1/gov.proto#L274
+ if scalar == cosmosDecType {
+ customType := proto.GetExtension(opts, &customTypeExtension)
+ if customType != "cosmossdk.io/math.LegacyDec" {
+ return nil
+ }
+ }
if fn, ok := enc.cosmosProtoScalarEncoders[scalar]; ok {
return fn
}
diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod
index 6505f6b4b02a..122dbd8d25da 100644
--- a/x/upgrade/go.mod
+++ b/x/upgrade/go.mod
@@ -28,12 +28,12 @@ require (
github.com/stretchr/testify v1.9.0
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.67.1
- google.golang.org/protobuf v1.34.2
+ google.golang.org/protobuf v1.35.1
)
require (
- buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
- buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
+ buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
+ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.8.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
@@ -145,7 +145,7 @@ require (
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.20.4 // indirect
+ github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
@@ -177,15 +177,15 @@ require (
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- golang.org/x/crypto v0.27.0 // indirect
+ golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
- golang.org/x/sys v0.25.0 // indirect
- golang.org/x/term v0.24.0 // indirect
- golang.org/x/text v0.18.0 // indirect
+ golang.org/x/sys v0.26.0 // indirect
+ golang.org/x/term v0.25.0 // indirect
+ golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/api v0.192.0 // indirect
diff --git a/x/upgrade/go.sum b/x/upgrade/go.sum
index 257f52f8aca0..ed7317d738db 100644
--- a/x/upgrade/go.sum
+++ b/x/upgrade/go.sum
@@ -1,7 +1,7 @@
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 h1:90/4O5QkHb8EZdA2SAhueRzYw6u5ZHCPKtReFqshnTY=
-buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2/go.mod h1:1+3gJj2NvZ1mTLAtHu+lMhOjGgQPiCKCeo+9MBww0Eo=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 h1:b7EEYTUHmWSBEyISHlHvXbJPqtKiHRuUignL1tsHnNQ=
-buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2/go.mod h1:HqcXMSa5qnNuakaMUo+hWhF51mKbcrZxGl9Vp5EeJXc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 h1:DIUSA9vcIz63uUotWfbXXlwv1iTL+C0O2kEMLsnIIbc=
+buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1/go.mod h1:JTBMfyi+qAXUHumX+rcD2WIq9FNWmdcNh5MjBnSw0L0=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 h1:F78ecjvMtgd1aZ1Aj9cvBjURxVGCYvRM+OOy5eR+pjw=
+buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -712,8 +712,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
-github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
-github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
+github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
+github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -851,8 +851,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
-golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
+golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
+golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1071,13 +1071,13 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
-golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
+golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
-golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
+golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
+golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1088,8 +1088,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
-golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
+golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
+golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1382,8 +1382,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
-google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
-google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
+google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
+google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=