Skip to content

Commit

Permalink
feat!: apply changes to replace Ostracon proto message with Tendermint (
Browse files Browse the repository at this point in the history
#869)

* feat!: apply the changes of Finschia/ostracon#546
 - (replace a some same proto message to Tendermint )

* chore: fix lint error

* chore: add changelog

* chore: add more unittest

* chore: increase upgrade_height of cosmovisor test. (5->20)

* fix: test-cosmovisor error

* chore: apply feedback of review.

* docs: update proto format and related document.
  • Loading branch information
zemyblue committed Feb 6, 2023
1 parent 6c84a4c commit ec7cd38
Show file tree
Hide file tree
Showing 212 changed files with 2,797 additions and 2,085 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Breaking Changes
* (rest) [\#807](https://github.com/line/lbm-sdk/pull/807) remove legacy REST API
* (codec) [\#833](https://github.com/line/lbm-sdk/pull/833) Fix foundation amino codec
* (ostracon) [\#869](https://github.com/line/lbm-sdk/pull/869) apply changes to replace Ostracon proto message with Tendermint
* (x/bank) [\#876](https://github.com/line/lbm-sdk/pull/876) Add `MultiSend` deactivation


### Build, CI
* (ci) [\#829](https://github.com/line/lbm-sdk/pull/829) automate release process
* (build) [\#872](https://github.com/line/lbm-sdk/pull/872) Retract v1.0.0
Expand Down
20 changes: 11 additions & 9 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
"google.golang.org/grpc/codes"
grpcstatus "google.golang.org/grpc/status"

abci "github.com/line/ostracon/abci/types"
abci "github.com/tendermint/tendermint/abci/types"

ocabci "github.com/line/ostracon/abci/types"
ocproto "github.com/line/ostracon/proto/ostracon/types"

"github.com/line/lbm-sdk/codec"
Expand Down Expand Up @@ -124,7 +126,7 @@ func (app *BaseApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOp
}

// BeginBlock implements the ABCI application interface.
func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock) {
func (app *BaseApp) BeginBlock(req ocabci.RequestBeginBlock) (res abci.ResponseBeginBlock) {
defer telemetry.MeasureSince(time.Now(), "abci", "begin_block")

if app.cms.TracingEnabled() {
Expand Down Expand Up @@ -228,7 +230,7 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
// internal CheckTx state if the AnteHandler passes. Otherwise, the ResponseCheckTx
// will contain releveant error information. Regardless of tx execution outcome,
// the ResponseCheckTx will contain relevant gas execution context.
func (app *BaseApp) CheckTxSync(req abci.RequestCheckTx) abci.ResponseCheckTx {
func (app *BaseApp) CheckTxSync(req abci.RequestCheckTx) ocabci.ResponseCheckTx {
defer telemetry.MeasureSince(time.Now(), "abci", "check_tx")

if req.Type != abci.CheckTxType_New && req.Type != abci.CheckTxType_Recheck {
Expand All @@ -251,13 +253,13 @@ func (app *BaseApp) CheckTxSync(req abci.RequestCheckTx) abci.ResponseCheckTx {
// return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace) // TODO(dudong2): need to fix to use ResponseCheckTxWithEvents
}

return abci.ResponseCheckTx{
return ocabci.ResponseCheckTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints?
}
}

func (app *BaseApp) CheckTxAsync(req abci.RequestCheckTx, callback abci.CheckTxCallback) {
func (app *BaseApp) CheckTxAsync(req abci.RequestCheckTx, callback ocabci.CheckTxCallback) {
if req.Type != abci.CheckTxType_New && req.Type != abci.CheckTxType_Recheck {
panic(fmt.Sprintf("unknown RequestCheckTx type: %s", req.Type))
}
Expand All @@ -274,15 +276,15 @@ func (app *BaseApp) CheckTxAsync(req abci.RequestCheckTx, callback abci.CheckTxC
}

// BeginRecheckTx implements the ABCI interface and set the check state based on the given header
func (app *BaseApp) BeginRecheckTx(req abci.RequestBeginRecheckTx) abci.ResponseBeginRecheckTx {
func (app *BaseApp) BeginRecheckTx(req ocabci.RequestBeginRecheckTx) ocabci.ResponseBeginRecheckTx {
// NOTE: This is safe because Ostracon holds a lock on the mempool for Rechecking.
app.setCheckState(req.Header)
return abci.ResponseBeginRecheckTx{Code: abci.CodeTypeOK}
return ocabci.ResponseBeginRecheckTx{Code: abci.CodeTypeOK}
}

// EndRecheckTx implements the ABCI interface.
func (app *BaseApp) EndRecheckTx(req abci.RequestEndRecheckTx) abci.ResponseEndRecheckTx {
return abci.ResponseEndRecheckTx{Code: abci.CodeTypeOK}
func (app *BaseApp) EndRecheckTx(req ocabci.RequestEndRecheckTx) ocabci.ResponseEndRecheckTx {
return ocabci.ResponseEndRecheckTx{Code: abci.CodeTypeOK}
}

// DeliverTx implements the ABCI interface and executes a tx in DeliverTx mode.
Expand Down
15 changes: 8 additions & 7 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"encoding/json"
"testing"

abci "github.com/line/ostracon/abci/types"
ocabci "github.com/line/ostracon/abci/types"
ocproto "github.com/line/ostracon/proto/ostracon/types"
ocprototypes "github.com/line/ostracon/proto/ostracon/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

sdk "github.com/line/lbm-sdk/types"
Expand Down Expand Up @@ -116,7 +117,7 @@ func TestGetBlockRentionHeight(t *testing.T) {
tc.bapp.SetParamStore(&paramStore{db: dbm.NewMemDB()})
tc.bapp.InitChain(abci.RequestInitChain{
ConsensusParams: &abci.ConsensusParams{
Evidence: &ocprototypes.EvidenceParams{
Evidence: &tmproto.EvidenceParams{
MaxAgeNumBlocks: tc.maxAgeBlocks,
},
},
Expand All @@ -141,10 +142,10 @@ func TestBaseAppCreateQueryContext(t *testing.T) {
app := NewBaseApp(name, logger, db, nil)
app.init()

app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
app.Commit()

app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
app.Commit()

testCases := []struct {
Expand Down Expand Up @@ -192,7 +193,7 @@ func TestBaseAppBeginBlockConsensusParams(t *testing.T) {
app.init()

// set block params
app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
ctx := app.deliverState.ctx
maxGas := int64(123456789)
app.paramStore.Set(ctx, ParamStoreKeyBlockParams,
Expand All @@ -202,7 +203,7 @@ func TestBaseAppBeginBlockConsensusParams(t *testing.T) {
app.Commit()

// confirm consensus params updated into the context
app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
newCtx := app.getContextForTx(app.checkState, []byte{})
require.Equal(t, maxGas, newCtx.ConsensusParams().Block.MaxGas)
}
Expand Down
13 changes: 8 additions & 5 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (

"github.com/gogo/protobuf/proto"

abci "github.com/line/ostracon/abci/types"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

ocabci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/crypto/tmhash"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"
Expand All @@ -25,7 +28,7 @@ import (
"github.com/line/lbm-sdk/x/auth/legacy/legacytx"
)

var _ abci.Application = (*BaseApp)(nil)
var _ ocabci.Application = (*BaseApp)(nil)

type (
// StoreLoader defines a customizable function to control how we load the CommitMultiStore
Expand Down Expand Up @@ -457,14 +460,14 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *abci.ConsensusParams {
}

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

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

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

app.paramStore.Get(ctx, ParamStoreKeyValidatorParams, &vp)
cp.Validator = &vp
Expand Down Expand Up @@ -518,7 +521,7 @@ func (app *BaseApp) getMaximumBlockGas(ctx sdk.Context) uint64 {
}
}

func (app *BaseApp) validateHeight(req abci.RequestBeginBlock) error {
func (app *BaseApp) validateHeight(req ocabci.RequestBeginBlock) error {
if req.Header.Height < 1 {
return fmt.Errorf("invalid height: %d", req.Header.Height)
}
Expand Down
5 changes: 3 additions & 2 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

abci "github.com/line/ostracon/abci/types"
ocabci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/line/lbm-sdk/codec"
"github.com/line/lbm-sdk/codec/legacy"
Expand Down Expand Up @@ -105,7 +106,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: ocproto.Header{Height: i}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: i}})
res := app.Commit()
lastCommitID = sdk.CommitID{Version: i, Hash: res.Data}
}
Expand Down
8 changes: 5 additions & 3 deletions baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (

"github.com/stretchr/testify/require"

abci "github.com/line/ostracon/abci/types"
abci "github.com/tendermint/tendermint/abci/types"
dbm "github.com/tendermint/tm-db"

ocabci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/libs/log"
ocproto "github.com/line/ostracon/proto/ostracon/types"
dbm "github.com/tendermint/tm-db"

"github.com/line/lbm-sdk/baseapp"
"github.com/line/lbm-sdk/client"
Expand Down Expand Up @@ -105,7 +107,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
_, txBytes, err := createTestTx(encCfg.TxConfig, txBuilder, privs, accNums, accSeqs, ctx.ChainID())
require.NoError(t, err)

app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
rsp := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes})

// check result
Expand Down
Loading

0 comments on commit ec7cd38

Please sign in to comment.