diff --git a/abci/client/grpc_client_test.go b/abci/client/grpc_client_test.go index c1ed4f7da..7162ad7bb 100644 --- a/abci/client/grpc_client_test.go +++ b/abci/client/grpc_client_test.go @@ -77,4 +77,4 @@ func TestGRPC(t *testing.T) { func dialerFunc(ctx context.Context, addr string) (net.Conn, error) { return tmnet.Connect(addr) -} \ No newline at end of file +} diff --git a/abci/client/socket_client_test.go b/abci/client/socket_client_test.go index ceb2765d2..2995c431c 100644 --- a/abci/client/socket_client_test.go +++ b/abci/client/socket_client_test.go @@ -50,7 +50,7 @@ func TestHangingAsyncCalls(t *testing.T) { resp := make(chan error, 1) go func() { - // Start BeginBlock and flush it + // Call CheckTx reqres, err := c.CheckTxAsync(context.Background(), &types.RequestCheckTx{}) require.NoError(t, err) // wait 20 ms for all events to travel socket, but @@ -60,7 +60,7 @@ func TestHangingAsyncCalls(t *testing.T) { err = s.Stop() require.NoError(t, err) - // wait for the response from BeginBlock + // wait for the response from CheckTx reqres.Wait() fmt.Print(reqres) resp <- c.Error() @@ -94,7 +94,7 @@ func TestBulk(t *testing.T) { // Connect to the socket client := abcicli.NewSocketClient(socket, false) - + t.Cleanup(func() { if err := client.Stop(); err != nil { t.Log(err) @@ -122,7 +122,6 @@ func TestBulk(t *testing.T) { require.NoError(t, err) } - func setupClientServer(t *testing.T, app types.Application) ( service.Service, abcicli.Client) { t.Helper() diff --git a/cmd/tendermint/commands/reindex_event.go b/cmd/tendermint/commands/reindex_event.go index 65070ef60..f5a9acb4d 100644 --- a/cmd/tendermint/commands/reindex_event.go +++ b/cmd/tendermint/commands/reindex_event.go @@ -41,7 +41,7 @@ reindex from the base block height(inclusive); and the default end-height is 0, the tooling will reindex until the latest block height(inclusive). User can omit either or both arguments. -Note: This operation requires ABCI Responses. Do not set DiscardFinalizeBlockResponses to true if you +Note: This operation requires ABCI Responses. Do not set DiscardABCIResponses to true if you want to use this command. `, Example: ` diff --git a/cmd/tendermint/commands/rollback.go b/cmd/tendermint/commands/rollback.go index 8a60e96ac..c232c0b8d 100644 --- a/cmd/tendermint/commands/rollback.go +++ b/cmd/tendermint/commands/rollback.go @@ -90,7 +90,7 @@ func loadStateAndBlockStore(config *cfg.Config) (*store.BlockStore, state.Store, return nil, nil, err } stateStore := state.NewStore(stateDB, state.StoreOptions{ - DiscardFinalizeBlockResponses: config.Storage.DiscardFinalizeBlockResponses, + DiscardABCIResponses: config.Storage.DiscardABCIResponses, }) return blockStore, stateStore, nil diff --git a/evidence/pool_test.go b/evidence/pool_test.go index 3b5c0626e..8283bb2f9 100644 --- a/evidence/pool_test.go +++ b/evidence/pool_test.go @@ -359,7 +359,7 @@ func TestRecoverPendingEvidence(t *testing.T) { func initializeStateFromValidatorSet(valSet *types.ValidatorSet, height int64) sm.Store { stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB, sm.StoreOptions{ - DiscardFinalizeBlockResponses: false, + DiscardABCIResponses: false, }) state := sm.State{ ChainID: evidenceChainID, diff --git a/mempool/v0/reactor_test.go b/mempool/v0/reactor_test.go index 3e4ef9074..b5022e260 100644 --- a/mempool/v0/reactor_test.go +++ b/mempool/v0/reactor_test.go @@ -98,11 +98,11 @@ func TestReactorConcurrency(t *testing.T) { reactors[0].mempool.Lock() defer reactors[0].mempool.Unlock() - deliverTxResponses := make([]*abci.ExecTxResult, len(txs)) + txResponses := make([]*abci.ExecTxResult, len(txs)) for i := range txs { - deliverTxResponses[i] = &abci.ExecTxResult{Code: 0} + txResponses[i] = &abci.ExecTxResult{Code: 0} } - err := reactors[0].mempool.Update(1, txs, deliverTxResponses, nil, nil) + err := reactors[0].mempool.Update(1, txs, txResponses, nil, nil) assert.NoError(t, err) }() diff --git a/mempool/v1/mempool.go b/mempool/v1/mempool.go index cd0a6cfd7..6f7b19e83 100644 --- a/mempool/v1/mempool.go +++ b/mempool/v1/mempool.go @@ -387,7 +387,7 @@ func (txmp *TxMempool) Update( ) error { // Safety check: Transactions and responses must match in number. if len(blockTxs) != len(txResults) { - panic(fmt.Sprintf("mempool: got %d transactions but %d DeliverTx responses", + panic(fmt.Sprintf("mempool: got %d transactions but %d TxResult responses", len(blockTxs), len(txResults))) } diff --git a/node/node.go b/node/node.go index ddf86e0dc..2342257cf 100644 --- a/node/node.go +++ b/node/node.go @@ -171,7 +171,7 @@ func NewNode(config *cfg.Config, // EventBus and IndexerService must be started before the handshake because // we might need to index the txs of the replayed block as this might not have happened // when the node stopped last time (i.e. the node stopped after it saved the block - // but before it indexed the txs, or, endblocker panicked) + // but before it indexed the txs) eventBus, err := createAndStartEventBus(logger) if err != nil { return nil, err diff --git a/rpc/client/interface.go b/rpc/client/interface.go index 92783634c..bc3df8f15 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -74,7 +74,7 @@ type SignClient interface { Tx(ctx context.Context, hash []byte, prove bool) (*ctypes.ResultTx, error) // TxSearch defines a method to search for a paginated set of transactions by - // DeliverTx event search criteria. + // transaction event search criteria. TxSearch( ctx context.Context, query string, @@ -83,8 +83,8 @@ type SignClient interface { orderBy string, ) (*ctypes.ResultTxSearch, error) - // BlockSearch defines a method to search for a paginated set of blocks by - // BeginBlock and EndBlock event search criteria. + // BlockSearch defines a method to search for a paginated set of blocks based + // from FinalizeBlock event search criteria. BlockSearch( ctx context.Context, query string, diff --git a/rpc/core/blocks.go b/rpc/core/blocks.go index c3f56d677..08568f5fb 100644 --- a/rpc/core/blocks.go +++ b/rpc/core/blocks.go @@ -191,8 +191,8 @@ func BlockResults(ctx *rpctypes.Context, heightPtr *int64) (*ctypes.ResultBlockR }, nil } -// BlockSearch searches for a paginated set of blocks matching BeginBlock and -// EndBlock event search criteria. +// BlockSearch searches for a paginated set of blocks matching +// FinalizeBlock event search criteria. func BlockSearch( ctx *rpctypes.Context, query string, diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 24e86c1d6..8c6683ff1 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -17,7 +17,7 @@ import ( // NOTE: tx should be signed, but this is only checked at the app level (not by Tendermint!) // BroadcastTxAsync returns right away, with no response. Does not wait for -// CheckTx nor DeliverTx results. +// CheckTx nor transcation results. // More: https://docs.tendermint.com/main/rpc/#/Tx/broadcast_tx_async func BroadcastTxAsync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) { err := env.Mempool.CheckTx(tx, nil, mempl.TxInfo{}) @@ -29,7 +29,7 @@ func BroadcastTxAsync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadca } // BroadcastTxSync returns with the response from CheckTx. Does not wait for -// DeliverTx result. +// the transaction result. // More: https://docs.tendermint.com/main/rpc/#/Tx/broadcast_tx_sync func BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) { resCh := make(chan *abci.ResponseCheckTx, 1) @@ -58,7 +58,7 @@ func BroadcastTxSync(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcas } } -// BroadcastTxCommit returns with the responses from CheckTx and DeliverTx. +// BroadcastTxCommit returns with the responses from CheckTx and ExecTxResult. // More: https://docs.tendermint.com/main/rpc/#/Tx/broadcast_tx_commit func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) { subscriber := ctx.RemoteAddr() @@ -73,7 +73,7 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc subCtx, cancel := context.WithTimeout(ctx.Context(), SubscribeTimeout) defer cancel() q := types.EventQueryTxFor(tx) - deliverTxSub, err := env.EventBus.Subscribe(subCtx, subscriber, q) + txSub, err := env.EventBus.Subscribe(subCtx, subscriber, q) if err != nil { err = fmt.Errorf("failed to subscribe to tx: %w", err) env.Logger.Error("Error on broadcast_tx_commit", "err", err) @@ -111,7 +111,7 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc // Wait for the tx to be included in a block or timeout. select { - case msg := <-deliverTxSub.Out(): // The tx was included in a block. + case msg := <-txSub.Out(): // The tx was included in a block. txResultEvent := msg.Data().(types.EventDataTx) return &ctypes.ResultBroadcastTxCommit{ CheckTx: *checkTxRes, @@ -119,14 +119,14 @@ func BroadcastTxCommit(ctx *rpctypes.Context, tx types.Tx) (*ctypes.ResultBroadc Hash: tx.Hash(), Height: txResultEvent.Height, }, nil - case <-deliverTxSub.Cancelled(): + case <-txSub.Cancelled(): var reason string - if deliverTxSub.Err() == nil { + if txSub.Err() == nil { reason = "Tendermint exited" } else { - reason = deliverTxSub.Err().Error() + reason = txSub.Err().Error() } - err = fmt.Errorf("deliverTxSub was canceled (reason: %s)", reason) + err = fmt.Errorf("txSub was canceled (reason: %s)", reason) env.Logger.Error("Error on broadcastTxCommit", "err", err) return &ctypes.ResultBroadcastTxCommit{ CheckTx: *checkTxRes, diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 9bc7a9601..e63271bd0 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -181,7 +181,7 @@ type ResultBroadcastTx struct { Hash bytes.HexBytes `json:"hash"` } -// CheckTx and DeliverTx results +// CheckTx and ExecTx results type ResultBroadcastTxCommit struct { CheckTx abci.ResponseCheckTx `json:"check_tx"` TxResult abci.ExecTxResult `json:"tx_result"` diff --git a/state/indexer/block.go b/state/indexer/block.go index 365b3ae08..96328dca0 100644 --- a/state/indexer/block.go +++ b/state/indexer/block.go @@ -15,10 +15,10 @@ type BlockIndexer interface { // upon database query failure. Has(height int64) (bool, error) - // Index indexes BeginBlock and EndBlock events for a given block by its height. + // Index indexes FinalizeBlock events for a given block by its height. Index(types.EventDataNewBlockEvents) error - // Search performs a query for block heights that match a given BeginBlock - // and Endblock event search criteria. + // Search performs a query for block heights that match a given FinalizeBlock + // event search criteria. Search(ctx context.Context, q *query.Query) ([]int64, error) } diff --git a/state/indexer/block/kv/kv.go b/state/indexer/block/kv/kv.go index 1a33ab2fe..b31684119 100644 --- a/state/indexer/block/kv/kv.go +++ b/state/indexer/block/kv/kv.go @@ -20,7 +20,7 @@ import ( var _ indexer.BlockIndexer = (*BlockerIndexer)(nil) -// BlockerIndexer implements a block indexer, indexing BeginBlock and EndBlock +// BlockerIndexer implements a block indexer, indexing FinalizeBlock // events with an underlying KV store. Block events are indexed by their height, // such that matching search criteria returns the respective block height(s). type BlockerIndexer struct { @@ -44,12 +44,11 @@ func (idx *BlockerIndexer) Has(height int64) (bool, error) { return idx.store.Has(key) } -// Index indexes BeginBlock and EndBlock events for a given block by its height. +// Index indexes FinalizeBlock events for a given block by its height. // The following is indexed: // // primary key: encode(block.height | height) => encode(height) -// BeginBlock events: encode(eventType.eventAttr|eventValue|height|begin_block) => encode(height) -// EndBlock events: encode(eventType.eventAttr|eventValue|height|end_block) => encode(height) +// FinalizeBlock events: encode(eventType.eventAttr|eventValue|height|finalize_block) => encode(height) func (idx *BlockerIndexer) Index(bh types.EventDataNewBlockEvents) error { batch := idx.store.NewBatch() defer batch.Close() @@ -66,15 +65,15 @@ func (idx *BlockerIndexer) Index(bh types.EventDataNewBlockEvents) error { } // 2. index block events - if err := idx.indexEvents(batch, bh.Events, "begin_block", height); err != nil { - return fmt.Errorf("failed to index BeginBlock events: %w", err) + if err := idx.indexEvents(batch, bh.Events, "finalize_block", height); err != nil { + return fmt.Errorf("failed to index FinalizeBlock events: %w", err) } return batch.WriteSync() } -// Search performs a query for block heights that match a given BeginBlock -// and Endblock event search criteria. The given query can match against zero, +// Search performs a query for block heights that match a given FinalizeBlock +// event search criteria. The given query can match against zero, // one or more block heights. In the case of height queries, i.e. block.height=H, // if the height is indexed, that height alone will be returned. An error and // nil slice is returned. Otherwise, a non-nil slice and nil error is returned. diff --git a/state/indexer/sink/psql/backport.go b/state/indexer/sink/psql/backport.go index ce4a137db..68efa2aae 100644 --- a/state/indexer/sink/psql/backport.go +++ b/state/indexer/sink/psql/backport.go @@ -24,8 +24,7 @@ import ( ) const ( - eventTypeBeginBlock = "begin_block" - eventTypeEndBlock = "end_block" + eventTypeFinalizeBlock = "finaliz_block" ) // TxIndexer returns a bridge from es to the Tendermint v0.34 transaction indexer. diff --git a/state/indexer/sink/psql/psql.go b/state/indexer/sink/psql/psql.go index 0c71541e5..a2417c8ac 100644 --- a/state/indexer/sink/psql/psql.go +++ b/state/indexer/sink/psql/psql.go @@ -165,7 +165,7 @@ INSERT INTO `+tableBlocks+` (height, chain_id, created_at) } // Insert all the block events. Order is important here, if err := insertEvents(dbtx, blockID, 0, h.Events); err != nil { - return fmt.Errorf("begin-block events: %w", err) + return fmt.Errorf("finalizeblock events: %w", err) } return nil }) diff --git a/state/indexer/sink/psql/psql_test.go b/state/indexer/sink/psql/psql_test.go index 2ee777611..b08c2dbf3 100644 --- a/state/indexer/sink/psql/psql_test.go +++ b/state/indexer/sink/psql/psql_test.go @@ -351,17 +351,8 @@ SELECT height FROM `+tableBlocks+` WHERE height = $1; if err := testDB().QueryRow(` SELECT type, height, chain_id FROM `+viewBlockEvents+` WHERE height = $1 AND type = $2 AND chain_id = $3; -`, height, eventTypeBeginBlock, chainID).Err(); err == sql.ErrNoRows { - t.Errorf("No %q event found for height=%d", eventTypeBeginBlock, height) - } else if err != nil { - t.Fatalf("Database query failed: %v", err) - } - - if err := testDB().QueryRow(` -SELECT type, height, chain_id FROM `+viewBlockEvents+` - WHERE height = $1 AND type = $2 AND chain_id = $3; -`, height, eventTypeEndBlock, chainID).Err(); err == sql.ErrNoRows { - t.Errorf("No %q event found for height=%d", eventTypeEndBlock, height) +`, height, eventTypeFinalizeBlock, chainID).Err(); err == sql.ErrNoRows { + t.Errorf("No %q event found for height=%d", eventTypeFinalizeBlock, height) } else if err != nil { t.Fatalf("Database query failed: %v", err) } diff --git a/state/metrics.gen.go b/state/metrics.gen.go index 1ce2c4de1..512bb7a37 100644 --- a/state/metrics.gen.go +++ b/state/metrics.gen.go @@ -18,7 +18,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Namespace: namespace, Subsystem: MetricsSubsystem, Name: "block_processing_time", - Help: "Time between BeginBlock and EndBlock in ms.", + Help: "Time spent processig finalize block.", Buckets: stdprometheus.LinearBuckets(1, 10, 10), }, labels).With(labelsAndValues...), diff --git a/state/metrics.go b/state/metrics.go index 6c238df76..a37515668 100644 --- a/state/metrics.go +++ b/state/metrics.go @@ -14,7 +14,7 @@ const ( // Metrics contains metrics exposed by this package. type Metrics struct { - // Time between BeginBlock and EndBlock in ms. + // Time spent processing FinalizeBlock BlockProcessingTime metrics.Histogram `metrics_buckettype:"lin" metrics_bucketsizes:"1, 10, 10"` // ConsensusParamUpdates is the total number of times the application has diff --git a/state/state.go b/state/state.go index 51ce5a3f8..171a4e713 100644 --- a/state/state.go +++ b/state/state.go @@ -68,7 +68,7 @@ type State struct { LastHeightValidatorsChanged int64 // Consensus parameters used for validating blocks. - // Changes returned by EndBlock and updated after Commit. + // Changes returned by FinalizeBlock and updated after Commit. ConsensusParams types.ConsensusParams LastHeightConsensusParamsChanged int64 diff --git a/state/store_test.go b/state/store_test.go index 6d4715c96..4d7847046 100644 --- a/state/store_test.go +++ b/state/store_test.go @@ -214,11 +214,11 @@ func TestTxResultsHash(t *testing.T) { root := sm.TxResultsHash(txResults) - // root should be Merkle tree root of DeliverTxs responses + // root should be Merkle tree root of ExecTxResult responses results := types.NewResults(txResults) assert.Equal(t, root, results.Hash()) - // test we can prove first DeliverTx + // test we can prove first ExecTxResult proof := results.ProveResult(0) bz, err := results[0].Marshal() require.NoError(t, err) diff --git a/types/block.go b/types/block.go index 5bf1cbfdb..3677be8af 100644 --- a/types/block.go +++ b/types/block.go @@ -342,7 +342,7 @@ type Header struct { ConsensusHash tmbytes.HexBytes `json:"consensus_hash"` // consensus params for current block AppHash tmbytes.HexBytes `json:"app_hash"` // state after txs from the previous block // root hash of all results from the txs from the previous block - // see `deterministicResponseDeliverTx` to understand which parts of a tx is hashed into here + // see `deterministicExecTxResult` to understand which parts of a tx is hashed into here LastResultsHash tmbytes.HexBytes `json:"last_results_hash"` // consensus info diff --git a/types/validation.go b/types/validation.go index 3b33e90db..3601f0479 100644 --- a/types/validation.go +++ b/types/validation.go @@ -19,7 +19,7 @@ func shouldBatchVerify(vals *ValidatorSet, commit *Commit) bool { // // It checks all the signatures! While it's safe to exit as soon as we have // 2/3+ signatures, doing so would impact incentivization logic in the ABCI -// application that depends on the LastCommitInfo sent in BeginBlock, which +// application that depends on the LastCommitInfo sent in FinalizeBlock, which // includes which validators signed. For instance, Gaia incentivizes proposers // with a bonus for including more than +2/3 of the signatures. func VerifyCommit(chainID string, vals *ValidatorSet, blockID BlockID,