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

feat!: apply the changes of vrf location in Ostracon #887

Merged
merged 9 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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