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

Update ostracon #1080

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (app *BaseApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOp
}

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

if app.cms.TracingEnabled() {
Expand Down Expand Up @@ -228,7 +228,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) ocabci.ResponseCheckTx {
func (app *BaseApp) CheckTxSync(req abci.RequestCheckTx) abci.ResponseCheckTx {
defer telemetry.MeasureSince(time.Now(), "abci", "check_tx")

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

return ocabci.ResponseCheckTx{
return abci.ResponseCheckTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints?
}
Expand Down
10 changes: 4 additions & 6 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

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

sdk "github.com/Finschia/finschia-sdk/types"
)

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

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

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

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

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

// confirm consensus params updated into the context
app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: 2}})
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 2}})
newCtx := app.getContextForTx(app.checkState, []byte{})
require.Equal(t, maxGas, newCtx.ConsensusParams().Block.MaxGas)
}
Expand Down
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (app *BaseApp) getMaximumBlockGas(ctx sdk.Context) uint64 {
}
}

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

ocabci "github.com/Finschia/ostracon/abci/types"
"github.com/Finschia/ostracon/libs/log"

"github.com/Finschia/finschia-sdk/codec"
Expand Down Expand Up @@ -106,7 +105,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: tmproto.Header{Height: i}})
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: i}})
res := app.Commit()
lastCommitID = sdk.CommitID{Version: i, Hash: res.Data}
}
Expand Down
3 changes: 1 addition & 2 deletions baseapp/block_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

ocabci "github.com/Finschia/ostracon/abci/types"
"github.com/Finschia/ostracon/libs/log"

"github.com/Finschia/finschia-sdk/baseapp"
Expand Down Expand Up @@ -106,7 +105,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: tmproto.Header{Height: 1}})
app.BeginBlock(abci.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 @@ -218,7 +218,7 @@ func TestWithRouter(t *testing.T) {

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

for i := 0; i < txPerHeight; i++ {
counter := int64(blockN*txPerHeight + i)
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestQuery(t *testing.T) {

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

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

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

req := testdata.SayHelloRequest{Name: "foo"}
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {
// with all msgs the same route

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

tx := newTxCounter(count, count)
txBytes, err := cdc.Marshal(tx)
Expand Down Expand Up @@ -554,7 +554,7 @@ func TestRunInvalidTransaction(t *testing.T) {
app := setupBaseApp(t, anteOpt, routerOpt)

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

// transaction with no messages
{
Expand Down Expand Up @@ -681,7 +681,7 @@ func TestTxGasLimits(t *testing.T) {
app := setupBaseApp(t, anteOpt, routerOpt)

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

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

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

// execute the transaction multiple times
for j := 0; j < tc.numDelivers; j++ {
Expand Down Expand Up @@ -848,7 +848,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) {
app := setupBaseApp(t, anteOpt, routerOpt)

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

app.AddRunTxRecoveryHandler(func(recoveryObj interface{}) error {
err, ok := recoveryObj.(error)
Expand Down Expand Up @@ -890,7 +890,7 @@ func TestBaseAppAnteHandler(t *testing.T) {
registerTestCodec(cdc)

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

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

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

tx := newTxCounter(5, 0)
tx.setFailOnAnte(true)
Expand Down Expand Up @@ -1092,7 +1092,7 @@ func TestInitChainer(t *testing.T) {

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

res = app.Query(query)
Expand Down Expand Up @@ -1128,14 +1128,14 @@ func TestBeginBlock_WithInitialHeight(t *testing.T) {
)

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

app.BeginBlock(ocabci.RequestBeginBlock{
app.BeginBlock(abci.RequestBeginBlock{
Header: tmproto.Header{
Height: 3,
},
Expand Down Expand Up @@ -1440,7 +1440,7 @@ func TestCheckTx(t *testing.T) {

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

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

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

for i := 0; i < txPerHeight; i++ {
counter := int64(blockN*txPerHeight + i)
Expand Down Expand Up @@ -1628,7 +1628,7 @@ func TestLoadVersionInvalid(t *testing.T) {
require.Error(t, err)

header := tmproto.Header{Height: 1}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
app.BeginBlock(abci.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: tmproto.Header{Height: height}})
app.BeginBlock(abci.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 @@ -1750,13 +1750,13 @@ func TestLoadVersion(t *testing.T) {

// execute a block, collect commit ID
header := tmproto.Header{Height: 1}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
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}
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
app.BeginBlock(abci.RequestBeginBlock{Header: header})
res = app.Commit()
commitID2 := sdk.CommitID{Version: 2, Hash: res.Data}

Expand All @@ -1773,7 +1773,7 @@ func TestLoadVersion(t *testing.T) {
err = app.LoadVersion(1)
require.Nil(t, err)
testLoadVersionHelper(t, app, int64(1), commitID1)
app.BeginBlock(ocabci.RequestBeginBlock{Header: header})
app.BeginBlock(abci.RequestBeginBlock{Header: header})
app.Commit()
testLoadVersionHelper(t, app, int64(2), commitID2)
}
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: tmproto.Header{Height: 2}})
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 2}})
res := app.Commit()
require.NotNil(t, res.Data)

Expand Down
3 changes: 1 addition & 2 deletions baseapp/msg_service_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

ocabci "github.com/Finschia/ostracon/abci/types"
"github.com/Finschia/ostracon/libs/log"

"github.com/Finschia/finschia-sdk/baseapp"
Expand Down Expand Up @@ -80,7 +79,7 @@ func TestMsgService(t *testing.T) {
app.MsgServiceRouter(),
testdata.MsgServerImpl{},
)
_ = app.BeginBlock(ocabci.RequestBeginBlock{Header: tmproto.Header{Height: 1}})
_ = app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 1}})

msg := testdata.MsgCreateDog{Dog: &testdata.Dog{Name: "Spot"}}
txBuilder := encCfg.TxConfig.NewTxBuilder()
Expand Down
3 changes: 2 additions & 1 deletion baseapp/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"sync"

ocabci "github.com/Finschia/ostracon/abci/types"
abci "github.com/tendermint/tendermint/abci/types"

sdk "github.com/Finschia/finschia-sdk/types"
sdkerrors "github.com/Finschia/finschia-sdk/types/errors"
Expand Down Expand Up @@ -52,7 +53,7 @@ func (app *BaseApp) checkTxAsync(req *RequestCheckTxAsync, waits []*sync.WaitGro
return
}

req.callback(ocabci.ResponseCheckTx{
req.callback(abci.ResponseCheckTx{
GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints?
GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints?
})
Expand Down
4 changes: 1 addition & 3 deletions baseapp/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import (

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

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

store "github.com/Finschia/finschia-sdk/store/types"
"github.com/Finschia/finschia-sdk/types"
)

// ABCIListener interface used to hook into the ABCI message processing of the BaseApp
type ABCIListener interface {
// ListenBeginBlock updates the streaming service with the latest BeginBlock messages
ListenBeginBlock(ctx types.Context, req ocabci.RequestBeginBlock, res abci.ResponseBeginBlock) error
ListenBeginBlock(ctx types.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error
// ListenEndBlock updates the steaming service with the latest EndBlock messages
ListenEndBlock(ctx types.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error
// ListenDeliverTx updates the steaming service with the latest DeliverTx messages
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module github.com/Finschia/finschia-sdk

require (
github.com/99designs/keyring v1.1.6
github.com/Finschia/ostracon v1.1.1
github.com/Finschia/ostracon v1.1.2-0.20230810030810-5836604d7dd0
github.com/VictoriaMetrics/fastcache v1.12.1
github.com/armon/go-metrics v0.4.1
github.com/bgentry/speakeasy v0.1.0
Expand Down Expand Up @@ -113,7 +113,7 @@ require (
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/cors v1.9.0 // indirect
github.com/rs/zerolog v1.29.1 // indirect
github.com/rs/zerolog v1.30.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand All @@ -122,7 +122,7 @@ require (
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/net v0.13.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
Expand Down
Loading
Loading