From 4171bd3bae9d655e3212ef0786ce1827580ac459 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 25 Dec 2017 13:54:19 -0500 Subject: [PATCH] fixes --- consensus/replay.go | 5 ++++- rpc/client/rpc_test.go | 10 ++++------ rpc/core/blocks.go | 10 +++++----- rpc/core/types/responses.go | 5 +++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/consensus/replay.go b/consensus/replay.go index 16d12e343..57a9dd4cc 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -301,7 +301,10 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int64, proxyApp } else if appBlockHeight == storeBlockHeight { // We ran Commit, but didn't save the state, so replayBlock with mock app - abciResponses := h.state.LoadABCIResponses() + abciResponses, err := h.state.LoadABCIResponses(storeBlockHeight) + if err != nil { + return nil, err + } mockApp := newMockProxyApp(appHash, abciResponses) h.logger.Info("Replay last block using mock app") return h.replayBlock(storeBlockHeight, mockApp) diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index 7d6bc8c38..9b956803e 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -168,17 +168,15 @@ func TestAppCalls(t *testing.T) { assert.EqualValues(apph, block.BlockMeta.Header.Height) // now check the results - blockResults, err := c.BlockResults(&apph) + blockResults, err := c.BlockResults(&txh) require.Nil(err, "%d: %+v", i, err) - assert.Equal(apph, blockResults.Height) - if assert.Equal(1, len(blockResults.Results)) { + assert.Equal(txh, blockResults.Height) + if assert.Equal(1, len(blockResults.Results.DeliverTx)) { // check success code - assert.EqualValues(0, blockResults.Results[0].Code) + assert.EqualValues(0, blockResults.Results.DeliverTx[0].Code) } // check blockchain info, now that we know there is info - // TODO: is this commented somewhere that they are returned - // in order of descending height??? info, err := c.BlockchainInfo(apph, apph) require.Nil(err, "%d: %+v", i, err) assert.True(info.LastHeight >= apph) diff --git a/rpc/core/blocks.go b/rpc/core/blocks.go index 14d9e9fc3..81d9469e9 100644 --- a/rpc/core/blocks.go +++ b/rpc/core/blocks.go @@ -9,6 +9,7 @@ import ( ) // Get block headers for minHeight <= height <= maxHeight. +// Block headers are returned in descending order (highest first). // // ```shell // curl 'localhost:46657/blockchain?minHeight=10&maxHeight=10' @@ -314,11 +315,10 @@ func Commit(heightPtr *int64) (*ctypes.ResultCommit, error) { } // BlockResults gets ABCIResults at a given height. -// If no height is provided, it will fetch the latest block. +// If no height is provided, it will fetch results for the latest block. // -// Results are for the tx of the last block with the same index. -// Thus response.results[5] is the results of executing -// getBlock(h-1).Txs[5] +// Results are for the height of the block containing the txs. +// Thus response.results[5] is the results of executing getBlock(h).Txs[5] // // ```shell // curl 'localhost:46657/block_results?height=10' @@ -364,7 +364,7 @@ func BlockResults(heightPtr *int64) (*ctypes.ResultBlockResults, error) { // load the results state := consensusState.GetState() - results, err := state.LoadResults(height) + results, err := state.LoadABCIResponses(height) if err != nil { return nil, err } diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index 31d86f94d..dae7c0046 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -9,6 +9,7 @@ import ( "github.com/tendermint/go-wire/data" cstypes "github.com/tendermint/tendermint/consensus/types" "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/types" ) @@ -34,8 +35,8 @@ type ResultCommit struct { } type ResultBlockResults struct { - Height int64 `json:"height"` - Results types.ABCIResults `json:"results"` + Height int64 `json:"height"` + Results *state.ABCIResponses `json:"results"` } // NewResultCommit is a helper to initialize the ResultCommit with