diff --git a/abci/proposals/proposals.go b/abci/proposals/proposals.go index 9d14b729f..bef381a1f 100644 --- a/abci/proposals/proposals.go +++ b/abci/proposals/proposals.go @@ -288,6 +288,9 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler { "vote_extensions_enabled", voteExtensionsEnabled, ) + // we save the injected tx so we can re-add it to the txs in case it is removed in a wrapped proposal handler. + var injectedTx []byte + if voteExtensionsEnabled { // Ensure that the commit info was correctly injected into the proposal. if len(req.Txs) < slinkyabci.NumInjectedTxs { @@ -331,6 +334,7 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler { // Remove the extended commit info from the proposal if required if !h.retainOracleDataInWrappedHandler { + injectedTx = req.Txs[slinkyabci.OracleInfoIndex] req.Txs = req.Txs[slinkyabci.NumInjectedTxs:] } } @@ -345,6 +349,11 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler { } } + if !h.retainOracleDataInWrappedHandler && injectedTx != nil { + // Re-inject the extended commit info back into the response if it was removed + req.Txs = append([][]byte{injectedTx}, req.Txs...) + } + wrappedProcessProposalLatency = time.Since(wrappedProcessProposalStartTime) return resp, err } diff --git a/abci/proposals/proposals_test.go b/abci/proposals/proposals_test.go index 0aef1e4d7..52c86038a 100644 --- a/abci/proposals/proposals_test.go +++ b/abci/proposals/proposals_test.go @@ -576,6 +576,7 @@ func (s *ProposalsTestSuite) TestProcessProposal() { currencyPairStrategy func() currencypair.CurrencyPairStrategy expectedError bool expectedResp *cometabci.ResponseProcessProposal + checkTxs func(before, after [][]byte) }{ { name: "returns an error on nil request", @@ -697,6 +698,9 @@ func (s *ProposalsTestSuite) TestProcessProposal() { expectedResp: &cometabci.ResponseProcessProposal{ Status: cometabci.ResponseProcessProposal_ACCEPT, }, + checkTxs: func(before, after [][]byte) { + s.Require().Equal(before, after) + }, }, { name: "can process a block with multiple vote extensions", @@ -936,6 +940,16 @@ func (s *ProposalsTestSuite) TestProcessProposal() { )) } + // make a copy of the txs before we run the proposal + var before [][]byte + if req != nil { // some tests use a nil request. + before = make([][]byte, len(req.Txs)) + for i, tx := range req.Txs { + before[i] = make([]byte, len(tx)) + copy(before[i], tx) + } + } + response, err := s.proposalHandler.ProcessProposalHandler()(s.ctx, req) s.Require().Equal(tc.expectedResp, response) @@ -944,6 +958,10 @@ func (s *ProposalsTestSuite) TestProcessProposal() { } else { s.Require().NoError(err) } + + if tc.checkTxs != nil { + tc.checkTxs(before, req.Txs) + } }) } }