Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate to query Consensus Params #19600

Merged
merged 57 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1f28529
feat: message router service
julienrbrt Feb 26, 2024
c8622b3
updates
julienrbrt Feb 26, 2024
cf6ff8a
`make lint-fix`
julienrbrt Feb 26, 2024
3c550b2
updates
julienrbrt Feb 27, 2024
9700f78
updates
julienrbrt Feb 27, 2024
c7b8a8a
nit
julienrbrt Feb 27, 2024
37c08d2
feedback
julienrbrt Feb 27, 2024
ad4ec72
go docs
julienrbrt Feb 29, 2024
3a986fa
add test
julienrbrt Feb 29, 2024
e8f8d24
updates
julienrbrt Feb 29, 2024
64a92c4
updates
julienrbrt Feb 29, 2024
aebdf33
migrate to query Consensus Params
tac0turtle Feb 29, 2024
c68b767
fix lint
tac0turtle Feb 29, 2024
7a64bb6
Merge branch 'main' into marko/consensus_param_read
tac0turtle Mar 4, 2024
9b87635
Merge branch 'main' into marko/consensus_param_read
tac0turtle Mar 4, 2024
29223e3
fix things
tac0turtle Mar 4, 2024
2b1c3c8
fix import
tac0turtle Mar 4, 2024
5170698
Merge branch 'main' into marko/consensus_param_read
tac0turtle Mar 6, 2024
5027474
Merge branch 'main' into marko/consensus_param_read
tac0turtle Mar 9, 2024
2f980da
Merge branch 'main' into marko/consensus_param_read
tac0turtle Mar 19, 2024
9d70599
push some changes
tac0turtle Mar 19, 2024
1cb6f9a
updates
tac0turtle Mar 19, 2024
d6cdc35
fix most tests
facundomedica Apr 2, 2024
3d97566
fix more tests
facundomedica Apr 3, 2024
e68b63c
Merge branch 'main' into marko/consensus_param_read
facundomedica Apr 3, 2024
42cf758
fix lint
facundomedica Apr 3, 2024
c3b1f3e
fix legacy simapp tests
facundomedica Apr 3, 2024
0e13333
mod tidy
facundomedica Apr 3, 2024
dfa96c0
Merge branch 'main' into marko/consensus_param_read
tac0turtle Apr 4, 2024
cec0d7f
linting
tac0turtle Apr 4, 2024
3ba007a
changelog and fix db test
tac0turtle Apr 4, 2024
aef8539
Merge branch 'main' into marko/consensus_param_read
tac0turtle Apr 4, 2024
4b13f04
fix
facundomedica Apr 4, 2024
a9db8b3
Merge branch 'marko/consensus_param_read' of https://github.com/cosmo…
facundomedica Apr 4, 2024
999808c
Merge branch 'main' into marko/consensus_param_read
tac0turtle Apr 15, 2024
9104f14
fixes
tac0turtle Apr 15, 2024
2e04392
linting
tac0turtle Apr 15, 2024
5ad437d
remove line
tac0turtle Apr 15, 2024
fe09a4f
remove comments
tac0turtle Apr 15, 2024
84b1a15
use protov1 types
tac0turtle Apr 15, 2024
6d0b2e9
fix build
tac0turtle Apr 15, 2024
241b63b
remove extra code
tac0turtle Apr 16, 2024
238e9ce
:x
tac0turtle Apr 18, 2024
620d121
add .Environment as param
kocubinski Apr 19, 2024
d0e75e8
fix simapp v1 test
kocubinski Apr 19, 2024
1c51342
linter fix
kocubinski Apr 19, 2024
7470ff8
Merge branch 'main' of github.com:cosmos/cosmos-sdk into marko/consen…
kocubinski Apr 19, 2024
80a178d
Merge branch 'main' of github.com:cosmos/cosmos-sdk into marko/consen…
kocubinski Apr 19, 2024
2cd37c7
Merge branch 'main' into marko/consensus_param_read
tac0turtle Apr 22, 2024
837b961
Merge branch 'main' into marko/consensus_param_read
tac0turtle Apr 23, 2024
ce24f22
fix: setting interface registry already happens at NewIntegrationApp
facundomedica Apr 23, 2024
e9e816f
fix build orm
hieuvubk Apr 23, 2024
a065b4f
Merge branch 'main' into marko/consensus_param_read
julienrbrt Apr 23, 2024
4ee3e9b
Merge branch 'main' into marko/consensus_param_read
tac0turtle Apr 25, 2024
7a7f6d0
Merge branch 'main' into marko/consensus_param_read
julienrbrt Apr 25, 2024
975281b
lint fixing
tac0turtle Apr 25, 2024
669ac75
go mod tidy
tac0turtle Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) {
return nil, err
}

cp := ctx.ConsensusParams()
cp := ctx.ConsensusParams() // nolint:staticcheck // ignore linting error
extsEnabled := cp.Abci != nil && req.Height >= cp.Abci.VoteExtensionsEnableHeight && cp.Abci.VoteExtensionsEnableHeight != 0
if extsEnabled {
req.Txs = append(req.Txs, []byte("some-tx-that-does-something-from-votes"))
Expand Down
6 changes: 3 additions & 3 deletions baseapp/abci_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ValidateVoteExtensions(
extCommit abci.ExtendedCommitInfo,
) error {
// Get values from context
cp := ctx.ConsensusParams()
cp := ctx.ConsensusParams() // nolint:staticcheck // ignore linting error
currentHeight := ctx.HeaderInfo().Height
chainID := ctx.HeaderInfo().ChainID
commitInfo := ctx.CometInfo().LastCommit
Expand Down Expand Up @@ -249,7 +249,7 @@ func (h *DefaultProposalHandler) SetTxSelector(ts TxSelector) {
func (h *DefaultProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
return func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) {
var maxBlockGas uint64
if b := ctx.ConsensusParams().Block; b != nil {
if b := ctx.ConsensusParams().Block; b != nil { // nolint:staticcheck // ignore linting error
maxBlockGas = uint64(b.MaxGas)
}

Expand Down Expand Up @@ -375,7 +375,7 @@ func (h *DefaultProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHan
var totalTxGas uint64

var maxBlockGas int64
if b := ctx.ConsensusParams().Block; b != nil {
if b := ctx.ConsensusParams().Block; b != nil { // nolint:staticcheck // ignore linting error
maxBlockGas = b.MaxGas
}

Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ replace (
cosmossdk.io/x/staking => ./x/staking
)

replace github.com/cosmos/iavl => github.com/cosmos/iavl v1.0.1 // TODO remove

// Below are the long-lived replace of the Cosmos SDK
replace (
// use cosmos fork of keyring
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gogoproto v1.4.12 h1:vB6Lbe/rtnYGjQuFxkPiPYiCybqFT8QvLipDZP8JpFE=
github.com/cosmos/gogoproto v1.4.12/go.mod h1:LnZob1bXRdUoqMMtwYlcR3wjiElmlC+FkjaZRv1/eLY=
github.com/cosmos/iavl v1.0.1 h1:D+mYbcRO2wptYzOM1Hxl9cpmmHU1ZEt9T2Wv5nZTeUw=
github.com/cosmos/iavl v1.0.1/go.mod h1:8xIUkgVvwvVrBu81scdPty+/Dx9GqwHnAvXz4cwF7RY=
github.com/cosmos/iavl v1.0.0 h1:bw6t0Mv/mVCJvlMTOPHWLs5uUE3BRBfVWCRelOzl+so=
github.com/cosmos/iavl v1.0.0/go.mod h1:CmTGqMnRnucjxbjduneZXT+0vPgNElYvdefjX2q9tYc=
github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM=
github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0=
github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=
Expand Down
4 changes: 2 additions & 2 deletions orm/model/ormdb/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type ModuleDB interface {
// func NewAppModule(keeper keeper.Keeper) AppModule {
// return AppModule{HasGenesis: keeper.GenesisHandler()}
// }
GenesisHandler() appmodule.HasGenesis // TODO should be appmodule.HasGenesisAuto with core v1
GenesisHandler() appmodule.HasGenesisAuto

private()
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func (m moduleDB) GetTable(message proto.Message) ormtable.Table {
return m.tablesByName[message.ProtoReflect().Descriptor().FullName()]
}

func (m moduleDB) GenesisHandler() appmodule.HasGenesis { // TODO should be appmodule.HasGenesisAuto with core v1
func (m moduleDB) GenesisHandler() appmodule.HasGenesisAuto {
return appModuleGenesisWrapper{m}
}

Expand Down
2 changes: 1 addition & 1 deletion simapp/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
}

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewSetUpContextDecorator(options.Environment), // outermost AnteDecorator. SetUpContext must be called first
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
ante.NewValidateBasicDecorator(options.AccountKeeper.Environment()),
Expand Down
5 changes: 4 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ var (
// capabilities aren't needed for testing.
type SimApp struct {
*baseapp.BaseApp
logger log.Logger
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
txConfig client.TxConfig
Expand Down Expand Up @@ -273,6 +274,7 @@ func NewSimApp(

app := &SimApp{
BaseApp: bApp,
logger: logger,
legacyAmino: legacyAmino,
appCodec: appCodec,
txConfig: txConfig,
Expand Down Expand Up @@ -338,7 +340,7 @@ func NewSimApp(
app.txConfig = txConfig

app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), logger), app.AuthKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), signingCtx.ValidatorAddressCodec(), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), logger, runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), app.AuthKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), signingCtx.ValidatorAddressCodec(), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
)
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger), app.StakingKeeper, app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())

Expand Down Expand Up @@ -598,6 +600,7 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) {
anteHandler, err := NewAnteHandler(
HandlerOptions{
ante.HandlerOptions{
Environment: runtime.NewEnvironment(nil, app.logger, runtime.EnvWithRouterService(app.GRPCQueryRouter(), app.MsgServiceRouter())), // nil is set as the kvstoreservice to avoid module access
AccountAbstractionKeeper: app.AccountsKeeper,
AccountKeeper: app.AuthKeeper,
BankKeeper: app.BankKeeper,
Expand Down
1 change: 0 additions & 1 deletion simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1"
"cosmossdk.io/depinject/appconfig"
"cosmossdk.io/x/accounts"
_ "cosmossdk.io/x/accounts" // import for side-effects
_ "cosmossdk.io/x/auth/tx/config" // import for side-effects
authtypes "cosmossdk.io/x/auth/types"
_ "cosmossdk.io/x/auth/vesting" // import for side-effects
Expand Down
2 changes: 1 addition & 1 deletion simapp/app_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func NewSimApp(
return app
}

// overwritte default ante handlers with custom ante handlers
// overwrite default ante handlers with custom ante handlers
// set SkipAnteHandler to true in app config and set custom ante handler on baseapp
func (app *SimApp) setCustomAnteHandler() {
anteHandler, err := NewAnteHandler(
Expand Down
1 change: 1 addition & 0 deletions simapp/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
epochstypes "cosmossdk.io/x/epochs/types"
protocolpooltypes "cosmossdk.io/x/protocolpool/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/types/module"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
)
Expand Down
6 changes: 3 additions & 3 deletions store/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ type RawDBType string

const (
DBTypeGoLevelDB RawDBType = "goleveldb"
DBTypeRocksDB = "rocksdb"
DBTypePebbleDB = "pebbledb"
DBTypePrefixDB = "prefixdb"
DBTypeRocksDB RawDBType = "rocksdb"
DBTypePebbleDB RawDBType = "pebbledb"
DBTypePrefixDB RawDBType = "prefixdb"

DBFileSuffix string = ".db"
)
Expand Down
9 changes: 0 additions & 9 deletions store/db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,6 @@ func TestPebbleDBSuite(t *testing.T) {
})
}

func TestRocksDBSuite(t *testing.T) {
db, err := NewRocksDB("test", t.TempDir())
require.NoError(t, err)

suite.Run(t, &DBTestSuite{
db: db,
})
}

func TestGoLevelDBSuite(t *testing.T) {
db, err := NewGoLevelDB("test", t.TempDir(), nil)
require.NoError(t, err)
Expand Down
36 changes: 0 additions & 36 deletions store/db/rocksdb_noflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,3 @@ func (db *RocksDB) NewBatch() store.RawBatch {
func (db *RocksDB) NewBatchWithSize(_ int) store.RawBatch {
return db.NewBatch()
}

var _ corestore.Iterator = (*rocksDBIterator)(nil)

type rocksDBIterator struct{}

func (itr *rocksDBIterator) Domain() (start, end []byte) {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) Valid() bool {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) Key() []byte {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) Value() []byte {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) Next() {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) Error() error {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) Close() error {
panic("rocksdb must be built with -tags rocksdb")
}

func (itr *rocksDBIterator) assertIsValid() {
panic("rocksdb must be built with -tags rocksdb")
}
20 changes: 20 additions & 0 deletions store/db/rocksdb_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build rocksdb
// +build rocksdb

package db

import (
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

func TestRocksDBSuite(t *testing.T) {
db, err := NewRocksDB("test", t.TempDir())
require.NoError(t, err)

suite.Run(t, &DBTestSuite{
db: db,
})
}
22 changes: 10 additions & 12 deletions tests/integration/auth/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import (
"cosmossdk.io/x/auth"
authkeeper "cosmossdk.io/x/auth/keeper"
authsims "cosmossdk.io/x/auth/simulation"
"cosmossdk.io/x/auth/types"
authtypes "cosmossdk.io/x/auth/types"
"cosmossdk.io/x/bank"
"cosmossdk.io/x/bank/keeper"
bankkeeper "cosmossdk.io/x/bank/keeper"
"cosmossdk.io/x/bank/testutil"
banktypes "cosmossdk.io/x/bank/types"
Expand Down Expand Up @@ -109,7 +107,7 @@ func initFixture(t *testing.T) *fixture {
blockedAddresses := map[string]bool{
authKeeper.GetAuthority(): false,
}
bankKeeper := keeper.NewBaseKeeper(
bankKeeper := bankkeeper.NewBaseKeeper(
runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), log.NewNopLogger()),
cdc,
authKeeper,
Expand All @@ -131,7 +129,7 @@ func initFixture(t *testing.T) *fixture {
accounts.ModuleName: accountsModule,
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
})
}, router, queryRouter)

authtypes.RegisterInterfaces(cdc.InterfaceRegistry())
banktypes.RegisterInterfaces(cdc.InterfaceRegistry())
Expand Down Expand Up @@ -187,13 +185,13 @@ func TestAsyncExec(t *testing.T) {

testCases := []struct {
name string
req *types.MsgNonAtomicExec
req *authtypes.MsgNonAtomicExec
expectErr bool
expErrMsg string
}{
{
name: "empty signer address",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: "",
Msgs: []*codectypes.Any{},
},
Expand All @@ -202,7 +200,7 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "invalid signer address",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: "invalid",
Msgs: []*codectypes.Any{},
},
Expand All @@ -211,7 +209,7 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "empty msgs",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{},
},
Expand All @@ -220,23 +218,23 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "valid msg",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny},
},
expectErr: false,
},
{
name: "multiple messages being executed",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny, msgAny},
},
expectErr: false,
},
{
name: "multiple messages with different signers",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny, msgAny2},
},
Expand All @@ -245,7 +243,7 @@ func TestAsyncExec(t *testing.T) {
},
{
name: "multi msg with one failing being executed",
req: &types.MsgNonAtomicExec{
req: &authtypes.MsgNonAtomicExec{
Signer: addrs[0].String(),
Msgs: []*codectypes.Any{msgAny, failingMsgAny},
},
Expand Down
7 changes: 5 additions & 2 deletions tests/integration/bank/keeper/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
minttypes "cosmossdk.io/x/mint/types"
_ "cosmossdk.io/x/staking"

"github.com/cosmos/cosmos-sdk/baseapp"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
"github.com/cosmos/cosmos-sdk/runtime"
Expand Down Expand Up @@ -99,7 +100,6 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
accountKeeper.GetAuthority(): false,
}
bankKeeper := keeper.NewBaseKeeper(

runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), log.NewNopLogger()),
cdc,
accountKeeper,
Expand All @@ -116,7 +116,10 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
map[string]appmodule.AppModule{
authtypes.ModuleName: authModule,
banktypes.ModuleName: bankModule,
})
},
baseapp.NewMsgServiceRouter(),
baseapp.NewGRPCQueryRouter(),
)

sdkCtx := sdk.UnwrapSDKContext(integrationApp.Context())

Expand Down
Loading
Loading