mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-05 15:47:07 +00:00
Remove the abci responses type - prune legacy responses (#8673)
Closes #8069 * Type `ABCIResponses` was just wrapping type `ResponseFinalizeBlock`. This patch removes the former. * Did some renaming to avoid confusion on the data structure we are working with. * We also remove any stale ABCIResponses we may have in the state store at the time of pruning **IMPORTANT**: There is an undesirable side-effect of the unwrapping. An empty `ResponseFinalizeBlock` yields a 0-length proto-buf serialized buffer. This was not the case with `ABCIResponses`. I have added an interim solution, but open for suggestions on more elegant ones.
This commit is contained in:
@@ -424,11 +424,11 @@ func (h *Handshaker) ReplayBlocks(
|
||||
|
||||
case appBlockHeight == storeBlockHeight:
|
||||
// We ran Commit, but didn't save the state, so replayBlock with mock app.
|
||||
abciResponses, err := h.stateStore.LoadABCIResponses(storeBlockHeight)
|
||||
finalizeBlockResponses, err := h.stateStore.LoadFinalizeBlockResponses(storeBlockHeight)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mockApp, err := newMockProxyApp(h.logger, appHash, abciResponses)
|
||||
mockApp, err := newMockProxyApp(h.logger, appHash, finalizeBlockResponses)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/tendermint/tendermint/internal/mempool"
|
||||
"github.com/tendermint/tendermint/internal/proxy"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
@@ -52,7 +51,7 @@ func (emptyMempool) InitWAL() error { return nil }
|
||||
func (emptyMempool) CloseWAL() {}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// mockProxyApp uses ABCIResponses to give the right results.
|
||||
// mockProxyApp uses Responses to FinalizeBlock to give the right results.
|
||||
//
|
||||
// Useful because we don't want to call Commit() twice for the same block on
|
||||
// the real app.
|
||||
@@ -60,24 +59,24 @@ func (emptyMempool) CloseWAL() {}
|
||||
func newMockProxyApp(
|
||||
logger log.Logger,
|
||||
appHash []byte,
|
||||
abciResponses *tmstate.ABCIResponses,
|
||||
finalizeBlockResponses *abci.ResponseFinalizeBlock,
|
||||
) (abciclient.Client, error) {
|
||||
return proxy.New(abciclient.NewLocalClient(logger, &mockProxyApp{
|
||||
appHash: appHash,
|
||||
abciResponses: abciResponses,
|
||||
appHash: appHash,
|
||||
finalizeBlockResponses: finalizeBlockResponses,
|
||||
}), logger, proxy.NopMetrics()), nil
|
||||
}
|
||||
|
||||
type mockProxyApp struct {
|
||||
abci.BaseApplication
|
||||
|
||||
appHash []byte
|
||||
txCount int
|
||||
abciResponses *tmstate.ABCIResponses
|
||||
appHash []byte
|
||||
txCount int
|
||||
finalizeBlockResponses *abci.ResponseFinalizeBlock
|
||||
}
|
||||
|
||||
func (mock *mockProxyApp) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
|
||||
r := mock.abciResponses.FinalizeBlock
|
||||
r := mock.finalizeBlockResponses
|
||||
mock.txCount++
|
||||
if r == nil {
|
||||
return &abci.ResponseFinalizeBlock{}, nil
|
||||
|
||||
@@ -1979,7 +1979,8 @@ func TestFinalizeBlockCalled(t *testing.T) {
|
||||
Status: abci.ResponseVerifyVoteExtension_ACCEPT,
|
||||
}, nil)
|
||||
}
|
||||
m.On("FinalizeBlock", mock.Anything, mock.Anything).Return(&abci.ResponseFinalizeBlock{}, nil).Maybe()
|
||||
r := &abci.ResponseFinalizeBlock{AppHash: []byte("the_hash")}
|
||||
m.On("FinalizeBlock", mock.Anything, mock.Anything).Return(r, nil).Maybe()
|
||||
m.On("Commit", mock.Anything).Return(&abci.ResponseCommit{}, nil).Maybe()
|
||||
|
||||
cs1, vss := makeState(ctx, t, makeStateArgs{config: config, application: m})
|
||||
@@ -2060,7 +2061,8 @@ func TestExtendVoteCalledWhenEnabled(t *testing.T) {
|
||||
}, nil)
|
||||
}
|
||||
m.On("Commit", mock.Anything).Return(&abci.ResponseCommit{}, nil).Maybe()
|
||||
m.On("FinalizeBlock", mock.Anything, mock.Anything).Return(&abci.ResponseFinalizeBlock{}, nil).Maybe()
|
||||
r := &abci.ResponseFinalizeBlock{AppHash: []byte("myHash")}
|
||||
m.On("FinalizeBlock", mock.Anything, mock.Anything).Return(r, nil).Maybe()
|
||||
c := factory.ConsensusParams()
|
||||
if !testCase.enabled {
|
||||
c.ABCI.VoteExtensionsEnableHeight = 0
|
||||
@@ -2357,7 +2359,8 @@ func TestVoteExtensionEnableHeight(t *testing.T) {
|
||||
Status: abci.ResponseVerifyVoteExtension_ACCEPT,
|
||||
}, nil).Times(numValidators - 1)
|
||||
}
|
||||
m.On("FinalizeBlock", mock.Anything, mock.Anything).Return(&abci.ResponseFinalizeBlock{}, nil).Maybe()
|
||||
r := &abci.ResponseFinalizeBlock{AppHash: []byte("hashyHash")}
|
||||
m.On("FinalizeBlock", mock.Anything, mock.Anything).Return(r, nil).Maybe()
|
||||
m.On("Commit", mock.Anything).Return(&abci.ResponseCommit{}, nil).Maybe()
|
||||
c := factory.ConsensusParams()
|
||||
c.ABCI.VoteExtensionsEnableHeight = testCase.enableHeight
|
||||
|
||||
Reference in New Issue
Block a user