diff --git a/app/app.go b/app/app.go index a3107c46..880375b3 100644 --- a/app/app.go +++ b/app/app.go @@ -847,7 +847,7 @@ func (app *App) registerUpgradeHandlers() { {PoolPercent: 8, Quantity: 60, IsUnique: false, DrawProbability: sdk.NewDecWithPrec(90, 2)}, }, } - err = app.MillionsKeeper.UpdatePool(ctx, pool.GetPoolId(), []string{}, nil, nil, nil, nil, &prizeStrategy, millionstypes.PoolState_Unspecified) + err = app.MillionsKeeper.UpdatePool(ctx, pool.GetPoolId(), []string{}, nil, nil, nil, nil, &prizeStrategy, millionstypes.PoolState_Unspecified, nil) if err != nil { return nil, err } @@ -874,7 +874,7 @@ func (app *App) registerUpgradeHandlers() { {PoolPercent: 8, Quantity: 60, IsUnique: true, DrawProbability: sdk.NewDecWithPrec(90, 2)}, }, } - err = app.MillionsKeeper.UpdatePool(ctx, pool.GetPoolId(), []string{}, nil, nil, nil, nil, &prizeStrategy, millionstypes.PoolState_Unspecified) + err = app.MillionsKeeper.UpdatePool(ctx, pool.GetPoolId(), []string{}, nil, nil, nil, nil, &prizeStrategy, millionstypes.PoolState_Unspecified, nil) if err != nil { return nil, err } @@ -914,6 +914,11 @@ func (app *App) registerUpgradeHandlers() { return app.mm.RunMigrations(ctx, app.configurator, fromVM) }) + app.UpgradeKeeper.SetUpgradeHandler("v1.6.4", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + app.Logger().Info("Starting v1.6.4 upgrade") + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) + upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) @@ -1010,4 +1015,9 @@ func (app *App) registerUpgradeHandlers() { storeUpgrades := storetypes.StoreUpgrades{} app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } + + if upgradeInfo.Name == "v1.6.4" && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{} + app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) + } } diff --git a/config.yml b/config.yml index 5bcd6a60..c2c12b18 100644 --- a/config.yml +++ b/config.yml @@ -45,7 +45,6 @@ genesis: min_draw_schedule_delta: "1h" max_draw_schedule_delta: "8784h" # 366days prize_expiration_delta: "720h" # 30days - fees_stakers: "0.10" min_deposit_draw_delta: "60s" faucet: name: user1 diff --git a/proto/lum/network/millions/gov.proto b/proto/lum/network/millions/gov.proto index c2de5e68..0711d67d 100644 --- a/proto/lum/network/millions/gov.proto +++ b/proto/lum/network/millions/gov.proto @@ -37,6 +37,7 @@ message ProposalRegisterPool { (gogoproto.nullable) = false ]; PoolType pool_type = 16; + repeated FeeTaker fee_takers = 17 [ (gogoproto.nullable) = false ]; } message ProposalUpdatePool { @@ -60,6 +61,7 @@ message ProposalUpdatePool { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = true ]; + repeated FeeTaker fee_takers = 11 [ (gogoproto.nullable) = false ]; } message ProposalUpdateParams { @@ -86,10 +88,8 @@ message ProposalUpdateParams { [ (gogoproto.stdduration) = true, (gogoproto.nullable) = true ]; google.protobuf.Duration prize_expiration_delta = 8 [ (gogoproto.stdduration) = true, (gogoproto.nullable) = true ]; - string fees_stakers = 9 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = true - ]; + // DO NOT USE - EX FEES STAKERS + reserved 9; google.protobuf.Duration min_deposit_draw_delta = 10 [ (gogoproto.stdduration) = true, (gogoproto.nullable) = true ]; } \ No newline at end of file diff --git a/proto/lum/network/millions/params.proto b/proto/lum/network/millions/params.proto index 2540ea44..51d77cbd 100644 --- a/proto/lum/network/millions/params.proto +++ b/proto/lum/network/millions/params.proto @@ -31,12 +31,8 @@ message Params { // pools) google.protobuf.Duration prize_expiration_delta = 6 [ (gogoproto.stdduration) = true, (gogoproto.nullable) = false ]; - // fees_stakers the fees distributed by stakers over prize won (common to all - // pools) - string fees_stakers = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; + // DEPRECATED - DO NOT USE IN THE FUTURE - EX FEES STAKERS + reserved 7; // min_deposit_draw_delta the minimum delta before a draw for a deposit to be // accepted during the time weighted balance computation for a draw google.protobuf.Duration min_deposit_draw_delta = 8 diff --git a/proto/lum/network/millions/pool.proto b/proto/lum/network/millions/pool.proto index 1e3a6676..496b6461 100644 --- a/proto/lum/network/millions/pool.proto +++ b/proto/lum/network/millions/pool.proto @@ -44,6 +44,28 @@ enum PoolType { POOL_TYPE_STAKING = 1 [ (gogoproto.enumvalue_customname) = "Staking" ]; } +enum FeeTakerType { + option (gogoproto.goproto_enum_prefix) = true; + + FEE_TAKER_TYPE_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = "Unspecified" ]; + FEE_TAKER_TYPE_LOCAL_ADDR = 1 + [ (gogoproto.enumvalue_customname) = "LocalAddr" ]; + FEE_TAKER_TYPE_LOCAL_MODULE_ACCOUNT = 2 + [ (gogoproto.enumvalue_customname) = "LocalModuleAccount" ]; + FEE_TAKER_TYPE_REMOTE_ADDR = 3 + [ (gogoproto.enumvalue_customname) = "RemoteAddr" ]; +} + +message FeeTaker { + string destination = 1; + string amount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + FeeTakerType type = 3; +} + message Pool { uint64 pool_id = 1; string denom = 2; @@ -96,7 +118,7 @@ message Pool { DrawState last_draw_state = 28; cosmos.base.v1beta1.Coin available_prize_pool = 29 [ (gogoproto.nullable) = false ]; - reserved 30; + repeated FeeTaker fee_takers = 30 [ (gogoproto.nullable) = false ]; reserved 31; PoolState state = 32; diff --git a/x/millions/genesis_test.go b/x/millions/genesis_test.go index 7c1bfc07..dbe514f4 100644 --- a/x/millions/genesis_test.go +++ b/x/millions/genesis_test.go @@ -5,6 +5,8 @@ import ( "testing" "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/require" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -43,7 +45,6 @@ var testGenesis = millionstypes.GenesisState{ MinDrawScheduleDelta: 1 * time.Hour, MaxDrawScheduleDelta: 366 * 24 * time.Hour, // 366 days PrizeExpirationDelta: 30 * 24 * time.Hour, // 30 days - FeesStakers: sdk.NewDec(0), MinDepositDrawDelta: 5 * time.Minute, }, NextPoolId: 6, @@ -55,26 +56,41 @@ var testGenesis = millionstypes.GenesisState{ ChainId: "c1", Validators: defaultValidators, MinDepositAmount: sdk.NewInt(1_000_000), UnbondingDuration: time.Duration(millionstypes.DefaultUnbondingDuration), MaxUnbondingEntries: sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), AvailablePrizePool: sdk.NewCoin("denom-1", sdk.ZeroInt()), DrawSchedule: defaultSchedule, PrizeStrategy: defaultPrizeStrat, State: millionstypes.PoolState_Created, Bech32PrefixAccAddr: "lum", Bech32PrefixValAddr: "lumvaloper", + FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, }, {PoolId: 2, PoolType: millionstypes.PoolType_Staking, TvlAmount: sdk.NewInt(603), DepositorsCount: 2, SponsorshipAmount: sdk.NewInt(401), Denom: "denom-2", NativeDenom: "denom-2", NextDrawId: 2, ChainId: "c1", Validators: defaultValidators, MinDepositAmount: sdk.NewInt(1_000_000), UnbondingDuration: time.Duration(millionstypes.DefaultUnbondingDuration), MaxUnbondingEntries: sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), AvailablePrizePool: sdk.NewCoin("denom-2", sdk.ZeroInt()), DrawSchedule: defaultSchedule, PrizeStrategy: defaultPrizeStrat, State: millionstypes.PoolState_Ready, Bech32PrefixAccAddr: "lum", Bech32PrefixValAddr: "lumvaloper", + FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, }, {PoolId: 3, PoolType: millionstypes.PoolType_Staking, TvlAmount: sdk.NewInt(601), DepositorsCount: 1, SponsorshipAmount: sdk.ZeroInt(), Denom: "denom-3", NativeDenom: "denom-3", NextDrawId: 1, ChainId: "c1", Validators: defaultValidators, MinDepositAmount: sdk.NewInt(1_000_000), UnbondingDuration: time.Duration(millionstypes.DefaultUnbondingDuration), MaxUnbondingEntries: sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), AvailablePrizePool: sdk.NewCoin("denom-3", sdk.ZeroInt()), DrawSchedule: defaultSchedule, PrizeStrategy: defaultPrizeStrat, State: millionstypes.PoolState_Killed, Bech32PrefixAccAddr: "lum", Bech32PrefixValAddr: "lumvaloper", + FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, }, {PoolId: 4, PoolType: millionstypes.PoolType_Staking, TvlAmount: sdk.NewInt(400), DepositorsCount: 1, SponsorshipAmount: sdk.ZeroInt(), Denom: "denom-4", NativeDenom: "denom-4", NextDrawId: 1, ChainId: "c1", Validators: defaultValidators, MinDepositAmount: sdk.NewInt(1_000_000), UnbondingDuration: time.Duration(millionstypes.DefaultUnbondingDuration), MaxUnbondingEntries: sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), AvailablePrizePool: sdk.NewCoin("denom-4", sdk.ZeroInt()), DrawSchedule: defaultSchedule, PrizeStrategy: defaultPrizeStrat, State: millionstypes.PoolState_Created, Bech32PrefixAccAddr: "lum", Bech32PrefixValAddr: "lumvaloper", + FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, }, {PoolId: 5, PoolType: millionstypes.PoolType_Staking, TvlAmount: sdk.NewInt(0), DepositorsCount: 0, SponsorshipAmount: sdk.ZeroInt(), Denom: "denom-5", NativeDenom: "denom-5", NextDrawId: 1, ChainId: "c1", Validators: defaultValidators, MinDepositAmount: sdk.NewInt(1_000_000), UnbondingDuration: time.Duration(millionstypes.DefaultUnbondingDuration), MaxUnbondingEntries: sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), AvailablePrizePool: sdk.NewCoin("denom-5", sdk.ZeroInt()), DrawSchedule: defaultSchedule, PrizeStrategy: defaultPrizeStrat, State: millionstypes.PoolState_Killed, Bech32PrefixAccAddr: "lum", Bech32PrefixValAddr: "lumvaloper", + FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, }, }, Deposits: []millionstypes.Deposit{ @@ -131,7 +147,6 @@ func TestInitGenesis(t *testing.T) { require.Equal(t, testGenesis.Params.MinDrawScheduleDelta, params.MinDrawScheduleDelta) require.Equal(t, testGenesis.Params.MaxDrawScheduleDelta, params.MaxDrawScheduleDelta) require.Equal(t, testGenesis.Params.PrizeExpirationDelta, params.PrizeExpirationDelta) - require.Equal(t, testGenesis.Params.FeesStakers, params.FeesStakers) require.Equal(t, testGenesis.Params.MinDepositDrawDelta, params.MinDepositDrawDelta) // Make sure genesis next poolID matches @@ -329,7 +344,6 @@ func TestExportGenesis(t *testing.T) { require.Equal(t, exportGenesis.Params.MinDrawScheduleDelta, testGenesis.Params.MinDrawScheduleDelta) require.Equal(t, exportGenesis.Params.MaxDrawScheduleDelta, testGenesis.Params.MaxDrawScheduleDelta) require.Equal(t, exportGenesis.Params.PrizeExpirationDelta, testGenesis.Params.PrizeExpirationDelta) - require.Equal(t, exportGenesis.Params.FeesStakers, testGenesis.Params.FeesStakers) require.Equal(t, exportGenesis.Params.MinDepositDrawDelta, testGenesis.Params.MinDepositDrawDelta) // Test IDs export diff --git a/x/millions/handler_proposal.go b/x/millions/handler_proposal.go index a1ffdf44..61212375 100644 --- a/x/millions/handler_proposal.go +++ b/x/millions/handler_proposal.go @@ -15,7 +15,7 @@ func NewMillionsProposalHandler(k keeper.Keeper) govtypes.Handler { switch c := content.(type) { case *types.ProposalUpdatePool: { - return k.UpdatePool(ctx, c.PoolId, c.Validators, c.MinDepositAmount, c.UnbondingDuration, c.MaxUnbondingEntries, c.DrawSchedule, c.PrizeStrategy, c.State) + return k.UpdatePool(ctx, c.PoolId, c.Validators, c.MinDepositAmount, c.UnbondingDuration, c.MaxUnbondingEntries, c.DrawSchedule, c.PrizeStrategy, c.State, c.FeeTakers) } case *types.ProposalRegisterPool: { @@ -35,6 +35,7 @@ func NewMillionsProposalHandler(k keeper.Keeper) govtypes.Handler { c.MaxUnbondingEntries, c.GetDrawSchedule(), c.GetPrizeStrategy(), + c.FeeTakers, ) return err } @@ -59,9 +60,6 @@ func NewMillionsProposalHandler(k keeper.Keeper) govtypes.Handler { if c.PrizeExpirationDelta != nil { params.PrizeExpirationDelta = *c.PrizeExpirationDelta } - if c.FeesStakers != nil { - params.FeesStakers = *c.FeesStakers - } if c.MinDepositDrawDelta != nil { params.MinDepositDrawDelta = *c.MinDepositDrawDelta } diff --git a/x/millions/handler_proposal_test.go b/x/millions/handler_proposal_test.go index 52c65170..df6c8305 100644 --- a/x/millions/handler_proposal_test.go +++ b/x/millions/handler_proposal_test.go @@ -4,6 +4,8 @@ import ( "testing" "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/suite" "cosmossdk.io/math" @@ -75,7 +77,10 @@ func (suite *HandlerTestSuite) SetupTest() { poolID := app.MillionsKeeper.GetNextPoolIDAndIncrement(ctx) drawDelta1 := 1 * time.Hour app.MillionsKeeper.AddPool(ctx, &millionstypes.Pool{ - PoolType: millionstypes.PoolType_Staking, + PoolType: millionstypes.PoolType_Staking, + FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, Denom: "ulum", NativeDenom: "ulum", ChainId: "lum-network-devnet", @@ -157,6 +162,26 @@ func (suite *HandlerTestSuite) TestProposal_RegisterPool() { UnbondingDuration := time.Duration(millionstypes.DefaultUnbondingDuration) maxUnbondingEntries := sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries) + validFees := []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } + + invalidFees := []millionstypes.FeeTaker{ + {Destination: "", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } + invalidExcessiveFees := []millionstypes.FeeTaker{ + {Destination: "test_1", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_2", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_3", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_4", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_5", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_6", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_7", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_8", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_9", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_10", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_11", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } cases := []struct { name string @@ -166,97 +191,109 @@ func (suite *HandlerTestSuite) TestProposal_RegisterPool() { }{ { "Title cannot be empty", - millionstypes.NewRegisterPoolProposal("", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, false, }, { "Description cannot be empty", - millionstypes.NewRegisterPoolProposal("Test", "", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, false, }, { "Pool Type cannot be unspecified", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Unspecified, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Unspecified, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "Chain ID cannot be empty", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "Bech 32 acc prefix cannot be empty", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "Bech 32 val prefix cannot be empty", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "Validators list cannot be empty", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", emptyValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", emptyValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "Validators list cannot be invalid", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", invalidValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", invalidValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), false, true, }, { "Min deposit amount cannot be less than min acceptable amount", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(millionstypes.MinAcceptableDepositAmount-1), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(millionstypes.MinAcceptableDepositAmount-1), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "Prize strategy cannot be empty", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), emptyPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), emptyPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "Prize strategy cannot be invalid", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), invalidPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), invalidPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), false, true, }, { "Draw Schedule cannot be invalid", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, invalidDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, invalidDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), true, true, }, { "ZoneUnbonding duration cannot be below the min unbonding", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, time.Duration(6*24*time.Hour), maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, time.Duration(6*24*time.Hour), maxUnbondingEntries, validFees), true, true, }, { "MaxUnbondingEntries cannot exceed 7 parallel unbondings", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, sdk.NewInt(8)), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, sdk.NewInt(8), validFees), true, true, }, { "MaxUnbondingEntries cannot exceed cannot be negative", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, sdk.NewInt(-2)), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, sdk.NewInt(-2), validFees), + true, + true, + }, + { + "FeesStakers cannot be invalid", + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, invalidFees), + true, + true, + }, + { + "FeesStakers cannot exceed maximum allowed amount", + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, invalidExcessiveFees), true, true, }, { "Fine should be fine", - millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries), + millionstypes.NewRegisterPoolProposal("Test", "Test", millionstypes.PoolType_Staking, "lum-network-devnet", "ulum", "ulum", "connection-0", "lum", "lumvaloper", validValidatorSet, sdk.NewInt(1000000), validPrizeStrategy, validDrawSchedule, UnbondingDuration, maxUnbondingEntries, validFees), false, false, }, @@ -332,6 +369,25 @@ func (suite *HandlerTestSuite) TestProposal_UpdatePool() { UnbondingDuration := time.Duration(millionstypes.DefaultUnbondingDuration) maxUnbondingEntries := sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries) + validFees := []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } + invalidFees := []millionstypes.FeeTaker{ + {Destination: "", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } + invalidExcessiveFees := []millionstypes.FeeTaker{ + {Destination: "test_1", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_2", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_3", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_4", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_5", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_6", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_7", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_8", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_9", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_10", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: "test_11", Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } cases := []struct { name string @@ -341,61 +397,73 @@ func (suite *HandlerTestSuite) TestProposal_UpdatePool() { }{ { "Title cannot be empty", - millionstypes.NewUpdatePoolProposal("", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStateUnspecified, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStateUnspecified, &UnbondingDuration, &maxUnbondingEntries, validFees), true, false, }, { "Description cannot be empty", - millionstypes.NewUpdatePoolProposal("Test", "", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries, validFees), true, false, }, { "Validators list can be empty", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStateReady, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStateReady, &UnbondingDuration, &maxUnbondingEntries, validFees), false, false, }, { "Validators list cannot be invalid", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), invalidValidatorSet, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), invalidValidatorSet, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries, validFees), false, true, }, { "Min deposit amount cannot be less than 1000000 (default params)", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &invalidMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStateReady, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &invalidMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStateReady, &UnbondingDuration, &maxUnbondingEntries, validFees), true, true, }, { "Prize strategy cannot be empty", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &emptyPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &emptyPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries, validFees), true, true, }, { "Prize strategy cannot be invalid", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &invalidPrizeStrategy, &validDrawSchedule, poolStateReady, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &invalidPrizeStrategy, &validDrawSchedule, poolStateReady, &UnbondingDuration, &maxUnbondingEntries, validFees), false, true, }, { "Draw Schedule cannot be invalid", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &invalidDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, &validMinDepositAmount, &validPrizeStrategy, &invalidDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries, validFees), + true, + true, + }, + { + "Fees Stakers cannot be invalid", + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), validValidatorSet, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries, invalidFees), + true, + true, + }, + { + "Fees Stakers cannot exceed maximum allowed amount", + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), validValidatorSet, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries, invalidExcessiveFees), true, true, }, { "Partial should be fine", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, nil, nil, nil, poolStateUnspecified, nil, nil), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), nil, nil, nil, nil, poolStateUnspecified, nil, nil, nil), false, false, }, { "Fine should be fine", - millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), validValidatorSet, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStatePaused, &UnbondingDuration, &maxUnbondingEntries), + millionstypes.NewUpdatePoolProposal("Test", "Test", suite.pool.GetPoolId(), validValidatorSet, &validMinDepositAmount, &validPrizeStrategy, &validDrawSchedule, poolStateUnspecified, &UnbondingDuration, &maxUnbondingEntries, validFees), false, false, }, @@ -422,7 +490,6 @@ func (suite *HandlerTestSuite) TestProposal_UpdatePool() { func (suite *HandlerTestSuite) TestProposal_UpdateParams() { validMinDepositAmount := sdk.NewInt(millionstypes.MinAcceptableDepositAmount) - validFees := sdk.NewDecWithPrec(int64(0.5*1_000_000), 6) prizeDelta := 5 * time.Hour depositDelta := 2 * time.Hour @@ -439,13 +506,13 @@ func (suite *HandlerTestSuite) TestProposal_UpdateParams() { }{ { "Full update should be fine", - millionstypes.NewUpdateParamsProposal("Test", "Test", &validMinDepositAmount, &validFees, &prizeDelta, &depositDelta, &minDrawDelta, &maxDrawDelta, &maxBatchQuantity, &maxStrategyBatches), + millionstypes.NewUpdateParamsProposal("Test", "Test", &validMinDepositAmount, &prizeDelta, &depositDelta, &minDrawDelta, &maxDrawDelta, &maxBatchQuantity, &maxStrategyBatches), false, false, }, { "Partial update should be fine", - millionstypes.NewUpdateParamsProposal("Test", "Test", nil, nil, nil, nil, nil, nil, nil, nil), + millionstypes.NewUpdateParamsProposal("Test", "Test", nil, nil, nil, nil, nil, nil, nil), false, false, }, diff --git a/x/millions/keeper/keeper_deposit.go b/x/millions/keeper/keeper_deposit.go index f705496c..085f12a9 100644 --- a/x/millions/keeper/keeper_deposit.go +++ b/x/millions/keeper/keeper_deposit.go @@ -388,3 +388,14 @@ func (k Keeper) ListDeposits(ctx sdk.Context) (deposits []types.Deposit) { } return } + +func (k Keeper) UnsafeSetUnpersistedDeposits(ctx sdk.Context) int { + i := 0 + for _, deposit := range k.ListDeposits(ctx) { + k.setPoolDeposit(ctx, &deposit) + k.setAccountDeposit(ctx, &deposit) + i++ + } + + return i +} diff --git a/x/millions/keeper/keeper_draw.go b/x/millions/keeper/keeper_draw.go index 45aa53d5..cae8aa02 100644 --- a/x/millions/keeper/keeper_draw.go +++ b/x/millions/keeper/keeper_draw.go @@ -435,7 +435,7 @@ func (k Keeper) ExecuteDraw(ctx sdk.Context, poolID uint64, drawID uint64) (*typ k.SetPoolDraw(ctx, draw) // Distribute prizes and collect fees - fc := k.NewFeeCollector(ctx, pool) + fc := k.NewFeeManager(ctx, pool) if err := k.DistributePrizes(ctx, fc, dRes, draw); err != nil { return k.OnExecuteDrawCompleted( ctx, @@ -758,7 +758,7 @@ func (k Keeper) RunDrawPrizesWithUniques(ctx sdk.Context, prizePool sdk.Coin, pr } // DistributePrizes distributes the prizes if they have a winner -func (k Keeper) DistributePrizes(ctx sdk.Context, fc *feeCollector, dRes DrawResult, draw types.Draw) error { +func (k Keeper) DistributePrizes(ctx sdk.Context, fc *feeManager, dRes DrawResult, draw types.Draw) error { var prizeRefs []types.PrizeRef for _, pd := range dRes.PrizeDraws { if pd.Winner != nil { diff --git a/x/millions/keeper/keeper_draw_test.go b/x/millions/keeper/keeper_draw_test.go index 093bb4ba..9bcf5e2e 100644 --- a/x/millions/keeper/keeper_draw_test.go +++ b/x/millions/keeper/keeper_draw_test.go @@ -457,6 +457,7 @@ func (suite *KeeperTestSuite) TestDraw_PrizePoolPersistence() { p.MaxUnbondingEntries, p.DrawSchedule, p.PrizeStrategy, + p.FeeTakers, ) suite.Require().NoError(err) pool1, err := app.MillionsKeeper.GetPool(ctx, newID) @@ -481,6 +482,7 @@ func (suite *KeeperTestSuite) TestDraw_PrizePoolPersistence() { p.MaxUnbondingEntries, p.DrawSchedule, p.PrizeStrategy, + p.FeeTakers, ) suite.Require().NoError(err) pool2, err := app.MillionsKeeper.GetPool(ctx, newID) @@ -781,7 +783,7 @@ func (suite *KeeperTestSuite) TestDraw_PrizeDistribution() { draw, err := app.MillionsKeeper.GetPoolDraw(ctx, poolID, pool.GetNextDrawId()) suite.Require().NoError(err) - err = app.MillionsKeeper.DistributePrizes(ctx, app.MillionsKeeper.NewFeeCollector(ctx, *pool), drawRes, draw) + err = app.MillionsKeeper.DistributePrizes(ctx, app.MillionsKeeper.NewFeeManager(ctx, *pool), drawRes, draw) suite.Require().NoError(err) for _, pd := range drawRes.PrizeDraws { diff --git a/x/millions/keeper/keeper_fees.go b/x/millions/keeper/keeper_fees.go index 2f0f48e3..85bec833 100644 --- a/x/millions/keeper/keeper_fees.go +++ b/x/millions/keeper/keeper_fees.go @@ -1,60 +1,163 @@ package keeper import ( + "fmt" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" "github.com/lum-network/chain/x/millions/types" ) -type feeCollector struct { - keeper Keeper - pool types.Pool - feesStakers sdk.Dec - stakersAmount sdk.Coin +type feeDestination struct { + taker types.FeeTaker + amount math.Int } -// NewFeeCollector creates a new fee collector for the specified pool -func (k Keeper) NewFeeCollector(ctx sdk.Context, pool types.Pool) *feeCollector { - params := k.GetParams(ctx) - feesStaker := params.FeesStakers - if feesStaker.IsNil() { - feesStaker = sdk.ZeroDec() - } - return &feeCollector{ - keeper: k, - pool: pool, - feesStakers: feesStaker, - stakersAmount: sdk.NewCoin(pool.Denom, math.ZeroInt()), - } +type feeManager struct { + keeper Keeper + pool types.Pool + collectedAmount sdk.Coin + destinations []*feeDestination } // CollectedAmount returns the collected and not sent amount -func (fc *feeCollector) CollectedAmount() sdk.Coin { - return fc.stakersAmount +func (fm *feeManager) CollectedAmount() sdk.Coin { + return fm.collectedAmount +} + +func (k Keeper) NewFeeManager(ctx sdk.Context, pool types.Pool) *feeManager { + destinations := []*feeDestination{} + + // Prepare takers destinations collectors + for _, ft := range pool.FeeTakers { + if !ft.Amount.IsNil() && !ft.Amount.LTE(sdk.ZeroDec()) { + destinations = append(destinations, &feeDestination{ + taker: ft, + amount: sdk.ZeroInt(), + }) + } + } + + return &feeManager{ + keeper: k, + pool: pool, + collectedAmount: sdk.NewCoin(pool.Denom, math.ZeroInt()), + destinations: destinations, + } } // CollectPrizeFees computes and collects the fees for a prize and updates its final amount -func (fc *feeCollector) CollectPrizeFees(ctx sdk.Context, prize *types.Prize) (newAmount, fees math.Int) { - fees = fc.feesStakers.MulInt(prize.Amount.Amount).RoundInt() - fc.stakersAmount = fc.stakersAmount.AddAmount(fees) +// It loops through the fee takers and collect the fees for each one of them +// returns the new prize amount alongside the total collected fees +func (fm *feeManager) CollectPrizeFees(ctx sdk.Context, prize *types.Prize) (newAmount, fees math.Int) { + fees = sdk.ZeroInt() + + // Collect fees + for _, fd := range fm.destinations { + // Compute taker fees + takerFees := fd.taker.Amount.MulInt(prize.Amount.Amount).RoundInt() + fees = fees.Add(takerFees) + // Collect it + fd.amount = fd.amount.Add(takerFees) + fm.collectedAmount = fm.collectedAmount.AddAmount(takerFees) + } + + // Deduce from prize amount prize.Amount = prize.Amount.SubAmount(fees) + return prize.Amount.Amount, fees } // SendCollectedFees effectively sends the collected fees (if any) to their destination -func (fc *feeCollector) SendCollectedFees(ctx sdk.Context) (err error) { - if fc.stakersAmount.Amount.GT(math.ZeroInt()) { - err = fc.keeper.BankKeeper.SendCoinsFromAccountToModule( - ctx, - sdk.MustAccAddressFromBech32(fc.pool.GetLocalAddress()), - authtypes.FeeCollectorName, - sdk.NewCoins(fc.stakersAmount), - ) +// For each destination type, it handles specific logic +// Reset the fee manager to 0 collected fees upon succesful completion +func (fm *feeManager) SendCollectedFees(ctx sdk.Context) (err error) { + // If nothing was collected, there is nothing to do + if fm.collectedAmount.Amount.IsZero() { + return nil } - if err == nil { - fc.stakersAmount.Amount = math.ZeroInt() + + // Otherwise, handle each fee taker by calling specific logic with the taker and amount to send + for _, destination := range fm.destinations { + if destination.amount.LTE(sdk.ZeroInt()) { + continue + } + + amount := sdk.NewCoin(fm.pool.Denom, destination.amount) + + // Process the fee taker depending on its type + switch destination.taker.Type { + case types.FeeTakerType_LocalAddr: + err = fm.sendCollectedFeesToLocalAddr(ctx, destination.taker, amount) + case types.FeeTakerType_LocalModuleAccount: + err = fm.sendCollectedFeesToLocalModuleAccount(ctx, destination.taker, amount) + case types.FeeTakerType_RemoteAddr: + err = fm.sendCollectedFeesToRemoteAddr(ctx, destination.taker, amount) + } + + if err != nil { + return err + } + } + + // Reset fee manager + fm.collectedAmount.Amount = math.ZeroInt() + for _, fd := range fm.destinations { + fd.amount = sdk.ZeroInt() } - return err + + return nil +} + +// sendCollectedFeesToLocalAddr sends the collected fees to a local address +func (fm *feeManager) sendCollectedFeesToLocalAddr(ctx sdk.Context, ft types.FeeTaker, amount sdk.Coin) (err error) { + return fm.keeper.BankKeeper.SendCoins( + ctx, + sdk.MustAccAddressFromBech32(fm.pool.GetLocalAddress()), + sdk.MustAccAddressFromBech32(ft.Destination), + sdk.NewCoins(amount), + ) +} + +// sendCollectedFeesToLocalModuleAccount sends the collected fees to a local module account +func (fm *feeManager) sendCollectedFeesToLocalModuleAccount(ctx sdk.Context, ft types.FeeTaker, amount sdk.Coin) (err error) { + return fm.keeper.BankKeeper.SendCoinsFromAccountToModule( + ctx, + sdk.MustAccAddressFromBech32(fm.pool.GetLocalAddress()), + ft.Destination, + sdk.NewCoins(amount), + ) +} + +// sendCollectedFeesToRemoteAddr sends the collected fees to a remote address through IBC +func (fm *feeManager) sendCollectedFeesToRemoteAddr(ctx sdk.Context, ft types.FeeTaker, amount sdk.Coin) (err error) { + // Build the timeout timestamp + timeoutTimestamp := uint64(ctx.BlockTime().UnixNano()) + types.IBCTimeoutNanos + + // Build the transfer message + msg := ibctransfertypes.NewMsgTransfer( + ibctransfertypes.PortID, + fm.pool.GetTransferChannelId(), + amount, + fm.pool.GetLocalAddress(), + ft.Destination, + clienttypes.Height{}, + timeoutTimestamp, + "Cosmos Millions Revenue Sharing", + ) + + res, err := fm.keeper.IBCTransferKeeper.Transfer(ctx, msg) + if err != nil { + return err + } + + fm.keeper.Logger(ctx).Debug( + fmt.Sprintf("Broadcasted IBC fees transfer with sequence %d", res.Sequence), + "pool_id", fm.pool.GetPoolId(), + ) + + return nil } diff --git a/x/millions/keeper/keeper_fees_test.go b/x/millions/keeper/keeper_fees_test.go index ca74d520..a01aadd2 100644 --- a/x/millions/keeper/keeper_fees_test.go +++ b/x/millions/keeper/keeper_fees_test.go @@ -19,16 +19,12 @@ func (suite *KeeperTestSuite) TestFees_FeeCollector() { // Fees should start at 0 and have the pool denom denom := app.StakingKeeper.BondDenom(ctx) feeAddr := app.AccountKeeper.GetModuleAccount(ctx, authtypes.FeeCollectorName).GetAddress() - fc := app.MillionsKeeper.NewFeeCollector(ctx, millionstypes.Pool{Denom: denom, LocalAddress: suite.addrs[0].String()}) + fc := app.MillionsKeeper.NewFeeManager(ctx, millionstypes.Pool{Denom: denom, LocalAddress: suite.addrs[0].String()}) suite.Require().Equal(math.ZeroInt(), fc.CollectedAmount().Amount) suite.Require().Equal(denom, fc.CollectedAmount().Denom) // 0 fees should do nothing - params := app.MillionsKeeper.GetParams(ctx) - params.FeesStakers = sdk.ZeroDec() - app.MillionsKeeper.SetParams(ctx, params) - - fc = app.MillionsKeeper.NewFeeCollector(ctx, millionstypes.Pool{Denom: denom, LocalAddress: suite.addrs[0].String()}) + fc = app.MillionsKeeper.NewFeeManager(ctx, millionstypes.Pool{Denom: denom, LocalAddress: suite.addrs[0].String()}) prize := &millionstypes.Prize{Amount: sdk.NewCoin(denom, math.ZeroInt())} a, f := fc.CollectPrizeFees(ctx, prize) suite.Require().Equal(math.ZeroInt(), a) @@ -40,9 +36,9 @@ func (suite *KeeperTestSuite) TestFees_FeeCollector() { suite.Require().Equal(math.ZeroInt(), f) // 10% fees should store collected fees (if possible) and update prize amount - params.FeesStakers = floatToDec(0.1) - app.MillionsKeeper.SetParams(ctx, params) - fc = app.MillionsKeeper.NewFeeCollector(ctx, millionstypes.Pool{Denom: denom, LocalAddress: suite.addrs[0].String()}) + fc = app.MillionsKeeper.NewFeeManager(ctx, millionstypes.Pool{Denom: denom, LocalAddress: suite.addrs[0].String(), FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }}) prize.Amount.Amount = math.NewInt(0) a, f = fc.CollectPrizeFees(ctx, prize) @@ -84,13 +80,16 @@ func (suite *KeeperTestSuite) TestFees_FeeCollector() { // Succeeding at sending collected fees should send and clear the collected amount poolBalanceBefore := app.BankKeeper.GetBalance(ctx, suite.addrs[0], denom) feeCollectorBalanceBefore := app.BankKeeper.GetBalance(ctx, feeAddr, denom) - collectedAmount := sdk.NewInt(123_456) + + collectedAmount := sdk.NewInt(123_456) // Manually set collected amount + fc.CollectPrizeFees(ctx, &millionstypes.Prize{Amount: sdk.NewCoin(denom, collectedAmount.MulRaw(10).SubRaw(1290))}) suite.Require().Equal(denom, fc.CollectedAmount().Denom) suite.Require().Equal(collectedAmount, fc.CollectedAmount().Amount) + err := fc.SendCollectedFees(ctx) suite.Require().NoError(err) - suite.Require().Equal(math.NewInt(0), fc.CollectedAmount().Amount) + suite.Require().Equal(math.NewInt(0).Int64(), fc.CollectedAmount().Amount.Int64()) suite.Require().Equal(poolBalanceBefore.SubAmount(collectedAmount), app.BankKeeper.GetBalance(ctx, suite.addrs[0], denom)) suite.Require().Equal(feeCollectorBalanceBefore.AddAmount(collectedAmount), app.BankKeeper.GetBalance(ctx, feeAddr, denom)) @@ -134,6 +133,10 @@ func (suite *KeeperTestSuite) TestFees_DrawPrizesFees() { {PoolPercent: 100, Quantity: 100, DrawProbability: floatToDec(1.00)}, }, }, + FeeTakers: []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + {Destination: suite.addrs[3].String(), Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalAddr}, + }, }) poolID, err := app.MillionsKeeper.RegisterPool( ctx, @@ -146,6 +149,7 @@ func (suite *KeeperTestSuite) TestFees_DrawPrizesFees() { p.MaxUnbondingEntries, p.DrawSchedule, p.PrizeStrategy, + p.FeeTakers, ) suite.Require().NoError(err) p, err = app.MillionsKeeper.GetPool(ctx, poolID) @@ -170,28 +174,32 @@ func (suite *KeeperTestSuite) TestFees_DrawPrizesFees() { ) suite.Require().NoError(err) - // set 10% fees - params := app.MillionsKeeper.GetParams(ctx) - params.FeesStakers = sdk.NewDecWithPrec(10, 2) - app.MillionsKeeper.SetParams(ctx, params) - - // force run draw and fee collection + // Force run draw and fee collection ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1).WithBlockTime(ctx.BlockTime().Add(24 * time.Hour)) draw, err := app.MillionsKeeper.LaunchNewDraw(ctx, poolID) suite.Require().NoError(err) suite.Require().Equal(prizePoolAmount, draw.PrizePoolFreshAmount.Int64()) suite.Require().Equal(prizePoolAmount, draw.TotalWinAmount.Int64()) - // prize ref should reflect the total win amount + + // Prize ref should reflect the total win amount suite.Require().Len(draw.PrizesRefs, 100) suite.Require().Equal(prizePoolAmount/100, draw.PrizesRefs[0].Amount.Int64()) - // prize entity should have fees subtracted + + // Prize entity should have fees subtracted prizes := app.MillionsKeeper.ListPrizes(ctx) suite.Require().Len(prizes, 100) - suite.Require().Equal(prizePoolAmount/100-params.FeesStakers.MulInt64(prizePoolAmount/100).RoundInt64(), prizes[0].Amount.Amount.Int64()) + + // Check the prizes fees over all fee takers + for _, prize := range prizes { + var totalFeeAmount int64 = 0 + for _, ft := range p.FeeTakers { + totalFeeAmount += ft.Amount.MulInt64(prizePoolAmount / 100).RoundInt64() + } + suite.Require().Equal(prizePoolAmount/100-totalFeeAmount, prize.Amount.Amount.Int64()) + } // Stakers should receive their share of the collected fees upon send success - // Community tax should apply as well - collectedAmount := params.FeesStakers.MulInt64(prizePoolAmount).RoundInt64() + collectedAmount := p.FeeTakers[0].Amount.MulInt64(prizePoolAmount).RoundInt64() vals := app.StakingKeeper.GetAllValidators(ctx) consAddr0, err := vals[0].GetConsAddr() suite.Require().NoError(err) diff --git a/x/millions/keeper/keeper_params_test.go b/x/millions/keeper/keeper_params_test.go index 743aa487..4ff34f09 100644 --- a/x/millions/keeper/keeper_params_test.go +++ b/x/millions/keeper/keeper_params_test.go @@ -49,21 +49,6 @@ func (suite *KeeperTestSuite) TestParams_Validation() { params.PrizeExpirationDelta = millionstypes.MinAcceptablePrizeExpirationDelta suite.Require().NoError(params.ValidateBasics()) - // Default FeesStakers should be equal to default 10% value - suite.Require().Equal(0.1, millionstypes.DefaultParams().FeesStakers.MustFloat64()) - // FeesStakers should always be gte 0 and lte MaxAcceptableFeesStakers - params.FeesStakers = sdk.NewDec(-1) - suite.Require().Error(params.ValidateBasics()) - maxFees := sdk.NewDecWithPrec(millionstypes.MaxAcceptableFeesStakers, 2) - maxFeesFloat, err := maxFees.Float64() - suite.Require().NoError(err) - suite.Require().Equal(0.5, maxFeesFloat) - suite.Require().NoError(err) - params.FeesStakers = sdk.NewDecWithPrec(millionstypes.MaxAcceptableFeesStakers+1, 2) - suite.Require().Error(params.ValidateBasics()) - params.FeesStakers = maxFees - suite.Require().NoError(params.ValidateBasics()) - // MinDepositDrawDelta should always be gte MinAcceptableDepositDrawDelta params.MinDepositDrawDelta = millionstypes.MinAcceptableDepositDrawDelta - 1 suite.Require().Error(params.ValidateBasics()) diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index 598b2c53..0a77a36d 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -274,6 +274,7 @@ func (k Keeper) RegisterPool( maxUnbondingEntries math.Int, drawSchedule types.DrawSchedule, prizeStrategy types.PrizeStrategy, + fees []types.FeeTaker, ) (uint64, error) { // Acquire new pool ID @@ -317,6 +318,7 @@ func (k Keeper) RegisterPool( SponsorshipAmount: sdk.ZeroInt(), AvailablePrizePool: sdk.NewCoin(denom, sdk.ZeroInt()), State: types.PoolState_Created, + FeeTakers: fees, TransferChannelId: transferChannelId, CreatedAtHeight: ctx.BlockHeight(), UpdatedAtHeight: ctx.BlockHeight(), @@ -381,6 +383,7 @@ func (k Keeper) UpdatePool( drawSchedule *types.DrawSchedule, prizeStrategy *types.PrizeStrategy, state types.PoolState, + feeTakers []types.FeeTaker, ) error { // Acquire and deserialize our pool entity pool, err := k.GetPool(ctx, poolID) @@ -409,6 +412,9 @@ func (k Keeper) UpdatePool( if prizeStrategy != nil { pool.PrizeStrategy = *prizeStrategy } + if feeTakers != nil { + pool.FeeTakers = feeTakers + } // Update pool state only if current pool state is in paused and incoming state ready // else if current pool state is in ready and incoming state paused @@ -648,6 +654,22 @@ func (k Keeper) UnsafeUpdatePoolUnbondingFrequencyAndType(ctx sdk.Context, poolI return pool, nil } +// UnsafeUpdatePoolFeeTakers raw updates the fee takers entries +// Unsafe and should only be used for store migration +func (k Keeper) UnsafeUpdatePoolFeeTakers(ctx sdk.Context, poolID uint64, feeTakers []types.FeeTaker) (types.Pool, error) { + // Grab our pool instance + pool, err := k.GetPool(ctx, poolID) + if err != nil { + return types.Pool{}, err + } + + // Patch and update our pool entity + pool.FeeTakers = feeTakers + k.updatePool(ctx, &pool) + + return pool, nil +} + func (k Keeper) updatePool(ctx sdk.Context, pool *types.Pool) { pool.UpdatedAt = ctx.BlockTime() pool.UpdatedAtHeight = ctx.BlockHeight() diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index d881357e..5d68c9a6 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -306,6 +308,9 @@ func (suite *KeeperTestSuite) TestPool_DepositorsCountAndTVL() { sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), millionstypes.DrawSchedule{DrawDelta: 24 * time.Hour, InitialDrawAt: ctx.BlockTime().Add(24 * time.Hour)}, millionstypes.PrizeStrategy{PrizeBatches: []millionstypes.PrizeBatch{{PoolPercent: 100, Quantity: 100, DrawProbability: sdk.NewDec(1)}}}, + []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, ) suite.Require().NoError(err) pool, err := app.MillionsKeeper.GetPool(ctx, poolID) @@ -973,6 +978,9 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { {PoolPercent: 10, DrawProbability: sdk.NewDec(1), Quantity: 10}, }, } + newFees := []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount+1, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } UnbondingDuration := time.Duration(millionstypes.DefaultUnbondingDuration) maxUnbondingEntries := sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries) @@ -1049,7 +1057,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { // Simulate that 2 validators are bonded but inactive in the poolSet // - Validator 2 and 4 are being removed - err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, []string{pool.Validators[0].GetOperatorAddress(), pool.Validators[2].GetOperatorAddress(), pool.Validators[4].GetOperatorAddress()}, nil, nil, nil, nil, nil, millionstypes.PoolState_Unspecified) + err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, []string{pool.Validators[0].GetOperatorAddress(), pool.Validators[2].GetOperatorAddress(), pool.Validators[4].GetOperatorAddress()}, nil, nil, nil, nil, nil, millionstypes.PoolState_Unspecified, nil) suite.Require().NoError(err) pool, err = app.MillionsKeeper.GetPool(ctx, 1) suite.Require().NoError(err) @@ -1067,7 +1075,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { suite.Require().Equal(true, pool.Validators[4].IsEnabled) // UpdatePool with new params - err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Paused) + err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Paused, newFees) suite.Require().NoError(err) pool, err = app.MillionsKeeper.GetPool(ctx, 1) suite.Require().NoError(err) @@ -1083,9 +1091,11 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { suite.Require().Equal(newPrizeStrategy, pool.PrizeStrategy) // New draw schedule applied suite.Require().Equal(newDrawSchedule, pool.DrawSchedule) + // New fees applied + suite.Require().Equal(len(newFees), len(pool.FeeTakers)) // UpdatePool with invalid pool_state -> PoolState_Killed - err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Killed) + err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Killed, newFees) suite.Require().ErrorIs(err, millionstypes.ErrPoolStateChangeNotAllowed) // Grab fresh pool instance pool, err = app.MillionsKeeper.GetPool(ctx, 1) @@ -1094,7 +1104,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { // UpdatePool with invalid pool_state -> PoolState_Unspecified // Should remain with the current poolState - err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Unspecified) + err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Unspecified, nil) suite.Require().NoError(err) // Grab fresh pool instance pool, err = app.MillionsKeeper.GetPool(ctx, 1) @@ -1102,7 +1112,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { suite.Require().Equal(millionstypes.PoolState_Paused, pool.State) // UpdatePool with valid pool_state -> PoolState_Ready - err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Ready) + err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Ready, newFees) suite.Require().NoError(err) // Grab fresh pool instance pool, err = app.MillionsKeeper.GetPool(ctx, 1) @@ -1188,7 +1198,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { suite.Require().Equal(sdk.NewInt(1_000_000), pool.Validators[4].BondedAmount) // Simulate validator 1 that gets removed from the valSet - err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, []string{pool.Validators[1].GetOperatorAddress(), pool.Validators[2].GetOperatorAddress(), pool.Validators[3].GetOperatorAddress(), pool.Validators[4].GetOperatorAddress()}, nil, nil, nil, nil, nil, millionstypes.PoolState_Unspecified) + err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, []string{pool.Validators[1].GetOperatorAddress(), pool.Validators[2].GetOperatorAddress(), pool.Validators[3].GetOperatorAddress(), pool.Validators[4].GetOperatorAddress()}, nil, nil, nil, nil, nil, millionstypes.PoolState_Unspecified, nil) suite.Require().Error(err) // No active channel for this owner pool, err = app.MillionsKeeper.GetPool(ctx, 2) diff --git a/x/millions/keeper/keeper_test.go b/x/millions/keeper/keeper_test.go index cb241da2..62223acf 100644 --- a/x/millions/keeper/keeper_test.go +++ b/x/millions/keeper/keeper_test.go @@ -4,6 +4,8 @@ import ( "testing" "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/suite" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -78,7 +80,6 @@ func (suite *KeeperTestSuite) SetupTest() { MinDrawScheduleDelta: 1 * time.Hour, MaxDrawScheduleDelta: 366 * 24 * time.Hour, PrizeExpirationDelta: 30 * 24 * time.Hour, - FeesStakers: sdk.ZeroDec(), MinDepositDrawDelta: millionstypes.MinAcceptableDepositDrawDelta, }) } @@ -186,6 +187,11 @@ func newValidPool(suite *KeeperTestSuite, pool millionstypes.Pool) *millionstype if pool.State == millionstypes.PoolState_Unspecified { pool.State = millionstypes.PoolState_Ready } + if len(pool.FeeTakers) == 0 { + pool.FeeTakers = []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } + } if pool.CreatedAt.IsZero() { pool.CreatedAt = suite.ctx.BlockTime() } diff --git a/x/millions/keeper/keeper_withdrawal.go b/x/millions/keeper/keeper_withdrawal.go index 22c64a24..f78fefe9 100644 --- a/x/millions/keeper/keeper_withdrawal.go +++ b/x/millions/keeper/keeper_withdrawal.go @@ -416,3 +416,14 @@ func (k Keeper) ListPoolWithdrawals(ctx sdk.Context, poolID uint64) (withdrawals } return } + +func (k Keeper) UnsafeSetUnpersistedWithdrawals(ctx sdk.Context) int { + i := 0 + for _, withdrawal := range k.ListWithdrawals(ctx) { + k.setPoolWithdrawal(ctx, withdrawal) + k.setAccountWithdrawal(ctx, withdrawal) + i++ + } + + return i +} diff --git a/x/millions/keeper/keeper_withdrawal_test.go b/x/millions/keeper/keeper_withdrawal_test.go index 4105ef9a..839b055c 100644 --- a/x/millions/keeper/keeper_withdrawal_test.go +++ b/x/millions/keeper/keeper_withdrawal_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -74,6 +76,9 @@ func (suite *KeeperTestSuite) TestWithdrawal_AddWithdrawal() { sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), millionstypes.DrawSchedule{DrawDelta: 24 * time.Hour, InitialDrawAt: ctx.BlockTime().Add(24 * time.Hour)}, millionstypes.PrizeStrategy{PrizeBatches: []millionstypes.PrizeBatch{{PoolPercent: 100, Quantity: 100, DrawProbability: sdk.NewDec(1)}}}, + []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, ) suite.Require().NoError(err) _, err = app.MillionsKeeper.GetPool(ctx, poolID) diff --git a/x/millions/keeper/msg_server_deposit.go b/x/millions/keeper/msg_server_deposit.go index 67e80c5a..52fbd284 100644 --- a/x/millions/keeper/msg_server_deposit.go +++ b/x/millions/keeper/msg_server_deposit.go @@ -4,6 +4,7 @@ import ( "context" "strconv" "strings" + "time" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -135,7 +136,13 @@ func (k msgServer) DepositRetry(goCtx context.Context, msg *types.MsgDepositRetr } newState := types.DepositState_Unspecified - if deposit.ErrorState == types.DepositState_IbcTransfer { + if deposit.State == types.DepositState_IbcTransfer && ctx.BlockTime().After(deposit.UpdatedAt.Add(2*types.IBCTimeoutNanos*time.Nanosecond)) { + // Handle IBC stucked operation for more than twice the specified IBC timeout + newState = types.DepositState_IbcTransfer + if err := k.TransferDepositToRemoteZone(ctx, deposit.PoolId, deposit.DepositId); err != nil { + return nil, err + } + } else if deposit.ErrorState == types.DepositState_IbcTransfer { newState = types.DepositState_IbcTransfer k.UpdateDepositStatus(ctx, deposit.PoolId, deposit.DepositId, newState, false) if err := k.TransferDepositToRemoteZone(ctx, deposit.PoolId, deposit.DepositId); err != nil { diff --git a/x/millions/keeper/msg_server_pool.go b/x/millions/keeper/msg_server_pool.go index 58144c44..45bbdc8a 100644 --- a/x/millions/keeper/msg_server_pool.go +++ b/x/millions/keeper/msg_server_pool.go @@ -82,6 +82,7 @@ func (k msgServer) restoreICADepositEntities(ctx sdk.Context, poolID uint64) { d.ErrorState = d.State d.State = types.DepositState_Failure k.Keeper.setPoolDeposit(ctx, &d) + k.Keeper.setAccountDeposit(ctx, &d) } } // Restore withdrawals ICA locked operations on ICADeposit account @@ -91,6 +92,7 @@ func (k msgServer) restoreICADepositEntities(ctx sdk.Context, poolID uint64) { w.ErrorState = w.State w.State = types.WithdrawalState_Failure k.Keeper.setPoolWithdrawal(ctx, w) + k.Keeper.setAccountWithdrawal(ctx, w) } } // Restore draws ICA locked operations on ICADeposit account diff --git a/x/millions/keeper/msg_server_test.go b/x/millions/keeper/msg_server_test.go index 67a42fae..bedae1dc 100644 --- a/x/millions/keeper/msg_server_test.go +++ b/x/millions/keeper/msg_server_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "time" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" gogotypes "github.com/cosmos/gogoproto/types" @@ -327,6 +329,9 @@ func (suite *KeeperTestSuite) TestMsgServer_Deposit() { sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), millionstypes.DrawSchedule{DrawDelta: 24 * time.Hour, InitialDrawAt: ctx.BlockTime().Add(24 * time.Hour)}, millionstypes.PrizeStrategy{PrizeBatches: []millionstypes.PrizeBatch{{PoolPercent: 100, Quantity: 100, DrawProbability: sdk.NewDec(1)}}}, + []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, ) suite.Require().NoError(err) _, err = app.MillionsKeeper.GetPool(ctx, poolID) @@ -448,6 +453,9 @@ func (suite *KeeperTestSuite) TestMsgServer_DepositRetry() { sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), millionstypes.DrawSchedule{DrawDelta: 24 * time.Hour, InitialDrawAt: ctx.BlockTime().Add(24 * time.Hour)}, millionstypes.PrizeStrategy{PrizeBatches: []millionstypes.PrizeBatch{{PoolPercent: 100, Quantity: 100, DrawProbability: sdk.NewDec(1)}}}, + []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, ) suite.Require().NoError(err) _, err = app.MillionsKeeper.GetPool(ctx, poolID) @@ -797,6 +805,9 @@ func (suite *KeeperTestSuite) TestMsgServer_WithdrawDeposit() { sdk.NewInt(millionstypes.DefaultMaxUnbondingEntries), millionstypes.DrawSchedule{DrawDelta: 24 * time.Hour, InitialDrawAt: ctx.BlockTime().Add(24 * time.Hour)}, millionstypes.PrizeStrategy{PrizeBatches: []millionstypes.PrizeBatch{{PoolPercent: 100, Quantity: 100, DrawProbability: sdk.NewDec(1)}}}, + []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + }, ) suite.Require().NoError(err) _, err = app.MillionsKeeper.GetPool(ctx, poolID) diff --git a/x/millions/migrations/migrator.go b/x/millions/migrations/migrator.go index 1f7e7394..c851a8b8 100644 --- a/x/millions/migrations/migrator.go +++ b/x/millions/migrations/migrator.go @@ -3,6 +3,8 @@ package migrations import ( sdk "github.com/cosmos/cosmos-sdk/types" + v164 "github.com/lum-network/chain/x/millions/migrations/v164" + millionskeeper "github.com/lum-network/chain/x/millions/keeper" v150 "github.com/lum-network/chain/x/millions/migrations/v150" v152 "github.com/lum-network/chain/x/millions/migrations/v152" @@ -37,3 +39,16 @@ func (m Migrator) Migrate3To4(ctx sdk.Context) error { func (m Migrator) Migrate4To5(ctx sdk.Context) error { return v162.MigratePendingWithdrawalsToNewEpochUnbonding(ctx, m.keeper) } + +// Migrate5To6 migrates from version 5 to 6 +func (m Migrator) Migrate5To6(ctx sdk.Context) error { + if err := v164.SaveEntitiesOnAccountLevel(ctx, m.keeper); err != nil { + return err + } + + if err := v164.InitializePoolFeeTakers(ctx, m.keeper); err != nil { + return err + } + + return nil +} diff --git a/x/millions/migrations/v150/store_test.go b/x/millions/migrations/v150/store_test.go index 6d59bf6e..7f348d5c 100644 --- a/x/millions/migrations/v150/store_test.go +++ b/x/millions/migrations/v150/store_test.go @@ -148,7 +148,6 @@ func (suite *StoreMigrationTestSuite) SetupTest() { MinDrawScheduleDelta: 1 * time.Hour, MaxDrawScheduleDelta: 366 * 24 * time.Hour, PrizeExpirationDelta: 30 * 24 * time.Hour, - FeesStakers: sdk.ZeroDec(), MinDepositDrawDelta: millionstypes.MinAcceptableDepositDrawDelta, }) } diff --git a/x/millions/migrations/v152/store_test.go b/x/millions/migrations/v152/store_test.go index 783425be..67d5b7e3 100644 --- a/x/millions/migrations/v152/store_test.go +++ b/x/millions/migrations/v152/store_test.go @@ -149,7 +149,6 @@ func (suite *StoreMigrationTestSuite) SetupTest() { MinDrawScheduleDelta: 1 * time.Hour, MaxDrawScheduleDelta: 366 * 24 * time.Hour, PrizeExpirationDelta: 30 * 24 * time.Hour, - FeesStakers: sdk.ZeroDec(), MinDepositDrawDelta: millionstypes.MinAcceptableDepositDrawDelta, }) } diff --git a/x/millions/migrations/v161/store_test.go b/x/millions/migrations/v161/store_test.go index 9a553495..11508760 100644 --- a/x/millions/migrations/v161/store_test.go +++ b/x/millions/migrations/v161/store_test.go @@ -149,7 +149,6 @@ func (suite *StoreMigrationTestSuite) SetupTest() { MinDrawScheduleDelta: 1 * time.Hour, MaxDrawScheduleDelta: 366 * 24 * time.Hour, PrizeExpirationDelta: 30 * 24 * time.Hour, - FeesStakers: sdk.ZeroDec(), MinDepositDrawDelta: millionstypes.MinAcceptableDepositDrawDelta, }) } diff --git a/x/millions/migrations/v162/store_test.go b/x/millions/migrations/v162/store_test.go index dd49ce94..403fecc2 100644 --- a/x/millions/migrations/v162/store_test.go +++ b/x/millions/migrations/v162/store_test.go @@ -178,7 +178,6 @@ func (suite *StoreMigrationTestSuite) SetupTest() { MinDrawScheduleDelta: 1 * time.Hour, MaxDrawScheduleDelta: 366 * 24 * time.Hour, PrizeExpirationDelta: 30 * 24 * time.Hour, - FeesStakers: sdk.ZeroDec(), MinDepositDrawDelta: millionstypes.MinAcceptableDepositDrawDelta, }) } diff --git a/x/millions/migrations/v164/store.go b/x/millions/migrations/v164/store.go new file mode 100644 index 00000000..c4966d2f --- /dev/null +++ b/x/millions/migrations/v164/store.go @@ -0,0 +1,39 @@ +package v164 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + millionskeeper "github.com/lum-network/chain/x/millions/keeper" + + millionstypes "github.com/lum-network/chain/x/millions/types" +) + +func SaveEntitiesOnAccountLevel(ctx sdk.Context, k millionskeeper.Keeper) error { + ctx.Logger().Info("Saving entities on account level") + + updatedDeposits := k.UnsafeSetUnpersistedDeposits(ctx) + updatedWithdrawals := k.UnsafeSetUnpersistedWithdrawals(ctx) + + ctx.Logger().Info("Saving entities on account level: deposits", "count", updatedDeposits) + ctx.Logger().Info("Saving entities on account level: withdrawals", "count", updatedWithdrawals) + return nil +} + +func InitializePoolFeeTakers(ctx sdk.Context, k millionskeeper.Keeper) error { + ctx.Logger().Info("Initializing pool fee takers...") + + defaultFeeTakers := []millionstypes.FeeTaker{ + {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, + } + + k.IteratePools(ctx, func(pool millionstypes.Pool) bool { + if _, err := k.UnsafeUpdatePoolFeeTakers(ctx, pool.GetPoolId(), defaultFeeTakers); err != nil { + panic(err) + } + return false + }) + + ctx.Logger().Info("Migration of pool fee takers completed successfully") + return nil +} diff --git a/x/millions/module.go b/x/millions/module.go index ca47fb99..e825bb3a 100644 --- a/x/millions/module.go +++ b/x/millions/module.go @@ -145,6 +145,11 @@ func (a AppModule) RegisterServices(cfg module.Configurator) { if err != nil { panic(err) } + + err = cfg.RegisterMigration(types.ModuleName, 5, migrator.Migrate5To6) + if err != nil { + panic(err) + } } func (a AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/millions/types/errors.go b/x/millions/types/errors.go index 5e84290f..cabb6bf5 100644 --- a/x/millions/types/errors.go +++ b/x/millions/types/errors.go @@ -53,4 +53,8 @@ var ( ErrInvalidEpochTracker = errorsmod.Register(ModuleName, 1700, "Invalid epoch tracker") ErrInvalidEpochUnbonding = errorsmod.Register(ModuleName, 1701, "Invalid epoch unbonding") ErrInvalidEpochField = errorsmod.Register(ModuleName, 1702, "Invalid epoch field") + ErrInvalidFeeTakerDestination = errorsmod.Register(ModuleName, 1800, "Invalid fee taker destination") + ErrInvalidFeeTakerType = errorsmod.Register(ModuleName, 1801, "Invalid fee taker type") + ErrInvalidFeeTakerAmount = errorsmod.Register(ModuleName, 1802, "Invalid fee taker amount") + ErrInvalidFeeTakersTotalAmount = errorsmod.Register(ModuleName, 1803, "Invalid fee takers total amount (cannot exceed 100%)") ) diff --git a/x/millions/types/fee_manager.go b/x/millions/types/fee_manager.go new file mode 100644 index 00000000..74d312ab --- /dev/null +++ b/x/millions/types/fee_manager.go @@ -0,0 +1,5 @@ +package types + +const ( + DefaultFeeTakerAmount = 10 // 10% +) diff --git a/x/millions/types/fee_taker.go b/x/millions/types/fee_taker.go new file mode 100644 index 00000000..4597535c --- /dev/null +++ b/x/millions/types/fee_taker.go @@ -0,0 +1,41 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type FeeTakers []FeeTaker + +func (feetaker *FeeTaker) ValidateBasic() error { + if feetaker.Destination == "" { + return ErrInvalidFeeTakerDestination + } + + if feetaker.Amount.IsZero() || feetaker.Amount.IsNegative() { + return ErrInvalidFeeTakerAmount + } + + if feetaker.Type == FeeTakerType_Unspecified { + return ErrInvalidFeeTakerType + } + + return nil +} + +func (feetakers FeeTakers) ValidateBasic() error { + totalFeePercentage := sdk.ZeroDec() + for _, feetaker := range feetakers { + if err := feetaker.ValidateBasic(); err != nil { + return err + } + totalFeePercentage = totalFeePercentage.Add(feetaker.Amount) + } + + if totalFeePercentage.GT(sdk.OneDec()) { + return ErrInvalidFeeTakersTotalAmount + } + + return nil +} + +func ValidateFeeTakers(feeTakers []FeeTaker) error { + return FeeTakers(feeTakers).ValidateBasic() +} diff --git a/x/millions/types/gov.pb.go b/x/millions/types/gov.pb.go index 12298842..813d1d74 100644 --- a/x/millions/types/gov.pb.go +++ b/x/millions/types/gov.pb.go @@ -46,6 +46,7 @@ type ProposalRegisterPool struct { UnbondingDuration time.Duration `protobuf:"bytes,14,opt,name=unbonding_duration,json=unbondingDuration,proto3,stdduration" json:"unbonding_duration"` MaxUnbondingEntries github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,15,opt,name=max_unbonding_entries,json=maxUnbondingEntries,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_unbonding_entries"` PoolType PoolType `protobuf:"varint,16,opt,name=pool_type,json=poolType,proto3,enum=lum.network.millions.PoolType" json:"pool_type,omitempty"` + FeeTakers []FeeTaker `protobuf:"bytes,17,rep,name=fee_takers,json=feeTakers,proto3" json:"fee_takers"` } func (m *ProposalRegisterPool) Reset() { *m = ProposalRegisterPool{} } @@ -178,6 +179,13 @@ func (m *ProposalRegisterPool) GetPoolType() PoolType { return PoolType_Unspecified } +func (m *ProposalRegisterPool) GetFeeTakers() []FeeTaker { + if m != nil { + return m.FeeTakers + } + return nil +} + type ProposalUpdatePool struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` @@ -189,6 +197,7 @@ type ProposalUpdatePool struct { State PoolState `protobuf:"varint,8,opt,name=state,proto3,enum=lum.network.millions.PoolState" json:"state,omitempty"` UnbondingDuration *time.Duration `protobuf:"bytes,9,opt,name=unbonding_duration,json=unbondingDuration,proto3,stdduration" json:"unbonding_duration,omitempty"` MaxUnbondingEntries *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=max_unbonding_entries,json=maxUnbondingEntries,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_unbonding_entries,omitempty"` + FeeTakers []FeeTaker `protobuf:"bytes,11,rep,name=fee_takers,json=feeTakers,proto3" json:"fee_takers"` } func (m *ProposalUpdatePool) Reset() { *m = ProposalUpdatePool{} } @@ -279,6 +288,13 @@ func (m *ProposalUpdatePool) GetUnbondingDuration() *time.Duration { return nil } +func (m *ProposalUpdatePool) GetFeeTakers() []FeeTaker { + if m != nil { + return m.FeeTakers + } + return nil +} + type ProposalUpdateParams struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` @@ -288,7 +304,6 @@ type ProposalUpdateParams struct { MinDrawScheduleDelta *time.Duration `protobuf:"bytes,6,opt,name=min_draw_schedule_delta,json=minDrawScheduleDelta,proto3,stdduration" json:"min_draw_schedule_delta,omitempty"` MaxDrawScheduleDelta *time.Duration `protobuf:"bytes,7,opt,name=max_draw_schedule_delta,json=maxDrawScheduleDelta,proto3,stdduration" json:"max_draw_schedule_delta,omitempty"` PrizeExpirationDelta *time.Duration `protobuf:"bytes,8,opt,name=prize_expiration_delta,json=prizeExpirationDelta,proto3,stdduration" json:"prize_expiration_delta,omitempty"` - FeesStakers *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=fees_stakers,json=feesStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fees_stakers,omitempty"` MinDepositDrawDelta *time.Duration `protobuf:"bytes,10,opt,name=min_deposit_draw_delta,json=minDepositDrawDelta,proto3,stdduration" json:"min_deposit_draw_delta,omitempty"` } @@ -375,66 +390,67 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/gov.proto", fileDescriptor_f51755d1062ffc9e) } var fileDescriptor_f51755d1062ffc9e = []byte{ - // 931 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcf, 0x4f, 0xe3, 0x46, - 0x14, 0x8e, 0x4b, 0xc8, 0x8f, 0x21, 0xd0, 0xdd, 0x21, 0x0b, 0x5e, 0x0e, 0x4e, 0xca, 0x56, 0x55, - 0x7a, 0xc0, 0x91, 0x40, 0xbd, 0xb4, 0x27, 0x68, 0x56, 0x55, 0x0e, 0x95, 0xb2, 0xa6, 0x5b, 0xb5, - 0xab, 0x4a, 0xd6, 0xc4, 0x33, 0x38, 0x23, 0xec, 0x19, 0x77, 0x66, 0x0c, 0xa1, 0x7f, 0x45, 0x8f, - 0x7b, 0xec, 0x9f, 0xc3, 0x71, 0x8f, 0x55, 0x0f, 0xdb, 0x0a, 0xfe, 0x8c, 0x1e, 0x5a, 0xcd, 0x8c, - 0x43, 0x92, 0x12, 0x54, 0xc2, 0x72, 0x22, 0x33, 0xef, 0x7b, 0xdf, 0x7b, 0x7e, 0xef, 0xfb, 0x8c, - 0x81, 0x97, 0xe4, 0x69, 0x97, 0x11, 0x75, 0xce, 0xc5, 0x69, 0x37, 0xa5, 0x49, 0x42, 0x39, 0x93, - 0xdd, 0x98, 0x9f, 0xf9, 0x99, 0xe0, 0x8a, 0xc3, 0x66, 0x92, 0xa7, 0x7e, 0x11, 0xf7, 0x27, 0xf1, - 0x9d, 0x66, 0xcc, 0x63, 0x6e, 0x00, 0x5d, 0xfd, 0xcb, 0x62, 0x77, 0xbc, 0x98, 0xf3, 0x38, 0x21, - 0x5d, 0x73, 0x1a, 0xe6, 0x27, 0x5d, 0x9c, 0x0b, 0xa4, 0x28, 0x67, 0x45, 0xbc, 0xb5, 0xb0, 0x56, - 0xc6, 0x79, 0x52, 0x00, 0x3a, 0x0b, 0x01, 0x58, 0xa0, 0xf3, 0x50, 0x46, 0x23, 0x82, 0xf3, 0x84, - 0x14, 0xc8, 0xcf, 0x17, 0x53, 0x09, 0xfa, 0x0b, 0x09, 0xa5, 0x12, 0x48, 0x91, 0xf8, 0xc2, 0x42, - 0x77, 0xff, 0xae, 0x80, 0xe6, 0x40, 0xf0, 0x8c, 0x4b, 0x94, 0x04, 0x24, 0xa6, 0x52, 0x11, 0x31, - 0xe0, 0x3c, 0x81, 0x4d, 0xb0, 0xaa, 0xa8, 0x4a, 0x88, 0xeb, 0xb4, 0x9d, 0x4e, 0x3d, 0xb0, 0x07, - 0xd8, 0x06, 0x6b, 0x98, 0xc8, 0x48, 0xd0, 0x4c, 0x77, 0xee, 0x7e, 0x64, 0x62, 0xb3, 0x57, 0xf0, - 0x39, 0xa8, 0x45, 0x23, 0x44, 0x59, 0x48, 0xb1, 0xbb, 0x62, 0xc2, 0x55, 0x73, 0xee, 0x63, 0x4d, - 0x89, 0x09, 0xe3, 0xa9, 0x5b, 0xb6, 0x94, 0xe6,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 0xa0, 0xae, 0x2d, 0x41, 0x6d, - 0x28, 0x5e, 0xde, 0x30, 0x58, 0xea, 0x57, 0xa0, 0x71, 0x42, 0x88, 0x0c, 0xa5, 0x42, 0xa7, 0x44, - 0x48, 0xe3, 0xa7, 0xe5, 0xe6, 0xdd, 0x23, 0x51, 0xb0, 0xa6, 0x39, 0x8e, 0x2d, 0x05, 0xfc, 0x01, - 0x6c, 0xcd, 0x2a, 0xd3, 0x4c, 0xc4, 0x76, 0x0b, 0xee, 0xdf, 0xed, 0xe6, 0x54, 0x92, 0x7a, 0x1e, - 0xa6, 0x59, 0x6b, 0xa5, 0xa3, 0x6f, 0x2e, 0xaf, 0x3c, 0xe7, 0xdd, 0x95, 0xe7, 0xfc, 0x75, 0xe5, - 0x39, 0xbf, 0x5e, 0x7b, 0xa5, 0x77, 0xd7, 0x5e, 0xe9, 0xf7, 0x6b, 0xaf, 0xf4, 0x66, 0x6f, 0xa6, - 0xdd, 0x24, 0x4f, 0xf7, 0x26, 0x9f, 0x66, 0xe6, 0xc3, 0xa8, 0x3b, 0x9e, 0x7e, 0xa2, 0x99, 0xce, - 0x87, 0x15, 0xd3, 0xc0, 0xc1, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x74, 0x37, 0xef, 0x7e, - 0x0a, 0x00, 0x00, + // 948 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6f, 0x23, 0x35, + 0x14, 0xc7, 0x3b, 0x34, 0x69, 0x12, 0xf7, 0x07, 0xad, 0x9b, 0x6d, 0x67, 0x7b, 0x98, 0x84, 0x2e, + 0x42, 0xe1, 0xd0, 0x89, 0xd4, 0x8a, 0x0b, 0x9c, 0xda, 0xcd, 0x82, 0x82, 0x84, 0x14, 0xa6, 0xbb, + 0x08, 0x56, 0x48, 0x23, 0x67, 0xec, 0x4c, 0xac, 0xce, 0xd8, 0x83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9e, 0x16, 0xd2, 0x02, 0xb8, 0x9e, 0x4d, 0x6f, + 0xc2, 0x23, 0xb0, 0xd3, 0x27, 0xd1, 0xf0, 0xe8, 0x30, 0xcc, 0x04, 0x19, 0xd0, 0x51, 0x88, 0xa2, + 0x28, 0x44, 0x18, 0x0b, 0x77, 0xd5, 0x5c, 0xe6, 0xb6, 0x8d, 0xf6, 0x4c, 0xf0, 0x38, 0x8a, 0x8e, + 0x31, 0x16, 0xb7, 0x93, 0xce, 0x51, 0x62, 0x93, 0xd6, 0x6e, 0x27, 0x7d, 0x87, 0x12, 0x93, 0xe4, + 0x83, 0x6d, 0x25, 0x10, 0x93, 0x03, 0x22, 0xc2, 0x68, 0x88, 0x18, 0x23, 0x89, 0xee, 0xd9, 0xba, + 0xc9, 0xd8, 0x1a, 0x87, 0x9e, 0xda, 0x48, 0x17, 0xc3, 0x00, 0xc0, 0x9c, 0xf5, 0x39, 0xc3, 0x94, + 0xc5, 0xe1, 0xd8, 0x14, 0xee, 0x86, 0x79, 0xde, 0xc7, 0xbe, 0x75, 0x8d, 0x3f, 0x76, 0x8d, 0xdf, + 0x29, 0x04, 0x27, 0x55, 0xfd, 0x94, 0xaf, 0xfe, 0x6a, 0x38, 0xc1, 0xd6, 0x4d, 0xfa, 0x38, 0x08, + 0xfb, 0xe0, 0x51, 0x8a, 0x46, 0xe1, 0x84, 0x4b, 0x98, 0x12, 0x94, 0x48, 0xf7, 0xc3, 0x07, 0xf5, + 0x7b, 0x3b, 0x45, 0xa3, 0x17, 0x63, 0xd6, 0x33, 0x8b, 0x82, 0x5f, 0x80, 0x9a, 0x76, 0x67, 0xa8, + 0x65, 0xee, 0x66, 0xd3, 0x69, 0x6d, 0x1c, 0x7a, 0x77, 0xb4, 0x87, 0xf3, 0xe4, 0xf9, 0x65, 0x46, + 0x82, 0x6a, 0x56, 0xfc, 0x82, 0x4f, 0x01, 0x18, 0x10, 0x12, 0x2a, 0x74, 0x46, 0x84, 0x74, 0xb7, + 0x9a,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, 0x40, 0x6b, 0x3d, 0x1a, 0x97, 0x32, 0x25, 0xbe, + 0x2d, 0x60, 0xf0, 0x25, 0xd8, 0x35, 0x77, 0x36, 0xed, 0xb1, 0x10, 0x93, 0x44, 0xa1, 0xc2, 0x69, + 0xf7, 0x1a, 0xc6, 0xba, 0xbe, 0xad, 0x29, 0x9f, 0x75, 0x34, 0xc0, 0xb0, 0xd1, 0x68, 0x2e, 0xbb, + 0xb2, 0x08, 0x1b, 0x8d, 0x6e, 0xb3, 0x7f, 0x00, 0x3b, 0xf6, 0x72, 0xc8, 0x28, 0xa3, 0x36, 0xa7, + 0x40, 0x57, 0x17, 0x40, 0x1b, 0xc4, 0xb3, 0x1b, 0x82, 0x45, 0x7f, 0x0f, 0x76, 0xa6, 0xc7, 0xc8, + 0x1c, 0xdf, 0xa2, 0xc1, 0xfd, 0xd1, 0xdb, 0x93, 0xf9, 0xd1, 0x87, 0x37, 0x64, 0x3b, 0xf7, 0x5f, + 0x97, 0xaa, 0xb5, 0x4d, 0x70, 0xf2, 0xd5, 0xeb, 0x2b, 0xcf, 0x79, 0x73, 0xe5, 0x39, 0x7f, 0x5f, + 0x79, 0xce, 0x2f, 0xd7, 0xde, 0xd2, 0x9b, 0x6b, 0x6f, 0xe9, 0x8f, 0x6b, 0x6f, 0xe9, 0xe5, 0xc1, + 0x54, 0x47, 0x93, 0x3c, 0x3d, 0x18, 0x7f, 0xd7, 0x99, 0xaf, 0xaa, 0xf6, 0x68, 0xf2, 0x7d, 0x67, + 0x9a, 0xdb, 0x5f, 0x31, 0xc7, 0x38, 0xfa, 0x37, 0x00, 0x00, 0xff, 0xff, 0xc0, 0xbc, 0xfd, 0x77, + 0xbb, 0x0a, 0x00, 0x00, } func (m *ProposalRegisterPool) Marshal() (dAtA []byte, err error) { @@ -457,6 +473,22 @@ func (m *ProposalRegisterPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.FeeTakers) > 0 { + for iNdEx := len(m.FeeTakers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeTakers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + } if m.PoolType != 0 { i = encodeVarintGov(dAtA, i, uint64(m.PoolType)) i-- @@ -607,6 +639,20 @@ func (m *ProposalUpdatePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.FeeTakers) > 0 { + for iNdEx := len(m.FeeTakers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeTakers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + } if m.MaxUnbondingEntries != nil { { size := m.MaxUnbondingEntries.Size() @@ -731,18 +777,6 @@ func (m *ProposalUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 } - if m.FeesStakers != nil { - { - size := m.FeesStakers.Size() - i -= size - if _, err := m.FeesStakers.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGov(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } if m.PrizeExpirationDelta != nil { n8, err8 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(*m.PrizeExpirationDelta, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(*m.PrizeExpirationDelta):]) if err8 != nil { @@ -898,6 +932,12 @@ func (m *ProposalRegisterPool) Size() (n int) { if m.PoolType != 0 { n += 2 + sovGov(uint64(m.PoolType)) } + if len(m.FeeTakers) > 0 { + for _, e := range m.FeeTakers { + l = e.Size() + n += 2 + l + sovGov(uint64(l)) + } + } return n } @@ -947,6 +987,12 @@ func (m *ProposalUpdatePool) Size() (n int) { l = m.MaxUnbondingEntries.Size() n += 1 + l + sovGov(uint64(l)) } + if len(m.FeeTakers) > 0 { + for _, e := range m.FeeTakers { + l = e.Size() + n += 1 + l + sovGov(uint64(l)) + } + } return n } @@ -988,10 +1034,6 @@ func (m *ProposalUpdateParams) Size() (n int) { l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(*m.PrizeExpirationDelta) n += 1 + l + sovGov(uint64(l)) } - if m.FeesStakers != nil { - l = m.FeesStakers.Size() - n += 1 + l + sovGov(uint64(l)) - } if m.MinDepositDrawDelta != nil { l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(*m.MinDepositDrawDelta) n += 1 + l + sovGov(uint64(l)) @@ -1540,6 +1582,40 @@ func (m *ProposalRegisterPool) Unmarshal(dAtA []byte) error { break } } + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeTakers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeTakers = append(m.FeeTakers, FeeTaker{}) + if err := m.FeeTakers[len(m.FeeTakers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGov(dAtA[iNdEx:]) @@ -1904,6 +1980,40 @@ func (m *ProposalUpdatePool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeTakers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeTakers = append(m.FeeTakers, FeeTaker{}) + if err := m.FeeTakers[len(m.FeeTakers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGov(dAtA[iNdEx:]) @@ -2234,42 +2344,6 @@ func (m *ProposalUpdateParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeesStakers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_cosmos_cosmos_sdk_types.Dec - m.FeesStakers = &v - if err := m.FeesStakers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinDepositDrawDelta", wireType) diff --git a/x/millions/types/keys.go b/x/millions/types/keys.go index cc9a3e4e..8e7bab32 100644 --- a/x/millions/types/keys.go +++ b/x/millions/types/keys.go @@ -14,7 +14,7 @@ import ( const ( ModuleName = "millions" - ModuleVersion = 5 + ModuleVersion = 6 StoreKey = ModuleName diff --git a/x/millions/types/params.go b/x/millions/types/params.go index e9273e51..6ab396e6 100644 --- a/x/millions/types/params.go +++ b/x/millions/types/params.go @@ -12,7 +12,6 @@ const ( MinAcceptableDrawDelta = 1 * time.Hour MinAcceptableDepositDrawDelta = 1 * time.Minute MinAcceptablePrizeExpirationDelta = 1 * time.Hour - MaxAcceptableFeesStakers = 50 // 50% defaultMinDepositAmount = 100_000 defaultMaxPrizeStrategyBatches = 10 @@ -20,7 +19,6 @@ const ( defaultMinDrawScheduleDelta = 1 * time.Hour defaultMaxDrawScheduleDelta = 366 * 24 * time.Hour // 366 days defaultPrizeExpirationDelta = 30 * 24 * time.Hour // 30 days - defaultFeesStakers = 10 // 10% defaultMinDepositDrawDelta = 5 * time.Minute ) @@ -32,7 +30,6 @@ func DefaultParams() Params { MinDrawScheduleDelta: defaultMinDrawScheduleDelta, MaxDrawScheduleDelta: defaultMaxDrawScheduleDelta, PrizeExpirationDelta: defaultPrizeExpirationDelta, - FeesStakers: sdk.NewDecWithPrec(defaultFeesStakers, 2), MinDepositDrawDelta: defaultMinDepositDrawDelta, } } @@ -61,11 +58,6 @@ func (p *Params) ValidateBasics() error { if p.PrizeExpirationDelta < MinAcceptablePrizeExpirationDelta { return errorsmod.Wrapf(ErrInvalidParams, "prize clawback delta must be gte %s, got: %s", MinAcceptablePrizeExpirationDelta.String(), p.PrizeExpirationDelta.String()) } - if p.FeesStakers.IsNil() { - return errorsmod.Wrapf(ErrInvalidParams, "stakers fees required") - } else if p.FeesStakers.LT(sdk.NewDec(0)) || p.FeesStakers.GT(sdk.NewDecWithPrec(MaxAcceptableFeesStakers, 2)) { - return errorsmod.Wrapf(ErrInvalidParams, "stakers fees must be gte 0 and lte %d/100, got: %f", MaxAcceptableFeesStakers, p.FeesStakers.MustFloat64()) - } if p.MinDepositDrawDelta < MinAcceptableDepositDrawDelta { return errorsmod.Wrapf(ErrInvalidParams, "min deposit draw delta must be gte %s, got: %s", MinAcceptableDepositDrawDelta.String(), p.MinDepositDrawDelta.String()) } diff --git a/x/millions/types/params.pb.go b/x/millions/types/params.pb.go index 7c8f806d..4bbbe158 100644 --- a/x/millions/types/params.pb.go +++ b/x/millions/types/params.pb.go @@ -48,9 +48,6 @@ type Params struct { // prize_expiration_delta the prize clawback expiration delta (common to all // pools) PrizeExpirationDelta time.Duration `protobuf:"bytes,6,opt,name=prize_expiration_delta,json=prizeExpirationDelta,proto3,stdduration" json:"prize_expiration_delta"` - // fees_stakers the fees distributed by stakers over prize won (common to all - // pools) - FeesStakers github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=fees_stakers,json=feesStakers,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fees_stakers"` // min_deposit_draw_delta the minimum delta before a draw for a deposit to be // accepted during the time weighted balance computation for a draw MinDepositDrawDelta time.Duration `protobuf:"bytes,8,opt,name=min_deposit_draw_delta,json=minDepositDrawDelta,proto3,stdduration" json:"min_deposit_draw_delta"` @@ -138,36 +135,35 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/params.proto", fileDescriptor_1f37cb471281f845) } var fileDescriptor_1f37cb471281f845 = []byte{ - // 463 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x3f, 0x8f, 0xd3, 0x30, - 0x18, 0xc6, 0x1b, 0xb8, 0x2b, 0x87, 0x8f, 0x01, 0x85, 0x72, 0x17, 0x3a, 0xa4, 0x85, 0x01, 0x75, - 0xa9, 0x2d, 0xc1, 0xc0, 0xc0, 0x44, 0x55, 0x84, 0xd8, 0xee, 0xda, 0x05, 0x4e, 0x48, 0x96, 0x9b, - 0xf8, 0x52, 0xab, 0xb1, 0x1d, 0xfc, 0x47, 0x4d, 0xf9, 0x14, 0x8c, 0x0c, 0x7c, 0xa0, 0x1b, 0x6f, - 0x44, 0x0c, 0x07, 0x6a, 0xbf, 0x08, 0x8a, 0x9d, 0xd0, 0x4a, 0x30, 0x5c, 0xa7, 0x36, 0x7a, 0x9f, - 0xe7, 0x97, 0xe7, 0x7d, 0x62, 0x83, 0xa7, 0xb9, 0xe5, 0x48, 0x50, 0xb3, 0x94, 0x6a, 0x81, 0x38, - 0xcb, 0x73, 0x26, 0x85, 0x46, 0x05, 0x51, 0x84, 0x6b, 0x58, 0x28, 0x69, 0x64, 0xd8, 0xc9, 0x2d, - 0x87, 0xb5, 0x04, 0x36, 0x92, 0x6e, 0x27, 0x93, 0x99, 0x74, 0x02, 0x54, 0xfd, 0xf3, 0xda, 0x6e, - 0x9c, 0x49, 0x99, 0xe5, 0x14, 0xb9, 0xa7, 0x99, 0xbd, 0x44, 0xa9, 0x55, 0xc4, 0x30, 0x29, 0xfc, - 0xfc, 0xd9, 0xf7, 0x43, 0xd0, 0x3e, 0x73, 0xf0, 0xf0, 0x13, 0x08, 0x39, 0x13, 0x38, 0xa5, 0x85, - 0xd4, 0xcc, 0x60, 0xc2, 0xa5, 0x15, 0x26, 0x0a, 0xfa, 0xc1, 0xe0, 0xfe, 0x08, 0x5e, 0xdd, 0xf4, - 0x5a, 0x3f, 0x6f, 0x7a, 0xcf, 0x33, 0x66, 0xe6, 0x76, 0x06, 0x13, 0xc9, 0x51, 0x22, 0x35, 0x97, - 0xba, 0xfe, 0x19, 0xea, 0x74, 0x81, 0xcc, 0xaa, 0xa0, 0x1a, 0xbe, 0x17, 0x66, 0xf2, 0x90, 0x33, - 0x31, 0xf6, 0xa0, 0x37, 0x8e, 0x13, 0xbe, 0x06, 0x5d, 0x4e, 0x4a, 0x5c, 0x28, 0xf6, 0x85, 0x62, - 0x6d, 0x14, 0x31, 0x34, 0x5b, 0xe1, 0x19, 0x31, 0xc9, 0x9c, 0xea, 0xe8, 0x4e, 0x3f, 0x18, 0x1c, - 0x4c, 0x4e, 0x39, 0x29, 0xcf, 0x2a, 0xc1, 0xb4, 0x9e, 0x8f, 0xfc, 0x38, 0x7c, 0x05, 0xa2, 0xad, - 0xd9, 0x79, 0xf0, 0x67, 0x4b, 0x84, 0x61, 0x66, 0x15, 0xdd, 0x75, 0xd6, 0xc7, 0x8d, 0xd5, 0x59, - 0xce, 0xeb, 0x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08, 0xba, 0xa2, 0xd6, 0x5f, 0x03, 0x00, 0x00, + // 441 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3d, 0x6f, 0xd3, 0x40, + 0x1c, 0xc6, 0x63, 0x08, 0x21, 0x1c, 0x4b, 0x65, 0x42, 0x6b, 0x32, 0x38, 0x81, 0x01, 0x65, 0xc9, + 0x9d, 0x04, 0x03, 0x03, 0x13, 0x51, 0x10, 0x82, 0xa9, 0xa4, 0x0b, 0x54, 0x48, 0xa7, 0x8b, 0x7d, + 0x38, 0xa7, 0xde, 0x8b, 0xb9, 0x17, 0xc5, 0xe1, 0x53, 0x30, 0xf2, 0x91, 0xba, 0xd1, 0x11, 0x31, + 0x14, 0x94, 0x7c, 0x11, 0xe4, 0x3b, 0x9b, 0x54, 0x82, 0x81, 0x4e, 0xf6, 0xe9, 0xff, 0x3c, 0x3f, + 0xfd, 0x5f, 0x1e, 0xf0, 0x90, 0x3b, 0x81, 0x24, 0xb5, 0x6b, 0xa5, 0xcf, 0x90, 0x60, 0x9c, 0x33, + 0x25, 0x0d, 0x2a, 0x89, 0x26, 0xc2, 0xc0, 0x52, 0x2b, 0xab, 0xe2, 0x01, 0x77, 0x02, 0x36, 0x12, + 0xd8, 0x4a, 0x86, 0x83, 0x42, 0x15, 0xca, 0x0b, 0x50, 0xfd, 0x17, 0xb4, 0xc3, 0xb4, 0x50, 0xaa, + 0xe0, 0x14, 0xf9, 0xd7, 0xd2, 0x7d, 0x44, 0xb9, 0xd3, 0xc4, 0x32, 0x25, 0x43, 0xfd, 0xd1, 0xb7, + 0x2e, 0xe8, 0x1d, 0x7b, 0x78, 0xfc, 0x01, 0xc4, 0x82, 0x49, 0x9c, 0xd3, 0x52, 0x19, 0x66, 0x31, + 0x11, 0xca, 0x49, 0x9b, 0x44, 0xe3, 0x68, 0x72, 0x67, 0x06, 0xcf, 0x2f, 0x47, 0x9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x77, 0xe0, 0xf0, 0xea, 0x99, 0x7d, 0xfb, 0x01, 0xdd, 0xff, 0x7f, 0xf4, + 0xbd, 0xfd, 0x7d, 0xeb, 0xe6, 0x3d, 0xf9, 0x4d, 0xb7, 0x7f, 0xfb, 0xa0, 0x3f, 0x7b, 0x75, 0xbe, + 0x4d, 0xa3, 0x8b, 0x6d, 0x1a, 0xfd, 0xda, 0xa6, 0xd1, 0x97, 0x5d, 0xda, 0xb9, 0xd8, 0xa5, 0x9d, + 0xef, 0xbb, 0xb4, 0x73, 0x3a, 0xbd, 0x12, 0x1e, 0xee, 0xc4, 0xb4, 0x4d, 0x79, 0xb6, 0x22, 0x4c, + 0xa2, 0x6a, 0x9f, 0x76, 0x9f, 0xa3, 0x65, 0xcf, 0x37, 0xf0, 0xf4, 0x77, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xf6, 0x46, 0xb0, 0x29, 0x12, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -198,16 +194,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(n1)) i-- dAtA[i] = 0x42 - { - size := m.FeesStakers.Size() - i -= size - if _, err := m.FeesStakers.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.PrizeExpirationDelta, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.PrizeExpirationDelta):]) if err2 != nil { return 0, err2 @@ -286,8 +272,6 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.PrizeExpirationDelta) n += 1 + l + sovParams(uint64(l)) - l = m.FeesStakers.Size() - n += 1 + l + sovParams(uint64(l)) l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.MinDepositDrawDelta) n += 1 + l + sovParams(uint64(l)) return n @@ -499,40 +483,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeesStakers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.FeesStakers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinDepositDrawDelta", wireType) diff --git a/x/millions/types/pool.go b/x/millions/types/pool.go index 573337a3..1c10542f 100644 --- a/x/millions/types/pool.go +++ b/x/millions/types/pool.go @@ -78,7 +78,8 @@ func (pool *Pool) ValidateBasic(params Params) error { } } } - return nil + + return ValidateFeeTakers(pool.FeeTakers) } func (p *Pool) IsLocalZone(ctx sdk.Context) bool { diff --git a/x/millions/types/pool.pb.go b/x/millions/types/pool.pb.go index feb2ff8f..881eb256 100644 --- a/x/millions/types/pool.pb.go +++ b/x/millions/types/pool.pb.go @@ -101,6 +101,90 @@ func (PoolType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_c1401529e8cac8ff, []int{1} } +type FeeTakerType int32 + +const ( + FeeTakerType_Unspecified FeeTakerType = 0 + FeeTakerType_LocalAddr FeeTakerType = 1 + FeeTakerType_LocalModuleAccount FeeTakerType = 2 + FeeTakerType_RemoteAddr FeeTakerType = 3 +) + +var FeeTakerType_name = map[int32]string{ + 0: "FEE_TAKER_TYPE_UNSPECIFIED", + 1: "FEE_TAKER_TYPE_LOCAL_ADDR", + 2: "FEE_TAKER_TYPE_LOCAL_MODULE_ACCOUNT", + 3: "FEE_TAKER_TYPE_REMOTE_ADDR", +} + +var FeeTakerType_value = map[string]int32{ + "FEE_TAKER_TYPE_UNSPECIFIED": 0, + "FEE_TAKER_TYPE_LOCAL_ADDR": 1, + "FEE_TAKER_TYPE_LOCAL_MODULE_ACCOUNT": 2, + "FEE_TAKER_TYPE_REMOTE_ADDR": 3, +} + +func (x FeeTakerType) String() string { + return proto.EnumName(FeeTakerType_name, int32(x)) +} + +func (FeeTakerType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c1401529e8cac8ff, []int{2} +} + +type FeeTaker struct { + Destination string `protobuf:"bytes,1,opt,name=destination,proto3" json:"destination,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"amount"` + Type FeeTakerType `protobuf:"varint,3,opt,name=type,proto3,enum=lum.network.millions.FeeTakerType" json:"type,omitempty"` +} + +func (m *FeeTaker) Reset() { *m = FeeTaker{} } +func (m *FeeTaker) String() string { return proto.CompactTextString(m) } +func (*FeeTaker) ProtoMessage() {} +func (*FeeTaker) Descriptor() ([]byte, []int) { + return fileDescriptor_c1401529e8cac8ff, []int{0} +} +func (m *FeeTaker) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeeTaker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FeeTaker.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FeeTaker) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeeTaker.Merge(m, src) +} +func (m *FeeTaker) XXX_Size() int { + return m.Size() +} +func (m *FeeTaker) XXX_DiscardUnknown() { + xxx_messageInfo_FeeTaker.DiscardUnknown(m) +} + +var xxx_messageInfo_FeeTaker proto.InternalMessageInfo + +func (m *FeeTaker) GetDestination() string { + if m != nil { + return m.Destination + } + return "" +} + +func (m *FeeTaker) GetType() FeeTakerType { + if m != nil { + return m.Type + } + return FeeTakerType_Unspecified +} + type Pool struct { PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` @@ -129,6 +213,7 @@ type Pool struct { LastDrawCreatedAt *time.Time `protobuf:"bytes,27,opt,name=last_draw_created_at,json=lastDrawCreatedAt,proto3,stdtime" json:"last_draw_created_at,omitempty"` LastDrawState DrawState `protobuf:"varint,28,opt,name=last_draw_state,json=lastDrawState,proto3,enum=lum.network.millions.DrawState" json:"last_draw_state,omitempty"` AvailablePrizePool types1.Coin `protobuf:"bytes,29,opt,name=available_prize_pool,json=availablePrizePool,proto3" json:"available_prize_pool"` + FeeTakers []FeeTaker `protobuf:"bytes,30,rep,name=fee_takers,json=feeTakers,proto3" json:"fee_takers"` State PoolState `protobuf:"varint,32,opt,name=state,proto3,enum=lum.network.millions.PoolState" json:"state,omitempty"` CreatedAtHeight int64 `protobuf:"varint,33,opt,name=created_at_height,json=createdAtHeight,proto3" json:"created_at_height,omitempty"` UpdatedAtHeight int64 `protobuf:"varint,34,opt,name=updated_at_height,json=updatedAtHeight,proto3" json:"updated_at_height,omitempty"` @@ -140,7 +225,7 @@ func (m *Pool) Reset() { *m = Pool{} } func (m *Pool) String() string { return proto.CompactTextString(m) } func (*Pool) ProtoMessage() {} func (*Pool) Descriptor() ([]byte, []int) { - return fileDescriptor_c1401529e8cac8ff, []int{0} + return fileDescriptor_c1401529e8cac8ff, []int{1} } func (m *Pool) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -330,6 +415,13 @@ func (m *Pool) GetAvailablePrizePool() types1.Coin { return types1.Coin{} } +func (m *Pool) GetFeeTakers() []FeeTaker { + if m != nil { + return m.FeeTakers + } + return nil +} + func (m *Pool) GetState() PoolState { if m != nil { return m.State @@ -375,7 +467,7 @@ func (m *PoolValidator) Reset() { *m = PoolValidator{} } func (m *PoolValidator) String() string { return proto.CompactTextString(m) } func (*PoolValidator) ProtoMessage() {} func (*PoolValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_c1401529e8cac8ff, []int{1} + return fileDescriptor_c1401529e8cac8ff, []int{2} } func (m *PoolValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -421,6 +513,8 @@ func (m *PoolValidator) GetIsEnabled() bool { func init() { proto.RegisterEnum("lum.network.millions.PoolState", PoolState_name, PoolState_value) proto.RegisterEnum("lum.network.millions.PoolType", PoolType_name, PoolType_value) + proto.RegisterEnum("lum.network.millions.FeeTakerType", FeeTakerType_name, FeeTakerType_value) + proto.RegisterType((*FeeTaker)(nil), "lum.network.millions.FeeTaker") proto.RegisterType((*Pool)(nil), "lum.network.millions.Pool") proto.RegisterType((*PoolValidator)(nil), "lum.network.millions.PoolValidator") } @@ -428,88 +522,144 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/pool.proto", fileDescriptor_c1401529e8cac8ff) } var fileDescriptor_c1401529e8cac8ff = []byte{ - // 1293 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x6e, 0xdb, 0xc6, - 0x16, 0x36, 0x63, 0xd9, 0x96, 0xc6, 0x56, 0x44, 0x8d, 0x65, 0x87, 0x56, 0x6e, 0x24, 0xc5, 0xb9, - 0xb8, 0x50, 0x7c, 0x61, 0x0a, 0x71, 0xd0, 0x55, 0xd1, 0x85, 0x2c, 0xa9, 0x89, 0x1c, 0x27, 0x51, - 0x29, 0x39, 0x40, 0x8a, 0x16, 0xec, 0x88, 0x1c, 0x4b, 0x83, 0x90, 0x1c, 0x82, 0x1c, 0x29, 0x76, - 0x9f, 0xa0, 0xf0, 0x2a, 0xcb, 0x6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, 0x35, 0xb4, 0x8a, - 0x56, 0x4d, 0x59, 0x8b, 0x7c, 0xd9, 0x76, 0x61, 0x01, 0x2c, 0xb8, 0x38, 0xa0, 0xbe, 0x71, 0xad, - 0xa2, 0x55, 0x33, 0x96, 0x5c, 0xc0, 0xdb, 0x60, 0x25, 0x40, 0x8c, 0x8c, 0xb1, 0x2d, 0x9d, 0xf3, - 0xc2, 0xb9, 0x2c, 0x6d, 0x4d, 0x01, 0xd9, 0x00, 0x69, 0x67, 0x88, 0x48, 0xc0, 0x29, 0x53, 0xc2, - 0xbd, 0x24, 0xd6, 0x6d, 0x17, 0xde, 0x01, 0x59, 0x87, 0x06, 0x01, 0x76, 0xb8, 0xb6, 0xdc, 0xbf, - 0x20, 0xfc, 0x2b, 0x53, 0x63, 0xdb, 0x85, 0x26, 0x58, 0x65, 0x11, 0x0a, 0xe2, 0x43, 0x1c, 0xd9, - 0xce, 0x10, 0x05, 0x01, 0x16, 0xd9, 0x2d, 0x0a, 0x68, 0x3e, 0x71, 0x35, 0xa4, 0xa7, 0xed, 0xc2, - 0x6d, 0xb0, 0x4a, 0x1c, 0x64, 0xbb, 0x38, 0xa4, 0x31, 0x61, 0x76, 0x48, 0x23, 0xc6, 0xf1, 0x4b, - 0x02, 0xaf, 0x13, 0x07, 0x35, 0xa5, 0xa7, 0x43, 0x23, 0xd6, 0x76, 0xe1, 0x3d, 0xb0, 0xc6, 0xe1, - 0x42, 0x15, 0x71, 0xf2, 0x24, 0x20, 0x2d, 0x02, 0x20, 0x71, 0x50, 0x27, 0xf1, 0xa9, 0x90, 0xcf, - 0x41, 0x46, 0x20, 0xd9, 0x71, 0x88, 0x8d, 0x4c, 0x45, 0xab, 0x5e, 0xdf, 0x29, 0x99, 0x17, 0xb5, - 0x97, 0xc9, 0x25, 0xed, 0x1d, 0x87, 0xd8, 0x4a, 0x87, 0xea, 0x1f, 0x6c, 0x03, 0x30, 0x46, 0x1e, - 0x71, 0x11, 0xa3, 0x51, 0x6c, 0x80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, - 0xf7, 0x1c, 0xe4, 0x51, 0x7b, 0x7f, 0xbf, 0xd5, 0xd4, 0x53, 0x12, 0xf2, 0x88, 0x78, 0x1e, 0x76, - 0x8b, 0xa9, 0x1f, 0x7e, 0x2a, 0x69, 0x5b, 0xdf, 0x81, 0x74, 0xf2, 0x1e, 0x80, 0x5b, 0x60, 0x4d, - 0x04, 0xf5, 0x9e, 0x77, 0x2e, 0x3d, 0xc9, 0xa6, 0xda, 0x40, 0x60, 0xbb, 0xbd, 0xfa, 0xa3, 0xf6, - 0x93, 0x07, 0xc9, 0x41, 0xba, 0x0c, 0xbd, 0x20, 0xc1, 0x40, 0xee, 0xb0, 0xfb, 0xe0, 0xf5, 0xbb, - 0x92, 0xf6, 0xe6, 0x5d, 0x49, 0xfb, 0xeb, 0x5d, 0x49, 0x7b, 0xf5, 0xbe, 0x34, 0xf7, 0xe6, 0x7d, - 0x69, 0xee, 0xf7, 0xf7, 0xa5, 0xb9, 0xaf, 0xb7, 0x67, 0xe4, 0xf7, 0x46, 0xfe, 0x76, 0xf2, 0x2a, - 0x14, 0x2f, 0xb1, 0xda, 0xd1, 0xf4, 0x75, 0x28, 0x2a, 0xd1, 0x5f, 0x14, 0x3d, 0x78, 0xff, 0xef, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x4c, 0x5e, 0x40, 0x56, 0x0b, 0x00, 0x00, + // 1468 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x4d, 0x6f, 0xdb, 0x46, + 0x1a, 0x36, 0x63, 0xd9, 0x96, 0xc6, 0x92, 0x4d, 0x8f, 0x3f, 0x42, 0x2b, 0x1b, 0x89, 0xb1, 0x17, + 0x0b, 0xc7, 0xbb, 0x96, 0x90, 0x04, 0xbb, 0x97, 0x45, 0x51, 0xc8, 0x12, 0x9d, 0x28, 0x96, 0x63, + 0x95, 0x92, 0x03, 0xa4, 0x68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5, 0xd6, 0xb5, 0x6c, 0xe6, 0xe4, 0xd4, 0x4c, 0xd5, 0xe2, 0x2b, 0x06, 0x7e, 0x09, + 0x56, 0x2f, 0x45, 0xef, 0xec, 0x56, 0xf6, 0x6a, 0x96, 0x53, 0x2a, 0x97, 0x77, 0xf7, 0x9e, 0x35, + 0xf5, 0x5b, 0xd9, 0xa5, 0x93, 0x53, 0x13, 0x0a, 0xbb, 0x1d, 0xca, 0xaf, 0xf8, 0x92, 0x2b, 0xce, + 0x60, 0x58, 0xb8, 0xe0, 0x9f, 0x6d, 0xed, 0xec, 0x36, 0x2d, 0xb9, 0xdf, 0x78, 0x76, 0xe6, 0xe4, + 0xd4, 0x04, 0x36, 0xee, 0x52, 0x86, 0xf9, 0x86, 0x32, 0xcc, 0xcd, 0xc7, 0x6f, 0xde, 0xe7, 0xb4, + 0xb7, 0xef, 0x73, 0xda, 0x9f, 0xef, 0x73, 0xda, 0xeb, 0x0f, 0xb9, 0xb1, 0xb7, 0x1f, 0x72, 0x63, + 0xbf, 0x7d, 0xc8, 0x8d, 0x7d, 0xbd, 0x31, 0xd2, 0x65, 0x7e, 0xbf, 0xbb, 0x11, 0x3f, 0xf5, 0xc5, + 0x7b, 0xb5, 0x78, 0x34, 0x7c, 0xf2, 0x8b, 0x86, 0x6b, 0x4d, 0x8a, 0x21, 0x7b, 0xf4, 0x77, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xf3, 0xe3, 0x56, 0x3f, 0x2b, 0x0d, 0x00, 0x00, +} + +func (m *FeeTaker) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FeeTaker) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeTaker) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Type != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Destination) > 0 { + i -= len(m.Destination) + copy(dAtA[i:], m.Destination) + i = encodeVarintPool(dAtA, i, uint64(len(m.Destination))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -573,6 +723,22 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x80 } + if len(m.FeeTakers) > 0 { + for iNdEx := len(m.FeeTakers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeTakers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xf2 + } + } { size, err := m.AvailablePrizePool.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -872,6 +1038,24 @@ func encodeVarintPool(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *FeeTaker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Destination) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovPool(uint64(l)) + if m.Type != 0 { + n += 1 + sovPool(uint64(m.Type)) + } + return n +} + func (m *Pool) Size() (n int) { if m == nil { return 0 @@ -967,6 +1151,12 @@ func (m *Pool) Size() (n int) { } l = m.AvailablePrizePool.Size() n += 2 + l + sovPool(uint64(l)) + if len(m.FeeTakers) > 0 { + for _, e := range m.FeeTakers { + l = e.Size() + n += 2 + l + sovPool(uint64(l)) + } + } if m.State != 0 { n += 2 + sovPool(uint64(m.State)) } @@ -1007,6 +1197,141 @@ func sovPool(x uint64) (n int) { func sozPool(x uint64) (n int) { return sovPool(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *FeeTaker) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FeeTaker: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeeTaker: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Destination", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Destination = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= FeeTakerType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Pool) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1853,6 +2178,40 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 30: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeTakers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeTakers = append(m.FeeTakers, FeeTaker{}) + if err := m.FeeTakers[len(m.FeeTakers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 32: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) diff --git a/x/millions/types/proposal_register_pool.go b/x/millions/types/proposal_register_pool.go index e7ea1fbd..b91342c7 100644 --- a/x/millions/types/proposal_register_pool.go +++ b/x/millions/types/proposal_register_pool.go @@ -24,7 +24,7 @@ func init() { govtypes.RegisterProposalType(ProposalTypeRegisterPool) } -func NewRegisterPoolProposal(title string, description string, poolType PoolType, chainID string, denom string, nativeDenom string, connectionId string, bech32PrefixAccAddr string, bech32PrefixValAddr string, validators []string, minDepositAmount math.Int, prizeStrategy PrizeStrategy, drawSchedule DrawSchedule, UnbondingDuration time.Duration, maxUnbondingEntries math.Int) govtypes.Content { +func NewRegisterPoolProposal(title string, description string, poolType PoolType, chainID string, denom string, nativeDenom string, connectionId string, bech32PrefixAccAddr string, bech32PrefixValAddr string, validators []string, minDepositAmount math.Int, prizeStrategy PrizeStrategy, drawSchedule DrawSchedule, UnbondingDuration time.Duration, maxUnbondingEntries math.Int, fees []FeeTaker) govtypes.Content { return &ProposalRegisterPool{ Title: title, Description: description, @@ -41,6 +41,7 @@ func NewRegisterPoolProposal(title string, description string, poolType PoolType DrawSchedule: drawSchedule, UnbondingDuration: UnbondingDuration, MaxUnbondingEntries: maxUnbondingEntries, + FeeTakers: fees, } } @@ -94,10 +95,18 @@ func (p *ProposalRegisterPool) ValidateBasic() error { if p.DrawSchedule.DrawDelta < MinAcceptableDrawDelta { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "draw delta cannot be lower than %s", MinAcceptableDrawDelta) } - return nil + + return ValidateFeeTakers(p.FeeTakers) } func (p ProposalRegisterPool) String() string { + // Prepare the fee takers string by iterating over the array + feeTakers := "" + for _, fee := range p.FeeTakers { + feeTakers += fee.String() + "\n" + } + + // Return the string return fmt.Sprintf(`Register Pool Proposal: Title: %s Description: %s @@ -116,6 +125,8 @@ func (p ProposalRegisterPool) String() string { %s ======Prize Strategy====== %s + ======Fee Takers====== + %s `, p.Title, p.Description, p.ChainId, p.Denom, p.NativeDenom, @@ -128,5 +139,6 @@ func (p ProposalRegisterPool) String() string { p.TransferChannelId, p.DrawSchedule.String(), p.PrizeStrategy.String(), + feeTakers, ) } diff --git a/x/millions/types/proposal_update_params.go b/x/millions/types/proposal_update_params.go index ec5d4181..9b11e021 100644 --- a/x/millions/types/proposal_update_params.go +++ b/x/millions/types/proposal_update_params.go @@ -5,7 +5,6 @@ import ( "time" "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -21,12 +20,11 @@ func init() { govtypes.RegisterProposalType(ProposalTypeUpdateParams) } -func NewUpdateParamsProposal(title, description string, minDepositAmount *math.Int, fees *sdk.Dec, prizeDelta *time.Duration, minDepDrawDelta *time.Duration, minDrawDelta *time.Duration, maxDrawDelta *time.Duration, maxBatchQuantity *math.Int, maxStrategyBatches *math.Int) govtypes.Content { +func NewUpdateParamsProposal(title, description string, minDepositAmount *math.Int, prizeDelta *time.Duration, minDepDrawDelta *time.Duration, minDrawDelta *time.Duration, maxDrawDelta *time.Duration, maxBatchQuantity *math.Int, maxStrategyBatches *math.Int) govtypes.Content { return &ProposalUpdateParams{ Title: title, Description: description, MinDepositAmount: minDepositAmount, - FeesStakers: fees, PrizeExpirationDelta: prizeDelta, MinDrawScheduleDelta: minDrawDelta, MaxDrawScheduleDelta: maxDrawDelta, @@ -69,9 +67,6 @@ func (p *ProposalUpdateParams) ValidateBasic() error { if p.PrizeExpirationDelta != nil { params.PrizeExpirationDelta = *p.PrizeExpirationDelta } - if p.FeesStakers != nil { - params.FeesStakers = *p.FeesStakers - } if p.MinDepositDrawDelta != nil { params.MinDepositDrawDelta = *p.MinDepositDrawDelta } @@ -88,7 +83,6 @@ func (p ProposalUpdateParams) String() string { Min Draw Schedule Delta %s Max Draw Schedule Delta %s Prize Expiration Delta %s - Fees Stakers %s Min Deposit Draw Delta %s `, p.Title, p.Description, @@ -98,6 +92,5 @@ func (p ProposalUpdateParams) String() string { p.MinDrawScheduleDelta.String(), p.MaxDrawScheduleDelta.String(), p.PrizeExpirationDelta.String(), - p.FeesStakers.String(), p.MinDepositDrawDelta.String()) } diff --git a/x/millions/types/proposal_update_pool.go b/x/millions/types/proposal_update_pool.go index 8800620c..b4d83aab 100644 --- a/x/millions/types/proposal_update_pool.go +++ b/x/millions/types/proposal_update_pool.go @@ -23,7 +23,7 @@ func init() { govtypes.RegisterProposalType(ProposalTypeUpdatePool) } -func NewUpdatePoolProposal(title, description string, poolId uint64, validators []string, minDepositAmount *math.Int, prizeStrategy *PrizeStrategy, drawSchedule *DrawSchedule, state PoolState, UnbondingDuration *time.Duration, maxUnbondingEntries *math.Int) govtypes.Content { +func NewUpdatePoolProposal(title, description string, poolId uint64, validators []string, minDepositAmount *math.Int, prizeStrategy *PrizeStrategy, drawSchedule *DrawSchedule, state PoolState, UnbondingDuration *time.Duration, maxUnbondingEntries *math.Int, fees []FeeTaker) govtypes.Content { return &ProposalUpdatePool{ Title: title, Description: description, @@ -35,6 +35,7 @@ func NewUpdatePoolProposal(title, description string, poolId uint64, validators State: state, UnbondingDuration: UnbondingDuration, MaxUnbondingEntries: maxUnbondingEntries, + FeeTakers: fees, } } @@ -76,10 +77,18 @@ func (p *ProposalUpdatePool) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "draw delta cannot be lower than %s", MinAcceptableDrawDelta.String()) } } - return nil + + return ValidateFeeTakers(p.FeeTakers) } func (p ProposalUpdatePool) String() string { + // Prepare the fee takers string by iterating over the array + feeTakers := "" + for _, fee := range p.FeeTakers { + feeTakers += fee.String() + "\n" + } + + // Return the string return fmt.Sprintf(`Update Pool Proposal: Title: %s Description: %s @@ -93,6 +102,8 @@ func (p ProposalUpdatePool) String() string { %s ======Prize Strategy====== %s + ======Fee Takers====== + %s `, p.Title, p.Description, p.PoolId, @@ -103,5 +114,6 @@ func (p ProposalUpdatePool) String() string { p.MaxUnbondingEntries.Int64(), p.DrawSchedule.String(), p.PrizeStrategy.String(), + feeTakers, ) }