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

begin with iavl v1.0.0 #492

Closed
wants to merge 15 commits into from
13 changes: 7 additions & 6 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"strings"
"testing"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/jsonpb"
"github.com/stretchr/testify/require"

"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/baseapp"
baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil"
"github.com/cosmos/cosmos-sdk/snapshots"
Expand Down Expand Up @@ -43,7 +44,7 @@ func TestABCI_Info(t *testing.T) {
func TestABCI_InitChain(t *testing.T) {
name := t.Name()
db := dbm.NewMemDB()
logger := defaultLogger()
logger := log.NewTestLogger(t)
app := baseapp.NewBaseApp(name, logger, db, nil, baseapp.SetChainID("test-chain-id"))

capKey := sdk.NewKVStoreKey("main")
Expand Down Expand Up @@ -128,7 +129,7 @@ func TestABCI_InitChain(t *testing.T) {
func TestABCI_InitChain_WithInitialHeight(t *testing.T) {
name := t.Name()
db := dbm.NewMemDB()
logger := defaultLogger()
logger := log.NewTestLogger(t)
app := baseapp.NewBaseApp(name, logger, db, nil)

app.InitChain(
Expand All @@ -144,7 +145,7 @@ func TestABCI_InitChain_WithInitialHeight(t *testing.T) {
func TestABCI_BeginBlock_WithInitialHeight(t *testing.T) {
name := t.Name()
db := dbm.NewMemDB()
logger := defaultLogger()
logger := log.NewTestLogger(t)
app := baseapp.NewBaseApp(name, logger, db, nil)

app.InitChain(
Expand Down Expand Up @@ -568,7 +569,7 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) {
func TestABCI_EndBlock(t *testing.T) {
db := dbm.NewMemDB()
name := t.Name()
logger := defaultLogger()
logger := log.NewTestLogger(t)

cp := &tmproto.ConsensusParams{
Block: &tmproto.BlockParams{
Expand Down Expand Up @@ -1213,7 +1214,7 @@ func TestABCI_Query(t *testing.T) {
}

func TestABCI_GetBlockRetentionHeight(t *testing.T) {
logger := defaultLogger()
logger := log.NewTestLogger(t)
db := dbm.NewMemDB()
name := t.Name()

Expand Down
4 changes: 2 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"sort"
"strings"

dbm "github.com/cometbft/cometbft-db"
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"
"golang.org/x/exp/maps"

Expand Down
25 changes: 10 additions & 15 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"testing"
"time"

dbm "github.com/cometbft/cometbft-db"
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -58,10 +58,9 @@ func NewBaseAppSuite(t *testing.T, opts ...func(*baseapp.BaseApp)) *BaseAppSuite
baseapptestutil.RegisterInterfaces(cdc.InterfaceRegistry())

txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
logger := defaultLogger()
db := dbm.NewMemDB()

app := baseapp.NewBaseApp(t.Name(), logger, db, txConfig.TxDecoder(), opts...)
app := baseapp.NewBaseApp(t.Name(), log.NewTestLogger(t), db, txConfig.TxDecoder(), opts...)
require.Equal(t, t.Name(), app.Name())

app.SetInterfaceRegistry(cdc.InterfaceRegistry())
Expand Down Expand Up @@ -158,11 +157,10 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun
}

func TestLoadVersion(t *testing.T) {
logger := defaultLogger()
pruningOpt := baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing))
db := dbm.NewMemDB()
name := t.Name()
app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil, pruningOpt)

// make a cap key and mount the store
err := app.LoadLatestVersion() // needed to make stores non-nil
Expand All @@ -189,7 +187,7 @@ func TestLoadVersion(t *testing.T) {
commitID2 := storetypes.CommitID{Version: 2, Hash: res.Data}

// reload with LoadLatestVersion
app = baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
app = baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil, pruningOpt)
app.MountStores()

err = app.LoadLatestVersion()
Expand All @@ -199,7 +197,7 @@ func TestLoadVersion(t *testing.T) {

// Reload with LoadVersion, see if you can commit the same block and get
// the same result.
app = baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
app = baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil, pruningOpt)
err = app.LoadVersion(1)
require.Nil(t, err)

Expand Down Expand Up @@ -283,7 +281,7 @@ func TestSetLoader(t *testing.T) {
if tc.setLoader != nil {
opts = append(opts, tc.setLoader)
}
app := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...)
app := baseapp.NewBaseApp(t.Name(), log.NewTestLogger(t), db, nil, opts...)
app.MountStores(sdk.NewKVStoreKey(tc.loadStoreKey))
err := app.LoadLatestVersion()
require.Nil(t, err)
Expand All @@ -301,11 +299,10 @@ func TestSetLoader(t *testing.T) {
}

func TestVersionSetterGetter(t *testing.T) {
logger := defaultLogger()
pruningOpt := baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault))
db := dbm.NewMemDB()
name := t.Name()
app := baseapp.NewBaseApp(name, logger, db, nil, pruningOpt)
app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil, pruningOpt)

require.Equal(t, "", app.Version())
res := app.Query(abci.RequestQuery{Path: "app/version"})
Expand Down Expand Up @@ -360,9 +357,8 @@ func TestOptionFunction(t *testing.T) {
}
}

logger := defaultLogger()
db := dbm.NewMemDB()
bap := baseapp.NewBaseApp("starting name", logger, db, nil, testChangeNameHelper("new name"))
bap := baseapp.NewBaseApp("starting name", log.NewTestLogger(t), db, nil, testChangeNameHelper("new name"))
require.Equal(t, bap.Name(), "new name", "BaseApp should have had name changed via option function")
}

Expand Down Expand Up @@ -542,10 +538,9 @@ func TestBaseAppAnteHandler(t *testing.T) {
func TestABCI_CreateQueryContext(t *testing.T) {
t.Parallel()

logger := defaultLogger()
db := dbm.NewMemDB()
name := t.Name()
app := baseapp.NewBaseApp(name, logger, db, nil)
app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil)

app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 1}})
app.Commit()
Expand Down
9 changes: 5 additions & 4 deletions baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"math"
"testing"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

"cosmossdk.io/depinject"

"cosmossdk.io/log"
baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
Expand Down Expand Up @@ -81,7 +81,8 @@ func TestBaseApp_BlockGas(t *testing.T) {
err error
)

appConfig := depinject.Configs(makeTestConfig())
appConfig := depinject.Configs(
makeTestConfig(), depinject.Supply(log.NewNopLogger()))

err = depinject.Inject(appConfig,
&bankKeeper,
Expand All @@ -93,7 +94,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
&appBuilder)
require.NoError(t, err)

bapp := appBuilder.Build(log.NewNopLogger(), dbm.NewMemDB(), nil)
bapp := appBuilder.Build(dbm.NewMemDB(), nil)
err = bapp.Load(true)
require.NoError(t, err)

Expand Down
13 changes: 8 additions & 5 deletions baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package baseapp_test

import (
"context"
"os"
"sync"
"testing"

dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

"cosmossdk.io/depinject"
"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
Expand Down Expand Up @@ -56,10 +55,14 @@ func TestGRPCQueryRouter(t *testing.T) {
func TestRegisterQueryServiceTwice(t *testing.T) {
// Setup baseapp.
var appBuilder *runtime.AppBuilder
err := depinject.Inject(makeMinimalConfig(), &appBuilder)
err := depinject.Inject(
depinject.Configs(
makeMinimalConfig(),
depinject.Supply(log.NewNopLogger()),
), &appBuilder)
require.NoError(t, err)
db := dbm.NewMemDB()
app := appBuilder.Build(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil)
app := appBuilder.Build(db, nil)

// First time registering service shouldn't panic.
require.NotPanics(t, func() {
Expand Down
29 changes: 20 additions & 9 deletions baseapp/msg_service_router_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package baseapp_test

import (
"os"
"testing"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

"cosmossdk.io/depinject"
"cosmossdk.io/log"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -27,9 +26,13 @@ func TestRegisterMsgService(t *testing.T) {
appBuilder *runtime.AppBuilder
registry codectypes.InterfaceRegistry
)
err := depinject.Inject(makeMinimalConfig(), &appBuilder, &registry)
err := depinject.Inject(
depinject.Configs(
makeMinimalConfig(),
depinject.Supply(log.NewNopLogger()),
), &appBuilder, &registry)
require.NoError(t, err)
app := appBuilder.Build(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), dbm.NewMemDB(), nil)
app := appBuilder.Build(dbm.NewMemDB(), nil)

require.Panics(t, func() {
testdata.RegisterMsgServer(
Expand All @@ -55,10 +58,14 @@ func TestRegisterMsgServiceTwice(t *testing.T) {
appBuilder *runtime.AppBuilder
registry codectypes.InterfaceRegistry
)
err := depinject.Inject(makeMinimalConfig(), &appBuilder, &registry)
err := depinject.Inject(
depinject.Configs(
makeMinimalConfig(),
depinject.Supply(log.NewNopLogger()),
), &appBuilder, &registry)
require.NoError(t, err)
db := dbm.NewMemDB()
app := appBuilder.Build(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil)
app := appBuilder.Build(db, nil)
testdata.RegisterInterfaces(registry)

// First time registering service shouldn't panic.
Expand Down Expand Up @@ -86,9 +93,13 @@ func TestMsgService(t *testing.T) {
cdc codec.ProtoCodecMarshaler
interfaceRegistry codectypes.InterfaceRegistry
)
err := depinject.Inject(makeMinimalConfig(), &appBuilder, &cdc, &interfaceRegistry)
err := depinject.Inject(
depinject.Configs(
makeMinimalConfig(),
depinject.Supply(log.NewNopLogger()),
), &appBuilder, &cdc, &interfaceRegistry)
require.NoError(t, err)
app := appBuilder.Build(log.NewNopLogger(), dbm.NewMemDB(), nil)
app := appBuilder.Build(dbm.NewMemDB(), nil)

// patch in TxConfig instead of using an output from x/auth/tx
txConfig := authtx.NewTxConfig(cdc, authtx.DefaultSignModes)
Expand Down
7 changes: 1 addition & 6 deletions baseapp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"io"

dbm "github.com/cometbft/cometbft-db"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/snapshots"
Expand Down Expand Up @@ -70,11 +70,6 @@ func SetIAVLDisableFastNode(disable bool) func(*BaseApp) {
return func(bapp *BaseApp) { bapp.cms.SetIAVLDisableFastNode(disable) }
}

// SetIAVLLazyLoading enables/disables lazy loading of the IAVL store.
func SetIAVLLazyLoading(lazyLoading bool) func(*BaseApp) {
return func(bapp *BaseApp) { bapp.cms.SetLazyLoading(lazyLoading) }
}

// SetInterBlockCache provides a BaseApp option function that sets the
// inter-block cache.
func SetInterBlockCache(cache sdk.MultiStorePersistentCache) func(*BaseApp) {
Expand Down
12 changes: 1 addition & 11 deletions baseapp/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"net/url"
"os"
"reflect"
"strconv"
"testing"
Expand All @@ -25,10 +24,9 @@ import (
txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/depinject"
dbm "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -62,14 +60,6 @@ var (
ParamStoreKey = []byte("paramstore")
)

func defaultLogger() log.Logger {
if testing.Verbose() {
return log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "baseapp/test")
}

return log.NewNopLogger()
}

// GenesisStateWithSingleValidator initializes GenesisState with a single validator and genesis accounts
// that also act as delegators.
func GenesisStateWithSingleValidator(t *testing.T, codec codec.Codec, builder *runtime.AppBuilder) map[string]json.RawMessage {
Expand Down
Loading
Loading