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.

54 lines
1.3 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 types
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. "github.com/stretchr/testify/require"
  6. abci "github.com/tendermint/tendermint/abci/types"
  7. )
  8. func TestABCIResults(t *testing.T) {
  9. a := &abci.ExecTxResult{Code: 0, Data: nil}
  10. b := &abci.ExecTxResult{Code: 0, Data: []byte{}}
  11. c := &abci.ExecTxResult{Code: 0, Data: []byte("one")}
  12. d := &abci.ExecTxResult{Code: 14, Data: nil}
  13. e := &abci.ExecTxResult{Code: 14, Data: []byte("foo")}
  14. f := &abci.ExecTxResult{Code: 14, Data: []byte("bar")}
  15. // Nil and []byte{} should produce the same bytes
  16. bzA, err := a.Marshal()
  17. require.NoError(t, err)
  18. bzB, err := b.Marshal()
  19. require.NoError(t, err)
  20. require.Equal(t, bzA, bzB)
  21. // a and b should be the same, don't go in results.
  22. results := ABCIResults{a, c, d, e, f}
  23. // Make sure each result serializes differently
  24. last := []byte{}
  25. assert.Equal(t, last, bzA) // first one is empty
  26. for i, res := range results[1:] {
  27. bz, err := res.Marshal()
  28. require.NoError(t, err)
  29. assert.NotEqual(t, last, bz, "%d", i)
  30. last = bz
  31. }
  32. // Make sure that we can get a root hash from results and verify proofs.
  33. root := results.Hash()
  34. assert.NotEmpty(t, root)
  35. for i, res := range results {
  36. bz, err := res.Marshal()
  37. require.NoError(t, err)
  38. proof := results.ProveResult(i)
  39. valid := proof.Verify(root, bz)
  40. assert.NoError(t, valid, "%d", i)
  41. }
  42. }