Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: backport https://github.com/skip-mev/connect/pull/735 #859

Merged
merged 6 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions abci/proposals/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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:]
}
}
Expand All @@ -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
}
Expand Down
18 changes: 18 additions & 0 deletions abci/proposals/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand All @@ -944,6 +958,10 @@ func (s *ProposalsTestSuite) TestProcessProposal() {
} else {
s.Require().NoError(err)
}

if tc.checkTxs != nil {
tc.checkTxs(before, req.Txs)
}
})
}
}
Expand Down
Loading