Skip to content

Commit

Permalink
perf: replace line/iavl, line/tm-db with cosmos/iavl, tendermint/tm-db (
Browse files Browse the repository at this point in the history
#605)

* feat: replace line/iavl/v2 to cosmos/iavl

* perf: remove iavl cache

* perf: replace line/tm-db/v2 to tendermint/tm-db

* build: remove iostats for build

* test: fix codecov patch test

* build: remove freecache and tm-db from go.mod

* docs: add changelog

* docs: combine log
  • Loading branch information
dudong2 authored Jul 26, 2022
1 parent 7cdbce7 commit 7b240f0
Show file tree
Hide file tree
Showing 85 changed files with 425 additions and 855 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (proto) [\#584](https://github.com/line/lbm-sdk/pull/564) remove `prove` field in the `GetTxsEventRequest` of `tx` proto
* (x/collection) [\#571](https://github.com/line/lbm-sdk/pull/571) add x/collection proto
* (x/collection) [\#574](https://github.com/line/lbm-sdk/pull/574) implement x/collection
* (amino) [\600](https://github.com/line/lbm-sdk/pull/600) change amino codec path from `lbm-sdk/` to `cosmos-sdk/`
* (amino) [\#600](https://github.com/line/lbm-sdk/pull/600) change amino codec path from `lbm-sdk/` to `cosmos-sdk/`
* (store) [\#605](https://github.com/line/lbm-sdk/pull/605) replace line/iavl and line/tm-db with cosmos/iavl and tendermint/tm-db.
* (server/grpc) [\#607](https://github.com/line/lbm-sdk/pull/607) revert gRPC block height header.

### Improvements
Expand Down Expand Up @@ -76,7 +77,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (ci) [\#457](https://github.com/line/lbm-sdk/pull/457), [\#471](https://github.com/line/lbm-sdk/pull/471) add swagger check
* (ci) [\#469](https://github.com/line/lbm-sdk/pull/469) publish docker image on tag push
* (ci) [\#580](https://github.com/line/lbm-sdk/pull/580) fix the problem that the registered docker image couldn't run on M1.
* (ci) [\#580](https://github.com/line/lbm-sdk/pull/580) fix the problem that the registered docker image couldn't run on M1.
* (simapp) [\#591](https://github.com/line/lbm-sdk/pull/591) chore: add x/wasm module to simapp

### Document Updates
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ cosmovisor:

mocks: $(MOCKS_DIR)
mockgen -source=client/account_retriever.go -package mocks -destination tests/mocks/account_retriever.go
mockgen -package mocks -destination tests/mocks/tendermint_tm_db_DB.go github.com/line/tm-db/v2 DB
mockgen -package mocks -destination tests/mocks/tendermint_tm_db_DB.go github.com/tendermint/tm-db DB
mockgen -source=types/module/module.go -package mocks -destination tests/mocks/types_module_module.go
mockgen -source=types/invariant.go -package mocks -destination tests/mocks/types_invariant.go
mockgen -source=types/router.go -package mocks -destination tests/mocks/types_router.go
Expand Down
3 changes: 0 additions & 3 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,6 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) {
commitID := app.cms.Commit()
app.logger.Info("commit synced", "commit", fmt.Sprintf("%X", commitID))

// iavl, db & disk stats
logIoStats(app.logger)

// empty/reset the deliver state
app.deliverState = nil

Expand Down
8 changes: 4 additions & 4 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (

abci "github.com/line/ostracon/abci/types"
ocprototypes "github.com/line/ostracon/proto/ostracon/types"
"github.com/line/tm-db/v2/memdb"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

sdk "github.com/line/lbm-sdk/types"
)

func TestGetBlockRentionHeight(t *testing.T) {
logger := defaultLogger()
db := memdb.NewDB()
db := dbm.NewMemDB()
name := t.Name()

testCases := map[string]struct {
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestGetBlockRentionHeight(t *testing.T) {
for name, tc := range testCases {
tc := tc

tc.bapp.SetParamStore(&paramStore{db: memdb.NewDB()})
tc.bapp.SetParamStore(&paramStore{db: dbm.NewMemDB()})
tc.bapp.InitChain(abci.RequestInitChain{
ConsensusParams: &abci.ConsensusParams{
Evidence: &ocprototypes.EvidenceParams{
Expand All @@ -124,7 +124,7 @@ func TestBaseAppCreateQueryContextRejectsNegativeHeights(t *testing.T) {
t.Parallel()

logger := defaultLogger()
db := memdb.NewDB()
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil)

Expand Down
6 changes: 3 additions & 3 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/line/ostracon/crypto/tmhash"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"
tmdb "github.com/line/tm-db/v2"
dbm "github.com/tendermint/tm-db"

"github.com/line/lbm-sdk/codec/types"
"github.com/line/lbm-sdk/snapshots"
Expand Down Expand Up @@ -41,7 +41,7 @@ type BaseApp struct { // nolint: maligned
// initialized on creation
logger log.Logger
name string // application name from abci.Info
db tmdb.DB // common DB backend
db dbm.DB // common DB backend
cms sdk.CommitMultiStore // Main (uncached) state
storeLoader StoreLoader // function to handle store loading, may be overridden with SetStoreLoader()
router sdk.Router // handle any kind of message
Expand Down Expand Up @@ -138,7 +138,7 @@ type BaseApp struct { // nolint: maligned
//
// NOTE: The db is used to store the version number for now.
func NewBaseApp(
name string, logger log.Logger, db tmdb.DB, txDecoder sdk.TxDecoder, options ...func(*BaseApp),
name string, logger log.Logger, db dbm.DB, txDecoder sdk.TxDecoder, options ...func(*BaseApp),
) *BaseApp {
app := &BaseApp{
logger: logger,
Expand Down
37 changes: 18 additions & 19 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import (
abci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"
tmdb "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

"github.com/line/lbm-sdk/codec"
"github.com/line/lbm-sdk/snapshots"
Expand All @@ -39,7 +38,7 @@ var (
)

type paramStore struct {
db *memdb.MemDB
db *dbm.MemDB
}

func (ps *paramStore) Set(_ sdk.Context, key []byte, value interface{}) {
Expand Down Expand Up @@ -81,7 +80,7 @@ func defaultLogger() log.Logger {

func newBaseApp(name string, options ...func(*BaseApp)) *BaseApp {
logger := defaultLogger()
db := memdb.NewDB()
db := dbm.NewMemDB()
codec := codec.NewLegacyAmino()
registerTestCodec(codec)
return NewBaseApp(name, logger, db, testTxDecoder(codec), options...)
Expand Down Expand Up @@ -113,7 +112,7 @@ func setupBaseApp(t *testing.T, options ...func(*BaseApp)) *BaseApp {
require.Equal(t, t.Name(), app.Name())

app.MountStores(capKey1, capKey2)
app.SetParamStore(&paramStore{db: memdb.NewDB()})
app.SetParamStore(&paramStore{db: dbm.NewMemDB()})

// stores are mounted
err := app.LoadLatestVersion()
Expand All @@ -137,7 +136,7 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options
snapshotTimeout := 1 * time.Minute
snapshotDir, err := ioutil.TempDir("", "baseapp")
require.NoError(t, err)
snapshotStore, err := snapshots.NewStore(memdb.NewDB(), snapshotDir)
snapshotStore, err := snapshots.NewStore(dbm.NewMemDB(), snapshotDir)
require.NoError(t, err)
teardown := func() {
os.RemoveAll(snapshotDir)
Expand Down Expand Up @@ -208,7 +207,7 @@ func TestMountStores(t *testing.T) {
func TestLoadVersion(t *testing.T) {
logger := defaultLogger()
pruningOpt := SetPruning(store.PruneNothing)
db := memdb.NewDB()
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil, pruningOpt)

Expand Down Expand Up @@ -258,7 +257,7 @@ func useDefaultLoader(app *BaseApp) {
app.SetStoreLoader(DefaultStoreLoader)
}

func initStore(t *testing.T, db tmdb.DB, storeKey string, k, v []byte) {
func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {
rs := rootmulti.NewStore(db)
rs.SetPruning(store.PruneNothing)
key := sdk.NewKVStoreKey(storeKey)
Expand All @@ -275,7 +274,7 @@ func initStore(t *testing.T, db tmdb.DB, storeKey string, k, v []byte) {
require.Equal(t, int64(1), commitID.Version)
}

func checkStore(t *testing.T, db tmdb.DB, ver int64, storeKey string, k, v []byte) {
func checkStore(t *testing.T, db dbm.DB, ver int64, storeKey string, k, v []byte) {
rs := rootmulti.NewStore(db)
rs.SetPruning(store.PruneDefault)
key := sdk.NewKVStoreKey(storeKey)
Expand Down Expand Up @@ -316,7 +315,7 @@ func TestSetLoader(t *testing.T) {
tc := tc
t.Run(name, func(t *testing.T) {
// prepare a db with some data
db := memdb.NewDB()
db := dbm.NewMemDB()
initStore(t, db, tc.origStoreKey, k, v)

// load the app with the existing db
Expand Down Expand Up @@ -344,7 +343,7 @@ func TestSetLoader(t *testing.T) {
func TestVersionSetterGetter(t *testing.T) {
logger := defaultLogger()
pruningOpt := SetPruning(store.PruneDefault)
db := memdb.NewDB()
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil, pruningOpt)

Expand All @@ -364,7 +363,7 @@ func TestVersionSetterGetter(t *testing.T) {
func TestLoadVersionInvalid(t *testing.T) {
logger := log.NewNopLogger()
pruningOpt := SetPruning(store.PruneNothing)
db := memdb.NewDB()
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil, pruningOpt)

Expand Down Expand Up @@ -401,7 +400,7 @@ func TestLoadVersionPruning(t *testing.T) {
Interval: 1,
}
pruningOpt := SetPruning(pruningOptions)
db := memdb.NewDB()
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil, pruningOpt)

Expand Down Expand Up @@ -458,7 +457,7 @@ func testLoadVersionHelper(t *testing.T, app *BaseApp, expectedHeight int64, exp

func TestOptionFunction(t *testing.T) {
logger := defaultLogger()
db := memdb.NewDB()
db := dbm.NewMemDB()
bap := NewBaseApp("starting name", logger, 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 @@ -555,7 +554,7 @@ func TestInitChainer(t *testing.T) {
name := t.Name()
// keep the db and logger ourselves so
// we can reload the same app later
db := memdb.NewDB()
db := dbm.NewMemDB()
logger := defaultLogger()
app := NewBaseApp(name, logger, db, nil)
capKey := sdk.NewKVStoreKey("main")
Expand Down Expand Up @@ -634,7 +633,7 @@ func TestInitChainer(t *testing.T) {

func TestInitChain_WithInitialHeight(t *testing.T) {
name := t.Name()
db := memdb.NewDB()
db := dbm.NewMemDB()
logger := defaultLogger()
app := NewBaseApp(name, logger, db, nil)

Expand All @@ -650,7 +649,7 @@ func TestInitChain_WithInitialHeight(t *testing.T) {

func TestBeginBlock_WithInitialHeight(t *testing.T) {
name := t.Name()
db := memdb.NewDB()
db := dbm.NewMemDB()
logger := defaultLogger()
app := NewBaseApp(name, logger, db, nil)

Expand Down Expand Up @@ -2014,7 +2013,7 @@ func TestWithRouter(t *testing.T) {
}

func TestBaseApp_EndBlock(t *testing.T) {
db := memdb.NewDB()
db := dbm.NewMemDB()
name := t.Name()
logger := defaultLogger()

Expand All @@ -2025,7 +2024,7 @@ func TestBaseApp_EndBlock(t *testing.T) {
}

app := NewBaseApp(name, logger, db, nil)
app.SetParamStore(&paramStore{db: memdb.NewDB()})
app.SetParamStore(&paramStore{db: dbm.NewMemDB()})
app.InitChain(abci.RequestInitChain{
ConsensusParams: cp,
})
Expand Down
4 changes: 2 additions & 2 deletions baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
abci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"
"github.com/line/tm-db/v2/memdb"
dbm "github.com/tendermint/tm-db"

"github.com/line/lbm-sdk/baseapp"
"github.com/line/lbm-sdk/client"
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
encCfg.InterfaceRegistry.RegisterImplementations((*sdk.Msg)(nil),
&testdata.TestMsg{},
)
app = simapp.NewSimApp(log.NewNopLogger(), memdb.NewDB(), nil, true, map[int64]bool{}, "", 0, encCfg, simapp.EmptyAppOptions{}, nil, routerOpt)
app = simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, map[int64]bool{}, "", 0, encCfg, simapp.EmptyAppOptions{}, nil, routerOpt)
genState := simapp.NewDefaultGenesisState(encCfg.Marshaler)
stateBytes, err := json.MarshalIndent(genState, "", " ")
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

"github.com/line/ostracon/libs/log"
"github.com/line/tm-db/v2/memdb"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

"github.com/line/lbm-sdk/baseapp"
"github.com/line/lbm-sdk/codec/types"
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestGRPCGatewayRouter(t *testing.T) {

func TestRegisterQueryServiceTwice(t *testing.T) {
// Setup baseapp.
db := memdb.NewDB()
db := dbm.NewMemDB()
encCfg := simapp.MakeTestEncodingConfig()
app := baseapp.NewBaseApp("test", log.NewOCLogger(log.NewSyncWriter(os.Stdout)), db, encCfg.TxConfig.TxDecoder())
app.SetInterfaceRegistry(encCfg.InterfaceRegistry)
Expand Down
Loading

0 comments on commit 7b240f0

Please sign in to comment.