chore(v0.50.0): Migrating codebase to latest SDK version (#215)
This commit is contained in:
@@ -123,7 +123,11 @@ func (bd BuilderDecorator) ValidateTimeout(ctx sdk.Context, timeout int64) error
|
||||
}
|
||||
|
||||
if timeout < currentBlockHeight {
|
||||
return fmt.Errorf("timeout height cannot be less than the current block height")
|
||||
return fmt.Errorf(
|
||||
"timeout height cannot be less than the current block height (timeout: %d, current block height: %d)",
|
||||
timeout,
|
||||
currentBlockHeight,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+20
-20
@@ -5,7 +5,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"cosmossdk.io/math"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/golang/mock/gomock"
|
||||
@@ -86,7 +87,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
TxEncoder: suite.encodingConfig.TxConfig.TxEncoder(),
|
||||
TxDecoder: suite.encodingConfig.TxConfig.TxDecoder(),
|
||||
AnteHandler: suite.anteHandler,
|
||||
MaxBlockSpace: sdk.ZeroDec(),
|
||||
MaxBlockSpace: math.LegacyZeroDec(),
|
||||
}
|
||||
suite.tobLane = auction.NewTOBLane(
|
||||
config,
|
||||
@@ -103,8 +104,7 @@ func (suite *AnteTestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
func (suite *AnteTestSuite) anteHandler(ctx sdk.Context, tx sdk.Tx, _ bool) (sdk.Context, error) {
|
||||
signer := tx.GetMsgs()[0].GetSigners()[0]
|
||||
suite.bankKeeper.EXPECT().GetBalance(ctx, signer, suite.balance.Denom).AnyTimes().Return(suite.balance)
|
||||
suite.bankKeeper.EXPECT().GetBalance(ctx, gomock.Any(), suite.balance.Denom).AnyTimes().Return(suite.balance)
|
||||
|
||||
next := func(ctx sdk.Context, tx sdk.Tx, _ bool) (sdk.Context, error) {
|
||||
return ctx, nil
|
||||
@@ -117,20 +117,20 @@ func (suite *AnteTestSuite) TestAnteHandler() {
|
||||
var (
|
||||
// Bid set up
|
||||
bidder = testutils.RandomAccounts(suite.random, 1)[0]
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(10000))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(10000))
|
||||
signers = []testutils.Account{bidder}
|
||||
|
||||
// Top bidding auction tx set up
|
||||
topBidder = testutils.RandomAccounts(suite.random, 1)[0]
|
||||
topBid = sdk.NewCoin("foo", sdk.NewInt(100))
|
||||
topBid = sdk.NewCoin("stake", math.NewInt(100))
|
||||
insertTopBid = true
|
||||
timeout = uint64(1000)
|
||||
|
||||
// Auction setup
|
||||
maxBundleSize uint32 = 5
|
||||
reserveFee = sdk.NewCoin("foo", sdk.NewInt(100))
|
||||
minBidIncrement = sdk.NewCoin("foo", sdk.NewInt(100))
|
||||
reserveFee = sdk.NewCoin("stake", math.NewInt(100))
|
||||
minBidIncrement = sdk.NewCoin("stake", math.NewInt(100))
|
||||
frontRunningProtection = true
|
||||
)
|
||||
|
||||
@@ -150,7 +150,7 @@ func (suite *AnteTestSuite) TestAnteHandler() {
|
||||
"smaller bid than winning bid, invalid auction tx",
|
||||
func() {
|
||||
insertTopBid = true
|
||||
topBid = sdk.NewCoin("foo", sdk.NewInt(100000))
|
||||
topBid = sdk.NewCoin("stake", math.NewInt(100000))
|
||||
},
|
||||
false,
|
||||
},
|
||||
@@ -158,25 +158,25 @@ func (suite *AnteTestSuite) TestAnteHandler() {
|
||||
"bidder has insufficient balance, invalid auction tx",
|
||||
func() {
|
||||
insertTopBid = false
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(10))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(10))
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"bid is smaller than reserve fee, invalid auction tx",
|
||||
func() {
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(10000))
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(101))
|
||||
reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(10000))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(101))
|
||||
reserveFee = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"valid auction bid tx",
|
||||
func() {
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(10000))
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
reserveFee = sdk.NewCoin("foo", sdk.NewInt(100))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(10000))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
reserveFee = sdk.NewCoin("stake", math.NewInt(100))
|
||||
},
|
||||
true,
|
||||
},
|
||||
@@ -191,9 +191,9 @@ func (suite *AnteTestSuite) TestAnteHandler() {
|
||||
"auction tx is the top bidding tx",
|
||||
func() {
|
||||
timeout = 1000
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(10000))
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
reserveFee = sdk.NewCoin("foo", sdk.NewInt(100))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(10000))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
reserveFee = sdk.NewCoin("stake", math.NewInt(100))
|
||||
|
||||
insertTopBid = true
|
||||
topBidder = bidder
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
"github.com/skip-mev/pob/x/builder/keeper"
|
||||
@@ -14,13 +15,13 @@ func (suite *KeeperTestSuite) TestValidateBidInfo() {
|
||||
var (
|
||||
// Tx building variables
|
||||
accounts = []testutils.Account{} // tracks the order of signers in the bundle
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(10000))
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(10000))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
|
||||
// Auction params
|
||||
maxBundleSize uint32 = 10
|
||||
reserveFee = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
minBidIncrement = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
reserveFee = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
minBidIncrement = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
escrowAddress = sdk.AccAddress([]byte("escrow"))
|
||||
frontRunningProtection = true
|
||||
|
||||
@@ -46,8 +47,8 @@ func (suite *KeeperTestSuite) TestValidateBidInfo() {
|
||||
{
|
||||
"insufficient balance",
|
||||
func() {
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(100))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(100))
|
||||
},
|
||||
false,
|
||||
},
|
||||
@@ -55,8 +56,8 @@ func (suite *KeeperTestSuite) TestValidateBidInfo() {
|
||||
"too many transactions in the bundle",
|
||||
func() {
|
||||
// reset the balance and bid to their original values
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1000))
|
||||
balance = sdk.NewCoin("foo", sdk.NewInt(10000))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(1000))
|
||||
balance = sdk.NewCoin("stake", math.NewInt(10000))
|
||||
accounts = testutils.RandomAccounts(rnd, int(maxBundleSize+1))
|
||||
},
|
||||
false,
|
||||
@@ -119,33 +120,33 @@ func (suite *KeeperTestSuite) TestValidateBidInfo() {
|
||||
"invalid bundle that does not outbid the highest bid",
|
||||
func() {
|
||||
accounts = []testutils.Account{bidder, bidder, bidder}
|
||||
highestBid = sdk.NewCoin("foo", sdk.NewInt(500))
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(500))
|
||||
highestBid = sdk.NewCoin("stake", math.NewInt(500))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(500))
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"valid bundle that outbids the highest bid",
|
||||
func() {
|
||||
highestBid = sdk.NewCoin("foo", sdk.NewInt(500))
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1500))
|
||||
highestBid = sdk.NewCoin("stake", math.NewInt(500))
|
||||
bid = sdk.NewCoin("stake", math.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))
|
||||
highestBid = sdk.NewCoin("stake", math.NewInt(500))
|
||||
bid = sdk.NewCoin("stake2", math.NewInt(1500))
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"min bid increment is different from bid denom", // THIS SHOULD NEVER HAPPEN
|
||||
func() {
|
||||
highestBid = sdk.NewCoin("foo", sdk.NewInt(500))
|
||||
bid = sdk.NewCoin("foo", sdk.NewInt(1500))
|
||||
minBidIncrement = sdk.NewCoin("foo2", sdk.NewInt(1000))
|
||||
highestBid = sdk.NewCoin("stake", math.NewInt(500))
|
||||
bid = sdk.NewCoin("stake", math.NewInt(1500))
|
||||
minBidIncrement = sdk.NewCoin("stake2", math.NewInt(1000))
|
||||
},
|
||||
false,
|
||||
},
|
||||
|
||||
@@ -3,10 +3,11 @@ package keeper
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cometbft/cometbft/libs/log"
|
||||
"cosmossdk.io/log"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/x/builder/rewards"
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
@@ -161,10 +162,10 @@ func (k Keeper) GetMinBidIncrement(ctx sdk.Context) (sdk.Coin, error) {
|
||||
}
|
||||
|
||||
// GetProposerFee returns the proposer fee for the builder module.
|
||||
func (k Keeper) GetProposerFee(ctx sdk.Context) (sdk.Dec, error) {
|
||||
func (k Keeper) GetProposerFee(ctx sdk.Context) (math.LegacyDec, error) {
|
||||
params, err := k.GetParams(ctx)
|
||||
if err != nil {
|
||||
return sdk.ZeroDec(), err
|
||||
return math.LegacyZeroDec(), err
|
||||
}
|
||||
|
||||
return params.ProposerFee, nil
|
||||
|
||||
@@ -3,7 +3,7 @@ package keeper_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/golang/mock/gomock"
|
||||
|
||||
@@ -51,7 +51,12 @@ func (m MsgServer) AuctionBid(goCtx context.Context, msg *types.MsgAuctionBid) (
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
rewardsAddress := m.rewardsAddressProvider.GetRewardsAddress(ctx)
|
||||
rewardsAddress, err := m.rewardsAddressProvider.GetRewardsAddress(ctx)
|
||||
if err != nil {
|
||||
// In the case where the rewards address provider returns an error, the
|
||||
// escrow account will receive the entire bid.
|
||||
rewardsAddress = escrowAddress
|
||||
}
|
||||
|
||||
// determine the amount of the bid that goes to the (previous) proposer
|
||||
bid := sdk.NewDecCoinsFromCoins(msg.Bid)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
testutils "github.com/skip-mev/pob/testutils"
|
||||
@@ -32,7 +33,7 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() {
|
||||
{
|
||||
name: "invalid bidder address",
|
||||
msg: &types.MsgAuctionBid{
|
||||
Bidder: "foo",
|
||||
Bidder: "stake",
|
||||
},
|
||||
malleate: func() {},
|
||||
expectErr: true,
|
||||
@@ -54,12 +55,12 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() {
|
||||
name: "valid bundle with no proposer fee",
|
||||
msg: &types.MsgAuctionBid{
|
||||
Bidder: bidder.Address.String(),
|
||||
Bid: sdk.NewInt64Coin("foo", 1024),
|
||||
Bid: sdk.NewInt64Coin("stake", 1024),
|
||||
Transactions: [][]byte{{0xFF}, {0xFF}},
|
||||
},
|
||||
malleate: func() {
|
||||
params := types.DefaultParams()
|
||||
params.ProposerFee = sdk.ZeroDec()
|
||||
params.ProposerFee = math.LegacyZeroDec()
|
||||
params.EscrowAccountAddress = escrow.Address
|
||||
suite.builderKeeper.SetParams(suite.ctx, params)
|
||||
|
||||
@@ -68,7 +69,7 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() {
|
||||
suite.ctx,
|
||||
bidder.Address,
|
||||
escrow.Address,
|
||||
sdk.NewCoins(sdk.NewInt64Coin("foo", 1024)),
|
||||
sdk.NewCoins(sdk.NewInt64Coin("stake", 1024)),
|
||||
).
|
||||
Return(nil).
|
||||
AnyTimes()
|
||||
@@ -79,30 +80,30 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() {
|
||||
name: "valid bundle with proposer fee",
|
||||
msg: &types.MsgAuctionBid{
|
||||
Bidder: bidder.Address.String(),
|
||||
Bid: sdk.NewInt64Coin("foo", 3416),
|
||||
Bid: sdk.NewInt64Coin("stake", 3416),
|
||||
Transactions: [][]byte{{0xFF}, {0xFF}},
|
||||
},
|
||||
malleate: func() {
|
||||
params := types.DefaultParams()
|
||||
params.ProposerFee = sdk.MustNewDecFromStr("0.30")
|
||||
params.ProposerFee = math.LegacyMustNewDecFromStr("0.30")
|
||||
params.EscrowAccountAddress = escrow.Address
|
||||
suite.builderKeeper.SetParams(suite.ctx, params)
|
||||
|
||||
suite.distrKeeper.EXPECT().
|
||||
GetPreviousProposerConsAddr(suite.ctx).
|
||||
Return(proposerCons.ConsKey.PubKey().Address().Bytes())
|
||||
Return(proposerCons.ConsKey.PubKey().Address().Bytes(), nil)
|
||||
|
||||
suite.stakingKeeper.EXPECT().
|
||||
ValidatorByConsAddr(suite.ctx, sdk.ConsAddress(proposerCons.ConsKey.PubKey().Address().Bytes())).
|
||||
Return(proposer).
|
||||
GetValidatorByConsAddr(suite.ctx, sdk.ConsAddress(proposerCons.ConsKey.PubKey().Address().Bytes())).
|
||||
Return(proposer, nil).
|
||||
AnyTimes()
|
||||
|
||||
suite.bankKeeper.EXPECT().
|
||||
SendCoins(suite.ctx, bidder.Address, proposerOperator.Address, sdk.NewCoins(sdk.NewInt64Coin("foo", 1024))).
|
||||
SendCoins(suite.ctx, bidder.Address, proposerOperator.Address, sdk.NewCoins(sdk.NewInt64Coin("stake", 1024))).
|
||||
Return(nil)
|
||||
|
||||
suite.bankKeeper.EXPECT().
|
||||
SendCoins(suite.ctx, bidder.Address, escrow.Address, sdk.NewCoins(sdk.NewInt64Coin("foo", 2392))).
|
||||
SendCoins(suite.ctx, bidder.Address, escrow.Address, sdk.NewCoins(sdk.NewInt64Coin("stake", 2392))).
|
||||
Return(nil)
|
||||
},
|
||||
expectErr: false,
|
||||
@@ -139,7 +140,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
msg: &types.MsgUpdateParams{
|
||||
Authority: suite.authorityAccount.String(),
|
||||
Params: types.Params{
|
||||
ProposerFee: sdk.MustNewDecFromStr("1.1"),
|
||||
ProposerFee: math.LegacyMustNewDecFromStr("1.1"),
|
||||
},
|
||||
},
|
||||
passBasic: false,
|
||||
@@ -150,7 +151,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
msg: &types.MsgUpdateParams{
|
||||
Authority: suite.authorityAccount.String(),
|
||||
Params: types.Params{
|
||||
ProposerFee: sdk.MustNewDecFromStr("0.1"),
|
||||
ProposerFee: math.LegacyMustNewDecFromStr("0.1"),
|
||||
},
|
||||
},
|
||||
passBasic: false,
|
||||
@@ -161,11 +162,11 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
msg: &types.MsgUpdateParams{
|
||||
Authority: account.Address.String(),
|
||||
Params: types.Params{
|
||||
ProposerFee: sdk.MustNewDecFromStr("0.1"),
|
||||
ProposerFee: math.LegacyMustNewDecFromStr("0.1"),
|
||||
MaxBundleSize: 2,
|
||||
EscrowAccountAddress: suite.authorityAccount,
|
||||
MinBidIncrement: sdk.NewInt64Coin("foo", 100),
|
||||
ReserveFee: sdk.NewInt64Coin("foo", 100),
|
||||
MinBidIncrement: sdk.NewInt64Coin("stake", 100),
|
||||
ReserveFee: sdk.NewInt64Coin("stake", 100),
|
||||
},
|
||||
},
|
||||
passBasic: true,
|
||||
|
||||
+1
-1
@@ -7,11 +7,11 @@ import (
|
||||
|
||||
"cosmossdk.io/core/appmodule"
|
||||
"cosmossdk.io/depinject"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package rewards
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
)
|
||||
|
||||
var _ types.RewardsAddressProvider = (*FixedAddressRewardsAddressProvider)(nil)
|
||||
|
||||
// FixedAddressRewardsAddressProvider provides a portion of
|
||||
// auction profits to a fixed address (i.e. the proposer portion).
|
||||
// This is useful for chains that do not have a distribution module.
|
||||
@@ -15,12 +19,16 @@ type FixedAddressRewardsAddressProvider struct {
|
||||
// NewFixedAddressRewardsAddressProvider creates a reward provider for a fixed address.
|
||||
func NewFixedAddressRewardsAddressProvider(
|
||||
rewardsAddress sdk.AccAddress,
|
||||
) types.RewardsAddressProvider {
|
||||
) *FixedAddressRewardsAddressProvider {
|
||||
return &FixedAddressRewardsAddressProvider{
|
||||
rewardsAddress: rewardsAddress,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *FixedAddressRewardsAddressProvider) GetRewardsAddress(_ sdk.Context) sdk.AccAddress {
|
||||
return p.rewardsAddress
|
||||
func (p *FixedAddressRewardsAddressProvider) GetRewardsAddress(_ sdk.Context) (sdk.AccAddress, error) {
|
||||
if p.rewardsAddress.Empty() {
|
||||
return nil, fmt.Errorf("rewards address is empty")
|
||||
}
|
||||
|
||||
return p.rewardsAddress, nil
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
)
|
||||
|
||||
var _ types.RewardsAddressProvider = (*ProposerRewardsAddressProvider)(nil)
|
||||
|
||||
// ProposerRewardsAddressProvider provides a portion of
|
||||
// auction profits to the block proposer.
|
||||
type ProposerRewardsAddressProvider struct {
|
||||
@@ -17,16 +19,23 @@ type ProposerRewardsAddressProvider struct {
|
||||
func NewProposerRewardsAddressProvider(
|
||||
distrKeeper types.DistributionKeeper,
|
||||
stakingKeeper types.StakingKeeper,
|
||||
) types.RewardsAddressProvider {
|
||||
) *ProposerRewardsAddressProvider {
|
||||
return &ProposerRewardsAddressProvider{
|
||||
distrKeeper: distrKeeper,
|
||||
stakingKeeper: stakingKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ProposerRewardsAddressProvider) GetRewardsAddress(ctx sdk.Context) sdk.AccAddress {
|
||||
prevPropConsAddr := p.distrKeeper.GetPreviousProposerConsAddr(ctx)
|
||||
prevProposer := p.stakingKeeper.ValidatorByConsAddr(ctx, prevPropConsAddr)
|
||||
func (p *ProposerRewardsAddressProvider) GetRewardsAddress(ctx sdk.Context) (sdk.AccAddress, error) {
|
||||
prevPropConsAddr, err := p.distrKeeper.GetPreviousProposerConsAddr(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sdk.AccAddress(prevProposer.GetOperator())
|
||||
prevProposer, err := p.stakingKeeper.GetValidatorByConsAddr(ctx, prevPropConsAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sdk.AccAddress(prevProposer.GetOperator()), nil
|
||||
}
|
||||
|
||||
@@ -7,27 +7,17 @@ import (
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
|
||||
govcodec "github.com/cosmos/cosmos-sdk/x/gov/codec"
|
||||
groupcodec "github.com/cosmos/cosmos-sdk/x/group/codec"
|
||||
)
|
||||
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
ModuleCdc = codec.NewLegacyAmino()
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(amino)
|
||||
cryptocodec.RegisterCrypto(amino)
|
||||
sdk.RegisterLegacyAminoCodec(amino)
|
||||
|
||||
// Register all Amino interfaces and concrete types on the authz and gov
|
||||
// Amino codec so that this can later be used to properly serialize MsgGrant,
|
||||
// MsgExec and MsgSubmitProposal instances.
|
||||
RegisterLegacyAminoCodec(authzcodec.Amino)
|
||||
RegisterLegacyAminoCodec(govcodec.Amino)
|
||||
RegisterLegacyAminoCodec(groupcodec.Amino)
|
||||
}
|
||||
|
||||
// RegisterLegacyAminoCodec registers the necessary x/builder interfaces and
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
@@ -12,22 +14,22 @@ type AccountKeeper interface {
|
||||
|
||||
// BankKeeper defines the expected API contract for the x/bank module.
|
||||
type BankKeeper interface {
|
||||
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
|
||||
SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin
|
||||
}
|
||||
|
||||
// DistributionKeeper defines the expected API contract for the x/distribution
|
||||
// module.
|
||||
type DistributionKeeper interface {
|
||||
GetPreviousProposerConsAddr(ctx sdk.Context) sdk.ConsAddress
|
||||
GetPreviousProposerConsAddr(ctx context.Context) (sdk.ConsAddress, error)
|
||||
}
|
||||
|
||||
// StakingKeeper defines the expected API contract for the x/staking module.
|
||||
type StakingKeeper interface {
|
||||
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI
|
||||
GetValidatorByConsAddr(context.Context, sdk.ConsAddress) (stakingtypes.Validator, error)
|
||||
}
|
||||
|
||||
// RewardsAddressProvider is an interface that provides an address where auction profits are sent.
|
||||
// RewardsAddressProvider is an interface that provides an address where proposer/subset of auction profits are sent.
|
||||
type RewardsAddressProvider interface {
|
||||
GetRewardsAddress(context sdk.Context) sdk.AccAddress
|
||||
GetRewardsAddress(context sdk.Context) (sdk.AccAddress, error)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
cosmossdk_io_math "cosmossdk.io/math"
|
||||
fmt "fmt"
|
||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
types "github.com/cosmos/cosmos-sdk/types"
|
||||
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
||||
_ "github.com/cosmos/gogoproto/gogoproto"
|
||||
@@ -89,7 +90,7 @@ type Params struct {
|
||||
FrontRunningProtection bool `protobuf:"varint,5,opt,name=front_running_protection,json=frontRunningProtection,proto3" json:"front_running_protection,omitempty"`
|
||||
// proposer_fee defines the portion of the winning bid that goes to the block
|
||||
// proposer that proposed the block.
|
||||
ProposerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=proposer_fee,json=proposerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"proposer_fee"`
|
||||
ProposerFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=proposer_fee,json=proposerFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"proposer_fee"`
|
||||
}
|
||||
|
||||
func (m *Params) Reset() { *m = Params{} }
|
||||
@@ -168,37 +169,39 @@ func init() {
|
||||
func init() { proto.RegisterFile("pob/builder/v1/genesis.proto", fileDescriptor_287f1bdff5ccfc33) }
|
||||
|
||||
var fileDescriptor_287f1bdff5ccfc33 = []byte{
|
||||
// 474 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x6e, 0xd4, 0x3c,
|
||||
0x14, 0x85, 0x27, 0x7f, 0xfb, 0x8f, 0xa8, 0x67, 0x4a, 0xd5, 0xa8, 0x1a, 0x85, 0x82, 0xd2, 0xa8,
|
||||
0x8b, 0x32, 0xaa, 0x54, 0x5b, 0x03, 0x2c, 0x10, 0xbb, 0x09, 0xa5, 0x88, 0xdd, 0x90, 0xee, 0xd8,
|
||||
0x44, 0x4e, 0x72, 0x1b, 0xac, 0xd6, 0x76, 0x64, 0x3b, 0x61, 0xe8, 0x23, 0xb0, 0xe2, 0x31, 0x58,
|
||||
0xa1, 0x3e, 0x46, 0x97, 0x5d, 0x22, 0x16, 0x15, 0x9a, 0x59, 0xf4, 0x35, 0x50, 0xec, 0xb4, 0x94,
|
||||
0x25, 0x9b, 0x24, 0xf2, 0x77, 0x7d, 0xce, 0x3d, 0xb9, 0x17, 0x3d, 0xa9, 0x64, 0x46, 0xb2, 0x9a,
|
||||
0x9d, 0x15, 0xa0, 0x48, 0x33, 0x21, 0x25, 0x08, 0xd0, 0x4c, 0xe3, 0x4a, 0x49, 0x23, 0xfd, 0x87,
|
||||
0x95, 0xcc, 0x70, 0x47, 0x71, 0x33, 0xd9, 0xde, 0x2a, 0x65, 0x29, 0x2d, 0x22, 0xed, 0x97, 0xab,
|
||||
0xda, 0x0e, 0x73, 0xa9, 0xb9, 0xd4, 0x24, 0xa3, 0x1a, 0x48, 0x33, 0xc9, 0xc0, 0xd0, 0x09, 0xc9,
|
||||
0x25, 0x13, 0x1d, 0xdf, 0xa4, 0x9c, 0x09, 0x49, 0xec, 0xd3, 0x1d, 0xed, 0x1e, 0xa2, 0xe1, 0x5b,
|
||||
0xe7, 0x74, 0x6c, 0xa8, 0x01, 0xff, 0x05, 0xea, 0x57, 0x54, 0x51, 0xae, 0x03, 0x2f, 0xf2, 0xc6,
|
||||
0x83, 0x67, 0x23, 0xfc, 0xb7, 0x33, 0x9e, 0x59, 0x1a, 0xaf, 0x5e, 0x5e, 0xef, 0xf4, 0x92, 0xae,
|
||||
0x76, 0xf7, 0xfb, 0x0a, 0xea, 0x3b, 0xe0, 0xef, 0xa1, 0x0d, 0x4e, 0xe7, 0x69, 0x56, 0x8b, 0xe2,
|
||||
0x0c, 0x52, 0xcd, 0xce, 0xc1, 0x2a, 0xad, 0x27, 0xeb, 0x9c, 0xce, 0x63, 0x7b, 0x7a, 0xcc, 0xce,
|
||||
0x5b, 0xa3, 0x11, 0xe8, 0x5c, 0xc9, 0x4f, 0x29, 0xcd, 0x73, 0x59, 0x0b, 0x93, 0xd2, 0xa2, 0x50,
|
||||
0xa0, 0x75, 0xf0, 0x5f, 0xe4, 0x8d, 0x87, 0xc9, 0x96, 0xa3, 0x53, 0x07, 0xa7, 0x8e, 0xf9, 0x6f,
|
||||
0xd0, 0x40, 0x81, 0x06, 0xd5, 0x40, 0x7a, 0x02, 0x10, 0xac, 0xd8, 0x1e, 0x1f, 0x61, 0x97, 0x1b,
|
||||
0xb7, 0xb9, 0x71, 0x97, 0x1b, 0xbf, 0x96, 0x4c, 0xc4, 0x6b, 0x6d, 0x9b, 0xdf, 0x6e, 0x2e, 0xf6,
|
||||
0xbd, 0x04, 0x75, 0x17, 0x8f, 0x00, 0xfc, 0x19, 0xda, 0xe4, 0x4c, 0xa4, 0x19, 0x2b, 0x52, 0x26,
|
||||
0x72, 0x05, 0x1c, 0x84, 0x09, 0x56, 0xff, 0x41, 0x6c, 0x83, 0x33, 0x11, 0xb3, 0xe2, 0xdd, 0xed,
|
||||
0x65, 0xff, 0x25, 0x0a, 0x4e, 0x94, 0x14, 0x26, 0x55, 0xb5, 0x10, 0x4c, 0x94, 0x69, 0xfb, 0x7b,
|
||||
0x21, 0x37, 0x4c, 0x8a, 0xe0, 0xff, 0xc8, 0x1b, 0x3f, 0x48, 0x46, 0x96, 0x27, 0x0e, 0xcf, 0xee,
|
||||
0xa8, 0xff, 0x1e, 0x0d, 0x2b, 0x25, 0x2b, 0xa9, 0x41, 0xd9, 0x4c, 0xfd, 0xc8, 0x1b, 0xaf, 0xc5,
|
||||
0xb8, 0xf5, 0xfa, 0x79, 0xbd, 0xb3, 0x57, 0x32, 0xf3, 0xb1, 0xce, 0x70, 0x2e, 0x39, 0xe9, 0xa6,
|
||||
0xeb, 0x5e, 0x07, 0xba, 0x38, 0x25, 0xe6, 0x73, 0x05, 0x1a, 0x1f, 0x42, 0x9e, 0x0c, 0x6e, 0x35,
|
||||
0x8e, 0x00, 0x5e, 0x45, 0x5f, 0x6e, 0x2e, 0xf6, 0x1f, 0xdf, 0xab, 0x9b, 0xdf, 0x6d, 0x56, 0x37,
|
||||
0xbe, 0xe9, 0xe5, 0x22, 0xf4, 0xae, 0x16, 0xa1, 0xf7, 0x6b, 0x11, 0x7a, 0x5f, 0x97, 0x61, 0xef,
|
||||
0x6a, 0x19, 0xf6, 0x7e, 0x2c, 0xc3, 0xde, 0x87, 0xa7, 0xf7, 0x0c, 0xf5, 0x29, 0xab, 0x0e, 0x38,
|
||||
0x34, 0xa4, 0xdd, 0xcd, 0x3f, 0x1a, 0xd6, 0x35, 0xeb, 0xdb, 0x05, 0x7a, 0xfe, 0x3b, 0x00, 0x00,
|
||||
0xff, 0xff, 0x3d, 0xb6, 0x59, 0xc6, 0xb9, 0x02, 0x00, 0x00,
|
||||
// 499 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x6e, 0xd3, 0x40,
|
||||
0x10, 0x86, 0x63, 0x5a, 0x22, 0xba, 0x49, 0xa9, 0x6a, 0x55, 0x91, 0x5b, 0x90, 0x1b, 0xf5, 0x00,
|
||||
0x51, 0xa5, 0xec, 0x2a, 0x80, 0x10, 0xe2, 0x96, 0x10, 0x8a, 0x90, 0x38, 0x44, 0xee, 0x09, 0x2e,
|
||||
0xd6, 0x7a, 0x3d, 0x75, 0x57, 0xe9, 0xee, 0x5a, 0xbb, 0x1b, 0x93, 0xf6, 0x11, 0x38, 0xf1, 0x18,
|
||||
0x1c, 0x7b, 0x40, 0x3c, 0x43, 0x8f, 0x15, 0x27, 0xc4, 0xa1, 0x42, 0xc9, 0xa1, 0xaf, 0x81, 0xec,
|
||||
0x75, 0x8b, 0x38, 0xf6, 0x62, 0xd9, 0xf3, 0xcd, 0xfc, 0xf3, 0xcf, 0x78, 0xd0, 0xe3, 0x5c, 0x25,
|
||||
0x24, 0x99, 0xf1, 0x93, 0x14, 0x34, 0x29, 0x06, 0x24, 0x03, 0x09, 0x86, 0x1b, 0x9c, 0x6b, 0x65,
|
||||
0x95, 0xff, 0x30, 0x57, 0x09, 0xae, 0x29, 0x2e, 0x06, 0x3b, 0x5b, 0x99, 0xca, 0x54, 0x85, 0x48,
|
||||
0xf9, 0xe6, 0xb2, 0x76, 0x42, 0xa6, 0x8c, 0x50, 0x86, 0x24, 0xd4, 0x00, 0x29, 0x06, 0x09, 0x58,
|
||||
0x3a, 0x20, 0x4c, 0x71, 0x59, 0xf3, 0x4d, 0x2a, 0xb8, 0x54, 0xa4, 0x7a, 0xd6, 0xa1, 0x6d, 0x57,
|
||||
0x12, 0x3b, 0x2d, 0xf7, 0xe1, 0xd0, 0xde, 0x18, 0xb5, 0xdf, 0x39, 0x13, 0x87, 0x96, 0x5a, 0xf0,
|
||||
0x5f, 0xa0, 0x66, 0x4e, 0x35, 0x15, 0x26, 0xf0, 0xba, 0x5e, 0xaf, 0xf5, 0xac, 0x83, 0xff, 0x37,
|
||||
0x85, 0x27, 0x15, 0x1d, 0xad, 0x5e, 0x5c, 0xed, 0x36, 0xa2, 0x3a, 0x77, 0xef, 0xc7, 0x0a, 0x6a,
|
||||
0x3a, 0xe0, 0x3f, 0x41, 0x1b, 0x82, 0xce, 0xe3, 0x64, 0x26, 0xd3, 0x13, 0x88, 0x0d, 0x3f, 0x83,
|
||||
0x4a, 0x69, 0x3d, 0x5a, 0x17, 0x74, 0x3e, 0xaa, 0xa2, 0x87, 0xfc, 0xac, 0x6c, 0xd4, 0x01, 0xc3,
|
||||
0xb4, 0xfa, 0x1c, 0x53, 0xc6, 0xd4, 0x4c, 0xda, 0x98, 0xa6, 0xa9, 0x06, 0x63, 0x82, 0x7b, 0x5d,
|
||||
0xaf, 0xd7, 0x8e, 0xb6, 0x1c, 0x1d, 0x3a, 0x38, 0x74, 0xcc, 0x7f, 0x8b, 0x5a, 0x1a, 0x0c, 0xe8,
|
||||
0x02, 0xe2, 0x23, 0x80, 0x60, 0xa5, 0xf2, 0xb8, 0x8d, 0xeb, 0x91, 0xca, 0x95, 0xe0, 0x7a, 0x25,
|
||||
0xf8, 0x8d, 0xe2, 0x72, 0xb4, 0x56, 0xda, 0xfc, 0x76, 0x7d, 0xbe, 0xef, 0x45, 0xa8, 0x2e, 0x3c,
|
||||
0x00, 0xf0, 0x27, 0x68, 0x53, 0x70, 0x19, 0x27, 0x3c, 0x8d, 0xb9, 0x64, 0x1a, 0x04, 0x48, 0x1b,
|
||||
0xac, 0xde, 0x41, 0x6c, 0x43, 0x70, 0x39, 0xe2, 0xe9, 0xfb, 0x9b, 0x62, 0xff, 0x15, 0x0a, 0x8e,
|
||||
0xb4, 0x92, 0x36, 0xd6, 0x33, 0x29, 0xb9, 0xcc, 0xaa, 0x5d, 0x03, 0xb3, 0x5c, 0xc9, 0xe0, 0x7e,
|
||||
0xd7, 0xeb, 0x3d, 0x88, 0x3a, 0x15, 0x8f, 0x1c, 0x9e, 0xdc, 0x52, 0xff, 0x23, 0x6a, 0xe7, 0x5a,
|
||||
0xe5, 0xca, 0x80, 0xae, 0x66, 0x6a, 0x76, 0xbd, 0xde, 0xda, 0xe8, 0x65, 0xd9, 0xeb, 0xf7, 0xd5,
|
||||
0xee, 0x23, 0xe7, 0xc6, 0xa4, 0x53, 0xcc, 0x15, 0x11, 0xd4, 0x1e, 0xe3, 0x0f, 0x90, 0x51, 0x76,
|
||||
0x3a, 0x06, 0xf6, 0xf3, 0x7b, 0x1f, 0xd5, 0x66, 0xc7, 0xc0, 0x9c, 0xb1, 0xd6, 0x8d, 0xd6, 0x01,
|
||||
0xc0, 0xeb, 0xee, 0x97, 0xeb, 0xf3, 0xfd, 0x5a, 0xa1, 0x6f, 0xd2, 0x29, 0x99, 0xdf, 0x1e, 0x5f,
|
||||
0xfd, 0x1b, 0x87, 0x17, 0x8b, 0xd0, 0xbb, 0x5c, 0x84, 0xde, 0x9f, 0x45, 0xe8, 0x7d, 0x5d, 0x86,
|
||||
0x8d, 0xcb, 0x65, 0xd8, 0xf8, 0xb5, 0x0c, 0x1b, 0x9f, 0x9e, 0x66, 0xdc, 0x1e, 0xcf, 0x12, 0xcc,
|
||||
0x94, 0x20, 0x66, 0xca, 0xf3, 0xbe, 0x80, 0x82, 0x94, 0xe7, 0xfb, 0x4f, 0xc3, 0x9e, 0xe6, 0x60,
|
||||
0x92, 0x66, 0x75, 0x48, 0xcf, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x0b, 0xb6, 0x7e, 0x29, 0xdc,
|
||||
0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package types_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/skip-mev/pob/x/builder/types"
|
||||
)
|
||||
@@ -36,7 +37,7 @@ func TestMsgAuctionBid(t *testing.T) {
|
||||
description: "invalid message with empty transactions",
|
||||
msg: types.MsgAuctionBid{
|
||||
Bidder: sdk.AccAddress([]byte("test")).String(),
|
||||
Bid: sdk.NewCoin("test", sdk.NewInt(100)),
|
||||
Bid: sdk.NewCoin("test", math.NewInt(100)),
|
||||
Transactions: [][]byte{},
|
||||
},
|
||||
expectPass: false,
|
||||
@@ -45,7 +46,7 @@ func TestMsgAuctionBid(t *testing.T) {
|
||||
description: "valid message",
|
||||
msg: types.MsgAuctionBid{
|
||||
Bidder: sdk.AccAddress([]byte("test")).String(),
|
||||
Bid: sdk.NewCoin("test", sdk.NewInt(100)),
|
||||
Bid: sdk.NewCoin("test", math.NewInt(100)),
|
||||
Transactions: [][]byte{[]byte("test")},
|
||||
},
|
||||
expectPass: true,
|
||||
@@ -54,7 +55,7 @@ func TestMsgAuctionBid(t *testing.T) {
|
||||
description: "valid message with multiple transactions",
|
||||
msg: types.MsgAuctionBid{
|
||||
Bidder: sdk.AccAddress([]byte("test")).String(),
|
||||
Bid: sdk.NewCoin("test", sdk.NewInt(100)),
|
||||
Bid: sdk.NewCoin("test", math.NewInt(100)),
|
||||
Transactions: [][]byte{[]byte("test"), []byte("test2")},
|
||||
},
|
||||
expectPass: true,
|
||||
@@ -63,7 +64,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.NewCoin("test", sdk.NewInt(100)),
|
||||
Bid: sdk.NewCoin("test", math.NewInt(100)),
|
||||
Transactions: [][]byte{[]byte("test"), []byte("")},
|
||||
},
|
||||
expectPass: false,
|
||||
@@ -101,15 +102,28 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
},
|
||||
expectPass: false,
|
||||
},
|
||||
{
|
||||
description: "invalid message with invalid params (invalid escrow address)",
|
||||
msg: types.MsgUpdateParams{
|
||||
Authority: sdk.AccAddress([]byte("test")).String(),
|
||||
Params: types.Params{
|
||||
EscrowAccountAddress: nil,
|
||||
ReserveFee: sdk.NewCoin("test", math.NewInt(100)),
|
||||
MinBidIncrement: sdk.NewCoin("test", math.NewInt(100)),
|
||||
ProposerFee: math.LegacyNewDecFromInt(math.NewInt(1)),
|
||||
},
|
||||
},
|
||||
expectPass: false,
|
||||
},
|
||||
{
|
||||
description: "valid message",
|
||||
msg: types.MsgUpdateParams{
|
||||
Authority: sdk.AccAddress([]byte("test")).String(),
|
||||
Params: types.Params{
|
||||
ProposerFee: sdk.NewDec(1),
|
||||
ProposerFee: math.LegacyNewDecFromInt(math.NewInt(1)),
|
||||
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
|
||||
ReserveFee: sdk.NewCoin("test", sdk.NewInt(100)),
|
||||
MinBidIncrement: sdk.NewCoin("test", sdk.NewInt(100)),
|
||||
ReserveFee: sdk.NewCoin("test", math.NewInt(100)),
|
||||
MinBidIncrement: sdk.NewCoin("test", math.NewInt(100)),
|
||||
},
|
||||
},
|
||||
expectPass: true,
|
||||
@@ -119,10 +133,10 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
msg: types.MsgUpdateParams{
|
||||
Authority: sdk.AccAddress([]byte("test")).String(),
|
||||
Params: types.Params{
|
||||
ProposerFee: sdk.NewDec(1),
|
||||
ProposerFee: math.LegacyNewDecFromInt(math.NewInt(1)),
|
||||
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
|
||||
ReserveFee: sdk.NewCoin("test", sdk.NewInt(100)),
|
||||
MinBidIncrement: sdk.NewCoin("test2", sdk.NewInt(100)),
|
||||
ReserveFee: sdk.NewCoin("test", math.NewInt(100)),
|
||||
MinBidIncrement: sdk.NewCoin("test2", math.NewInt(100)),
|
||||
},
|
||||
},
|
||||
expectPass: false,
|
||||
@@ -132,7 +146,7 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
msg: types.MsgUpdateParams{
|
||||
Authority: sdk.AccAddress([]byte("test")).String(),
|
||||
Params: types.Params{
|
||||
ProposerFee: sdk.NewDec(1),
|
||||
ProposerFee: math.LegacyNewDecFromInt(math.NewInt(1)),
|
||||
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
|
||||
},
|
||||
},
|
||||
@@ -143,10 +157,10 @@ func TestMsgUpdateParams(t *testing.T) {
|
||||
msg: types.MsgUpdateParams{
|
||||
Authority: sdk.AccAddress([]byte("test")).String(),
|
||||
Params: types.Params{
|
||||
ProposerFee: sdk.NewDec(1),
|
||||
ProposerFee: math.LegacyNewDecFromInt(math.NewInt(1)),
|
||||
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
|
||||
ReserveFee: sdk.NewCoin("test", sdk.NewInt(100)),
|
||||
MinBidIncrement: sdk.NewCoin("test", sdk.NewInt(0)),
|
||||
ReserveFee: sdk.NewCoin("test", math.NewInt(100)),
|
||||
MinBidIncrement: sdk.NewCoin("test", math.NewInt(0)),
|
||||
},
|
||||
},
|
||||
expectPass: false,
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
var (
|
||||
DefaultMaxBundleSize uint32 = 2
|
||||
DefaultEscrowAccountAddress = authtypes.NewModuleAddress(ModuleName)
|
||||
DefaultReserveFee = sdk.NewCoin("stake", sdk.NewInt(1))
|
||||
DefaultMinBidIncrement = sdk.NewCoin("stake", sdk.NewInt(1))
|
||||
DefaultReserveFee = sdk.NewCoin("stake", math.NewInt(1))
|
||||
DefaultMinBidIncrement = sdk.NewCoin("stake", math.NewInt(1))
|
||||
DefaultFrontRunningProtection = true
|
||||
DefaultProposerFee = sdk.ZeroDec()
|
||||
DefaultProposerFee = math.LegacyNewDec(0)
|
||||
)
|
||||
|
||||
// NewParams returns a new Params instance with the provided values.
|
||||
@@ -23,7 +23,7 @@ func NewParams(
|
||||
escrowAccountAddress []byte,
|
||||
reserveFee, minBidIncrement sdk.Coin,
|
||||
frontRunningProtection bool,
|
||||
proposerFee sdk.Dec,
|
||||
proposerFee math.LegacyDec,
|
||||
) Params {
|
||||
return Params{
|
||||
MaxBundleSize: maxBundleSize,
|
||||
@@ -49,15 +49,20 @@ func DefaultParams() Params {
|
||||
|
||||
// Validate performs basic validation on the parameters.
|
||||
func (p Params) Validate() error {
|
||||
if p.EscrowAccountAddress == nil {
|
||||
return fmt.Errorf("escrow account address cannot be nil")
|
||||
}
|
||||
|
||||
if err := validateFee(p.ReserveFee); err != nil {
|
||||
return fmt.Errorf("invalid reserve fee (%s)", err)
|
||||
}
|
||||
|
||||
if err := validateFee(p.MinBidIncrement); err != nil {
|
||||
return fmt.Errorf("invalid minimum bid increment (%s)", err)
|
||||
}
|
||||
|
||||
// Minimum bid increment must always be greater than 0.
|
||||
if p.MinBidIncrement.IsLTE(sdk.NewCoin(p.MinBidIncrement.Denom, sdk.ZeroInt())) {
|
||||
if p.MinBidIncrement.IsLTE(sdk.NewCoin(p.MinBidIncrement.Denom, math.ZeroInt())) {
|
||||
return fmt.Errorf("minimum bid increment cannot be zero")
|
||||
}
|
||||
|
||||
@@ -81,7 +86,7 @@ func validateFee(fee sdk.Coin) error {
|
||||
return fee.Validate()
|
||||
}
|
||||
|
||||
func validateProposerFee(v sdk.Dec) error {
|
||||
func validateProposerFee(v math.LegacyDec) error {
|
||||
if v.IsNil() {
|
||||
return fmt.Errorf("proposer fee cannot be nil: %s", v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user