From a0dacf78a1268c26d3c2616829b3904f9af492fa Mon Sep 17 00:00:00 2001 From: David Terpay <35130517+davidterpay@users.noreply.github.com> Date: Wed, 5 Apr 2023 18:04:45 -0400 Subject: [PATCH] [ENG-684]: Single Coin Fees (#48) --- abci/abci_test.go | 48 ++++---- mempool/mempool_test.go | 12 +- mempool/tx.go | 6 +- mempool/tx_test.go | 2 +- proto/pob/builder/v1/genesis.proto | 29 ++--- proto/pob/builder/v1/tx.proto | 9 +- testutils/utils.go | 4 +- x/builder/ante/ante.go | 6 +- x/builder/ante/ante_test.go | 34 +++--- x/builder/keeper/auction.go | 26 ++-- x/builder/keeper/auction_test.go | 34 ++++-- x/builder/keeper/keeper.go | 12 +- x/builder/keeper/msg_server.go | 4 +- x/builder/keeper/msg_server_test.go | 4 +- x/builder/types/genesis.pb.go | 178 ++++++++++++---------------- x/builder/types/msgs.go | 2 +- x/builder/types/msgs_test.go | 15 ++- x/builder/types/params.go | 24 ++-- x/builder/types/tx.pb.go | 109 ++++++++--------- 19 files changed, 266 insertions(+), 292 deletions(-) diff --git a/abci/abci_test.go b/abci/abci_test.go index 1fed3f2..e72e54e 100644 --- a/abci/abci_test.go +++ b/abci/abci_test.go @@ -32,8 +32,8 @@ type ABCITestSuite struct { proposalHandler *abci.ProposalHandler // auction bid setup - auctionBidAmount sdk.Coins - minBidIncrement sdk.Coins + auctionBidAmount sdk.Coin + minBidIncrement sdk.Coin // builder setup builderKeeper keeper.Keeper @@ -66,8 +66,8 @@ func (suite *ABCITestSuite) SetupTest() { // Mempool set up suite.mempool = mempool.NewAuctionMempool(suite.encodingConfig.TxConfig.TxDecoder(), 0) - suite.auctionBidAmount = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000000000))) - suite.minBidIncrement = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + suite.auctionBidAmount = sdk.NewCoin("foo", sdk.NewInt(1000000000)) + suite.minBidIncrement = sdk.NewCoin("foo", sdk.NewInt(1000)) // Mock keepers set up ctrl := gomock.NewController(suite.T()) @@ -198,7 +198,7 @@ func (suite *ABCITestSuite) createFilledMempool(numNormalTxs, numAuctionTxs, num } // decrement the bid amount for the next auction tx - suite.auctionBidAmount = suite.auctionBidAmount.Sub(suite.minBidIncrement...) + suite.auctionBidAmount = suite.auctionBidAmount.Sub(suite.minBidIncrement) } numSeenGlobalTxs := 0 @@ -276,8 +276,8 @@ func (suite *ABCITestSuite) TestPrepareProposal() { // auction configuration maxBundleSize uint32 = 10 - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) + minBuyInFee = sdk.NewCoin("foo", sdk.NewInt(1000)) frontRunningProtection = true ) @@ -315,8 +315,8 @@ func (suite *ABCITestSuite) TestPrepareProposal() { { "single bundle in the mempool, not valid", func() { - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100000))) - suite.auctionBidAmount = sdk.Coins{sdk.NewCoin("foo", sdk.NewInt(10000))} // this will fail the ante handler + reserveFee = sdk.NewCoin("foo", sdk.NewInt(100000)) + suite.auctionBidAmount = sdk.NewCoin("foo", sdk.NewInt(10000)) // this will fail the ante handler numNormalTxs = 0 numAuctionTxs = 1 numBundledTxs = 3 @@ -328,8 +328,8 @@ func (suite *ABCITestSuite) TestPrepareProposal() { { "single bundle in the mempool, not valid with ref txs in mempool", func() { - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100000))) - suite.auctionBidAmount = sdk.Coins{sdk.NewCoin("foo", sdk.NewInt(10000))} // this will fail the ante handler + reserveFee = sdk.NewCoin("foo", sdk.NewInt(100000)) + suite.auctionBidAmount = sdk.NewCoin("foo", sdk.NewInt(10000)) // this will fail the ante handler numNormalTxs = 0 numAuctionTxs = 1 numBundledTxs = 3 @@ -342,8 +342,8 @@ func (suite *ABCITestSuite) TestPrepareProposal() { { "multiple bundles in the mempool, no normal txs + no ref txs in mempool", func() { - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - suite.auctionBidAmount = sdk.Coins{sdk.NewCoin("foo", sdk.NewInt(10000000))} + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) + suite.auctionBidAmount = sdk.NewCoin("foo", sdk.NewInt(10000000)) numNormalTxs = 0 numAuctionTxs = 10 numBundledTxs = 3 @@ -417,8 +417,8 @@ func (suite *ABCITestSuite) TestPrepareProposal() { numAuctionTxs = 1 numBundledTxs = 3 insertRefTxs = true - suite.auctionBidAmount = sdk.Coins{sdk.NewCoin("foo", sdk.NewInt(2000))} // this will fail the ante handler - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000000000))) + suite.auctionBidAmount = sdk.NewCoin("foo", sdk.NewInt(2000)) // this will fail the ante handler + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000000000)) }, 4, 4, @@ -427,8 +427,8 @@ func (suite *ABCITestSuite) TestPrepareProposal() { { "many normal tx, single auction tx with no ref txs", func() { - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - suite.auctionBidAmount = sdk.Coins{sdk.NewCoin("foo", sdk.NewInt(2000000))} + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) + suite.auctionBidAmount = sdk.NewCoin("foo", sdk.NewInt(2000000)) numNormalTxs = 100 numAuctionTxs = 1 numBundledTxs = 0 @@ -559,8 +559,8 @@ func (suite *ABCITestSuite) TestProcessProposal() { // auction set up maxBundleSize uint32 = 10 - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) + minBuyInFee = sdk.NewCoin("foo", sdk.NewInt(1000)) frontRunningProtection = true ) @@ -650,7 +650,7 @@ func (suite *ABCITestSuite) TestProcessProposal() { numNormalTxs = 100 numAuctionTxs = 1 numBundledTxs = 4 - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100000000000000000))) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(100000000000000000)) insertRefTxs = true }, false, @@ -662,7 +662,7 @@ func (suite *ABCITestSuite) TestProcessProposal() { numNormalTxs = 0 numAuctionTxs = 1 numBundledTxs = 4 - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) insertRefTxs = false exportRefTxs = false }, @@ -675,7 +675,7 @@ func (suite *ABCITestSuite) TestProcessProposal() { numNormalTxs = 100 numAuctionTxs = 1 numBundledTxs = 4 - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) insertRefTxs = false exportRefTxs = false }, @@ -687,7 +687,7 @@ func (suite *ABCITestSuite) TestProcessProposal() { func() { randomAccount := testutils.RandomAccounts(suite.random, 1)[0] bidder := suite.accounts[0] - bid := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(696969696969))) + bid := sdk.NewCoin("foo", sdk.NewInt(696969696969)) nonce := suite.nonces[bidder.Address.String()] frontRunningTx, _ = testutils.CreateAuctionTxWithSigners(suite.encodingConfig.TxConfig, suite.accounts[0], bid, nonce+1, []testutils.Account{bidder, randomAccount}) suite.Require().NotNil(frontRunningTx) @@ -706,7 +706,7 @@ func (suite *ABCITestSuite) TestProcessProposal() { func() { randomAccount := testutils.RandomAccounts(suite.random, 1)[0] bidder := suite.accounts[0] - bid := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(696969696969))) + bid := sdk.NewCoin("foo", sdk.NewInt(696969696969)) nonce := suite.nonces[bidder.Address.String()] frontRunningTx, _ = testutils.CreateAuctionTxWithSigners(suite.encodingConfig.TxConfig, suite.accounts[0], bid, nonce+1, []testutils.Account{bidder, randomAccount}) suite.Require().NotNil(frontRunningTx) diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index 6443fd2..411859f 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -76,7 +76,7 @@ func (suite *IntegrationTestSuite) CreateFilledMempool(numNormalTxs, numAuctionT // create a new auction bid msg with numBundledTxs bundled transactions priority := suite.random.Int63n(100) + 1 - bid := sdk.NewCoins(sdk.NewInt64Coin("foo", priority)) + bid := sdk.NewInt64Coin("foo", priority) nonce := suite.nonces[acc.Address.String()] bidMsg, err := testutils.CreateMsgAuctionBid(suite.encCfg.TxConfig, acc, bid, nonce, numBundledTxs) suite.nonces[acc.Address.String()] += uint64(numBundledTxs) @@ -150,8 +150,8 @@ func (suite *IntegrationTestSuite) TestAuctionMempoolSelect() { suite.CreateFilledMempool(numberTotalTxs, numberAuctionTxs, numberBundledTxs, insertRefTxs) // iterate through the entire auction mempool and ensure the bids are in order - var highestBid sdk.Coins - var prevBid sdk.Coins + var highestBid sdk.Coin + var prevBid sdk.Coin auctionIterator := suite.mempool.AuctionBidSelect(suite.ctx) numberTxsSeen := 0 for auctionIterator != nil { @@ -159,12 +159,12 @@ func (suite *IntegrationTestSuite) TestAuctionMempoolSelect() { suite.Require().Len(tx.GetMsgs(), 1) msgAuctionBid := tx.GetMsgs()[0].(*buildertypes.MsgAuctionBid) - if highestBid == nil { + if highestBid.IsNil() { highestBid = msgAuctionBid.Bid prevBid = msgAuctionBid.Bid } else { - suite.Require().True(msgAuctionBid.Bid.IsAllLTE(highestBid)) - suite.Require().True(msgAuctionBid.Bid.IsAllLTE(prevBid)) + suite.Require().True(msgAuctionBid.Bid.IsLTE(highestBid)) + suite.Require().True(msgAuctionBid.Bid.IsLTE(prevBid)) prevBid = msgAuctionBid.Bid } diff --git a/mempool/tx.go b/mempool/tx.go index fba2395..5efb6e2 100644 --- a/mempool/tx.go +++ b/mempool/tx.go @@ -13,17 +13,17 @@ import ( type WrappedBidTx struct { signing.Tx - bid sdk.Coins + bid sdk.Coin } -func NewWrappedBidTx(tx sdk.Tx, bid sdk.Coins) *WrappedBidTx { +func NewWrappedBidTx(tx sdk.Tx, bid sdk.Coin) *WrappedBidTx { return &WrappedBidTx{ Tx: tx.(signing.Tx), bid: bid, } } -func (wbtx *WrappedBidTx) GetBid() sdk.Coins { return wbtx.bid } +func (wbtx *WrappedBidTx) GetBid() sdk.Coin { return wbtx.bid } // GetMsgAuctionBidFromTx attempts to retrieve a MsgAuctionBid from an sdk.Tx if // one exists. If a MsgAuctionBid does exist and other messages are also present, diff --git a/mempool/tx_test.go b/mempool/tx_test.go index 1e1e848..00187b2 100644 --- a/mempool/tx_test.go +++ b/mempool/tx_test.go @@ -55,7 +55,7 @@ func TestGetUnwrappedTx(t *testing.T) { txBuilder.SetMsgs(&buildertypes.MsgAuctionBid{}) tx := txBuilder.GetTx() - bid := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000000))) + bid := sdk.NewCoin("foo", sdk.NewInt(1000000)) wrappedTx := mempool.NewWrappedBidTx(tx, bid) unWrappedTx := mempool.UnwrapBidTx(wrappedTx) diff --git a/proto/pob/builder/v1/genesis.proto b/proto/pob/builder/v1/genesis.proto index 54c7132..94e4ff4 100644 --- a/proto/pob/builder/v1/genesis.proto +++ b/proto/pob/builder/v1/genesis.proto @@ -8,9 +8,7 @@ import "amino/amino.proto"; option go_package = "github.com/skip-mev/pob/x/builder/types"; // GenesisState defines the genesis state of the x/builder module. -message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; -} +message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; } // Params defines the parameters of the x/builder module. message Params { @@ -25,27 +23,18 @@ message Params { string escrow_account_address = 2; // reserve_fee specifies the bid floor for the auction. - repeated cosmos.base.v1beta1.Coin reserve_fee = 3 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + cosmos.base.v1beta1.Coin reserve_fee = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; // min_buy_in_fee specifies the fee that the bidder must pay to enter the // auction. - repeated cosmos.base.v1beta1.Coin min_buy_in_fee = 4 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + cosmos.base.v1beta1.Coin min_buy_in_fee = 4 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; // min_bid_increment specifies the minimum amount that the next bid must be // greater than the previous bid. - repeated cosmos.base.v1beta1.Coin min_bid_increment = 5 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + cosmos.base.v1beta1.Coin min_bid_increment = 5 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; // front_running_protection specifies whether front running and sandwich // attack protection is enabled. @@ -54,7 +43,7 @@ message Params { // proposer_fee defines the portion of the winning bid that goes to the block // proposer that proposed the block. string proposer_fee = 7 [ - (gogoproto.nullable) = false, + (gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec" ]; -} +} \ No newline at end of file diff --git a/proto/pob/builder/v1/tx.proto b/proto/pob/builder/v1/tx.proto index 7a42dfd..feee198 100644 --- a/proto/pob/builder/v1/tx.proto +++ b/proto/pob/builder/v1/tx.proto @@ -38,11 +38,8 @@ message MsgAuctionBid { string bidder = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; // bid is the amount of coins that the bidder is bidding to participate in the // auction. - repeated cosmos.base.v1beta1.Coin bid = 3 [ - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + cosmos.base.v1beta1.Coin bid = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; // transactions are the bytes of the transactions that the bidder wants to // bundle together. repeated bytes transactions = 4; @@ -67,4 +64,4 @@ message MsgUpdateParams { } // MsgUpdateParamsResponse defines the Msg/UpdateParams response type. -message MsgUpdateParamsResponse {} +message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/testutils/utils.go b/testutils/utils.go index 61609cf..ba4eb03 100644 --- a/testutils/utils.go +++ b/testutils/utils.go @@ -121,7 +121,7 @@ func CreateRandomTx(txCfg client.TxConfig, account Account, nonce, numberMsgs ui return txBuilder.GetTx(), nil } -func CreateAuctionTxWithSigners(txCfg client.TxConfig, bidder Account, bid sdk.Coins, nonce uint64, signers []Account) (authsigning.Tx, error) { +func CreateAuctionTxWithSigners(txCfg client.TxConfig, bidder Account, bid sdk.Coin, nonce uint64, signers []Account) (authsigning.Tx, error) { bidMsg := &buildertypes.MsgAuctionBid{ Bidder: bidder.Address.String(), Bid: bid, @@ -175,7 +175,7 @@ func CreateRandomMsgs(acc sdk.AccAddress, numberMsgs int) []sdk.Msg { return msgs } -func CreateMsgAuctionBid(txCfg client.TxConfig, bidder Account, bid sdk.Coins, nonce uint64, numberMsgs int) (*buildertypes.MsgAuctionBid, error) { +func CreateMsgAuctionBid(txCfg client.TxConfig, bidder Account, bid sdk.Coin, nonce uint64, numberMsgs int) (*buildertypes.MsgAuctionBid, error) { bidMsg := &buildertypes.MsgAuctionBid{ Bidder: bidder.Address.String(), Bid: bid, diff --git a/x/builder/ante/ante.go b/x/builder/ante/ante.go index 93b364c..72dd852 100644 --- a/x/builder/ante/ante.go +++ b/x/builder/ante/ante.go @@ -52,7 +52,7 @@ func (ad BuilderDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, transactions[i] = decodedTx } - topBid := sdk.NewCoins() + topBid := sdk.Coin{} // If the current transaction is the highest bidding transaction, then the highest bid is empty. isTopBidTx, err := ad.IsTopBidTx(ctx, tx) @@ -77,10 +77,10 @@ func (ad BuilderDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, } // GetTopAuctionBid returns the highest auction bid if one exists. -func (ad BuilderDecorator) GetTopAuctionBid(ctx sdk.Context) (sdk.Coins, error) { +func (ad BuilderDecorator) GetTopAuctionBid(ctx sdk.Context) (sdk.Coin, error) { auctionTx := ad.mempool.GetTopAuctionTx(ctx) if auctionTx == nil { - return sdk.NewCoins(), nil + return sdk.Coin{}, nil } return auctionTx.(*mempool.WrappedBidTx).GetBid(), nil diff --git a/x/builder/ante/ante_test.go b/x/builder/ante/ante_test.go index 25dd71e..da7c281 100644 --- a/x/builder/ante/ante_test.go +++ b/x/builder/ante/ante_test.go @@ -84,20 +84,20 @@ func (suite *AnteTestSuite) TestAnteHandler() { var ( // Bid set up bidder = testutils.RandomAccounts(suite.random, 1)[0] - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + bid = sdk.NewCoin("foo", sdk.NewInt(1000)) balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))) signers = []testutils.Account{bidder} // Top bidding auction tx set up topBidder = testutils.RandomAccounts(suite.random, 1)[0] - topBid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) + topBid = sdk.NewCoin("foo", sdk.NewInt(100)) insertTopBid = true // Auction setup maxBundleSize uint32 = 5 - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) - minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) - minBidIncrement = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(100)) + minBuyInFee = sdk.NewCoin("foo", sdk.NewInt(100)) + minBidIncrement = sdk.NewCoin("foo", sdk.NewInt(100)) frontRunningProtection = true ) @@ -117,7 +117,7 @@ func (suite *AnteTestSuite) TestAnteHandler() { "smaller bid than winning bid, invalid auction tx", func() { insertTopBid = true - topBid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100000))) + topBid = sdk.NewCoin("foo", sdk.NewInt(100000)) }, false, }, @@ -133,8 +133,8 @@ func (suite *AnteTestSuite) TestAnteHandler() { "bid is smaller than reserve fee, invalid auction tx", func() { balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(101))) - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + bid = sdk.NewCoin("foo", sdk.NewInt(101)) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) }, false, }, @@ -142,9 +142,9 @@ func (suite *AnteTestSuite) TestAnteHandler() { "bid is greater than reserve fee but has insufficient balance to pay the buy in fee", func() { balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(101))) - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) - minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + bid = sdk.NewCoin("foo", sdk.NewInt(101)) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(100)) + minBuyInFee = sdk.NewCoin("foo", sdk.NewInt(1000)) }, false, }, @@ -152,9 +152,9 @@ func (suite *AnteTestSuite) TestAnteHandler() { "valid auction bid tx", func() { balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) - minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) + bid = sdk.NewCoin("foo", sdk.NewInt(1000)) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(100)) + minBuyInFee = sdk.NewCoin("foo", sdk.NewInt(100)) }, true, }, @@ -162,9 +162,9 @@ func (suite *AnteTestSuite) TestAnteHandler() { "auction tx is the top bidding tx", func() { balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) - minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) + bid = sdk.NewCoin("foo", sdk.NewInt(1000)) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(100)) + minBuyInFee = sdk.NewCoin("foo", sdk.NewInt(100)) insertTopBid = true topBidder = bidder diff --git a/x/builder/keeper/auction.go b/x/builder/keeper/auction.go index 4184d92..0d9612d 100644 --- a/x/builder/keeper/auction.go +++ b/x/builder/keeper/auction.go @@ -7,7 +7,7 @@ import ( ) // ValidateAuctionMsg validates that the MsgAuctionBid can be included in the auction. -func (k Keeper) ValidateAuctionMsg(ctx sdk.Context, bidder sdk.AccAddress, bid, highestBid sdk.Coins, transactions []sdk.Tx) error { +func (k Keeper) ValidateAuctionMsg(ctx sdk.Context, bidder sdk.AccAddress, bid, highestBid sdk.Coin, transactions []sdk.Tx) error { // Validate the bundle size. maxBundleSize, err := k.GetMaxBundleSize(ctx) if err != nil { @@ -40,26 +40,36 @@ func (k Keeper) ValidateAuctionMsg(ctx sdk.Context, bidder sdk.AccAddress, bid, // ValidateAuctionBid validates that the bidder has sufficient funds to participate in the auction and that the bid amount // is sufficiently high enough. -func (k Keeper) ValidateAuctionBid(ctx sdk.Context, bidder sdk.AccAddress, bid, highestBid sdk.Coins) error { +func (k Keeper) ValidateAuctionBid(ctx sdk.Context, bidder sdk.AccAddress, bid, highestBid sdk.Coin) error { + if bid.IsNil() { + return fmt.Errorf("bid amount cannot be nil") + } + // Get the bid floor. reserveFee, err := k.GetReserveFee(ctx) if err != nil { return err } - if !bid.IsAllGTE(reserveFee) { + // Ensure that the bid denomination matches the fee denominations. + if bid.Denom != reserveFee.Denom { + return fmt.Errorf("bid denom (%s) does not match the reserve fee denom (%s)", bid, reserveFee) + } + + // Bid must be greater than the bid floor. + if !bid.IsGTE(reserveFee) { return fmt.Errorf("bid amount (%s) is less than the reserve fee (%s)", bid, reserveFee) } - if !highestBid.Empty() { + if !highestBid.IsNil() { // Ensure the bid is greater than the highest bid + min bid increment. minBidIncrement, err := k.GetMinBidIncrement(ctx) if err != nil { return err } - minBid := highestBid.Add(minBidIncrement...) - if !bid.IsAllGTE(minBid) { + minBid := highestBid.Add(minBidIncrement) + if !bid.IsGTE(minBid) { return fmt.Errorf("bid amount (%s) is less than the highest bid (%s) + min bid increment (%s)", bid, highestBid, minBidIncrement) } } @@ -71,9 +81,9 @@ func (k Keeper) ValidateAuctionBid(ctx sdk.Context, bidder sdk.AccAddress, bid, } // Ensure the bidder has enough funds to cover all the inclusion fees. - minBalance := bid.Add(minBuyInFee...) + minBalance := bid.Add(minBuyInFee) balances := k.bankKeeper.GetAllBalances(ctx, bidder) - if !balances.IsAllGTE(minBalance) { + if !balances.IsAllGTE(sdk.NewCoins(minBalance)) { return fmt.Errorf("insufficient funds to bid %s (reserve fee + bid) with balance %s", minBalance, balances) } diff --git a/x/builder/keeper/auction_test.go b/x/builder/keeper/auction_test.go index bd7d5a1..a7e46dc 100644 --- a/x/builder/keeper/auction_test.go +++ b/x/builder/keeper/auction_test.go @@ -15,18 +15,18 @@ func (suite *KeeperTestSuite) TestValidateAuctionMsg() { // Tx building variables accounts = []testutils.Account{} // tracks the order of signers in the bundle balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + bid = sdk.NewCoin("foo", sdk.NewInt(1000)) // Auction params maxBundleSize uint32 = 10 - reserveFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - minBuyInFee = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) - minBidIncrement = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000)) + minBuyInFee = sdk.NewCoin("foo", sdk.NewInt(1000)) + minBidIncrement = sdk.NewCoin("foo", sdk.NewInt(1000)) escrowAddress = sdk.AccAddress([]byte("escrow")) frontRunningProtection = true // mempool variables - highestBid = sdk.NewCoins() + highestBid = sdk.Coin{} ) rnd := rand.New(rand.NewSource(time.Now().Unix())) @@ -40,14 +40,14 @@ func (suite *KeeperTestSuite) TestValidateAuctionMsg() { { "insufficient bid amount", func() { - bid = sdk.NewCoins() + bid = sdk.Coin{} }, false, }, { "insufficient balance", func() { - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + bid = sdk.NewCoin("foo", sdk.NewInt(1000)) balance = sdk.NewCoins() }, false, @@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) TestValidateAuctionMsg() { "bid amount equals the balance (not accounting for the reserve fee)", func() { balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(2000))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(2000))) + bid = sdk.NewCoin("foo", sdk.NewInt(2000)) }, false, }, @@ -64,7 +64,7 @@ func (suite *KeeperTestSuite) TestValidateAuctionMsg() { "too many transactions in the bundle", func() { // reset the balance and bid to their original values - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000))) + bid = sdk.NewCoin("foo", sdk.NewInt(1000)) balance = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))) accounts = testutils.RandomAccounts(rnd, int(maxBundleSize+1)) }, @@ -128,19 +128,27 @@ func (suite *KeeperTestSuite) TestValidateAuctionMsg() { "invalid bundle that does not outbid the highest bid", func() { accounts = []testutils.Account{bidder, bidder, bidder} - highestBid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500))) + highestBid = sdk.NewCoin("foo", sdk.NewInt(500)) + bid = sdk.NewCoin("foo", sdk.NewInt(500)) }, false, }, { "valid bundle that outbids the highest bid", func() { - highestBid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500))) - bid = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1500))) + highestBid = sdk.NewCoin("foo", sdk.NewInt(500)) + bid = sdk.NewCoin("foo", sdk.NewInt(1500)) }, true, }, + { + "attempting to bid with a different denom", + func() { + highestBid = sdk.NewCoin("foo", sdk.NewInt(500)) + bid = sdk.NewCoin("foo2", sdk.NewInt(1500)) + }, + false, + }, } for _, tc := range cases { diff --git a/x/builder/keeper/keeper.go b/x/builder/keeper/keeper.go index a93fcb0..bb6c0b0 100644 --- a/x/builder/keeper/keeper.go +++ b/x/builder/keeper/keeper.go @@ -122,30 +122,30 @@ func (k Keeper) GetEscrowAccount(ctx sdk.Context) (sdk.AccAddress, error) { } // GetReserveFee returns the reserve fee of the builder module. -func (k Keeper) GetReserveFee(ctx sdk.Context) (sdk.Coins, error) { +func (k Keeper) GetReserveFee(ctx sdk.Context) (sdk.Coin, error) { params, err := k.GetParams(ctx) if err != nil { - return sdk.NewCoins(), err + return sdk.Coin{}, err } return params.ReserveFee, nil } // GetMinBuyInFee returns the fee that the bidder must pay to enter the builder. -func (k Keeper) GetMinBuyInFee(ctx sdk.Context) (sdk.Coins, error) { +func (k Keeper) GetMinBuyInFee(ctx sdk.Context) (sdk.Coin, error) { params, err := k.GetParams(ctx) if err != nil { - return sdk.NewCoins(), err + return sdk.Coin{}, err } return params.MinBuyInFee, nil } // GetMinBidIncrement returns the minimum bid increment for the builder. -func (k Keeper) GetMinBidIncrement(ctx sdk.Context) (sdk.Coins, error) { +func (k Keeper) GetMinBidIncrement(ctx sdk.Context) (sdk.Coin, error) { params, err := k.GetParams(ctx) if err != nil { - return sdk.NewCoins(), err + return sdk.Coin{}, err } return params.MinBidIncrement, nil diff --git a/x/builder/keeper/msg_server.go b/x/builder/keeper/msg_server.go index f07d6f2..e3535a6 100644 --- a/x/builder/keeper/msg_server.go +++ b/x/builder/keeper/msg_server.go @@ -53,7 +53,7 @@ func (m MsgServer) AuctionBid(goCtx context.Context, msg *types.MsgAuctionBid) ( if proposerFee.IsZero() { // send the entire bid to the escrow account when no proposer fee is set - if err := m.bankKeeper.SendCoins(ctx, bidder, escrow, msg.Bid); err != nil { + if err := m.bankKeeper.SendCoins(ctx, bidder, escrow, sdk.NewCoins(msg.Bid)); err != nil { return nil, err } } else { @@ -61,7 +61,7 @@ func (m MsgServer) AuctionBid(goCtx context.Context, msg *types.MsgAuctionBid) ( prevProposer := m.stakingKeeper.ValidatorByConsAddr(ctx, prevPropConsAddr) // determine the amount of the bid that goes to the (previous) proposer - bid := sdk.NewDecCoinsFromCoins(msg.Bid...) + bid := sdk.NewDecCoinsFromCoins(msg.Bid) proposerReward, _ := bid.MulDecTruncate(proposerFee).TruncateDecimal() if err := m.bankKeeper.SendCoins(ctx, bidder, sdk.AccAddress(prevProposer.GetOperator()), proposerReward); err != nil { diff --git a/x/builder/keeper/msg_server_test.go b/x/builder/keeper/msg_server_test.go index 00625df..b4c962d 100644 --- a/x/builder/keeper/msg_server_test.go +++ b/x/builder/keeper/msg_server_test.go @@ -54,7 +54,7 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() { name: "valid bundle with no proposer fee", msg: &types.MsgAuctionBid{ Bidder: bidder.Address.String(), - Bid: sdk.NewCoins(sdk.NewInt64Coin("foo", 1024)), + Bid: sdk.NewInt64Coin("foo", 1024), Transactions: [][]byte{{0xFF}, {0xFF}}, }, malleate: func() { @@ -79,7 +79,7 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() { name: "valid bundle with proposer fee", msg: &types.MsgAuctionBid{ Bidder: bidder.Address.String(), - Bid: sdk.NewCoins(sdk.NewInt64Coin("foo", 3416)), + Bid: sdk.NewInt64Coin("foo", 3416), Transactions: [][]byte{{0xFF}, {0xFF}}, }, malleate: func() { diff --git a/x/builder/types/genesis.pb.go b/x/builder/types/genesis.pb.go index 2243b8d..adf8ab5 100644 --- a/x/builder/types/genesis.pb.go +++ b/x/builder/types/genesis.pb.go @@ -80,13 +80,13 @@ type Params struct { // portion of the bid proceeds. EscrowAccountAddress string `protobuf:"bytes,2,opt,name=escrow_account_address,json=escrowAccountAddress,proto3" json:"escrow_account_address,omitempty"` // reserve_fee specifies the bid floor for the auction. - ReserveFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=reserve_fee,json=reserveFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"reserve_fee"` + ReserveFee types.Coin `protobuf:"bytes,3,opt,name=reserve_fee,json=reserveFee,proto3" json:"reserve_fee"` // min_buy_in_fee specifies the fee that the bidder must pay to enter the // auction. - MinBuyInFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=min_buy_in_fee,json=minBuyInFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"min_buy_in_fee"` + MinBuyInFee types.Coin `protobuf:"bytes,4,opt,name=min_buy_in_fee,json=minBuyInFee,proto3" json:"min_buy_in_fee"` // min_bid_increment specifies the minimum amount that the next bid must be // greater than the previous bid. - MinBidIncrement github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,5,rep,name=min_bid_increment,json=minBidIncrement,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"min_bid_increment"` + MinBidIncrement types.Coin `protobuf:"bytes,5,opt,name=min_bid_increment,json=minBidIncrement,proto3" json:"min_bid_increment"` // front_running_protection specifies whether front running and sandwich // attack protection is enabled. FrontRunningProtection bool `protobuf:"varint,6,opt,name=front_running_protection,json=frontRunningProtection,proto3" json:"front_running_protection,omitempty"` @@ -142,25 +142,25 @@ func (m *Params) GetEscrowAccountAddress() string { return "" } -func (m *Params) GetReserveFee() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *Params) GetReserveFee() types.Coin { if m != nil { return m.ReserveFee } - return nil + return types.Coin{} } -func (m *Params) GetMinBuyInFee() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *Params) GetMinBuyInFee() types.Coin { if m != nil { return m.MinBuyInFee } - return nil + return types.Coin{} } -func (m *Params) GetMinBidIncrement() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *Params) GetMinBidIncrement() types.Coin { if m != nil { return m.MinBidIncrement } - return nil + return types.Coin{} } func (m *Params) GetFrontRunningProtection() bool { @@ -178,40 +178,39 @@ func init() { func init() { proto.RegisterFile("pob/builder/v1/genesis.proto", fileDescriptor_287f1bdff5ccfc33) } var fileDescriptor_287f1bdff5ccfc33 = []byte{ - // 521 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0xbf, 0x6e, 0x13, 0x4f, - 0x10, 0xc7, 0x7d, 0xbf, 0xf8, 0x67, 0x60, 0x9d, 0x10, 0xe5, 0x14, 0x59, 0x47, 0x40, 0x67, 0x2b, - 0x45, 0xb0, 0x22, 0x65, 0x57, 0x0e, 0x20, 0x21, 0x44, 0x63, 0x83, 0x82, 0x22, 0x51, 0x84, 0x4b, - 0x47, 0x73, 0xba, 0x3f, 0x13, 0xb3, 0x4a, 0x76, 0xf7, 0xd8, 0xdd, 0x3b, 0xec, 0x88, 0x27, 0xa0, - 0xe2, 0x31, 0x10, 0x55, 0x1e, 0x23, 0x65, 0x4a, 0x44, 0x11, 0x90, 0x5d, 0xe4, 0x29, 0x90, 0xd0, - 0xee, 0x5e, 0x42, 0x0a, 0x0a, 0x9a, 0x34, 0x77, 0xa7, 0xfd, 0x7e, 0x77, 0x3e, 0x33, 0x73, 0x33, - 0xe8, 0x41, 0x21, 0x52, 0x92, 0x96, 0xf4, 0x28, 0x07, 0x49, 0xaa, 0x01, 0x19, 0x03, 0x07, 0x45, - 0x15, 0x2e, 0xa4, 0xd0, 0xc2, 0xef, 0xa8, 0x43, 0x5a, 0x30, 0xa8, 0x70, 0x21, 0x52, 0x5c, 0xbb, - 0x70, 0x35, 0x58, 0x5b, 0x1d, 0x8b, 0xb1, 0xb0, 0x16, 0x62, 0xbe, 0x9c, 0x7b, 0x2d, 0xcc, 0x84, - 0x62, 0x42, 0x91, 0x34, 0x51, 0x40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0xff, 0xe5, 0xc0, 0xeb, 0xb3, 0x98, 0x03, 0x00, 0x00, + // 503 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0x63, 0x5a, 0x02, 0xbd, 0xb4, 0x54, 0xb5, 0xaa, 0xc8, 0x14, 0xe4, 0x46, 0x1d, 0x4a, + 0x54, 0xa9, 0x77, 0x0a, 0x30, 0x20, 0xc4, 0x92, 0x00, 0x45, 0x91, 0x18, 0x82, 0xbb, 0xb1, 0x58, + 0xfe, 0xf3, 0xd6, 0x9c, 0xda, 0xbb, 0xb3, 0xee, 0xce, 0x26, 0xe9, 0x47, 0x60, 0xe2, 0x63, 0x30, + 0xf6, 0x63, 0x74, 0xec, 0x88, 0x18, 0x2a, 0x94, 0x0c, 0xfd, 0x0c, 0x6c, 0xe8, 0xee, 0xdc, 0xd2, + 0x81, 0xa5, 0x8b, 0x6d, 0xdd, 0xf3, 0xbc, 0xbf, 0xf7, 0x7d, 0x7d, 0x0f, 0x7a, 0x5a, 0x8a, 0x94, + 0xa4, 0x15, 0x3d, 0xc9, 0x41, 0x92, 0x7a, 0x40, 0x0a, 0xe0, 0xa0, 0xa8, 0xc2, 0xa5, 0x14, 0x5a, + 0xf8, 0x5d, 0x75, 0x4c, 0x4b, 0x06, 0x35, 0x2e, 0x45, 0x8a, 0x1b, 0x17, 0xae, 0x07, 0x5b, 0x9b, + 0x85, 0x28, 0x84, 0xb5, 0x10, 0xf3, 0xe5, 0xdc, 0x5b, 0x61, 0x26, 0x14, 0x13, 0x8a, 0xa4, 0x89, + 0x02, 0x52, 0x0f, 0x52, 0xd0, 0xc9, 0x80, 0x64, 0x82, 0xf2, 0x46, 0xdf, 0x48, 0x18, 0xe5, 0x82, + 0xd8, 0xa7, 0x3b, 0xda, 0xf9, 0x88, 0x56, 0x3f, 0xb8, 0x8e, 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57, 0x28, 0x38, 0x92, 0x82, 0xeb, 0x58, 0x56, 0x9c, 0x53, 0x5e, 0xc4, 0xe6, 0xc6, 0x20, + 0xd3, 0x54, 0xf0, 0xa0, 0xdd, 0xf3, 0xfa, 0x0f, 0xa3, 0xae, 0xd5, 0x23, 0x27, 0x4f, 0x6e, 0x54, + 0xff, 0x13, 0x5a, 0x2d, 0xa5, 0x28, 0x85, 0x02, 0x69, 0x97, 0x7a, 0x60, 0xfe, 0xe4, 0x08, 0x9b, + 0x5e, 0xbf, 0x2e, 0xb7, 0x77, 0x0b, 0xaa, 0xbf, 0x54, 0x29, 0xce, 0x04, 0x23, 0x4d, 0x60, 0xdc, + 0x6b, 0x5f, 0xe5, 0xc7, 0x44, 0xcf, 0x4a, 0x50, 0xf8, 0x1d, 0x64, 0x51, 0xe7, 0x9a, 0x71, 0x00, + 0xf0, 0xba, 0xf7, 0xed, 0xea, 0x6c, 0xef, 0xc9, 0x2d, 0xdf, 0xf4, 0x26, 0xb4, 0x4d, 0x12, 0x86, + 0xe7, 0xf3, 0xd0, 0xbb, 0x98, 0x87, 0xde, 0xef, 0x79, 0xe8, 0x7d, 0x5f, 0x84, 0xad, 0x8b, 0x45, + 0xd8, 0xfa, 0xb9, 0x08, 0x5b, 0x9f, 0x9f, 0xdd, 0x6a, 0x68, 0xd2, 0xb4, 0xcf, 0xa0, 0x26, 0x26, + 0xf6, 0xff, 0x18, 0xb6, 0x6b, 0xda, 0xb6, 0x99, 0x7c, 0xf1, 0x37, 0x00, 0x00, 0xff, 0xff, 0xd7, + 0x67, 0xa2, 0x8e, 0x14, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -287,48 +286,36 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x30 } - if len(m.MinBidIncrement) > 0 { - for iNdEx := len(m.MinBidIncrement) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MinBidIncrement[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a + { + size, err := m.MinBidIncrement.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } - if len(m.MinBuyInFee) > 0 { - for iNdEx := len(m.MinBuyInFee) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MinBuyInFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 + i-- + dAtA[i] = 0x2a + { + size, err := m.MinBuyInFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } - if len(m.ReserveFee) > 0 { - for iNdEx := len(m.ReserveFee) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ReserveFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + i-- + dAtA[i] = 0x22 + { + size, err := m.ReserveFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.EscrowAccountAddress) > 0 { i -= len(m.EscrowAccountAddress) copy(dAtA[i:], m.EscrowAccountAddress) @@ -379,24 +366,12 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } - if len(m.ReserveFee) > 0 { - for _, e := range m.ReserveFee { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.MinBuyInFee) > 0 { - for _, e := range m.MinBuyInFee { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.MinBidIncrement) > 0 { - for _, e := range m.MinBidIncrement { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } + l = m.ReserveFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.MinBuyInFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.MinBidIncrement.Size() + n += 1 + l + sovGenesis(uint64(l)) if m.FrontRunningProtection { n += 2 } @@ -603,8 +578,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ReserveFee = append(m.ReserveFee, types.Coin{}) - if err := m.ReserveFee[len(m.ReserveFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ReserveFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -637,8 +611,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MinBuyInFee = append(m.MinBuyInFee, types.Coin{}) - if err := m.MinBuyInFee[len(m.MinBuyInFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MinBuyInFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -671,8 +644,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MinBidIncrement = append(m.MinBidIncrement, types.Coin{}) - if err := m.MinBidIncrement[len(m.MinBidIncrement)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MinBidIncrement.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/builder/types/msgs.go b/x/builder/types/msgs.go index 3fb74ea..10e5a74 100644 --- a/x/builder/types/msgs.go +++ b/x/builder/types/msgs.go @@ -51,7 +51,7 @@ func (m MsgAuctionBid) ValidateBasic() error { } // Validate the bid. - if m.Bid.IsZero() { + if m.Bid.IsNil() { return fmt.Errorf("no bid included") } diff --git a/x/builder/types/msgs_test.go b/x/builder/types/msgs_test.go index a2f9ca4..64f8ffa 100644 --- a/x/builder/types/msgs_test.go +++ b/x/builder/types/msgs_test.go @@ -18,7 +18,7 @@ func TestMsgAuctionBid(t *testing.T) { description: "invalid message with empty bidder", msg: types.MsgAuctionBid{ Bidder: "", - Bid: sdk.NewCoins(), + Bid: sdk.Coin{}, Transactions: [][]byte{}, }, expectPass: false, @@ -27,7 +27,7 @@ func TestMsgAuctionBid(t *testing.T) { description: "invalid message with empty bid", msg: types.MsgAuctionBid{ Bidder: sdk.AccAddress([]byte("test")).String(), - Bid: sdk.NewCoins(), + Bid: sdk.Coin{}, Transactions: [][]byte{}, }, expectPass: false, @@ -36,7 +36,7 @@ func TestMsgAuctionBid(t *testing.T) { description: "invalid message with empty transactions", msg: types.MsgAuctionBid{ Bidder: sdk.AccAddress([]byte("test")).String(), - Bid: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Bid: sdk.NewCoin("test", sdk.NewInt(100)), Transactions: [][]byte{}, }, expectPass: false, @@ -45,7 +45,7 @@ func TestMsgAuctionBid(t *testing.T) { description: "valid message", msg: types.MsgAuctionBid{ Bidder: sdk.AccAddress([]byte("test")).String(), - Bid: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Bid: sdk.NewCoin("test", sdk.NewInt(100)), Transactions: [][]byte{[]byte("test")}, }, expectPass: true, @@ -54,7 +54,7 @@ func TestMsgAuctionBid(t *testing.T) { description: "valid message with multiple transactions", msg: types.MsgAuctionBid{ Bidder: sdk.AccAddress([]byte("test")).String(), - Bid: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Bid: sdk.NewCoin("test", sdk.NewInt(100)), Transactions: [][]byte{[]byte("test"), []byte("test2")}, }, expectPass: true, @@ -63,7 +63,7 @@ func TestMsgAuctionBid(t *testing.T) { description: "invalid message with empty transaction in transactions", msg: types.MsgAuctionBid{ Bidder: sdk.AccAddress([]byte("test")).String(), - Bid: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Bid: sdk.NewCoin("test", sdk.NewInt(100)), Transactions: [][]byte{[]byte("test"), []byte("")}, }, expectPass: false, @@ -118,6 +118,9 @@ func TestMsgUpdateParams(t *testing.T) { Params: types.Params{ ProposerFee: sdk.NewDec(1), EscrowAccountAddress: sdk.AccAddress([]byte("test")).String(), + ReserveFee: sdk.NewCoin("test", sdk.NewInt(100)), + MinBidIncrement: sdk.NewCoin("test", sdk.NewInt(100)), + MinBuyInFee: sdk.NewCoin("test", sdk.NewInt(100)), }, }, expectPass: true, diff --git a/x/builder/types/params.go b/x/builder/types/params.go index 4a7deab..f3186c4 100644 --- a/x/builder/types/params.go +++ b/x/builder/types/params.go @@ -10,9 +10,9 @@ import ( var ( DefaultMaxBundleSize uint32 = 2 DefaultEscrowAccountAddress string - DefaultReserveFee = sdk.Coins{} - DefaultMinBuyInFee = sdk.Coins{} - DefaultMinBidIncrement = sdk.Coins{} + DefaultReserveFee = sdk.Coin{} + DefaultMinBuyInFee = sdk.Coin{} + DefaultMinBidIncrement = sdk.Coin{} DefaultFrontRunningProtection = true DefaultProposerFee = sdk.ZeroDec() ) @@ -21,7 +21,7 @@ var ( func NewParams( maxBundleSize uint32, escrowAccountAddress string, - reserveFee, minBuyInFee, minBidIncrement sdk.Coins, + reserveFee, minBuyInFee, minBidIncrement sdk.Coin, frontRunningProtection bool, proposerFee sdk.Dec, ) Params { @@ -55,21 +55,29 @@ func (p Params) Validate() error { return err } - if err := p.ReserveFee.Validate(); err != nil { + if err := validateFee(p.ReserveFee); err != nil { return fmt.Errorf("invalid reserve fee (%s)", err) } - if err := p.MinBuyInFee.Validate(); err != nil { + if err := validateFee(p.MinBuyInFee); err != nil { return fmt.Errorf("invalid minimum buy-in fee (%s)", err) } - if err := p.MinBidIncrement.Validate(); err != nil { + if err := validateFee(p.MinBidIncrement); err != nil { return fmt.Errorf("invalid minimum bid increment (%s)", err) } return validateProposerFee(p.ProposerFee) } +func validateFee(fee sdk.Coin) error { + if fee.IsNil() { + return fmt.Errorf("fee cannot be nil: %s", fee) + } + + return fee.Validate() +} + func validateProposerFee(v sdk.Dec) error { if v.IsNil() { return fmt.Errorf("proposer fee cannot be nil: %s", v) @@ -84,8 +92,6 @@ func validateProposerFee(v sdk.Dec) error { return nil } -// validateEscrowAccountAddress ensures the escrow account address is a valid -// address. func validateEscrowAccountAddress(account string) error { // If the escrow account address is set, ensure it is a valid address. if _, err := sdk.AccAddressFromBech32(account); err != nil { diff --git a/x/builder/types/tx.pb.go b/x/builder/types/tx.pb.go index 3b0e34b..2481570 100644 --- a/x/builder/types/tx.pb.go +++ b/x/builder/types/tx.pb.go @@ -7,7 +7,6 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" @@ -42,7 +41,7 @@ type MsgAuctionBid struct { Bidder string `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` // bid is the amount of coins that the bidder is bidding to participate in the // auction. - Bid github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=bid,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"bid"` + Bid types.Coin `protobuf:"bytes,3,opt,name=bid,proto3" json:"bid"` // transactions are the bytes of the transactions that the bidder wants to // bundle together. Transactions [][]byte `protobuf:"bytes,4,rep,name=transactions,proto3" json:"transactions,omitempty"` @@ -88,11 +87,11 @@ func (m *MsgAuctionBid) GetBidder() string { return "" } -func (m *MsgAuctionBid) GetBid() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *MsgAuctionBid) GetBid() types.Coin { if m != nil { return m.Bid } - return nil + return types.Coin{} } func (m *MsgAuctionBid) GetTransactions() [][]byte { @@ -243,42 +242,41 @@ func init() { func init() { proto.RegisterFile("pob/builder/v1/tx.proto", fileDescriptor_5cab4e3a4b082d0a) } var fileDescriptor_5cab4e3a4b082d0a = []byte{ - // 559 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbd, 0x6f, 0xd3, 0x4e, - 0x18, 0x8e, 0x9b, 0xfe, 0x22, 0xf5, 0x9a, 0x9f, 0x10, 0xa6, 0x25, 0x1f, 0x05, 0x27, 0xb2, 0x84, - 0x1a, 0x45, 0x8a, 0x8f, 0x84, 0x8f, 0xa1, 0x62, 0x49, 0x98, 0x23, 0xa1, 0x20, 0x16, 0x16, 0x74, - 0x8e, 0x4f, 0x97, 0x53, 0x6b, 0x9f, 0xe5, 0xf7, 0x12, 0xb5, 0x13, 0xa8, 0x23, 0x13, 0x12, 0xff, - 0x00, 0x23, 0x62, 0xca, 0xc0, 0xca, 0xde, 0xb1, 0x82, 0x85, 0x09, 0x50, 0x82, 0x14, 0xfe, 0x03, - 0x24, 0x26, 0x74, 0xf6, 0xb9, 0x8d, 0xc3, 0x57, 0x97, 0xc4, 0x7e, 0xdf, 0xe7, 0x7d, 0xee, 0x79, - 0x9e, 0x7b, 0x8d, 0x4a, 0xa1, 0x70, 0xb1, 0x3b, 0xe6, 0x07, 0x1e, 0x8d, 0xf0, 0xa4, 0x8d, 0xe5, - 0xa1, 0x13, 0x46, 0x42, 0x0a, 0xf3, 0x2a, 0xec, 0xf3, 0xd0, 0xa7, 0x13, 0x27, 0x14, 0xae, 0xa3, - 0x01, 0xce, 0xa4, 0x5d, 0xdd, 0x62, 0x82, 0x89, 0x18, 0x82, 0xd5, 0x53, 0x82, 0xae, 0x5e, 0x63, - 0x42, 0xb0, 0x03, 0x8a, 0x49, 0xc8, 0x31, 0x09, 0x02, 0x21, 0x89, 0xe4, 0x22, 0x00, 0xdd, 0xb5, - 0x86, 0x02, 0x7c, 0x01, 0xd8, 0x25, 0x40, 0xf1, 0xa4, 0xed, 0x52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b, 0xe5, 0xd3, 0x09, 0xce, 0x26, 0x1c, 0x6f, 0xa5, 0x5b, 0x88, 0x3f, 0x9a, - 0x5b, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3d, 0x06, 0x90, 0xd0, 0x20, 0x04, 0x00, 0x00, + // 535 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbf, 0x6f, 0x13, 0x31, + 0x18, 0x8d, 0x9b, 0x12, 0x29, 0x26, 0x08, 0x71, 0xb4, 0xe4, 0x47, 0xe1, 0x1a, 0x9d, 0x84, 0x1a, + 0x45, 0x8a, 0x4d, 0x0a, 0xea, 0x50, 0xb1, 0x24, 0xcc, 0x91, 0x50, 0x10, 0x0b, 0x0b, 0xf2, 0xe5, + 0x2c, 0xc7, 0xa2, 0x67, 0x9f, 0xce, 0x4e, 0xd4, 0x4e, 0xa0, 0x8e, 0x4c, 0x48, 0xfc, 0x03, 0x8c, + 0x8c, 0x19, 0x58, 0xd9, 0x3b, 0xa1, 0x0a, 0x16, 0x26, 0x84, 0x12, 0xa4, 0xf0, 0x1f, 0xb0, 0x22, + 0xdf, 0x39, 0x6d, 0x2e, 0xfc, 0x68, 0x97, 0xd3, 0xdd, 0xe7, 0xf7, 0xbd, 0xef, 0xbd, 0xe7, 0xef, + 0x60, 0x39, 0x92, 0x3e, 0xf6, 0x47, 0xfc, 0x20, 0xa0, 0x31, 0x1e, 0xb7, 0xb1, 0x3e, 0x44, 0x51, + 0x2c, 0xb5, 0x74, 0x6e, 0xa9, 0x17, 0x3c, 0x0a, 0xe9, 0x18, 0x45, 0xd2, 0x47, 0x16, 0x80, 0xc6, + 0xed, 0xda, 0x06, 0x93, 0x4c, 0x26, 0x10, 0x6c, 0xde, 0x52, 0x74, 0xed, 0x36, 0x93, 0x92, 0x1d, + 0x50, 0x4c, 0x22, 0x8e, 0x89, 0x10, 0x52, 0x13, 0xcd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, 0x45, 0x54, 0xf9, 0x85, 0xe4, 0x47, 0xb8, 0xff, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xfe, + 0xe2, 0x14, 0x08, 0xf4, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -432,20 +430,16 @@ func (m *MsgAuctionBid) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x22 } } - if len(m.Bid) > 0 { - for iNdEx := len(m.Bid) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Bid[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a + { + size, err := m.Bid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if len(m.Bidder) > 0 { i -= len(m.Bidder) copy(dAtA[i:], m.Bidder) @@ -563,12 +557,8 @@ func (m *MsgAuctionBid) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Bid) > 0 { - for _, e := range m.Bid { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } + l = m.Bid.Size() + n += 1 + l + sovTx(uint64(l)) if len(m.Transactions) > 0 { for _, b := range m.Transactions { l = len(b) @@ -707,8 +697,7 @@ func (m *MsgAuctionBid) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Bid = append(m.Bid, types.Coin{}) - if err := m.Bid[len(m.Bid)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Bid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex