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.

70 lines
1.5 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
3 years ago
  1. package kv
  2. import (
  3. "context"
  4. "crypto/rand"
  5. "fmt"
  6. "testing"
  7. dbm "github.com/tendermint/tm-db"
  8. abci "github.com/tendermint/tendermint/abci/types"
  9. "github.com/tendermint/tendermint/internal/pubsub/query"
  10. "github.com/tendermint/tendermint/types"
  11. )
  12. func BenchmarkTxSearch(b *testing.B) {
  13. dbDir := b.TempDir()
  14. db, err := dbm.NewGoLevelDB("benchmark_tx_search_test", dbDir)
  15. if err != nil {
  16. b.Errorf("failed to create database: %s", err)
  17. }
  18. indexer := NewTxIndex(db)
  19. for i := 0; i < 35000; i++ {
  20. events := []abci.Event{
  21. {
  22. Type: "transfer",
  23. Attributes: []abci.EventAttribute{
  24. {Key: "address", Value: fmt.Sprintf("address_%d", i%100), Index: true},
  25. {Key: "amount", Value: "50", Index: true},
  26. },
  27. },
  28. }
  29. txBz := make([]byte, 8)
  30. if _, err := rand.Read(txBz); err != nil {
  31. b.Errorf("failed produce random bytes: %s", err)
  32. }
  33. txResult := &abci.TxResult{
  34. Height: int64(i),
  35. Index: 0,
  36. Tx: types.Tx(string(txBz)),
  37. Result: abci.ExecTxResult{
  38. Data: []byte{0},
  39. Code: abci.CodeTypeOK,
  40. Log: "",
  41. Events: events,
  42. },
  43. }
  44. if err := indexer.Index([]*abci.TxResult{txResult}); err != nil {
  45. b.Errorf("failed to index tx: %s", err)
  46. }
  47. }
  48. txQuery := query.MustCompile(`transfer.address = 'address_43' AND transfer.amount = 50`)
  49. b.ResetTimer()
  50. ctx := context.Background()
  51. for i := 0; i < b.N; i++ {
  52. if _, err := indexer.Search(ctx, txQuery); err != nil {
  53. b.Errorf("failed to query for txs: %s", err)
  54. }
  55. }
  56. }