diff --git a/abci/example/kvstore/kvstore_test.go b/abci/example/kvstore/kvstore_test.go index 0e23c2b4e..002c1cb41 100644 --- a/abci/example/kvstore/kvstore_test.go +++ b/abci/example/kvstore/kvstore_test.go @@ -107,7 +107,7 @@ func TestPersistentKVStoreInfo(t *testing.T) { header := tmproto.Header{ Height: height, } - kvstore.FinalizeBlock(types.RequestFinalizeBlock{Hash: hash, Header: header, Height: height}) + kvstore.FinalizeBlock(types.RequestFinalizeBlock{Hash: hash, Header: header}) kvstore.Commit() resInfo = kvstore.Info(types.RequestInfo{}) @@ -196,7 +196,6 @@ func makeApplyBlock( resFinalizeBlock := kvstore.FinalizeBlock(types.RequestFinalizeBlock{ Hash: hash, Header: header, - Height: height, Txs: txs, }) diff --git a/abci/types/messages_test.go b/abci/types/messages_test.go index fb219fe07..d7fbf34d2 100644 --- a/abci/types/messages_test.go +++ b/abci/types/messages_test.go @@ -13,7 +13,7 @@ import ( ) func TestMarshalJSON(t *testing.T) { - b, err := json.Marshal(&ResponseDeliverTx{}) + b, err := json.Marshal(&ExecTxResult{}) assert.NoError(t, err) // include empty fields. assert.True(t, strings.Contains(string(b), "code")) diff --git a/abci/types/result.go b/abci/types/result.go index d899b771a..a7198b633 100644 --- a/abci/types/result.go +++ b/abci/types/result.go @@ -33,6 +33,16 @@ func (r ResponseDeliverTx) IsErr() bool { return r.Code != CodeTypeOK } +// IsOK returns true if Code is OK. +func (r ExecTxResult) IsOK() bool { + return r.Code == CodeTypeOK +} + +// IsErr returns true if Code is something other than OK. +func (r ExecTxResult) IsErr() bool { + return r.Code != CodeTypeOK +} + // IsOK returns true if Code is OK. func (r ResponseQuery) IsOK() bool { return r.Code == CodeTypeOK diff --git a/internal/eventbus/event_bus.go b/internal/eventbus/event_bus.go index 87e07c471..e70c0de73 100644 --- a/internal/eventbus/event_bus.go +++ b/internal/eventbus/event_bus.go @@ -132,7 +132,7 @@ func (b *EventBus) PublishEventStateSyncStatus(ctx context.Context, data types.E // predefined keys (EventTypeKey, TxHashKey). Existing events with the same keys // will be overwritten. func (b *EventBus) PublishEventTx(ctx context.Context, data types.EventDataTx) error { - events := data.Result.Events + events := data.Result.TxEvents // add Tendermint-reserved events events = append(events, types.EventTx) diff --git a/internal/eventbus/event_bus_test.go b/internal/eventbus/event_bus_test.go index a7dc9687f..b582317cf 100644 --- a/internal/eventbus/event_bus_test.go +++ b/internal/eventbus/event_bus_test.go @@ -27,9 +27,9 @@ func TestEventBusPublishEventTx(t *testing.T) { require.NoError(t, err) tx := types.Tx("foo") - result := abci.ResponseDeliverTx{ + result := abci.ExecTxResult{ Data: []byte("bar"), - Events: []abci.Event{ + TxEvents: []abci.Event{ {Type: "testType", Attributes: []abci.EventAttribute{{Key: "baz", Value: "1"}}}, }, } @@ -134,9 +134,9 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) { require.NoError(t, err) tx := types.Tx("foo") - result := abci.ResponseDeliverTx{ + result := abci.ExecTxResult{ Data: []byte("bar"), - Events: []abci.Event{ + TxEvents: []abci.Event{ { Type: "transfer", Attributes: []abci.EventAttribute{ diff --git a/internal/state/execution.go b/internal/state/execution.go index ec32b5f0f..04243e4bb 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -398,7 +398,6 @@ func execBlockOnProxyApp( Txs: block.Txs.ToSliceOfBytes(), Hash: block.Hash(), Header: *pbh, - Height: block.Height, LastCommitInfo: buildLastCommitInfo(block, store, initialHeight), ByzantineValidators: block.Evidence.ToABCI(), }, diff --git a/internal/state/indexer/indexer_service_test.go b/internal/state/indexer/indexer_service_test.go index d640d4b23..f6261c519 100644 --- a/internal/state/indexer/indexer_service_test.go +++ b/internal/state/indexer/indexer_service_test.go @@ -80,7 +80,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) { Height: 1, Index: uint32(0), Tx: types.Tx("foo"), - Result: abci.ResponseDeliverTx{Code: 0}, + Result: abci.ExecTxResult{Code: 0}, } err = eventBus.PublishEventTx(ctx, types.EventDataTx{TxResult: *txResult1}) require.NoError(t, err) @@ -88,7 +88,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) { Height: 1, Index: uint32(1), Tx: types.Tx("bar"), - Result: abci.ResponseDeliverTx{Code: 0}, + Result: abci.ExecTxResult{Code: 0}, } err = eventBus.PublishEventTx(ctx, types.EventDataTx{TxResult: *txResult2}) require.NoError(t, err) diff --git a/internal/state/indexer/sink/kv/kv_test.go b/internal/state/indexer/sink/kv/kv_test.go index 53532f9fa..c178e6cb7 100644 --- a/internal/state/indexer/sink/kv/kv_test.go +++ b/internal/state/indexer/sink/kv/kv_test.go @@ -338,11 +338,11 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult { Height: 1, Index: 0, Tx: tx, - Result: abci.ResponseDeliverTx{ - Data: []byte{0}, - Code: abci.CodeTypeOK, - Log: "", - Events: events, + Result: abci.ExecTxResult{ + Data: []byte{0}, + Code: abci.CodeTypeOK, + Log: "", + TxEvents: events, }, } } diff --git a/internal/state/indexer/sink/psql/psql.go b/internal/state/indexer/sink/psql/psql.go index 353926102..9670d6c13 100644 --- a/internal/state/indexer/sink/psql/psql.go +++ b/internal/state/indexer/sink/psql/psql.go @@ -221,7 +221,7 @@ INSERT INTO `+tableTxResults+` (block_id, index, created_at, tx_hash, tx_result) return fmt.Errorf("indexing transaction meta-events: %w", err) } // Index any events packaged with the transaction. - if err := insertEvents(dbtx, blockID, txID, txr.Result.Events); err != nil { + if err := insertEvents(dbtx, blockID, txID, txr.Result.TxEvents); err != nil { return fmt.Errorf("indexing transaction events: %w", err) } return nil diff --git a/internal/state/indexer/sink/psql/psql_test.go b/internal/state/indexer/sink/psql/psql_test.go index 09453319e..5d44e2d25 100644 --- a/internal/state/indexer/sink/psql/psql_test.go +++ b/internal/state/indexer/sink/psql/psql_test.go @@ -266,11 +266,11 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult { Height: 1, Index: 0, Tx: types.Tx("HELLO WORLD"), - Result: abci.ResponseDeliverTx{ - Data: []byte{0}, - Code: abci.CodeTypeOK, - Log: "", - Events: events, + Result: abci.ExecTxResult{ + Data: []byte{0}, + Code: abci.CodeTypeOK, + Log: "", + TxEvents: events, }, } } diff --git a/internal/state/indexer/tx/kv/kv.go b/internal/state/indexer/tx/kv/kv.go index 108700523..0e0c83c70 100644 --- a/internal/state/indexer/tx/kv/kv.go +++ b/internal/state/indexer/tx/kv/kv.go @@ -97,7 +97,7 @@ func (txi *TxIndex) Index(results []*abci.TxResult) error { } func (txi *TxIndex) indexEvents(result *abci.TxResult, hash []byte, store dbm.Batch) error { - for _, event := range result.Result.Events { + for _, event := range result.Result.TxEvents { // only index events with a non-empty type if len(event.Type) == 0 { continue diff --git a/internal/state/indexer/tx/kv/kv_bench_test.go b/internal/state/indexer/tx/kv/kv_bench_test.go index e36aed185..4d8aee794 100644 --- a/internal/state/indexer/tx/kv/kv_bench_test.go +++ b/internal/state/indexer/tx/kv/kv_bench_test.go @@ -43,11 +43,11 @@ func BenchmarkTxSearch(b *testing.B) { Height: int64(i), Index: 0, Tx: types.Tx(string(txBz)), - Result: abci.ResponseDeliverTx{ - Data: []byte{0}, - Code: abci.CodeTypeOK, - Log: "", - Events: events, + Result: abci.ExecTxResult{ + Data: []byte{0}, + Code: abci.CodeTypeOK, + Log: "", + TxEvents: events, }, } diff --git a/internal/state/indexer/tx/kv/kv_test.go b/internal/state/indexer/tx/kv/kv_test.go index 2caf9efc1..8b92cb2d7 100644 --- a/internal/state/indexer/tx/kv/kv_test.go +++ b/internal/state/indexer/tx/kv/kv_test.go @@ -25,9 +25,9 @@ func TestTxIndex(t *testing.T) { Height: 1, Index: 0, Tx: tx, - Result: abci.ResponseDeliverTx{ + Result: abci.ExecTxResult{ Data: []byte{0}, - Code: abci.CodeTypeOK, Log: "", Events: nil, + Code: abci.CodeTypeOK, Log: "", TxEvents: nil, }, } hash := tx.Hash() @@ -48,9 +48,9 @@ func TestTxIndex(t *testing.T) { Height: 1, Index: 0, Tx: tx2, - Result: abci.ResponseDeliverTx{ + Result: abci.ExecTxResult{ Data: []byte{0}, - Code: abci.CodeTypeOK, Log: "", Events: nil, + Code: abci.CodeTypeOK, Log: "", TxEvents: nil, }, } hash2 := tx2.Hash() @@ -322,11 +322,11 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult { Height: 1, Index: 0, Tx: tx, - Result: abci.ResponseDeliverTx{ - Data: []byte{0}, - Code: abci.CodeTypeOK, - Log: "", - Events: events, + Result: abci.ExecTxResult{ + Data: []byte{0}, + Code: abci.CodeTypeOK, + Log: "", + TxEvents: events, }, } } @@ -346,11 +346,11 @@ func benchmarkTxIndex(txsCount int64, b *testing.B) { Height: 1, Index: txIndex, Tx: tx, - Result: abci.ResponseDeliverTx{ - Data: []byte{0}, - Code: abci.CodeTypeOK, - Log: "", - Events: []abci.Event{}, + Result: abci.ExecTxResult{ + Data: []byte{0}, + Code: abci.CodeTypeOK, + Log: "", + TxEvents: []abci.Event{}, }, } if err := batch.Add(txResult); err != nil { diff --git a/internal/state/state_test.go b/internal/state/state_test.go index ce14e2659..9555de0ef 100644 --- a/internal/state/state_test.go +++ b/internal/state/state_test.go @@ -111,8 +111,8 @@ func TestABCIResponsesSaveLoad1(t *testing.T) { abciResponses.FinalizeBlock = new(abci.ResponseFinalizeBlock) abciResponses.FinalizeBlock.TxResults = dtxs - abciResponses.FinalizeBlock.TxResults[0] = &abci.ExecTxResult{Data: []byte("foo"), Events: nil} - abciResponses.FinalizeBlock.TxResults[1] = &abci.ExecTxResult{Data: []byte("bar"), Log: "ok", Events: nil} + abciResponses.FinalizeBlock.TxResults[0] = &abci.ExecTxResult{Data: []byte("foo"), TxEvents: nil} + abciResponses.FinalizeBlock.TxResults[1] = &abci.ExecTxResult{Data: []byte("bar"), Log: "ok", TxEvents: nil} pbpk, err := encoding.PubKeyToProto(ed25519.GenPrivKey().PubKey()) require.NoError(t, err) abciResponses.FinalizeBlock.ValidatorUpdates = []abci.ValidatorUpdate{{PubKey: pbpk, Power: 10}} @@ -156,7 +156,7 @@ func TestABCIResponsesSaveLoad2(t *testing.T) { {Code: 383}, { Data: []byte("Gotcha!"), - Events: []abci.Event{ + TxEvents: []abci.Event{ {Type: "type1", Attributes: []abci.EventAttribute{{Key: "a", Value: "1"}}}, {Type: "type2", Attributes: []abci.EventAttribute{{Key: "build", Value: "stuff"}}}, }, @@ -164,7 +164,7 @@ func TestABCIResponsesSaveLoad2(t *testing.T) { }, []*abci.ExecTxResult{ {Code: 383, Data: nil}, - {Code: 0, Data: []byte("Gotcha!"), Events: []abci.Event{ + {Code: 0, Data: []byte("Gotcha!"), TxEvents: []abci.Event{ {Type: "type1", Attributes: []abci.EventAttribute{{Key: "a", Value: "1"}}}, {Type: "type2", Attributes: []abci.EventAttribute{{Key: "build", Value: "stuff"}}}, }}, diff --git a/test/e2e/app/app.go b/test/e2e/app/app.go index e824682f3..53d0a6e46 100644 --- a/test/e2e/app/app.go +++ b/test/e2e/app/app.go @@ -170,7 +170,7 @@ func (app *Application) FinalizeBlock(req abci.RequestFinalizeBlock) abci.Respon txs[i] = &abci.ExecTxResult{Code: code.CodeTypeOK} } - valUpdates, err := app.validatorUpdates(uint64(req.Height)) + valUpdates, err := app.validatorUpdates(uint64(req.Header.Height)) if err != nil { panic(err) } @@ -188,7 +188,7 @@ func (app *Application) FinalizeBlock(req abci.RequestFinalizeBlock) abci.Respon }, { Key: "height", - Value: strconv.Itoa(int(req.Height)), + Value: strconv.Itoa(int(req.Header.Height)), }, }, },