fix: ABCI top bid bug (#102)

This commit is contained in:
David Terpay 2023-05-01 12:09:13 -05:00 committed by GitHub
parent 03f6f22b39
commit ab6385e959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -74,16 +74,23 @@ func (ad BuilderDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool,
// If the current transaction is the highest bidding transaction, then the highest bid is empty.
topBid := sdk.Coin{}
isTopBidTx, err := ad.IsTopBidTx(ctx, tx)
if err != nil {
return ctx, errors.Wrap(err, "failed to check if current transaction is highest bidding transaction")
}
if !isTopBidTx {
// Set the top bid to the highest bidding transaction.
topBid, err = ad.GetTopAuctionBid(ctx)
// We only need to verify the auction bid relative to the local validator's mempool if the mode
// is checkTx or recheckTx. Otherwise, the ABCI handlers (VerifyVoteExtension, ExtendVoteExtension, etc.)
// will always compare the auction bid to the highest bidding transaction in the mempool leading to
// poor liveness guarantees.
if ctx.IsCheckTx() || ctx.IsReCheckTx() {
isTopBidTx, err := ad.IsTopBidTx(ctx, tx)
if err != nil {
return ctx, errors.Wrap(err, "failed to get highest auction bid")
return ctx, errors.Wrap(err, "failed to check if current transaction is highest bidding transaction")
}
if !isTopBidTx {
// Set the top bid to the highest bidding transaction.
topBid, err = ad.GetTopAuctionBid(ctx)
if err != nil {
return ctx, errors.Wrap(err, "failed to get highest auction bid")
}
}
}

View File

@ -47,6 +47,7 @@ func (suite *AnteTestSuite) SetupTest() {
suite.key = storetypes.NewKVStoreKey(buildertypes.StoreKey)
testCtx := testutil.DefaultContextWithDB(suite.T(), suite.key, storetypes.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx
suite.ctx = suite.ctx.WithIsCheckTx(true)
// Keepers set up
ctrl := gomock.NewController(suite.T())