You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.1 KiB

abci: Synchronize FinalizeBlock with the updated specification (#7983) This change set implements the most recent version of `FinalizeBlock`. # What does this change actually contain? * This change set is rather large but fear not! The majority of the files touched and changes are renaming `ResponseDeliverTx` to `ExecTxResult`. This should be a pretty inoffensive change since they're effectively the same type but with a different name. * The `execBlockOnProxyApp` was totally removed since it served as just a wrapper around the logic that is now mostly encapsulated within `FinalizeBlock` * The `updateState` helper function has been made a public method on `State`. It was being exposed as a shim through the testing infrastructure, so this seemed innocuous. * Tests already existed to ensure that the application received the `ByzantineValidators` and the `ValidatorUpdates`, but one was fixed up to ensure that `LastCommitInfo` was being sent across. * Tests were removed from the `psql` indexer that seemed to search for an event in the indexer that was not being created. # Questions for reviewers * We store this [ABCIResponses](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/proto/tendermint/state/types.pb.go#L37) type in the data base as the block results. This type has changed since v0.35 to contain the `FinalizeBlock` response. I'm wondering if we need to do any shimming to keep the old data retrieveable? * Similarly, this change is exposed via the RPC through [ResultBlockResults](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/rpc/coretypes/responses.go#L69) changing. Should we somehow shim or notify for this change? closes: #7658
2 years ago
abci: Synchronize FinalizeBlock with the updated specification (#7983) This change set implements the most recent version of `FinalizeBlock`. # What does this change actually contain? * This change set is rather large but fear not! The majority of the files touched and changes are renaming `ResponseDeliverTx` to `ExecTxResult`. This should be a pretty inoffensive change since they're effectively the same type but with a different name. * The `execBlockOnProxyApp` was totally removed since it served as just a wrapper around the logic that is now mostly encapsulated within `FinalizeBlock` * The `updateState` helper function has been made a public method on `State`. It was being exposed as a shim through the testing infrastructure, so this seemed innocuous. * Tests already existed to ensure that the application received the `ByzantineValidators` and the `ValidatorUpdates`, but one was fixed up to ensure that `LastCommitInfo` was being sent across. * Tests were removed from the `psql` indexer that seemed to search for an event in the indexer that was not being created. # Questions for reviewers * We store this [ABCIResponses](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/proto/tendermint/state/types.pb.go#L37) type in the data base as the block results. This type has changed since v0.35 to contain the `FinalizeBlock` response. I'm wondering if we need to do any shimming to keep the old data retrieveable? * Similarly, this change is exposed via the RPC through [ResultBlockResults](https://github.com/tendermint/tendermint/blob/5721a13ab1f4479f9807f449f0bf5c536b9a05f2/rpc/coretypes/responses.go#L69) changing. Should we somehow shim or notify for this change? closes: #7658
2 years ago
7 years ago
6 years ago
  1. package indexer
  2. import (
  3. "context"
  4. "errors"
  5. abci "github.com/tendermint/tendermint/abci/types"
  6. "github.com/tendermint/tendermint/internal/pubsub/query"
  7. "github.com/tendermint/tendermint/types"
  8. )
  9. // TxIndexer interface defines methods to index and search transactions.
  10. type TxIndexer interface {
  11. // Index analyzes, indexes and stores transactions. For indexing multiple
  12. // Transacions must guarantee the Index of the TxResult is in order.
  13. // See Batch struct.
  14. Index(results []*abci.TxResult) error
  15. // Get returns the transaction specified by hash or nil if the transaction is not indexed
  16. // or stored.
  17. Get(hash []byte) (*abci.TxResult, error)
  18. // Search allows you to query for transactions.
  19. Search(ctx context.Context, q *query.Query) ([]*abci.TxResult, error)
  20. }
  21. // BlockIndexer defines an interface contract for indexing block events.
  22. type BlockIndexer interface {
  23. // Has returns true if the given height has been indexed. An error is returned
  24. // upon database query failure.
  25. Has(height int64) (bool, error)
  26. // Index indexes FinalizeBlock events for a given block by its height.
  27. Index(types.EventDataNewBlockHeader) error
  28. // Search performs a query for block heights that match a given FinalizeBlock
  29. // event search criteria.
  30. Search(ctx context.Context, q *query.Query) ([]int64, error)
  31. }
  32. // Batch groups together multiple Index operations to be performed at the same time.
  33. // NOTE: Batch is NOT thread-safe and must not be modified after starting its execution.
  34. type Batch struct {
  35. Ops []*abci.TxResult
  36. Pending int64
  37. }
  38. // NewBatch creates a new Batch.
  39. func NewBatch(n int64) *Batch {
  40. return &Batch{Ops: make([]*abci.TxResult, n), Pending: n}
  41. }
  42. // Add or update an entry for the given result.Index.
  43. func (b *Batch) Add(result *abci.TxResult) error {
  44. if b.Ops[result.Index] == nil {
  45. b.Pending--
  46. b.Ops[result.Index] = result
  47. }
  48. return nil
  49. }
  50. // Size returns the total number of operations inside the batch.
  51. func (b *Batch) Size() int { return len(b.Ops) }
  52. // ErrorEmptyHash indicates empty hash
  53. var ErrorEmptyHash = errors.New("transaction hash cannot be empty")