Skip to content

Commit b886473

Browse files
authored
feat!: apply the changes of vrf location in Ostracon (#887)
* 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.
1 parent e2aa3ea commit b886473

File tree

146 files changed

+2559
-2741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2559
-2741
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4242
* (x/foundation) [\#848](https://github.com/line/lbm-sdk/pull/848) remove `gov mint` for x/foundation proposal
4343
* (x/wasm) [\#850](https://github.com/line/lbm-sdk/pull/850) remove `x/wasm` module in lbm-sdk
4444
* (log) [\#883](https://github.com/line/lbm-sdk/pull/883) add zerolog based rolling log system
45+
* (Ostracon) [\#887](https://github.com/line/lbm-sdk/pull/887) apply the changes of vrf location in Ostracon
4546

4647
### Improvements
4748
* (cosmovisor) [\#792](https://github.com/line/lbm-sdk/pull/792) Use upstream's cosmovisor

baseapp/abci.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,32 @@ import (
1212
"time"
1313

1414
"github.com/gogo/protobuf/proto"
15+
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1516
"google.golang.org/grpc/codes"
1617
grpcstatus "google.golang.org/grpc/status"
1718

1819
abci "github.com/tendermint/tendermint/abci/types"
1920

20-
ocabci "github.com/line/ostracon/abci/types"
21-
ocproto "github.com/line/ostracon/proto/ostracon/types"
22-
2321
"github.com/line/lbm-sdk/codec"
2422
snapshottypes "github.com/line/lbm-sdk/snapshots/types"
2523
"github.com/line/lbm-sdk/telemetry"
2624
sdk "github.com/line/lbm-sdk/types"
2725
sdkerrors "github.com/line/lbm-sdk/types/errors"
26+
ocabci "github.com/line/ostracon/abci/types"
2827
)
2928

3029
// InitChain implements the ABCI interface. It runs the initialization logic
3130
// directly on the CommitMultiStore.
3231
func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain) {
3332
// On a new chain, we consider the init chain block height as 0, even though
3433
// req.InitialHeight is 1 by default.
35-
initHeader := ocproto.Header{ChainID: req.ChainId, Time: req.Time}
34+
initHeader := tmproto.Header{ChainID: req.ChainId, Time: req.Time}
3635

3736
// If req.InitialHeight is > 1, then we set the initial version in the
3837
// stores.
3938
if req.InitialHeight > 1 {
4039
app.initialHeight = req.InitialHeight
41-
initHeader = ocproto.Header{ChainID: req.ChainId, Height: req.InitialHeight, Time: req.Time}
40+
initHeader = tmproto.Header{ChainID: req.ChainId, Height: req.InitialHeight, Time: req.Time}
4241
err := app.cms.SetInitialVersion(req.InitialHeight)
4342
if err != nil {
4443
panic(err)

baseapp/abci_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import (
44
"encoding/json"
55
"testing"
66

7-
ocabci "github.com/line/ostracon/abci/types"
8-
ocproto "github.com/line/ostracon/proto/ostracon/types"
97
"github.com/stretchr/testify/require"
108
abci "github.com/tendermint/tendermint/abci/types"
119
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1210
dbm "github.com/tendermint/tm-db"
1311

12+
ocabci "github.com/line/ostracon/abci/types"
13+
1414
sdk "github.com/line/lbm-sdk/types"
1515
)
1616

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

145-
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
145+
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: 1}})
146146
app.Commit()
147147

148-
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
148+
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: 2}})
149149
app.Commit()
150150

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

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

205205
// confirm consensus params updated into the context
206-
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
206+
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: 2}})
207207
newCtx := app.getContextForTx(app.checkState, []byte{})
208208
require.Equal(t, maxGas, newCtx.ConsensusParams().Block.MaxGas)
209209
}

baseapp/baseapp.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
ocabci "github.com/line/ostracon/abci/types"
1616
"github.com/line/ostracon/crypto/tmhash"
1717
"github.com/line/ostracon/libs/log"
18-
ocproto "github.com/line/ostracon/proto/ostracon/types"
1918
dbm "github.com/tendermint/tm-db"
2019

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

342341
// needed for the export command which inits from store but never calls initchain
343-
app.setCheckState(ocproto.Header{})
342+
app.setCheckState(tmproto.Header{})
344343
app.Seal()
345344

346345
// make sure the snapshot interval is a multiple of the pruning KeepEvery interval
@@ -416,7 +415,7 @@ func (app *BaseApp) IsSealed() bool { return app.sealed }
416415
// (i.e. a CacheMultiStore) and a new Context with the same multi-store branch,
417416
// provided header, and minimum gas prices set. It is set on InitChain and reset
418417
// on Commit.
419-
func (app *BaseApp) setCheckState(header ocproto.Header) {
418+
func (app *BaseApp) setCheckState(header tmproto.Header) {
420419
ms := app.cms.CacheMultiStore()
421420
app.checkStateMtx.Lock()
422421
defer app.checkStateMtx.Unlock()
@@ -435,7 +434,7 @@ func (app *BaseApp) setCheckState(header ocproto.Header) {
435434
// (i.e. a CacheMultiStore) and a new Context with the same multi-store branch,
436435
// and provided header. It is set on InitChain and BeginBlock and set to nil on
437436
// Commit.
438-
func (app *BaseApp) setDeliverState(header ocproto.Header) {
437+
func (app *BaseApp) setDeliverState(header tmproto.Header) {
439438
ms := app.cms.CacheMultiStore()
440439
app.deliverState = &state{
441440
ms: ms,

baseapp/baseapp_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import (
77

88
"github.com/stretchr/testify/assert"
99
"github.com/stretchr/testify/require"
10+
abci "github.com/tendermint/tendermint/abci/types"
11+
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1012
dbm "github.com/tendermint/tm-db"
1113

1214
ocabci "github.com/line/ostracon/abci/types"
1315
"github.com/line/ostracon/libs/log"
14-
ocproto "github.com/line/ostracon/proto/ostracon/types"
15-
abci "github.com/tendermint/tendermint/abci/types"
1616

1717
"github.com/line/lbm-sdk/codec"
1818
"github.com/line/lbm-sdk/codec/legacy"
@@ -106,7 +106,7 @@ func TestLoadVersionPruning(t *testing.T) {
106106
// Commit seven blocks, of which 7 (latest) is kept in addition to 6, 5
107107
// (keep recent) and 3 (keep every).
108108
for i := int64(1); i <= 7; i++ {
109-
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: i}})
109+
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: i}})
110110
res := app.Commit()
111111
lastCommitID = sdk.CommitID{Version: i, Hash: res.Data}
112112
}
@@ -146,7 +146,7 @@ func TestSetMinGasPrices(t *testing.T) {
146146
func TestGetMaximumBlockGas(t *testing.T) {
147147
app := setupBaseApp(t)
148148
app.InitChain(abci.RequestInitChain{})
149-
ctx := app.NewContext(true, ocproto.Header{})
149+
ctx := app.NewContext(true, tmproto.Header{})
150150

151151
app.StoreConsensusParams(ctx, &abci.ConsensusParams{Block: &abci.BlockParams{MaxGas: 0}})
152152
require.Equal(t, uint64(0), app.getMaximumBlockGas(ctx))

baseapp/block_gas_test.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77
"testing"
88

99
"github.com/stretchr/testify/require"
10-
1110
abci "github.com/tendermint/tendermint/abci/types"
11+
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1212
dbm "github.com/tendermint/tm-db"
1313

1414
ocabci "github.com/line/ostracon/abci/types"
1515
"github.com/line/ostracon/libs/log"
16-
ocproto "github.com/line/ostracon/proto/ostracon/types"
1716

1817
"github.com/line/lbm-sdk/baseapp"
1918
"github.com/line/lbm-sdk/client"
@@ -79,7 +78,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
7978
AppStateBytes: stateBytes,
8079
})
8180

82-
ctx := app.NewContext(false, ocproto.Header{})
81+
ctx := app.NewContext(false, tmproto.Header{})
8382

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

110-
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
109+
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: 1}})
111110
rsp := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes})
112111

113112
// check result

baseapp/deliver_tx_test.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import (
1515
"github.com/stretchr/testify/assert"
1616
"github.com/stretchr/testify/require"
1717
abci "github.com/tendermint/tendermint/abci/types"
18+
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1819
dbm "github.com/tendermint/tm-db"
1920

2021
ocabci "github.com/line/ostracon/abci/types"
2122
"github.com/line/ostracon/libs/log"
22-
ocproto "github.com/line/ostracon/proto/ostracon/types"
2323

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

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

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

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

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

340340
app.InitChain(abci.RequestInitChain{})
341-
header := ocproto.Header{Height: app.LastBlockHeight() + 1}
341+
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
342342
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
343343
app.Commit()
344344

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

420-
header := ocproto.Header{Height: 1}
420+
header := tmproto.Header{Height: 1}
421421
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
422422
tx := newTxCounter(0, 0, 1, 2)
423423
txBytes, err := codec.Marshal(tx)
@@ -498,7 +498,7 @@ func TestSimulateTx(t *testing.T) {
498498
nBlocks := 3
499499
for blockN := 0; blockN < nBlocks; blockN++ {
500500
count := int64(blockN + 1)
501-
header := ocproto.Header{Height: count}
501+
header := tmproto.Header{Height: count}
502502
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
503503

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

554554
app := setupBaseApp(t, anteOpt, routerOpt)
555555

556-
header := ocproto.Header{Height: 1}
556+
header := tmproto.Header{Height: 1}
557557
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
558558

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

681681
app := setupBaseApp(t, anteOpt, routerOpt)
682682

683-
header := ocproto.Header{Height: 1}
683+
header := tmproto.Header{Height: 1}
684684
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
685685

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

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

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

848848
app := setupBaseApp(t, anteOpt, routerOpt)
849849

850-
header := ocproto.Header{Height: 1}
850+
header := tmproto.Header{Height: 1}
851851
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
852852

853853
app.AddRunTxRecoveryHandler(func(recoveryObj interface{}) error {
@@ -889,7 +889,7 @@ func TestBaseAppAnteHandler(t *testing.T) {
889889
app.InitChain(abci.RequestInitChain{})
890890
registerTestCodec(cdc)
891891

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

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

999999
app.InitChain(abci.RequestInitChain{})
10001000

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

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

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

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

11301130
require.PanicsWithError(t, "invalid height: 4; expected: 3", func() {
11311131
app.BeginBlock(ocabci.RequestBeginBlock{
1132-
Header: ocproto.Header{
1132+
Header: tmproto.Header{
11331133
Height: 4,
11341134
},
11351135
})
11361136
})
11371137

11381138
app.BeginBlock(ocabci.RequestBeginBlock{
1139-
Header: ocproto.Header{
1139+
Header: tmproto.Header{
11401140
Height: 3,
11411141
},
11421142
})
@@ -1439,7 +1439,7 @@ func TestCheckTx(t *testing.T) {
14391439
require.Equal(t, nTxs, storedCounter)
14401440

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

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

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

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

1630-
header := ocproto.Header{Height: 1}
1630+
header := tmproto.Header{Height: 1}
16311631
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
16321632
res := app.Commit()
16331633
commitID1 := sdk.CommitID{Version: 1, Hash: res.Data}
@@ -1678,7 +1678,7 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options
16781678
r := rand.New(rand.NewSource(3920758213583))
16791679
keyCounter := 0
16801680
for height := int64(1); height <= int64(blocks); height++ {
1681-
app.BeginBlock(ocabci.RequestBeginBlock{Header: ocproto.Header{Height: height}})
1681+
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: height}})
16821682
for txNum := 0; txNum < blockTxs; txNum++ {
16831683
tx := txTest{Msgs: []sdk.Msg{}}
16841684
for msgNum := 0; msgNum < 100; msgNum++ {
@@ -1749,13 +1749,13 @@ func TestLoadVersion(t *testing.T) {
17491749
require.Equal(t, emptyCommitID, lastID)
17501750

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

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

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

0 commit comments

Comments
 (0)