[ENG-683]: Ignore auction txs in second portion of PrepareProposal (#51)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
David Terpay 2023-04-10 10:08:25 -04:00 committed by GitHub
parent cc3012a129
commit d301b3adcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View File

@ -141,6 +141,18 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
for ; iterator != nil; iterator = iterator.Next() {
memTx := iterator.Tx()
// We've already selected the highest bid transaction, so we can skip
// all other auction transactions.
isAuctionTx, err := h.isAuctionTx(memTx)
if err != nil {
txsToRemove[memTx] = struct{}{}
continue selectTxLoop
}
if isAuctionTx {
continue selectTxLoop
}
txBz, err := h.txVerifier.PrepareProposalVerifyTx(memTx)
if err != nil {
txsToRemove[memTx] = struct{}{}
@ -216,3 +228,12 @@ func (h *ProposalHandler) RemoveTx(tx sdk.Tx) {
panic(fmt.Errorf("failed to remove invalid transaction from the mempool: %w", err))
}
}
func (h *ProposalHandler) isAuctionTx(tx sdk.Tx) (bool, error) {
msgAuctionBid, err := mempool.GetMsgAuctionBidFromTx(tx)
if err != nil {
return false, err
}
return msgAuctionBid != nil, nil
}

View File

@ -350,7 +350,7 @@ func (suite *ABCITestSuite) TestPrepareProposal() {
insertRefTxs = false
},
4,
1,
10,
true,
},
{
@ -362,7 +362,7 @@ func (suite *ABCITestSuite) TestPrepareProposal() {
insertRefTxs = true
},
31,
31,
40,
true,
},
{
@ -470,7 +470,7 @@ func (suite *ABCITestSuite) TestPrepareProposal() {
insertRefTxs = true
},
201,
201,
300,
true,
},
}