feat: Provide Configuration Options for POB (#206) (#211)

Co-authored-by: Keefer Taylor | Tessellated <keefer@tessellated.io>
This commit is contained in:
Nikhil Vasan
2023-07-17 14:32:20 +00:00
committed by GitHub
co-authored by Keefer Taylor | Tessellated
parent 43789945e9
commit 8b5ebc310a
17 changed files with 322 additions and 308 deletions
+1 -1
View File
@@ -173,7 +173,7 @@ func (suite *KeeperTestSuite) TestValidateBidInfo() {
params := types.Params{
MaxBundleSize: maxBundleSize,
ReserveFee: reserveFee,
EscrowAccountAddress: escrowAddress.String(),
EscrowAccountAddress: escrowAddress,
FrontRunningProtection: frontRunningProtection,
MinBidIncrement: minBidIncrement,
}
+34 -15
View File
@@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
rewardsaddressprovider "github.com/skip-mev/pob/x/builder/rewards_address_provider"
"github.com/skip-mev/pob/x/builder/types"
)
@@ -15,15 +16,15 @@ type Keeper struct {
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
bankKeeper types.BankKeeper
distrKeeper types.DistributionKeeper
stakingKeeper types.StakingKeeper
bankKeeper types.BankKeeper
rewardsAddressProvider types.RewardsAddressProvider
// The address that is capable of executing a MsgUpdateParams message.
// Typically this will be the governance module's address.
authority string
}
// NewKeeper is a wrapper around NewKeeperWithRewardsAddressProvider for backwards compatibility.
func NewKeeper(
cdc codec.BinaryCodec,
storeKey storetypes.StoreKey,
@@ -32,6 +33,30 @@ func NewKeeper(
distrKeeper types.DistributionKeeper,
stakingKeeper types.StakingKeeper,
authority string,
) Keeper {
// Build a rewards address provider
rewardsAddressProvider := rewardsaddressprovider.NewProposerRewardsAddressProvider(
distrKeeper,
stakingKeeper,
)
return NewKeeperWithRewardsAddressProvider(
cdc,
storeKey,
accountKeeper,
bankKeeper,
rewardsAddressProvider,
authority,
)
}
func NewKeeperWithRewardsAddressProvider(
cdc codec.BinaryCodec,
storeKey storetypes.StoreKey,
accountKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
rewardsAddressProvider types.RewardsAddressProvider,
authority string,
) Keeper {
// Ensure that the authority address is valid.
if _, err := sdk.AccAddressFromBech32(authority); err != nil {
@@ -44,12 +69,11 @@ func NewKeeper(
}
return Keeper{
cdc: cdc,
storeKey: storeKey,
bankKeeper: bankKeeper,
distrKeeper: distrKeeper,
stakingKeeper: stakingKeeper,
authority: authority,
cdc: cdc,
storeKey: storeKey,
bankKeeper: bankKeeper,
rewardsAddressProvider: rewardsAddressProvider,
authority: authority,
}
}
@@ -113,12 +137,7 @@ func (k Keeper) GetEscrowAccount(ctx sdk.Context) (sdk.AccAddress, error) {
return nil, err
}
account, err := sdk.AccAddressFromBech32(params.EscrowAccountAddress)
if err != nil {
return nil, err
}
return account, nil
return params.EscrowAccountAddress, nil
}
// GetReserveFee returns the reserve fee of the builder module.
+3 -7
View File
@@ -42,10 +42,7 @@ func (m MsgServer) AuctionBid(goCtx context.Context, msg *types.MsgAuctionBid) (
return nil, fmt.Errorf("the number of transactions in the bid is greater than the maximum allowed; expected <= %d, got %d", params.MaxBundleSize, len(msg.Transactions))
}
escrowAddress, err := sdk.AccAddressFromBech32(params.EscrowAccountAddress)
if err != nil {
return nil, err
}
escrowAddress := params.EscrowAccountAddress
var proposerReward sdk.Coins
if params.ProposerFee.IsZero() {
@@ -54,14 +51,13 @@ func (m MsgServer) AuctionBid(goCtx context.Context, msg *types.MsgAuctionBid) (
return nil, err
}
} else {
prevPropConsAddr := m.distrKeeper.GetPreviousProposerConsAddr(ctx)
prevProposer := m.stakingKeeper.ValidatorByConsAddr(ctx, prevPropConsAddr)
rewardsAddress := m.rewardsAddressProvider.GetRewardsAddress(ctx)
// determine the amount of the bid that goes to the (previous) proposer
bid := sdk.NewDecCoinsFromCoins(msg.Bid)
proposerReward, _ = bid.MulDecTruncate(params.ProposerFee).TruncateDecimal()
if err := m.bankKeeper.SendCoins(ctx, bidder, sdk.AccAddress(prevProposer.GetOperator()), proposerReward); err != nil {
if err := m.bankKeeper.SendCoins(ctx, bidder, rewardsAddress, proposerReward); err != nil {
return nil, err
}
+3 -3
View File
@@ -60,7 +60,7 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() {
malleate: func() {
params := types.DefaultParams()
params.ProposerFee = sdk.ZeroDec()
params.EscrowAccountAddress = escrow.Address.String()
params.EscrowAccountAddress = escrow.Address
suite.builderKeeper.SetParams(suite.ctx, params)
suite.bankKeeper.EXPECT().
@@ -85,7 +85,7 @@ func (suite *KeeperTestSuite) TestMsgAuctionBid() {
malleate: func() {
params := types.DefaultParams()
params.ProposerFee = sdk.MustNewDecFromStr("0.30")
params.EscrowAccountAddress = escrow.Address.String()
params.EscrowAccountAddress = escrow.Address
suite.builderKeeper.SetParams(suite.ctx, params)
suite.distrKeeper.EXPECT().
@@ -163,7 +163,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
Params: types.Params{
ProposerFee: sdk.MustNewDecFromStr("0.1"),
MaxBundleSize: 2,
EscrowAccountAddress: suite.authorityAccount.String(),
EscrowAccountAddress: suite.authorityAccount,
MinBidIncrement: sdk.NewInt64Coin("foo", 100),
ReserveFee: sdk.NewInt64Coin("foo", 100),
},
@@ -0,0 +1,47 @@
package rewardsaddressprovider
import (
"cosmossdk.io/depinject"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/skip-mev/pob/x/builder/types"
)
// FixedAddressRewardsAddressProvider provides auction profits to a fixed address
type FixedAddressRewardsAddressProvider struct {
rewardsAddress sdk.AccAddress
}
// NewFixedAddressRewardsAddressProvider creates a reward provider for a fixed address.
func NewFixedAddressRewardsAddressProvider(
rewardsAddress sdk.AccAddress,
) types.RewardsAddressProvider {
return &FixedAddressRewardsAddressProvider{
rewardsAddress: rewardsAddress,
}
}
func (p *FixedAddressRewardsAddressProvider) GetRewardsAddress(_ sdk.Context) sdk.AccAddress {
return p.rewardsAddress
}
// Dependency injection
type FixedAddressDepInjectInput struct {
depinject.In
AccountKeeper types.AccountKeeper
}
type FixedAddressDepInjectOutput struct {
depinject.Out
RewardsAddressProvider types.RewardsAddressProvider
}
func ProvideModuleAddress(in FixedAddressDepInjectInput) FixedAddressDepInjectOutput {
rewardAddressProvider := NewFixedAddressRewardsAddressProvider(
in.AccountKeeper.GetModuleAddress(types.ModuleName),
)
return FixedAddressDepInjectOutput{RewardsAddressProvider: rewardAddressProvider}
}
@@ -0,0 +1,56 @@
package rewardsaddressprovider
import (
"cosmossdk.io/depinject"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/skip-mev/pob/x/builder/types"
)
// ProposerRewardsAddressProvider provides auction profits to the block proposer.
type ProposerRewardsAddressProvider struct {
distrKeeper types.DistributionKeeper
stakingKeeper types.StakingKeeper
}
// NewFixedAddressRewardsAddressProvider creates a reward provider for a fixed address.
func NewProposerRewardsAddressProvider(
distrKeeper types.DistributionKeeper,
stakingKeeper types.StakingKeeper,
) types.RewardsAddressProvider {
return &ProposerRewardsAddressProvider{
distrKeeper: distrKeeper,
stakingKeeper: stakingKeeper,
}
}
func (p *ProposerRewardsAddressProvider) GetRewardsAddress(context sdk.Context) sdk.AccAddress {
prevPropConsAddr := p.distrKeeper.GetPreviousProposerConsAddr(context)
prevProposer := p.stakingKeeper.ValidatorByConsAddr(context, prevPropConsAddr)
return sdk.AccAddress(prevProposer.GetOperator())
}
// Dependency injection
type ProposerRewardsDepInjectInput struct {
depinject.In
types.DistributionKeeper
types.StakingKeeper
}
type ProposerRewardsDepInjectOutput struct {
depinject.Out
RewardsAddressProvider types.RewardsAddressProvider
}
func ProvideProposerRewards(in ProposerRewardsDepInjectInput) ProposerRewardsDepInjectOutput {
rewardAddressProvider := NewProposerRewardsAddressProvider(
in.DistributionKeeper,
in.StakingKeeper,
)
return ProposerRewardsDepInjectOutput{RewardsAddressProvider: rewardAddressProvider}
}
+5
View File
@@ -26,3 +26,8 @@ type DistributionKeeper interface {
type StakingKeeper interface {
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI
}
// RewardsAddressProvider is an interface that provides an address where auction profits are sent.
type RewardsAddressProvider interface {
GetRewardsAddress(context sdk.Context) sdk.AccAddress
}
+42 -40
View File
@@ -78,7 +78,7 @@ type Params struct {
MaxBundleSize uint32 `protobuf:"varint,1,opt,name=max_bundle_size,json=maxBundleSize,proto3" json:"max_bundle_size,omitempty"`
// escrow_account_address is the address of the account that will receive a
// portion of the bid proceeds.
EscrowAccountAddress string `protobuf:"bytes,2,opt,name=escrow_account_address,json=escrowAccountAddress,proto3" json:"escrow_account_address,omitempty"`
EscrowAccountAddress []byte `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 types.Coin `protobuf:"bytes,3,opt,name=reserve_fee,json=reserveFee,proto3" json:"reserve_fee"`
// min_bid_increment specifies the minimum amount that the next bid must be
@@ -132,11 +132,11 @@ func (m *Params) GetMaxBundleSize() uint32 {
return 0
}
func (m *Params) GetEscrowAccountAddress() string {
func (m *Params) GetEscrowAccountAddress() []byte {
if m != nil {
return m.EscrowAccountAddress
}
return ""
return nil
}
func (m *Params) GetReserveFee() types.Coin {
@@ -168,37 +168,37 @@ func init() {
func init() { proto.RegisterFile("pob/builder/v1/genesis.proto", fileDescriptor_287f1bdff5ccfc33) }
var fileDescriptor_287f1bdff5ccfc33 = []byte{
// 472 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x41, 0x4f, 0xd4, 0x40,
0x14, 0xc7, 0xb7, 0x82, 0x1b, 0x99, 0x05, 0x09, 0x0d, 0xd9, 0x54, 0x34, 0x65, 0xc3, 0x01, 0x37,
0x24, 0xcc, 0x64, 0xd5, 0x83, 0xf1, 0xb6, 0x2b, 0x62, 0xbc, 0xad, 0xe5, 0xe6, 0xa5, 0x99, 0x4e,
0x1f, 0x75,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x71, 0x70, 0x39, 0x8f, 0x83, 0x3f, 0xf3, 0x38, 0xf8, 0xbe, 0x88, 0x3b, 0x97, 0x8b, 0xb8,
0xf3, 0x6b, 0x11, 0x77, 0x3e, 0x3d, 0xbf, 0x63, 0x68, 0x4e, 0x78, 0xb9, 0x2f, 0xa0, 0x26, 0xcd,
0x6e, 0xfe, 0xd3, 0x70, 0xae, 0x59, 0xd7, 0x2d, 0xd0, 0xcb, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff,
0xb7, 0x08, 0xb3, 0xa2, 0xb9, 0x02, 0x00, 0x00,
// 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,
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x6c, 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,
}
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
@@ -497,7 +497,7 @@ func (m *Params) Unmarshal(dAtA []byte) error {
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field EscrowAccountAddress", wireType)
}
var stringLen uint64
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
@@ -507,23 +507,25 @@ func (m *Params) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.EscrowAccountAddress = string(dAtA[iNdEx:postIndex])
m.EscrowAccountAddress = append(m.EscrowAccountAddress[:0], dAtA[iNdEx:postIndex]...)
if m.EscrowAccountAddress == nil {
m.EscrowAccountAddress = []byte{}
}
iNdEx = postIndex
case 3:
if wireType != 2 {
+4 -14
View File
@@ -101,23 +101,13 @@ 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: "test",
},
},
expectPass: false,
},
{
description: "valid message",
msg: types.MsgUpdateParams{
Authority: sdk.AccAddress([]byte("test")).String(),
Params: types.Params{
ProposerFee: sdk.NewDec(1),
EscrowAccountAddress: sdk.AccAddress([]byte("test")).String(),
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
ReserveFee: sdk.NewCoin("test", sdk.NewInt(100)),
MinBidIncrement: sdk.NewCoin("test", sdk.NewInt(100)),
},
@@ -130,7 +120,7 @@ func TestMsgUpdateParams(t *testing.T) {
Authority: sdk.AccAddress([]byte("test")).String(),
Params: types.Params{
ProposerFee: sdk.NewDec(1),
EscrowAccountAddress: sdk.AccAddress([]byte("test")).String(),
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
ReserveFee: sdk.NewCoin("test", sdk.NewInt(100)),
MinBidIncrement: sdk.NewCoin("test2", sdk.NewInt(100)),
},
@@ -143,7 +133,7 @@ func TestMsgUpdateParams(t *testing.T) {
Authority: sdk.AccAddress([]byte("test")).String(),
Params: types.Params{
ProposerFee: sdk.NewDec(1),
EscrowAccountAddress: sdk.AccAddress([]byte("test")).String(),
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
},
},
expectPass: false,
@@ -154,7 +144,7 @@ func TestMsgUpdateParams(t *testing.T) {
Authority: sdk.AccAddress([]byte("test")).String(),
Params: types.Params{
ProposerFee: sdk.NewDec(1),
EscrowAccountAddress: sdk.AccAddress([]byte("test")).String(),
EscrowAccountAddress: sdk.AccAddress([]byte("test")),
ReserveFee: sdk.NewCoin("test", sdk.NewInt(100)),
MinBidIncrement: sdk.NewCoin("test", sdk.NewInt(0)),
},
+2 -13
View File
@@ -10,7 +10,7 @@ import (
var (
DefaultMaxBundleSize uint32 = 2
DefaultEscrowAccountAddress string = authtypes.NewModuleAddress(ModuleName).String()
DefaultEscrowAccountAddress = authtypes.NewModuleAddress(ModuleName)
DefaultReserveFee = sdk.NewCoin("stake", sdk.NewInt(1))
DefaultMinBidIncrement = sdk.NewCoin("stake", sdk.NewInt(1))
DefaultFrontRunningProtection = true
@@ -20,7 +20,7 @@ var (
// NewParams returns a new Params instance with the provided values.
func NewParams(
maxBundleSize uint32,
escrowAccountAddress string,
escrowAccountAddress []byte,
reserveFee, minBidIncrement sdk.Coin,
frontRunningProtection bool,
proposerFee sdk.Dec,
@@ -49,9 +49,6 @@ func DefaultParams() Params {
// Validate performs basic validation on the parameters.
func (p Params) Validate() error {
if err := validateEscrowAccountAddress(p.EscrowAccountAddress); err != nil {
return err
}
if err := validateFee(p.ReserveFee); err != nil {
return fmt.Errorf("invalid reserve fee (%s)", err)
}
@@ -97,11 +94,3 @@ func validateProposerFee(v sdk.Dec) error {
return nil
}
func validateEscrowAccountAddress(account string) error {
if _, err := sdk.AccAddressFromBech32(account); err != nil {
return fmt.Errorf("invalid escrow account address (%s)", err)
}
return nil
}