Skip to content

Commit

Permalink
feat!: apply the changes of vrf location in Ostracon (#887)
Browse files Browse the repository at this point in the history
* feat: apply the changes of vrf location in Ostracon.
 - change ostracon block.header to tendermint block.header

* chore: remove unused import

* chore: bump up ostracon

* chore: proto file linting

* chore: update changelog

* chore: update swagger

* chore: apply the import ordering rule.

* chore: fix strange new line.
  • Loading branch information
zemyblue authored Feb 9, 2023
1 parent e2aa3ea commit b886473
Show file tree
Hide file tree
Showing 146 changed files with 2,559 additions and 2,741 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/foundation) [\#848](https://github.com/line/lbm-sdk/pull/848) remove `gov mint` for x/foundation proposal
* (x/wasm) [\#850](https://github.com/line/lbm-sdk/pull/850) remove `x/wasm` module in lbm-sdk
* (log) [\#883](https://github.com/line/lbm-sdk/pull/883) add zerolog based rolling log system
* (Ostracon) [\#887](https://github.com/line/lbm-sdk/pull/887) apply the changes of vrf location in Ostracon

### Improvements
* (cosmovisor) [\#792](https://github.com/line/lbm-sdk/pull/792) Use upstream's cosmovisor
Expand Down
9 changes: 4 additions & 5 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,32 @@ import (
"time"

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

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"
snapshottypes "github.com/line/lbm-sdk/snapshots/types"
"github.com/line/lbm-sdk/telemetry"
sdk "github.com/line/lbm-sdk/types"
sdkerrors "github.com/line/lbm-sdk/types/errors"
ocabci "github.com/line/ostracon/abci/types"
)

// InitChain implements the ABCI interface. It runs the initialization logic
// directly on the CommitMultiStore.
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 := ocproto.Header{ChainID: req.ChainId, Time: req.Time}
initHeader := tmproto.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 = ocproto.Header{ChainID: req.ChainId, Height: req.InitialHeight, Time: req.Time}
initHeader = tmproto.Header{ChainID: req.ChainId, Height: req.InitialHeight, Time: req.Time}
err := app.cms.SetInitialVersion(req.InitialHeight)
if err != nil {
panic(err)
Expand Down
12 changes: 6 additions & 6 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"encoding/json"
"testing"

ocabci "github.com/line/ostracon/abci/types"
ocproto "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"

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

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

Expand Down Expand Up @@ -142,10 +142,10 @@ func TestBaseAppCreateQueryContext(t *testing.T) {
app := NewBaseApp(name, logger, db, nil)
app.init()

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

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

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

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

// confirm consensus params updated into the context
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: 2}})
newCtx := app.getContextForTx(app.checkState, []byte{})
require.Equal(t, maxGas, newCtx.ConsensusParams().Block.MaxGas)
}
Expand Down
7 changes: 3 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
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"
dbm "github.com/tendermint/tm-db"

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

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

// make sure the snapshot interval is a multiple of the pruning KeepEvery interval
Expand Down Expand Up @@ -416,7 +415,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 ocproto.Header) {
func (app *BaseApp) setCheckState(header tmproto.Header) {
ms := app.cms.CacheMultiStore()
app.checkStateMtx.Lock()
defer app.checkStateMtx.Unlock()
Expand All @@ -435,7 +434,7 @@ func (app *BaseApp) setCheckState(header ocproto.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 ocproto.Header) {
func (app *BaseApp) setDeliverState(header tmproto.Header) {
ms := app.cms.CacheMultiStore()
app.deliverState = &state{
ms: ms,
Expand Down
8 changes: 4 additions & 4 deletions baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (

"github.com/stretchr/testify/assert"
"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"

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 @@ -106,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(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: i}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: i}})
res := app.Commit()
lastCommitID = sdk.CommitID{Version: i, Hash: res.Data}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestSetMinGasPrices(t *testing.T) {
func TestGetMaximumBlockGas(t *testing.T) {
app := setupBaseApp(t)
app.InitChain(abci.RequestInitChain{})
ctx := app.NewContext(true, ocproto.Header{})
ctx := app.NewContext(true, tmproto.Header{})

app.StoreConsensusParams(ctx, &abci.ConsensusParams{Block: &abci.BlockParams{MaxGas: 0}})
require.Equal(t, uint64(0), app.getMaximumBlockGas(ctx))
Expand Down
7 changes: 3 additions & 4 deletions baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import (
"testing"

"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"

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

"github.com/line/lbm-sdk/baseapp"
"github.com/line/lbm-sdk/client"
Expand Down Expand Up @@ -79,7 +78,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
AppStateBytes: stateBytes,
})

ctx := app.NewContext(false, ocproto.Header{})
ctx := app.NewContext(false, tmproto.Header{})

// tx fee
feeCoin := sdk.NewCoin("atom", sdk.NewInt(150))
Expand Down Expand Up @@ -107,7 +106,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
_, txBytes, err := createTestTx(encCfg.TxConfig, txBuilder, privs, accNums, accSeqs, ctx.ChainID())
require.NoError(t, err)

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

// check result
Expand Down
44 changes: 22 additions & 22 deletions baseapp/deliver_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"github.com/stretchr/testify/assert"
"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"

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

"github.com/line/lbm-sdk/codec"
"github.com/line/lbm-sdk/snapshots"
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestWithRouter(t *testing.T) {
txPerHeight := 5

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

for i := 0; i < txPerHeight; i++ {
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestQuery(t *testing.T) {
require.Equal(t, 0, len(res.Value))

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

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

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

Expand Down Expand Up @@ -417,7 +417,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {
// run a multi-msg tx
// with all msgs the same route

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

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

app := setupBaseApp(t, anteOpt, routerOpt)

header := ocproto.Header{Height: 1}
header := tmproto.Header{Height: 1}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})

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

app := setupBaseApp(t, anteOpt, routerOpt)

header := ocproto.Header{Height: 1}
header := tmproto.Header{Height: 1}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})

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

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

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

app := setupBaseApp(t, anteOpt, routerOpt)

header := ocproto.Header{Height: 1}
header := tmproto.Header{Height: 1}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})

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

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

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

app.InitChain(abci.RequestInitChain{})

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

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

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

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

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

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

// If a block is committed, CheckTx state should be reset.
header := ocproto.Header{Height: 1}
header := tmproto.Header{Height: 1}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header, Hash: []byte("hash")})

require.NotNil(t, app.checkState.ctx.BlockGasMeter(), "block gas meter should have been set to checkState")
Expand Down Expand Up @@ -1481,7 +1481,7 @@ func TestDeliverTx(t *testing.T) {
txPerHeight := 5

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

for i := 0; i < txPerHeight; i++ {
Expand Down Expand Up @@ -1627,7 +1627,7 @@ func TestLoadVersionInvalid(t *testing.T) {
err = app.LoadVersion(-1)
require.Error(t, err)

header := ocproto.Header{Height: 1}
header := tmproto.Header{Height: 1}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
res := app.Commit()
commitID1 := sdk.CommitID{Version: 1, Hash: res.Data}
Expand Down Expand Up @@ -1678,7 +1678,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(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: height}})
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: height}})
for txNum := 0; txNum < blockTxs; txNum++ {
tx := txTest{Msgs: []sdk.Msg{}}
for msgNum := 0; msgNum < 100; msgNum++ {
Expand Down Expand Up @@ -1749,13 +1749,13 @@ func TestLoadVersion(t *testing.T) {
require.Equal(t, emptyCommitID, lastID)

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

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

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

Expand Down
Loading

0 comments on commit b886473

Please sign in to comment.