Skip to content

Commit

Permalink
chore: adopt ostracon, line/tm-db and line/iavl (#93)
Browse files Browse the repository at this point in the history
* chore: adopt ostracon

* chore: adopt `line/tm-db`

* chore: adopt `line/iavl`

* chore: replace `tendermint` to `ostracon` more

* fix: typo

* chore: rename `third_party/proto/tendermint` to `ostracon`

* chore: rename `proto/cosmos/base/tendermint` to `ostracon`

* chore: revise proto files

* chore: apply `make proto-format`

* chore: revise Makefile & protocgen.sh to work with GITHUB_TOKEN

* chore: commit the result of proto-gen

* fix: build error

* fix: handler_test.go rebase error

* fix: service_test has a wrong path that has `tendermint`
  • Loading branch information
jinsan-line authored Mar 17, 2021
1 parent 48d7061 commit 78226eb
Show file tree
Hide file tree
Showing 474 changed files with 5,499 additions and 5,466 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ 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/tendermint/tm-db DB
mockgen -package mocks -destination tests/mocks/tendermint_tm_db_DB.go github.com/line/tm-db/v2 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
mockgen -source=types/handler.go -package mocks -destination tests/mocks/types_handler.go
mockgen -package mocks -destination tests/mocks/grpc_server.go github.com/gogo/protobuf/grpc Server
mockgen -package mocks -destination tests/mocks/tendermint_tendermint_libs_log_DB.go github.com/tendermint/tendermint/libs/log Logger
mockgen -package mocks -destination tests/mocks/tendermint_tendermint_libs_log_DB.go github.com/line/ostracon/libs/log Logger
.PHONY: mocks

$(MOCKS_DIR):
Expand Down Expand Up @@ -371,7 +371,7 @@ proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh
$(DOCKER) run --rm -e GITHUB_TOKEN=$(GITHUB_TOKEN) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh

proto-format:
@echo "Formatting Protobuf files"
Expand Down
8 changes: 4 additions & 4 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

"github.com/gogo/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
abci "github.com/line/ostracon/abci/types"
ostproto "github.com/line/ostracon/proto/ostracon/types"
"google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"

Expand All @@ -28,13 +28,13 @@ import (
func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) {
// On a new chain, we consider the init chain block height as 0, even though
// req.InitialHeight is 1 by default.
initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time}
initHeader := ostproto.Header{ChainID: req.ChainId, Time: req.Time}

// If req.InitialHeight is > 1, then we set the initial version in the
// stores.
if req.InitialHeight > 1 {
app.initialHeight = req.InitialHeight
initHeader = tmproto.Header{ChainID: req.ChainId, Height: req.InitialHeight, Time: req.Time}
initHeader = ostproto.Header{ChainID: req.ChainId, Height: req.InitialHeight, Time: req.Time}
err := app.cms.SetInitialVersion(req.InitialHeight)
if err != nil {
panic(err)
Expand Down
8 changes: 4 additions & 4 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"testing"

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

sdk "github.com/line/lbm-sdk/v2/types"
)
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestGetBlockRentionHeight(t *testing.T) {
tc.bapp.SetParamStore(&paramStore{db: dbm.NewMemDB()})
tc.bapp.InitChain(abci.RequestInitChain{
ConsensusParams: &abci.ConsensusParams{
Evidence: &tmprototypes.EvidenceParams{
Evidence: &ostprototypes.EvidenceParams{
MaxAgeNumBlocks: tc.maxAgeBlocks,
},
},
Expand Down
20 changes: 10 additions & 10 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"strings"

"github.com/gogo/protobuf/proto"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/tmhash"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
abci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/crypto/tmhash"
"github.com/line/ostracon/libs/log"
ostproto "github.com/line/ostracon/proto/ostracon/types"
dbm "github.com/line/tm-db/v2"

"github.com/line/lbm-sdk/v2/codec/types"
"github.com/line/lbm-sdk/v2/snapshots"
Expand Down Expand Up @@ -285,7 +285,7 @@ func (app *BaseApp) init() error {
}

// needed for the export command which inits from store but never calls initchain
app.setCheckState(tmproto.Header{})
app.setCheckState(ostproto.Header{})
app.Seal()

// make sure the snapshot interval is a multiple of the pruning KeepEvery interval
Expand Down Expand Up @@ -361,7 +361,7 @@ func (app *BaseApp) IsSealed() bool { return app.sealed }
// (i.e. a CacheMultiStore) and a new Context with the same multi-store branch,
// provided header, and minimum gas prices set. It is set on InitChain and reset
// on Commit.
func (app *BaseApp) setCheckState(header tmproto.Header) {
func (app *BaseApp) setCheckState(header ostproto.Header) {
ms := app.cms.CacheMultiStore()
app.checkState = &state{
ms: ms,
Expand All @@ -373,7 +373,7 @@ func (app *BaseApp) setCheckState(header tmproto.Header) {
// (i.e. a CacheMultiStore) and a new Context with the same multi-store branch,
// and provided header. It is set on InitChain and BeginBlock and set to nil on
// Commit.
func (app *BaseApp) setDeliverState(header tmproto.Header) {
func (app *BaseApp) setDeliverState(header ostproto.Header) {
ms := app.cms.CacheMultiStore()
app.deliverState = &state{
ms: ms,
Expand All @@ -398,14 +398,14 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams {
}

if app.paramStore.Has(ctx, ParamStoreKeyEvidenceParams) {
var ep tmproto.EvidenceParams
var ep ostproto.EvidenceParams

app.paramStore.Get(ctx, ParamStoreKeyEvidenceParams, &ep)
cp.Evidence = &ep
}

if app.paramStore.Has(ctx, ParamStoreKeyValidatorParams) {
var vp tmproto.ValidatorParams
var vp ostproto.ValidatorParams

app.paramStore.Get(ctx, ParamStoreKeyValidatorParams, &vp)
cp.Validator = &vp
Expand Down
54 changes: 27 additions & 27 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"time"

"github.com/gogo/protobuf/jsonpb"
abci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"
ostproto "github.com/line/ostracon/proto/ostracon/types"
dbm "github.com/line/tm-db/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/line/lbm-sdk/v2/codec"
"github.com/line/lbm-sdk/v2/snapshots"
Expand Down Expand Up @@ -153,7 +153,7 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options
r := rand.New(rand.NewSource(3920758213583))
keyCounter := 0
for height := int64(1); height <= int64(blocks); height++ {
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height}})
app.BeginBlock(abci.RequestBeginBlock{Header: ostproto.Header{Height: height}})
for txNum := 0; txNum < blockTxs; txNum++ {
tx := txTest{Msgs: []sdk.Msg{}}
for msgNum := 0; msgNum < 100; msgNum++ {
Expand Down Expand Up @@ -224,13 +224,13 @@ func TestLoadVersion(t *testing.T) {
require.Equal(t, emptyCommitID, lastID)

// execute a block, collect commit ID
header := tmproto.Header{Height: 1}
header := ostproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res := app.Commit()
commitID1 := sdk.CommitID{Version: 1, Hash: res.Data}

// execute a block, collect commit ID
header = tmproto.Header{Height: 2}
header = ostproto.Header{Height: 2}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res = app.Commit()
commitID2 := sdk.CommitID{Version: 2, Hash: res.Data}
Expand Down Expand Up @@ -329,7 +329,7 @@ func TestSetLoader(t *testing.T) {
require.Nil(t, err)

// "execute" one block
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 2}})
app.BeginBlock(abci.RequestBeginBlock{Header: ostproto.Header{Height: 2}})
res := app.Commit()
require.NotNil(t, res.Data)

Expand Down Expand Up @@ -374,7 +374,7 @@ func TestLoadVersionInvalid(t *testing.T) {
err = app.LoadVersion(-1)
require.Error(t, err)

header := tmproto.Header{Height: 1}
header := ostproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res := app.Commit()
commitID1 := sdk.CommitID{Version: 1, Hash: res.Data}
Expand Down Expand Up @@ -424,7 +424,7 @@ func TestLoadVersionPruning(t *testing.T) {
// Commit seven blocks, of which 7 (latest) is kept in addition to 6, 5
// (keep recent) and 3 (keep every).
for i := int64(1); i <= 7; i++ {
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: i}})
app.BeginBlock(abci.RequestBeginBlock{Header: ostproto.Header{Height: i}})
res := app.Commit()
lastCommitID = sdk.CommitID{Version: i, Hash: res.Data}
}
Expand Down Expand Up @@ -623,7 +623,7 @@ func TestInitChainer(t *testing.T) {
require.Equal(t, value, res.Value)

// commit and ensure we can still query
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
header := ostproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.Commit()

Expand Down Expand Up @@ -661,14 +661,14 @@ func TestBeginBlock_WithInitialHeight(t *testing.T) {

require.PanicsWithError(t, "invalid height: 4; expected: 3", func() {
app.BeginBlock(abci.RequestBeginBlock{
Header: tmproto.Header{
Header: ostproto.Header{
Height: 4,
},
})
})

app.BeginBlock(abci.RequestBeginBlock{
Header: tmproto.Header{
Header: ostproto.Header{
Height: 3,
},
})
Expand Down Expand Up @@ -949,7 +949,7 @@ func TestCheckTx(t *testing.T) {
require.Equal(t, nTxs, storedCounter)

// If a block is committed, CheckTx state should be reset.
header := tmproto.Header{Height: 1}
header := ostproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.EndBlock(abci.RequestEndBlock{})
app.Commit()
Expand Down Expand Up @@ -984,7 +984,7 @@ func TestDeliverTx(t *testing.T) {
txPerHeight := 5

for blockN := 0; blockN < nBlocks; blockN++ {
header := tmproto.Header{Height: int64(blockN) + 1}
header := ostproto.Header{Height: int64(blockN) + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

for i := 0; i < txPerHeight; i++ {
Expand Down Expand Up @@ -1038,7 +1038,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {
// run a multi-msg tx
// with all msgs the same route

header := tmproto.Header{Height: 1}
header := ostproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
tx := newTxCounter(0, 0, 1, 2)
txBytes, err := codec.MarshalBinaryBare(tx)
Expand Down Expand Up @@ -1119,7 +1119,7 @@ func TestSimulateTx(t *testing.T) {
nBlocks := 3
for blockN := 0; blockN < nBlocks; blockN++ {
count := int64(blockN + 1)
header := tmproto.Header{Height: count}
header := ostproto.Header{Height: count}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

tx := newTxCounter(count, count)
Expand Down Expand Up @@ -1174,7 +1174,7 @@ func TestRunInvalidTransaction(t *testing.T) {

app := setupBaseApp(t, anteOpt, routerOpt)

header := tmproto.Header{Height: 1}
header := ostproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

// transaction with no messages
Expand Down Expand Up @@ -1302,7 +1302,7 @@ func TestTxGasLimits(t *testing.T) {

app := setupBaseApp(t, anteOpt, routerOpt)

header := tmproto.Header{Height: 1}
header := ostproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

testCases := []struct {
Expand Down Expand Up @@ -1416,7 +1416,7 @@ func TestMaxBlockGasLimits(t *testing.T) {
tx := tc.tx

// reset the block gas
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
header := ostproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

// execute the transaction multiple times
Expand Down Expand Up @@ -1469,7 +1469,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) {

app := setupBaseApp(t, anteOpt, routerOpt)

header := tmproto.Header{Height: 1}
header := ostproto.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

app.AddRunTxRecoveryHandler(func(recoveryObj interface{}) error {
Expand Down Expand Up @@ -1511,7 +1511,7 @@ func TestBaseAppAnteHandler(t *testing.T) {
app.InitChain(abci.RequestInitChain{})
registerTestCodec(cdc)

header := tmproto.Header{Height: app.LastBlockHeight() + 1}
header := ostproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

// execute a tx that will fail ante handler execution
Expand Down Expand Up @@ -1619,7 +1619,7 @@ func TestGasConsumptionBadTx(t *testing.T) {

app.InitChain(abci.RequestInitChain{})

header := tmproto.Header{Height: app.LastBlockHeight() + 1}
header := ostproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

tx := newTxCounter(5, 0)
Expand Down Expand Up @@ -1684,7 +1684,7 @@ func TestQuery(t *testing.T) {
require.Equal(t, 0, len(res.Value))

// query is still empty after a DeliverTx before we commit
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
header := ostproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

_, resTx, err = app.Deliver(aminoTxEncoder(), tx)
Expand All @@ -1710,7 +1710,7 @@ func TestGRPCQuery(t *testing.T) {
app := setupBaseApp(t, grpcQueryOpt)

app.InitChain(abci.RequestInitChain{})
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
header := ostproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.Commit()

Expand Down Expand Up @@ -1767,7 +1767,7 @@ func TestP2PQuery(t *testing.T) {
func TestGetMaximumBlockGas(t *testing.T) {
app := setupBaseApp(t)
app.InitChain(abci.RequestInitChain{})
ctx := app.NewContext(true, tmproto.Header{})
ctx := app.NewContext(true, ostproto.Header{})

app.StoreConsensusParams(ctx, &abci.ConsensusParams{Block: &abci.BlockParams{MaxGas: 0}})
require.Equal(t, uint64(0), app.getMaximumBlockGas(ctx))
Expand Down Expand Up @@ -1985,7 +1985,7 @@ func TestWithRouter(t *testing.T) {
txPerHeight := 5

for blockN := 0; blockN < nBlocks; blockN++ {
header := tmproto.Header{Height: int64(blockN) + 1}
header := ostproto.Header{Height: int64(blockN) + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})

for i := 0; i < txPerHeight; i++ {
Expand Down
2 changes: 1 addition & 1 deletion baseapp/grpcrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"

gogogrpc "github.com/gogo/protobuf/grpc"
abci "github.com/tendermint/tendermint/abci/types"
abci "github.com/line/ostracon/abci/types"
"google.golang.org/grpc"
"google.golang.org/grpc/encoding"
"google.golang.org/grpc/encoding/proto"
Expand Down
2 changes: 1 addition & 1 deletion baseapp/grpcrouter_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

gogogrpc "github.com/gogo/protobuf/grpc"
abci "github.com/tendermint/tendermint/abci/types"
abci "github.com/line/ostracon/abci/types"
"google.golang.org/grpc"

"github.com/line/lbm-sdk/v2/codec/types"
Expand Down
4 changes: 2 additions & 2 deletions baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"os"
"testing"

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

"github.com/line/lbm-sdk/v2/baseapp"
"github.com/line/lbm-sdk/v2/codec/types"
Expand Down
Loading

0 comments on commit 78226eb

Please sign in to comment.