diff --git a/internal/rpc/core/blocks.go b/internal/rpc/core/blocks.go index f2910df2d..d17e50cc1 100644 --- a/internal/rpc/core/blocks.go +++ b/internal/rpc/core/blocks.go @@ -220,8 +220,8 @@ func (env *Environment) BlockResults(ctx context.Context, heightPtr *int64) (*co }, 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 the provided +// query. func (env *Environment) BlockSearch( ctx context.Context, query string, diff --git a/internal/state/execution_test.go b/internal/state/execution_test.go index 636e654e7..01b3df079 100644 --- a/internal/state/execution_test.go +++ b/internal/state/execution_test.go @@ -68,8 +68,8 @@ func TestApplyBlock(t *testing.T) { assert.EqualValues(t, 1, state.Version.Consensus.App, "App version wasn't updated") } -// TestBeginBlockValidators ensures we send absent validators list. -func TestBeginBlockValidators(t *testing.T) { +// TestFinalizeBlockValidators ensures we send absent validators list. +func TestFinalizeBlockValidators(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -139,8 +139,8 @@ func TestBeginBlockValidators(t *testing.T) { } } -// TestBeginBlockByzantineValidators ensures we send byzantine validators list. -func TestBeginBlockByzantineValidators(t *testing.T) { +// TestFinalizeBlockByzantineValidators ensures we send byzantine validators list. +func TestFinalizeBlockByzantineValidators(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/internal/state/indexer/block/kv/kv.go b/internal/state/indexer/block/kv/kv.go index 27a02412f..3bf64e7d7 100644 --- a/internal/state/indexer/block/kv/kv.go +++ b/internal/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.EventDataNewBlockHeader) error { batch := idx.store.NewBatch() defer batch.Close() @@ -65,7 +64,7 @@ func (idx *BlockerIndexer) Index(bh types.EventDataNewBlockHeader) error { return err } - // 2. index BeginBlock events + // 2. index FinalizeBlock events if err := idx.indexEvents(batch, bh.ResultFinalizeBlock.BlockEvents, "finalize_block", height); err != nil { return fmt.Errorf("failed to index FinalizeBlock events: %w", err) } @@ -73,11 +72,11 @@ func (idx *BlockerIndexer) Index(bh types.EventDataNewBlockHeader) error { 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, -// 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. +// Search performs a query for block heights that match a given FinalizeBlock +// 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. func (idx *BlockerIndexer) Search(ctx context.Context, q *query.Query) ([]int64, error) { results := make([]int64, 0) select { diff --git a/internal/state/indexer/indexer.go b/internal/state/indexer/indexer.go index a1b78a257..7ff6733db 100644 --- a/internal/state/indexer/indexer.go +++ b/internal/state/indexer/indexer.go @@ -30,11 +30,11 @@ 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.EventDataNewBlockHeader) 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/rpc/client/interface.go b/rpc/client/interface.go index acc54889f..4b55d36e6 100644 --- a/rpc/client/interface.go +++ b/rpc/client/interface.go @@ -90,7 +90,7 @@ type SignClient interface { ) (*coretypes.ResultTxSearch, error) // BlockSearch defines a method to search for a paginated set of blocks by - // BeginBlock and EndBlock event search criteria. + // FinalizeBlock event search criteria. BlockSearch( ctx context.Context, query string, diff --git a/types/events.go b/types/events.go index d20ecfa93..e16c8f241 100644 --- a/types/events.go +++ b/types/events.go @@ -270,12 +270,8 @@ const ( // see EventBus#PublishEventTx TxHeightKey = "tx.height" - // BlockHeightKey is a reserved key used for indexing BeginBlock and Endblock - // events. + // BlockHeightKey is a reserved key used for indexing FinalizeBlock events. BlockHeightKey = "block.height" - - EventTypeBeginBlock = "begin_block" - EventTypeEndBlock = "end_block" ) var ( diff --git a/types/validation.go b/types/validation.go index e8f53f2a0..8655bdabd 100644 --- a/types/validation.go +++ b/types/validation.go @@ -15,11 +15,13 @@ func shouldBatchVerify(vals *ValidatorSet, commit *Commit) bool { return len(commit.Signatures) >= batchVerifyThreshold && batch.SupportsBatchVerifier(vals.GetProposer().PubKey) } +// TODO(wbanfield): determine if the following comment is still true regarding Gaia. + // VerifyCommit verifies +2/3 of the set had signed the given commit. // // 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,