From e53be0f7ea9fe60da7b7353197417b2d53bc3dfe Mon Sep 17 00:00:00 2001 From: Segfault <5221072+Segfaultd@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:26:34 +0100 Subject: [PATCH 01/11] First build --- app/app.go | 12 -- proto/lum/network/millions/pool.proto | 15 +- x/millions/keeper/keeper_draw.go | 13 ++ x/millions/keeper/keeper_pool.go | 135 ++++++++++-- x/millions/keeper/keeper_prize.go | 13 ++ x/millions/keeper/keeper_withdrawal.go | 10 +- x/millions/types/errors.go | 3 + x/millions/types/pool.pb.go | 271 ++++++++++++++++--------- 8 files changed, 338 insertions(+), 134 deletions(-) diff --git a/app/app.go b/app/app.go index 880375b3..9009df42 100644 --- a/app/app.go +++ b/app/app.go @@ -781,18 +781,6 @@ func (app *App) registerUpgradeHandlers() { return app.mm.RunMigrations(ctx, app.configurator, fromVM) }) - app.UpgradeKeeper.SetUpgradeHandler("v1.4.5", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // Kill the first pool that shouldn't be used anymore after that upgrade - _, err := app.MillionsKeeper.UnsafeKillPool(ctx, 1) - if err != nil { - return fromVM, err - } - - // Continue normal upgrade processing - app.Logger().Info("Pool killed. v1.4.5 upgrade applied") - return app.mm.RunMigrations(ctx, app.configurator, fromVM) - }) - app.UpgradeKeeper.SetUpgradeHandler("v1.5.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { app.Logger().Info("Starting v1.5.0 upgrade") diff --git a/proto/lum/network/millions/pool.proto b/proto/lum/network/millions/pool.proto index 496b6461..8f350f63 100644 --- a/proto/lum/network/millions/pool.proto +++ b/proto/lum/network/millions/pool.proto @@ -30,7 +30,18 @@ enum PoolState { POOL_STATE_CREATED = 1 [ (gogoproto.enumvalue_customname) = "Created" ]; POOL_STATE_READY = 2 [ (gogoproto.enumvalue_customname) = "Ready" ]; POOL_STATE_PAUSED = 3 [ (gogoproto.enumvalue_customname) = "Paused" ]; - POOL_STATE_KILLED = 4 [ (gogoproto.enumvalue_customname) = "Killed" ]; + POOL_STATE_CLOSING = 4 [ (gogoproto.enumvalue_customname) = "Closing" ]; + POOL_STATE_CLOSED = 5 [ (gogoproto.enumvalue_customname) = "Closed" ]; +} + +enum PoolClosingStep { + option (gogoproto.goproto_enum_prefix) = true; + + POOL_CLOSING_STEP_UNSPECIFIED = 0 + [ (gogoproto.enumvalue_customname) = "Unspecified" ]; + POOL_CLOSING_STEP_WITHDRAW = 1 + [ (gogoproto.enumvalue_customname) = "Withdraw" ]; + POOL_CLOSING_STEP_DRAW = 2 [ (gogoproto.enumvalue_customname) = "Draw" ]; } // PoolType the type of Pool @@ -119,8 +130,8 @@ message Pool { cosmos.base.v1beta1.Coin available_prize_pool = 29 [ (gogoproto.nullable) = false ]; repeated FeeTaker fee_takers = 30 [ (gogoproto.nullable) = false ]; - reserved 31; + PoolClosingStep closing_step = 31; PoolState state = 32; int64 created_at_height = 33; diff --git a/x/millions/keeper/keeper_draw.go b/x/millions/keeper/keeper_draw.go index cae8aa02..bd2981c6 100644 --- a/x/millions/keeper/keeper_draw.go +++ b/x/millions/keeper/keeper_draw.go @@ -83,6 +83,7 @@ func (k Keeper) ClaimYieldOnRemoteZone(ctx sdk.Context, poolID uint64, drawID ui if err != nil { return nil, err } + // Acquire Draw draw, err := k.GetPoolDraw(ctx, poolID, drawID) if err != nil { @@ -483,6 +484,7 @@ func (k Keeper) ExecuteDraw(ctx sdk.Context, poolID uint64, drawID uint64) (*typ // OnExecuteDrawCompleted wrappers for draw state update upon drawing phase completion // returns the error specified in parameters and does not produce any internal error func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw *types.Draw, err error) (*types.Draw, error) { + // If it's a failure, we do not update the pool state if err != nil { draw.State = types.DrawState_Failure draw.ErrorState = types.DrawState_Drawing @@ -493,6 +495,8 @@ func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw * k.updatePool(ctx, pool) return draw, err } + + // Update draw state draw.State = types.DrawState_Success draw.ErrorState = types.DrawState_Unspecified draw.UpdatedAtHeight = ctx.BlockHeight() @@ -500,6 +504,15 @@ func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw * k.SetPoolDraw(ctx, *draw) pool.LastDrawState = draw.State k.updatePool(ctx, pool) + + // If the pool is in closing state, notify the close method + // Discard the error here since we do not want to return an error on a successful draw + if pool.State == types.PoolState_Closing { + if err := k.ClosePool(ctx, pool.PoolId); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("Failed to close pool %d: %v", pool.PoolId, err)) + return draw, nil + } + } return draw, err } diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index 0a77a36d..daceeb39 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -318,6 +318,7 @@ func (k Keeper) RegisterPool( SponsorshipAmount: sdk.ZeroInt(), AvailablePrizePool: sdk.NewCoin(denom, sdk.ZeroInt()), State: types.PoolState_Created, + ClosingStep: types.PoolClosingStep_Unspecified, FeeTakers: fees, TransferChannelId: transferChannelId, CreatedAtHeight: ctx.BlockHeight(), @@ -479,6 +480,120 @@ func (k Keeper) UpdatePool( return nil } +// ClosePool It is a deterministic method that proceed with pool closure steps based on the current pool state +func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { + // Make sure we always have a valid pool entity + pool, err := k.GetPool(ctx, poolID) + if err != nil { + return err + } + + // Make sure the pool is not already closed + if pool.State == types.PoolState_Closed { + return types.ErrPoolClosed + } + + // If the pool is in state "ready", it means we are in the very first step of the closure process + if pool.State == types.PoolState_Ready { + // Update the pool state to "Closing" + pool.State = types.PoolState_Closing + pool.ClosingStep = types.PoolClosingStep_Withdraw + k.updatePool(ctx, &pool) + k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state closing", poolID)) + + // Acquire all deposits + deposits := k.ListPoolDeposits(ctx, poolID) + + // Update the prize strategy now to distribute 100% of the prize pool to the depositors + // Do it now because once you create a withdrawal, you delete deposit + pool.PrizeStrategy = types.PrizeStrategy{ + PrizeBatches: []types.PrizeBatch{ + {Quantity: uint64(len(deposits)), PoolPercent: 1, DrawProbability: sdk.NewDec(1), IsUnique: true}, + }, + } + k.updatePool(ctx, &pool) + k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d prize strategy to distribute 100%% of the prize pool to the depositors", poolID)) + + // Iterate over all deposits + for _, deposit := range deposits { + // Make sure the deposit can be withdrawn + if deposit.State != types.DepositState_Success { + continue + } + + // Trigger the withdrawal + withdrawal := types.Withdrawal{ + PoolId: poolID, + DepositId: deposit.DepositId, + WithdrawalId: k.GetNextWithdrawalIdAndIncrement(ctx), + State: types.WithdrawalState_Pending, + DepositorAddress: deposit.GetDepositorAddress(), + ToAddress: deposit.GetDepositorAddress(), + Amount: deposit.Amount, + CreatedAtHeight: ctx.BlockHeight(), + UpdatedAtHeight: ctx.BlockHeight(), + CreatedAt: ctx.BlockTime(), + UpdatedAt: ctx.BlockTime(), + } + + // Adds the withdrawal and remove the deposit + k.AddWithdrawal(ctx, withdrawal) + k.RemoveDeposit(ctx, &deposit) + } + + k.Logger(ctx).Info(fmt.Sprintf("Created %d withdrawals for pool %d", len(deposits), poolID)) + } else if pool.State == types.PoolState_Closing { + // After that, we are in the second step of the closure process + // If the actual closing step is withdrawal, we have to watch the withdrawal list and wait for it to be empty + // Then we can proceed with the final draw + if pool.ClosingStep == types.PoolClosingStep_Withdraw { + // Acquire the withdrawals and make sure we have none + withdrawals := k.ListPoolWithdrawals(ctx, poolID) + if len(withdrawals) > 0 { + k.Logger(ctx).Debug(fmt.Sprintf("Pool %d has %d withdrawals pending", poolID, len(withdrawals))) + return nil + } + + // If we have no withdrawals, we can proceed with the final draw + draw, err := k.LaunchNewDraw(ctx, poolID) + if err != nil { + return err + } + + // And update the final state + pool.ClosingStep = types.PoolClosingStep_Draw + k.updatePool(ctx, &pool) + k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state draw with drawID %d", poolID, draw.DrawId)) + return nil + } else if pool.ClosingStep == types.PoolClosingStep_Draw { + // Wait for the actual draw to be completed + if pool.LastDrawState != types.DrawState_Success { + k.Logger(ctx).Debug(fmt.Sprintf("Pool %d last draw is not yet completed", poolID)) + return nil + } + + // Transfer the remaining dust on local module account to community pool + // This is to avoid having dust on the module account + // This is not a critical step, so we don't need to return an error if it fails + currentLocalBalance := k.BankKeeper.GetBalance(ctx, sdk.MustAccAddressFromBech32(pool.LocalAddress), pool.Denom) + if currentLocalBalance.IsPositive() { + if err := k.BankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, distribtypes.ModuleName, sdk.NewCoins(currentLocalBalance)); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("Failed to transfer dust from pool %d local module account to community pool: %v", poolID, err)) + } + } + + // Once everything is done, we can update the state to closed + pool.State = types.PoolState_Closed + k.updatePool(ctx, &pool) + k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state closed", poolID)) + } + } else { + return types.ErrPoolNotClosing + } + + return nil +} + // RebalanceValidatorsBondings allows rebalancing of validators bonded assets // Current implementation: // - Initiate an even redelegate distribution from inactive bonded validators to active validators @@ -600,26 +715,6 @@ func (k Keeper) OnRedelegateToActiveValidatorsOnRemoteZoneCompleted(ctx sdk.Cont return nil } -// UnsafeKillPool This method switches the provided pool state but does not handle any withdrawal or deposit. -// It shouldn't be used and is very specific to UNUSED and EMPTY pools -func (k Keeper) UnsafeKillPool(ctx sdk.Context, poolID uint64) (types.Pool, error) { - // Grab our pool instance - pool, err := k.GetPool(ctx, poolID) - if err != nil { - return types.Pool{}, err - } - - // Make sure the pool isn't killed yet - if pool.GetState() == types.PoolState_Killed { - return pool, errorsmod.Wrapf(types.ErrPoolKilled, "%d", poolID) - } - - // Kill the pool - pool.State = types.PoolState_Killed - k.updatePool(ctx, &pool) - return pool, nil -} - // UnsafeUpdatePoolPortIds This method raw update the provided pool port ids. // It's heavily unsafe and could break the ICA implementation. It should only be used by store migrations. func (k Keeper) UnsafeUpdatePoolPortIds(ctx sdk.Context, poolID uint64, icaDepositPortId, icaPrizePoolPortId string) (types.Pool, error) { diff --git a/x/millions/keeper/keeper_prize.go b/x/millions/keeper/keeper_prize.go index 1bfe8038..61607ce3 100644 --- a/x/millions/keeper/keeper_prize.go +++ b/x/millions/keeper/keeper_prize.go @@ -14,21 +14,34 @@ import ( // ClawBackPrize claw backs a prize by adding its amount to the clawback prize pool func (k Keeper) ClawBackPrize(ctx sdk.Context, poolID uint64, drawID uint64, prizeID uint64) error { + // Acquire the pool instance pool, err := k.GetPool(ctx, poolID) if err != nil { return err } + + // If the pool is in closing or closed state, we do not process any prize clawback + // We want all user to be able to claim their prize, no matter the state + if pool.State == types.PoolState_Closing || pool.State == types.PoolState_Closed { + return nil + } + + // Acquire the prize instance prize, err := k.GetPoolDrawPrize(ctx, poolID, drawID, prizeID) if err != nil { return err } + + // If the prize is not in pending state, we do not process any prize clawback if prize.State != types.PrizeState_Pending { return errorsmod.Wrapf(types.ErrIllegalStateOperation, "expecting %s but state is %s", types.PrizeState_Pending, prize.State) } + // Add the prize amount to the clawback prize pool pool.AvailablePrizePool = pool.AvailablePrizePool.Add(prize.Amount) k.updatePool(ctx, &pool) + // Remove the prize from the prize queue if err := k.RemovePrize(ctx, prize); err != nil { return err } diff --git a/x/millions/keeper/keeper_withdrawal.go b/x/millions/keeper/keeper_withdrawal.go index f78fefe9..ca6d6c45 100644 --- a/x/millions/keeper/keeper_withdrawal.go +++ b/x/millions/keeper/keeper_withdrawal.go @@ -133,8 +133,8 @@ func (k Keeper) TransferWithdrawalToRecipient(ctx sdk.Context, poolID uint64, wi return nil } -// OnTransferWithdrawalToRecipientCompleted Acknowledge the withdraw IBC transfer -// - To to the local chain response if it's a transfer to local chain +// OnTransferWithdrawalToRecipientCompleted Acknowledge the withdrawal IBC transfer +// - To the local chain response if it's a transfer to local chain // - To the native chain if it's BankSend for a native pool with a native destination address func (k Keeper) OnTransferWithdrawalToRecipientCompleted(ctx sdk.Context, poolID uint64, withdrawalID uint64, isError bool) error { withdrawal, err := k.GetPoolWithdrawal(ctx, poolID, withdrawalID) @@ -154,6 +154,12 @@ func (k Keeper) OnTransferWithdrawalToRecipientCompleted(ctx sdk.Context, poolID if err := k.RemoveWithdrawal(ctx, withdrawal); err != nil { return err } + + // Notify the closing method to check if the step can continue + // Discard any error here to avoid blocking the process on relaying side + if err := k.ClosePool(ctx, poolID); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("ClosePool %v", err.Error())) + } return nil } diff --git a/x/millions/types/errors.go b/x/millions/types/errors.go index cabb6bf5..a8034060 100644 --- a/x/millions/types/errors.go +++ b/x/millions/types/errors.go @@ -25,6 +25,9 @@ var ( ErrValidatorNotFound = errorsmod.Register(ModuleName, 1112, "Validator not found in pool validator set") ErrInvalidValidatorEnablementStatus = errorsmod.Register(ModuleName, 1113, "Invalid validator enablement status") ErrInvalidPoolType = errorsmod.Register(ModuleName, 1114, "Invalid pool type") + ErrPoolNotClosing = errorsmod.Register(ModuleName, 1115, "Pool is not closing") + ErrPoolClosed = errorsmod.Register(ModuleName, 1116, "Pool is closed") + ErrPoolWithdrawalsInProgress = errorsmod.Register(ModuleName, 1117, "Pool has withdrawals in progress") ErrInvalidDepositAmount = errorsmod.Register(ModuleName, 1200, "Deposit amount must be positive") ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 1201, "Invalid deposit denom") ErrInvalidDepositorAddress = errorsmod.Register(ModuleName, 1202, "Invalid depositor address") diff --git a/x/millions/types/pool.pb.go b/x/millions/types/pool.pb.go index 881eb256..aec9f78a 100644 --- a/x/millions/types/pool.pb.go +++ b/x/millions/types/pool.pb.go @@ -46,7 +46,8 @@ const ( PoolState_Created PoolState = 1 PoolState_Ready PoolState = 2 PoolState_Paused PoolState = 3 - PoolState_Killed PoolState = 4 + PoolState_Closing PoolState = 4 + PoolState_Closed PoolState = 5 ) var PoolState_name = map[int32]string{ @@ -54,7 +55,8 @@ var PoolState_name = map[int32]string{ 1: "POOL_STATE_CREATED", 2: "POOL_STATE_READY", 3: "POOL_STATE_PAUSED", - 4: "POOL_STATE_KILLED", + 4: "POOL_STATE_CLOSING", + 5: "POOL_STATE_CLOSED", } var PoolState_value = map[string]int32{ @@ -62,7 +64,8 @@ var PoolState_value = map[string]int32{ "POOL_STATE_CREATED": 1, "POOL_STATE_READY": 2, "POOL_STATE_PAUSED": 3, - "POOL_STATE_KILLED": 4, + "POOL_STATE_CLOSING": 4, + "POOL_STATE_CLOSED": 5, } func (x PoolState) String() string { @@ -73,6 +76,34 @@ func (PoolState) EnumDescriptor() ([]byte, []int) { return fileDescriptor_c1401529e8cac8ff, []int{0} } +type PoolClosingStep int32 + +const ( + PoolClosingStep_Unspecified PoolClosingStep = 0 + PoolClosingStep_Withdraw PoolClosingStep = 1 + PoolClosingStep_Draw PoolClosingStep = 2 +) + +var PoolClosingStep_name = map[int32]string{ + 0: "POOL_CLOSING_STEP_UNSPECIFIED", + 1: "POOL_CLOSING_STEP_WITHDRAW", + 2: "POOL_CLOSING_STEP_DRAW", +} + +var PoolClosingStep_value = map[string]int32{ + "POOL_CLOSING_STEP_UNSPECIFIED": 0, + "POOL_CLOSING_STEP_WITHDRAW": 1, + "POOL_CLOSING_STEP_DRAW": 2, +} + +func (x PoolClosingStep) String() string { + return proto.EnumName(PoolClosingStep_name, int32(x)) +} + +func (PoolClosingStep) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c1401529e8cac8ff, []int{1} +} + // PoolType the type of Pool // Each PoolType implements a dedicated runner which applies its own Pool // Lifecycle in order to deliver yield and distribute prizes @@ -98,7 +129,7 @@ func (x PoolType) String() string { } func (PoolType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_c1401529e8cac8ff, []int{1} + return fileDescriptor_c1401529e8cac8ff, []int{2} } type FeeTakerType int32 @@ -129,7 +160,7 @@ func (x FeeTakerType) String() string { } func (FeeTakerType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_c1401529e8cac8ff, []int{2} + return fileDescriptor_c1401529e8cac8ff, []int{3} } type FeeTaker struct { @@ -214,6 +245,7 @@ type Pool struct { 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"` + ClosingStep PoolClosingStep `protobuf:"varint,31,opt,name=closing_step,json=closingStep,proto3,enum=lum.network.millions.PoolClosingStep" json:"closing_step,omitempty"` 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"` @@ -422,6 +454,13 @@ func (m *Pool) GetFeeTakers() []FeeTaker { return nil } +func (m *Pool) GetClosingStep() PoolClosingStep { + if m != nil { + return m.ClosingStep + } + return PoolClosingStep_Unspecified +} + func (m *Pool) GetState() PoolState { if m != nil { return m.State @@ -512,6 +551,7 @@ func (m *PoolValidator) GetIsEnabled() bool { func init() { proto.RegisterEnum("lum.network.millions.PoolState", PoolState_name, PoolState_value) + proto.RegisterEnum("lum.network.millions.PoolClosingStep", PoolClosingStep_name, PoolClosingStep_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") @@ -522,99 +562,105 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/pool.proto", fileDescriptor_c1401529e8cac8ff) } var fileDescriptor_c1401529e8cac8ff = []byte{ - // 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, 0xc1, 0x8e, 0xc8, 0xb1, 0x34, 0x30, 0xc5, 0x11, 0xc8, 0x91, 0x63, - 0xf7, 0x17, 0x04, 0x3e, 0xe5, 0xd8, 0x8b, 0x4f, 0xbd, 0xf6, 0xd8, 0x1f, 0x11, 0xf4, 0x14, 0xf4, - 0x54, 0xf4, 0x90, 0x16, 0x49, 0x7f, 0x48, 0x31, 0x1f, 0x94, 0xe4, 0xaf, 0x38, 0xf1, 0x89, 0x9c, - 0xf7, 0x7d, 0xde, 0x67, 0xde, 0xcf, 0x99, 0x01, 0x79, 0xbf, 0xdf, 0x2d, 0x06, 0x98, 0xbd, 0xa4, - 0xe1, 0x41, 0xb1, 0x4b, 0x7c, 0x9f, 0xd0, 0x20, 0x2a, 0xf6, 0x28, 0xf5, 0x0b, 0xbd, 0x90, 0x32, - 0x0a, 0x17, 0xfc, 0x7e, 0xb7, 0xa0, 0x00, 0x85, 0x18, 0x90, 0x5d, 0x68, 0xd3, 0x36, 0x15, 0x80, - 0x22, 0xff, 0x93, 0xd8, 0x6c, 0xae, 0x4d, 0x69, 0xdb, 0xc7, 0x45, 0xb1, 0x6a, 0xf5, 0xf7, 0x8b, - 0x5e, 0x3f, 0x44, 0x8c, 0xd0, 0x40, 0xe9, 0xf3, 0xe7, 0xf5, 0x8c, 0x74, 0x71, 0xc4, 0x50, 0xb7, - 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4, 0x77, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xf3, 0xe3, 0x56, 0x3f, 0x2b, 0x0d, 0x00, 0x00, + // 1566 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4d, 0x6f, 0xdb, 0xc8, + 0x19, 0x36, 0x63, 0xd9, 0x91, 0xc6, 0x52, 0x4c, 0x8f, 0x1d, 0x2f, 0xcd, 0x6d, 0x24, 0xc6, 0xd9, + 0x16, 0xde, 0x74, 0x2d, 0x21, 0x0e, 0xda, 0x4b, 0x51, 0x14, 0xb4, 0x44, 0x27, 0xda, 0xb5, 0x63, + 0x95, 0x92, 0x37, 0xd8, 0xa2, 0x05, 0x3b, 0x22, 0xc7, 0xd2, 0xc0, 0x14, 0x87, 0x20, 0x47, 0x8e, + 0xdd, 0x5f, 0x50, 0xe8, 0xb4, 0xc7, 0x5e, 0x84, 0x1e, 0x7a, 0xed, 0xb1, 0x3f, 0x22, 0x87, 0x1e, + 0x16, 0x3d, 0x15, 0x3d, 0x6c, 0x8b, 0xa4, 0xf7, 0xfe, 0x85, 0x62, 0x3e, 0x28, 0xc9, 0x5f, 0xf1, + 0xc6, 0x27, 0x71, 0xe6, 0x7d, 0xde, 0x67, 0xde, 0xef, 0x19, 0x81, 0x4a, 0x38, 0x1c, 0xd4, 0x22, + 0xcc, 0xde, 0xd0, 0xe4, 0xa4, 0x36, 0x20, 0x61, 0x48, 0x68, 0x94, 0xd6, 0x62, 0x4a, 0xc3, 0x6a, + 0x9c, 0x50, 0x46, 0xe1, 0x5a, 0x38, 0x1c, 0x54, 0x15, 0xa0, 0x9a, 0x01, 0xcc, 0xb5, 0x1e, 0xed, + 0x51, 0x01, 0xa8, 0xf1, 0x2f, 0x89, 0x35, 0xcb, 0x3d, 0x4a, 0x7b, 0x21, 0xae, 0x89, 0x55, 0x77, + 0x78, 0x5c, 0x0b, 0x86, 0x09, 0x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x21, 0xfc, 0x04, 0xdc, + 0xe7, 0x39, 0xf6, 0x48, 0x20, 0xcc, 0xcc, 0xb9, 0x8b, 0x7c, 0xd9, 0x0c, 0xe0, 0x1a, 0x58, 0x08, + 0x70, 0x44, 0x07, 0xd2, 0x40, 0x57, 0x2e, 0xe0, 0x63, 0x50, 0xe4, 0x1e, 0x9c, 0x62, 0x4f, 0x0a, + 0xe7, 0xa5, 0x6b, 0x72, 0xaf, 0x21, 0x20, 0x1b, 0x20, 0xef, 0xf7, 0x11, 0x89, 0x38, 0x65, 0x4e, + 0x88, 0xef, 0x8b, 0x75, 0x33, 0x80, 0x4f, 0x40, 0xc9, 0xa7, 0x51, 0x84, 0x7d, 0x1e, 0x03, 0x2e, + 0x5f, 0x10, 0xf2, 0xe2, 0x74, 0xb3, 0x19, 0xc0, 0x2a, 0x58, 0x65, 0x09, 0x8a, 0xd2, 0x63, 0x9c, + 0x78, 0x7e, 0x1f, 0x45, 0x11, 0x16, 0xd6, 0x2d, 0x0a, 0xe8, 0x4a, 0x26, 0xaa, 0x4b, 0x49, 0x33, + 0x80, 0xdb, 0x60, 0x95, 0xf8, 0xc8, 0x0b, 0x70, 0x4c, 0x53, 0xc2, 0xbc, 0x98, 0x26, 0x8c, 0xe3, + 0xef, 0x0b, 0xbc, 0x4e, 0x7c, 0xd4, 0x90, 0x92, 0x16, 0x4d, 0x58, 0x33, 0x80, 0xcf, 0xc0, 0x43, + 0x0e, 0x17, 0x49, 0x14, 0x9e, 0x67, 0x0a, 0x79, 0xa1, 0x00, 0x89, 0x8f, 0x5a, 0x99, 0x4c, 0xa9, + 0xfc, 0x02, 0x14, 0x04, 0x52, 0x44, 0xba, 0x20, 0x22, 0x5d, 0xbe, 0x3e, 0xd2, 0x3c, 0xa4, 0x22, + 0xca, 0xf9, 0x58, 0x7d, 0xc1, 0x26, 0x00, 0xa7, 0x28, 0x24, 0x01, 0x62, 0x34, 0x49, 0x0d, 0x60, + 0xcd, 0x6f, 0x2d, 0xed, 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0xb9, 0x16, 0x7d, 0x70, 0xd8, 0x38, 0xda, 0x77, 0x3c, 0xbb, 0x5e, 0x3f, 0x3c, 0x7a, + 0xd5, 0xd1, 0xef, 0x99, 0xeb, 0xa3, 0xb1, 0x05, 0x85, 0xde, 0x01, 0xe5, 0xaf, 0x1d, 0xdb, 0x17, + 0xd7, 0x11, 0xac, 0x5e, 0xb1, 0xcf, 0x75, 0x0e, 0x0e, 0x3b, 0x8e, 0x3c, 0x6f, 0xde, 0x7c, 0x30, + 0x1a, 0x5b, 0xc0, 0xc5, 0x03, 0xca, 0x30, 0x3f, 0x50, 0xba, 0xb9, 0xfb, 0xe2, 0xed, 0xbb, 0xb2, + 0xf6, 0xdd, 0xbb, 0xb2, 0xf6, 0x9f, 0x77, 0x65, 0xed, 0xdb, 0xf7, 0xe5, 0xb9, 0xef, 0xde, 0x97, + 0xe7, 0xfe, 0xf9, 0xbe, 0x3c, 0xf7, 0x9b, 0xed, 0x99, 0x66, 0x09, 0x87, 0x83, 0xed, 0xec, 0x5f, + 0x8f, 0x78, 0xba, 0xd7, 0xce, 0xa6, 0xff, 0x7e, 0x44, 0xdf, 0x74, 0x17, 0xc5, 0x94, 0x78, 0xfe, + 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, 0xab, 0x71, 0x34, 0x36, 0x0e, 0x00, 0x00, } func (m *FeeTaker) Marshal() (dAtA []byte, err error) { @@ -723,6 +769,13 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x80 } + if m.ClosingStep != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.ClosingStep)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xf8 + } if len(m.FeeTakers) > 0 { for iNdEx := len(m.FeeTakers) - 1; iNdEx >= 0; iNdEx-- { { @@ -1157,6 +1210,9 @@ func (m *Pool) Size() (n int) { n += 2 + l + sovPool(uint64(l)) } } + if m.ClosingStep != 0 { + n += 2 + sovPool(uint64(m.ClosingStep)) + } if m.State != 0 { n += 2 + sovPool(uint64(m.State)) } @@ -2212,6 +2268,25 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 31: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClosingStep", wireType) + } + m.ClosingStep = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClosingStep |= PoolClosingStep(b&0x7F) << shift + if b < 0x80 { + break + } + } case 32: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) From 904ea8263a4e50ce0f9711f4a79dfcd54cf9e670 Mon Sep 17 00:00:00 2001 From: Segfault <5221072+Segfaultd@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:27:04 +0100 Subject: [PATCH 02/11] Final implementation files --- app/app.go | 1 + proto/lum/network/millions/gov.proto | 9 + proto/lum/network/millions/pool.proto | 12 +- x/millions/client/cli/proposal.go | 84 ++++++ x/millions/client/proposal_handler.go | 1 + x/millions/genesis_test.go | 4 +- x/millions/handler_proposal.go | 4 + x/millions/keeper/keeper_draw.go | 5 +- x/millions/keeper/keeper_pool.go | 63 ++-- x/millions/keeper/keeper_pool_test.go | 4 +- x/millions/keeper/keeper_withdrawal.go | 2 +- x/millions/types/codec.go | 2 + x/millions/types/gov.pb.go | 380 ++++++++++++++++++++---- x/millions/types/pool.pb.go | 263 ++++++---------- x/millions/types/proposal_close_pool.go | 53 ++++ 15 files changed, 603 insertions(+), 284 deletions(-) create mode 100644 x/millions/types/proposal_close_pool.go diff --git a/app/app.go b/app/app.go index 9009df42..8ac4d369 100644 --- a/app/app.go +++ b/app/app.go @@ -142,6 +142,7 @@ var ( ibcclientclient.UpgradeProposalHandler, dfractclient.UpdateParamsProposalHandler, millionsclient.RegisterPoolProposalHandler, + millionsclient.ClosePoolProposalHandler, millionsclient.UpdatePoolProposalHandler, millionsclient.UpdateParamsProposalHandler, }, diff --git a/proto/lum/network/millions/gov.proto b/proto/lum/network/millions/gov.proto index 0711d67d..00e7c2b8 100644 --- a/proto/lum/network/millions/gov.proto +++ b/proto/lum/network/millions/gov.proto @@ -64,6 +64,15 @@ message ProposalUpdatePool { repeated FeeTaker fee_takers = 11 [ (gogoproto.nullable) = false ]; } +message ProposalClosePool { + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + + uint64 pool_id = 3; +} + message ProposalUpdateParams { option (gogoproto.goproto_stringer) = false; diff --git a/proto/lum/network/millions/pool.proto b/proto/lum/network/millions/pool.proto index 8f350f63..f415ffab 100644 --- a/proto/lum/network/millions/pool.proto +++ b/proto/lum/network/millions/pool.proto @@ -34,16 +34,6 @@ enum PoolState { POOL_STATE_CLOSED = 5 [ (gogoproto.enumvalue_customname) = "Closed" ]; } -enum PoolClosingStep { - option (gogoproto.goproto_enum_prefix) = true; - - POOL_CLOSING_STEP_UNSPECIFIED = 0 - [ (gogoproto.enumvalue_customname) = "Unspecified" ]; - POOL_CLOSING_STEP_WITHDRAW = 1 - [ (gogoproto.enumvalue_customname) = "Withdraw" ]; - POOL_CLOSING_STEP_DRAW = 2 [ (gogoproto.enumvalue_customname) = "Draw" ]; -} - // PoolType the type of Pool // Each PoolType implements a dedicated runner which applies its own Pool // Lifecycle in order to deliver yield and distribute prizes @@ -131,7 +121,7 @@ message Pool { [ (gogoproto.nullable) = false ]; repeated FeeTaker fee_takers = 30 [ (gogoproto.nullable) = false ]; - PoolClosingStep closing_step = 31; + reserved 31; PoolState state = 32; int64 created_at_height = 33; diff --git a/x/millions/client/cli/proposal.go b/x/millions/client/cli/proposal.go index 65eee953..e7e1106f 100644 --- a/x/millions/client/cli/proposal.go +++ b/x/millions/client/cli/proposal.go @@ -17,6 +17,18 @@ import ( "github.com/lum-network/chain/x/millions/types" ) +func parseClosePoolProposalFile(cdc codec.JSONCodec, proposalFile string) (proposal types.ProposalClosePool, err error) { + contents, err := os.ReadFile(proposalFile) + if err != nil { + return proposal, err + } + + if err = cdc.UnmarshalJSON(contents, &proposal); err != nil { + return proposal, err + } + return proposal, nil +} + func parseRegisterPoolProposalFile(cdc codec.JSONCodec, proposalFile string) (proposal types.ProposalRegisterPool, err error) { contents, err := os.ReadFile(proposalFile) if err != nil { @@ -235,6 +247,78 @@ Where proposal.json contains: return cmd } +func CmdProposalClosePool() *cobra.Command { + cmd := &cobra.Command{ + Use: "millions-close-pool [proposal-file]", + Short: "Submit a millions close pool proposal", + Long: strings.TrimSpace( + fmt.Sprintf(`Submit a ClosePool proposal along with an initial deposit. +The proposal details must be supplied via a JSON file. + +Example: +$ %s tx gov submit-legacy-proposal millions-close-pool --from= + +Where proposal.json contains: +{ + "title": "Close my pool", + "description": "This is my close pool", + "pool_id": 1 +} +`, version.AppName), + ), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + // Acquire the client context + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // Parse the proposal file + proposal, err := parseClosePoolProposalFile(clientCtx.Codec, args[0]) + if err != nil { + return err + } + + if err := proposal.ValidateBasic(); err != nil { + return err + } + + // Grab the parameters + from := clientCtx.GetFromAddress() + + // Grab the deposit + depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit) + if err != nil { + return err + } + + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + msg, err := govtypes.NewMsgSubmitProposal(&proposal, deposit, from) + if err != nil { + return err + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + // Generate the transaction + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(govcli.FlagDeposit, "1ulum", "deposit of proposal") + if err := cmd.MarkFlagRequired(govcli.FlagDeposit); err != nil { + panic(err) + } + return cmd +} + func CmdProposalUpdateParams() *cobra.Command { cmd := &cobra.Command{ Use: "millions-update-params [proposal-file]", diff --git a/x/millions/client/proposal_handler.go b/x/millions/client/proposal_handler.go index dcbe7eec..a9d24ec5 100644 --- a/x/millions/client/proposal_handler.go +++ b/x/millions/client/proposal_handler.go @@ -9,5 +9,6 @@ import ( var ( RegisterPoolProposalHandler = govclient.NewProposalHandler(cli.CmdProposalRegisterPool) UpdatePoolProposalHandler = govclient.NewProposalHandler(cli.CmdProposalUpdatePool) + ClosePoolProposalHandler = govclient.NewProposalHandler(cli.CmdProposalClosePool) UpdateParamsProposalHandler = govclient.NewProposalHandler(cli.CmdProposalUpdateParams) ) diff --git a/x/millions/genesis_test.go b/x/millions/genesis_test.go index dbe514f4..69d90647 100644 --- a/x/millions/genesis_test.go +++ b/x/millions/genesis_test.go @@ -71,7 +71,7 @@ var testGenesis = millionstypes.GenesisState{ {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", + State: millionstypes.PoolState_Closed, Bech32PrefixAccAddr: "lum", Bech32PrefixValAddr: "lumvaloper", FeeTakers: []millionstypes.FeeTaker{ {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, }, @@ -87,7 +87,7 @@ var testGenesis = millionstypes.GenesisState{ {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", + State: millionstypes.PoolState_Closed, Bech32PrefixAccAddr: "lum", Bech32PrefixValAddr: "lumvaloper", FeeTakers: []millionstypes.FeeTaker{ {Destination: authtypes.FeeCollectorName, Amount: sdk.NewDecWithPrec(millionstypes.DefaultFeeTakerAmount, 2), Type: millionstypes.FeeTakerType_LocalModuleAccount}, }, diff --git a/x/millions/handler_proposal.go b/x/millions/handler_proposal.go index 61212375..a5539ad5 100644 --- a/x/millions/handler_proposal.go +++ b/x/millions/handler_proposal.go @@ -13,6 +13,10 @@ import ( func NewMillionsProposalHandler(k keeper.Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { + case *types.ProposalClosePool: + { + return k.ClosePool(ctx, c.PoolId, false) + } case *types.ProposalUpdatePool: { return k.UpdatePool(ctx, c.PoolId, c.Validators, c.MinDepositAmount, c.UnbondingDuration, c.MaxUnbondingEntries, c.DrawSchedule, c.PrizeStrategy, c.State, c.FeeTakers) diff --git a/x/millions/keeper/keeper_draw.go b/x/millions/keeper/keeper_draw.go index bd2981c6..cbecf8b5 100644 --- a/x/millions/keeper/keeper_draw.go +++ b/x/millions/keeper/keeper_draw.go @@ -508,8 +508,7 @@ func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw * // If the pool is in closing state, notify the close method // Discard the error here since we do not want to return an error on a successful draw if pool.State == types.PoolState_Closing { - if err := k.ClosePool(ctx, pool.PoolId); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Failed to close pool %d: %v", pool.PoolId, err)) + if err := k.ClosePool(ctx, pool.PoolId, true); err != nil { return draw, nil } } @@ -517,7 +516,7 @@ func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw * } // ComputeDepositsTWB takes deposits and computes the weight based on their deposit time and the draw duration -// It essentially compute the Time Weighted Balance of each deposit for the DrawPrizes phase +// It essentially computes the Time Weighted Balance of each deposit for the DrawPrizes phase func (k Keeper) ComputeDepositsTWB(ctx sdk.Context, depositStartAt time.Time, drawAt time.Time, deposits []types.Deposit) []DepositTWB { params := k.GetParams(ctx) diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index daceeb39..b159aa6e 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -318,7 +318,6 @@ func (k Keeper) RegisterPool( SponsorshipAmount: sdk.ZeroInt(), AvailablePrizePool: sdk.NewCoin(denom, sdk.ZeroInt()), State: types.PoolState_Created, - ClosingStep: types.PoolClosingStep_Unspecified, FeeTakers: fees, TransferChannelId: transferChannelId, CreatedAtHeight: ctx.BlockHeight(), @@ -481,7 +480,7 @@ func (k Keeper) UpdatePool( } // ClosePool It is a deterministic method that proceed with pool closure steps based on the current pool state -func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { +func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64, finalStep bool) error { // Make sure we always have a valid pool entity pool, err := k.GetPool(ctx, poolID) if err != nil { @@ -497,7 +496,6 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { if pool.State == types.PoolState_Ready { // Update the pool state to "Closing" pool.State = types.PoolState_Closing - pool.ClosingStep = types.PoolClosingStep_Withdraw k.updatePool(ctx, &pool) k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state closing", poolID)) @@ -543,10 +541,7 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { k.Logger(ctx).Info(fmt.Sprintf("Created %d withdrawals for pool %d", len(deposits), poolID)) } else if pool.State == types.PoolState_Closing { - // After that, we are in the second step of the closure process - // If the actual closing step is withdrawal, we have to watch the withdrawal list and wait for it to be empty - // Then we can proceed with the final draw - if pool.ClosingStep == types.PoolClosingStep_Withdraw { + if !finalStep { // Acquire the withdrawals and make sure we have none withdrawals := k.ListPoolWithdrawals(ctx, poolID) if len(withdrawals) > 0 { @@ -554,38 +549,34 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { return nil } - // If we have no withdrawals, we can proceed with the final draw - draw, err := k.LaunchNewDraw(ctx, poolID) - if err != nil { - return err - } - - // And update the final state - pool.ClosingStep = types.PoolClosingStep_Draw - k.updatePool(ctx, &pool) - k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state draw with drawID %d", poolID, draw.DrawId)) - return nil - } else if pool.ClosingStep == types.PoolClosingStep_Draw { - // Wait for the actual draw to be completed - if pool.LastDrawState != types.DrawState_Success { - k.Logger(ctx).Debug(fmt.Sprintf("Pool %d last draw is not yet completed", poolID)) - return nil - } - - // Transfer the remaining dust on local module account to community pool - // This is to avoid having dust on the module account - // This is not a critical step, so we don't need to return an error if it fails - currentLocalBalance := k.BankKeeper.GetBalance(ctx, sdk.MustAccAddressFromBech32(pool.LocalAddress), pool.Denom) - if currentLocalBalance.IsPositive() { - if err := k.BankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, distribtypes.ModuleName, sdk.NewCoins(currentLocalBalance)); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Failed to transfer dust from pool %d local module account to community pool: %v", poolID, err)) + // If the last draw state is success, it means we haven't launched the final draw yet + if pool.LastDrawState == types.DrawState_Success { + draw, err := k.LaunchNewDraw(ctx, poolID) + if err != nil { + return err } + k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to launch draw with drawID %d", poolID, draw.DrawId)) } + } else { + // Only proceed if the final draw succeeded + if pool.LastDrawState == types.DrawState_Success { + // Transfer the remaining dust on local module account to community pool + // This is to avoid having dust on the module account + // This is not a critical step, so we don't need to return an error if it fails + currentLocalBalance := k.BankKeeper.GetBalance(ctx, sdk.MustAccAddressFromBech32(pool.LocalAddress), pool.Denom) + if currentLocalBalance.IsPositive() { + if err := k.BankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, distribtypes.ModuleName, sdk.NewCoins(currentLocalBalance)); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("Failed to transfer dust from pool %d local module account to community pool: %v", poolID, err)) + } + } - // Once everything is done, we can update the state to closed - pool.State = types.PoolState_Closed - k.updatePool(ctx, &pool) - k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state closed", poolID)) + // Once everything is done, we can update the state to closed + pool.State = types.PoolState_Closed + k.updatePool(ctx, &pool) + k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state closed", poolID)) + } else { + k.Logger(ctx).Error(fmt.Sprintf("Pool %d cannot be closed because the last draw state is not success", poolID)) + } } } else { return types.ErrPoolNotClosing diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index 5d68c9a6..58ab53e9 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -207,7 +207,7 @@ func (suite *KeeperTestSuite) TestPool_DrawScheduleBasics() { suite.Require().True(pool.ShouldDraw(ctx.WithBlockTime((*pool.LastDrawCreatedAt).Add(48 * time.Hour)))) // Test pool not ready states which should not allow any draw - pool.State = millionstypes.PoolState_Killed + pool.State = millionstypes.PoolState_Closed suite.Require().False(pool.ShouldDraw(ctx.WithBlockTime(now.Add(48 * time.Hour)))) pool.State = millionstypes.PoolState_Created @@ -1095,7 +1095,7 @@ func (suite *KeeperTestSuite) TestPool_UpdatePool() { 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, newFees) + err = app.MillionsKeeper.UpdatePool(ctx, pool.PoolId, nil, &newDepositAmount, &UnbondingDuration, &maxUnbondingEntries, &newDrawSchedule, &newPrizeStrategy, millionstypes.PoolState_Closed, newFees) suite.Require().ErrorIs(err, millionstypes.ErrPoolStateChangeNotAllowed) // Grab fresh pool instance pool, err = app.MillionsKeeper.GetPool(ctx, 1) diff --git a/x/millions/keeper/keeper_withdrawal.go b/x/millions/keeper/keeper_withdrawal.go index ca6d6c45..2279abb0 100644 --- a/x/millions/keeper/keeper_withdrawal.go +++ b/x/millions/keeper/keeper_withdrawal.go @@ -157,7 +157,7 @@ func (k Keeper) OnTransferWithdrawalToRecipientCompleted(ctx sdk.Context, poolID // Notify the closing method to check if the step can continue // Discard any error here to avoid blocking the process on relaying side - if err := k.ClosePool(ctx, poolID); err != nil { + if err := k.ClosePool(ctx, poolID, false); err != nil { k.Logger(ctx).Error(fmt.Sprintf("ClosePool %v", err.Error())) } return nil diff --git a/x/millions/types/codec.go b/x/millions/types/codec.go index 4819b579..0c0aadb5 100644 --- a/x/millions/types/codec.go +++ b/x/millions/types/codec.go @@ -32,6 +32,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&ProposalUpdateParams{}, "lum-network/millions/ProposalUpdateParams", nil) cdc.RegisterConcrete(&ProposalRegisterPool{}, "lum-network/millions/ProposalRegisterPool", nil) cdc.RegisterConcrete(&ProposalUpdatePool{}, "lum-network/millions/ProposalUpdatePool", nil) + cdc.RegisterConcrete(&ProposalClosePool{}, "lum-network/millions/ProposalClosePool", nil) } // RegisterInterfaces Register the implementations for the given codecs @@ -51,6 +52,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*govtypesv1beta1.Content)(nil), &ProposalUpdateParams{}) registry.RegisterImplementations((*govtypesv1beta1.Content)(nil), &ProposalRegisterPool{}) registry.RegisterImplementations((*govtypesv1beta1.Content)(nil), &ProposalUpdatePool{}) + registry.RegisterImplementations((*govtypesv1beta1.Content)(nil), &ProposalClosePool{}) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/millions/types/gov.pb.go b/x/millions/types/gov.pb.go index 813d1d74..1681949c 100644 --- a/x/millions/types/gov.pb.go +++ b/x/millions/types/gov.pb.go @@ -295,6 +295,65 @@ func (m *ProposalUpdatePool) GetFeeTakers() []FeeTaker { return nil } +type ProposalClosePool 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"` + PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` +} + +func (m *ProposalClosePool) Reset() { *m = ProposalClosePool{} } +func (*ProposalClosePool) ProtoMessage() {} +func (*ProposalClosePool) Descriptor() ([]byte, []int) { + return fileDescriptor_f51755d1062ffc9e, []int{2} +} +func (m *ProposalClosePool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProposalClosePool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProposalClosePool.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 *ProposalClosePool) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProposalClosePool.Merge(m, src) +} +func (m *ProposalClosePool) XXX_Size() int { + return m.Size() +} +func (m *ProposalClosePool) XXX_DiscardUnknown() { + xxx_messageInfo_ProposalClosePool.DiscardUnknown(m) +} + +var xxx_messageInfo_ProposalClosePool proto.InternalMessageInfo + +func (m *ProposalClosePool) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *ProposalClosePool) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *ProposalClosePool) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + 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"` @@ -310,7 +369,7 @@ type ProposalUpdateParams struct { func (m *ProposalUpdateParams) Reset() { *m = ProposalUpdateParams{} } func (*ProposalUpdateParams) ProtoMessage() {} func (*ProposalUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_f51755d1062ffc9e, []int{2} + return fileDescriptor_f51755d1062ffc9e, []int{3} } func (m *ProposalUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -384,73 +443,75 @@ func (m *ProposalUpdateParams) GetMinDepositDrawDelta() *time.Duration { func init() { proto.RegisterType((*ProposalRegisterPool)(nil), "lum.network.millions.ProposalRegisterPool") proto.RegisterType((*ProposalUpdatePool)(nil), "lum.network.millions.ProposalUpdatePool") + proto.RegisterType((*ProposalClosePool)(nil), "lum.network.millions.ProposalClosePool") proto.RegisterType((*ProposalUpdateParams)(nil), "lum.network.millions.ProposalUpdateParams") } func init() { proto.RegisterFile("lum/network/millions/gov.proto", fileDescriptor_f51755d1062ffc9e) } var fileDescriptor_f51755d1062ffc9e = []byte{ - // 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, 0xed, 0x69, 0x53, 0xfe, 0x0a, - 0x8e, 0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 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, 0xcb, 0xad, 0xd5, 0xbb, 0xb2, 0xbf, 0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25, 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, + // 961 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0x6b, 0x9a, 0x34, 0xc9, 0xa4, 0x2d, 0xed, 0x34, 0xdb, 0x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, 0xea, 0xe6, 0x0e, 0x56, + 0xf4, 0x31, 0x0e, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x7a, 0x9b, 0x23, 0x27, 0x0b, 0x00, + 0x00, } func (m *ProposalRegisterPool) Marshal() (dAtA []byte, err error) { @@ -747,6 +808,48 @@ func (m *ProposalUpdatePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ProposalClosePool) 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 *ProposalClosePool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProposalClosePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintGov(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x18 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *ProposalUpdateParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -996,6 +1099,26 @@ func (m *ProposalUpdatePool) Size() (n int) { return n } +func (m *ProposalClosePool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if m.PoolId != 0 { + n += 1 + sovGov(uint64(m.PoolId)) + } + return n +} + func (m *ProposalUpdateParams) Size() (n int) { if m == nil { return 0 @@ -2035,6 +2158,139 @@ func (m *ProposalUpdatePool) Unmarshal(dAtA []byte) error { } return nil } +func (m *ProposalClosePool) 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 ErrIntOverflowGov + } + 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: ProposalClosePool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProposalClosePool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", 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 + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", 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 + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ProposalUpdateParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/millions/types/pool.pb.go b/x/millions/types/pool.pb.go index aec9f78a..020dff28 100644 --- a/x/millions/types/pool.pb.go +++ b/x/millions/types/pool.pb.go @@ -76,34 +76,6 @@ func (PoolState) EnumDescriptor() ([]byte, []int) { return fileDescriptor_c1401529e8cac8ff, []int{0} } -type PoolClosingStep int32 - -const ( - PoolClosingStep_Unspecified PoolClosingStep = 0 - PoolClosingStep_Withdraw PoolClosingStep = 1 - PoolClosingStep_Draw PoolClosingStep = 2 -) - -var PoolClosingStep_name = map[int32]string{ - 0: "POOL_CLOSING_STEP_UNSPECIFIED", - 1: "POOL_CLOSING_STEP_WITHDRAW", - 2: "POOL_CLOSING_STEP_DRAW", -} - -var PoolClosingStep_value = map[string]int32{ - "POOL_CLOSING_STEP_UNSPECIFIED": 0, - "POOL_CLOSING_STEP_WITHDRAW": 1, - "POOL_CLOSING_STEP_DRAW": 2, -} - -func (x PoolClosingStep) String() string { - return proto.EnumName(PoolClosingStep_name, int32(x)) -} - -func (PoolClosingStep) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_c1401529e8cac8ff, []int{1} -} - // PoolType the type of Pool // Each PoolType implements a dedicated runner which applies its own Pool // Lifecycle in order to deliver yield and distribute prizes @@ -129,7 +101,7 @@ func (x PoolType) String() string { } func (PoolType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_c1401529e8cac8ff, []int{2} + return fileDescriptor_c1401529e8cac8ff, []int{1} } type FeeTakerType int32 @@ -160,7 +132,7 @@ func (x FeeTakerType) String() string { } func (FeeTakerType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_c1401529e8cac8ff, []int{3} + return fileDescriptor_c1401529e8cac8ff, []int{2} } type FeeTaker struct { @@ -245,7 +217,6 @@ type Pool struct { 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"` - ClosingStep PoolClosingStep `protobuf:"varint,31,opt,name=closing_step,json=closingStep,proto3,enum=lum.network.millions.PoolClosingStep" json:"closing_step,omitempty"` 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"` @@ -454,13 +425,6 @@ func (m *Pool) GetFeeTakers() []FeeTaker { return nil } -func (m *Pool) GetClosingStep() PoolClosingStep { - if m != nil { - return m.ClosingStep - } - return PoolClosingStep_Unspecified -} - func (m *Pool) GetState() PoolState { if m != nil { return m.State @@ -551,7 +515,6 @@ func (m *PoolValidator) GetIsEnabled() bool { func init() { proto.RegisterEnum("lum.network.millions.PoolState", PoolState_name, PoolState_value) - proto.RegisterEnum("lum.network.millions.PoolClosingStep", PoolClosingStep_name, PoolClosingStep_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") @@ -562,105 +525,100 @@ func init() { func init() { proto.RegisterFile("lum/network/millions/pool.proto", fileDescriptor_c1401529e8cac8ff) } var fileDescriptor_c1401529e8cac8ff = []byte{ - // 1566 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4d, 0x6f, 0xdb, 0xc8, - 0x19, 0x36, 0x63, 0xd9, 0x91, 0xc6, 0x52, 0x4c, 0x8f, 0x1d, 0x2f, 0xcd, 0x6d, 0x24, 0xc6, 0xd9, - 0x16, 0xde, 0x74, 0x2d, 0x21, 0x0e, 0xda, 0x4b, 0x51, 0x14, 0xb4, 0x44, 0x27, 0xda, 0xb5, 0x63, - 0x95, 0x92, 0x37, 0xd8, 0xa2, 0x05, 0x3b, 0x22, 0xc7, 0xd2, 0xc0, 0x14, 0x87, 0x20, 0x47, 0x8e, - 0xdd, 0x5f, 0x50, 0xe8, 0xb4, 0xc7, 0x5e, 0x84, 0x1e, 0x7a, 0xed, 0xb1, 0x3f, 0x22, 0x87, 0x1e, - 0x16, 0x3d, 0x15, 0x3d, 0x6c, 0x8b, 0xa4, 0xf7, 0xfe, 0x85, 0x62, 0x3e, 0x28, 0xc9, 0x5f, 0xf1, - 0xc6, 0x27, 0x71, 0xe6, 0x7d, 0xde, 0x67, 0xde, 0xef, 0x19, 0x81, 0x4a, 0x38, 0x1c, 0xd4, 0x22, - 0xcc, 0xde, 0xd0, 0xe4, 0xa4, 0x36, 0x20, 0x61, 0x48, 0x68, 0x94, 0xd6, 0x62, 0x4a, 0xc3, 0x6a, - 0x9c, 0x50, 0x46, 0xe1, 0x5a, 0x38, 0x1c, 0x54, 0x15, 0xa0, 0x9a, 0x01, 0xcc, 0xb5, 0x1e, 0xed, - 0x51, 0x01, 0xa8, 0xf1, 0x2f, 0x89, 0x35, 0xcb, 0x3d, 0x4a, 0x7b, 0x21, 0xae, 0x89, 0x55, 0x77, - 0x78, 0x5c, 0x0b, 0x86, 0x09, 0x62, 0x84, 0x46, 0x4a, 0x5e, 0xb9, 0x2c, 0x67, 0x64, 0x80, 0x53, - 0x86, 0x06, 0x71, 0x46, 0xe0, 0xd3, 0x74, 0x40, 0xd3, 0x5a, 0x17, 0xa5, 0xb8, 0x76, 0xfa, 0xac, - 0x8b, 0x19, 0x7a, 0x56, 0xf3, 0x29, 0xc9, 0x08, 0x36, 0xa4, 0xdc, 0x93, 0x27, 0xcb, 0x45, 0xc6, - 0x7d, 0xad, 0x23, 0x41, 0x82, 0xde, 0x28, 0xc0, 0xd6, 0x8d, 0x00, 0x2f, 0xf5, 0xfb, 0x38, 0x18, - 0x86, 0x58, 0x21, 0x3f, 0xbf, 0x3e, 0x26, 0x09, 0xf9, 0x03, 0xf6, 0x52, 0x96, 0x20, 0x86, 0x7b, - 0xe7, 0x12, 0xba, 0xf9, 0x57, 0x0d, 0xe4, 0xf7, 0x30, 0xee, 0xa0, 0x13, 0x9c, 0x40, 0x0b, 0x2c, - 0x05, 0x38, 0x65, 0x24, 0x12, 0x3e, 0x1b, 0x9a, 0xa5, 0x6d, 0x15, 0xdc, 0xd9, 0x2d, 0xb8, 0x07, - 0x16, 0xd1, 0x80, 0x0e, 0x23, 0x66, 0xdc, 0xe3, 0xc2, 0xdd, 0xea, 0xdb, 0xef, 0x2b, 0x73, 0xff, - 0xfa, 0xbe, 0xf2, 0x93, 0x1e, 0x61, 0xfd, 0x61, 0xb7, 0xea, 0xd3, 0x81, 0xf2, 0x4a, 0xfd, 0x6c, - 0xa7, 0xc1,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, 0x59, 0xb0, 0x71, 0x27, 0x0b, 0x56, 0x66, 0x98, 0x94, 0x25, - 0x47, 0x60, 0x2d, 0x44, 0xa9, 0x72, 0xdd, 0x4f, 0x30, 0x62, 0x38, 0xf0, 0x10, 0x33, 0x3e, 0x15, - 0xb5, 0x68, 0x5e, 0xa9, 0xc5, 0x4e, 0x76, 0x8f, 0x8a, 0x62, 0xd4, 0xbe, 0x15, 0xc5, 0xc8, 0x19, - 0x78, 0xa0, 0xea, 0x52, 0xdf, 0x66, 0xf0, 0x05, 0x58, 0x9e, 0xd2, 0xa6, 0x0c, 0x31, 0x6c, 0xfc, - 0x48, 0xcc, 0xb5, 0xca, 0x07, 0x7a, 0x90, 0xc3, 0xdc, 0x52, 0x46, 0x26, 0x96, 0xf0, 0xd7, 0x60, - 0x0d, 0x9d, 0x22, 0x12, 0xa2, 0x6e, 0x88, 0x65, 0xba, 0x3d, 0x9e, 0x39, 0xe3, 0x91, 0xea, 0x15, - 0x95, 0x64, 0x7e, 0x8d, 0x57, 0xd5, 0x35, 0x5e, 0xad, 0x53, 0x12, 0xa9, 0xbe, 0x83, 0x13, 0x65, - 0x91, 0x74, 0x71, 0x23, 0xd5, 0x01, 0x38, 0xc6, 0xd8, 0x63, 0xfc, 0xc6, 0x4a, 0x8d, 0xb2, 0x18, - 0x98, 0xe5, 0x0f, 0x5f, 0x6c, 0x8a, 0xad, 0x70, 0xac, 0xd6, 0xbc, 0x94, 0x8b, 0x7e, 0x48, 0x53, - 0xde, 0x67, 0x29, 0xc3, 0xb1, 0x51, 0x11, 0xde, 0xfd, 0xf8, 0xe6, 0xb9, 0x5b, 0x97, 0xe8, 0x36, - 0xc3, 0xb1, 0xbb, 0xe4, 0x4f, 0x17, 0xf0, 0x67, 0x60, 0x41, 0x06, 0xc8, 0xfa, 0x50, 0x80, 0x38, - 0x85, 0x0c, 0x90, 0x44, 0xc3, 0xa7, 0x60, 0x65, 0x9a, 0x2e, 0xaf, 0x8f, 0x49, 0xaf, 0x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 0x33, 0x19, 0xd6, 0x80, 0xb9, 0xe7, 0x38, 0x5e, - 0xc7, 0xfe, 0xca, 0x71, 0x7f, 0xd0, 0x59, 0x5f, 0x80, 0x8d, 0x4b, 0x0a, 0xfb, 0x87, 0x75, 0x7b, - 0xdf, 0xb3, 0x1b, 0x0d, 0x57, 0xd7, 0xcc, 0xd2, 0x68, 0x6c, 0x15, 0xf6, 0xb3, 0xdb, 0x16, 0xfe, - 0x0a, 0x3c, 0xb9, 0x16, 0x7d, 0x70, 0xd8, 0x38, 0xda, 0x77, 0x3c, 0xbb, 0x5e, 0x3f, 0x3c, 0x7a, - 0xd5, 0xd1, 0xef, 0x99, 0xeb, 0xa3, 0xb1, 0x05, 0x85, 0xde, 0x01, 0xe5, 0xaf, 0x1d, 0xdb, 0x17, - 0xd7, 0x11, 0xac, 0x5e, 0xb1, 0xcf, 0x75, 0x0e, 0x0e, 0x3b, 0x8e, 0x3c, 0x6f, 0xde, 0x7c, 0x30, - 0x1a, 0x5b, 0xc0, 0xc5, 0x03, 0xca, 0x30, 0x3f, 0x50, 0xba, 0xb9, 0xfb, 0xe2, 0xed, 0xbb, 0xb2, - 0xf6, 0xdd, 0xbb, 0xb2, 0xf6, 0x9f, 0x77, 0x65, 0xed, 0xdb, 0xf7, 0xe5, 0xb9, 0xef, 0xde, 0x97, - 0xe7, 0xfe, 0xf9, 0xbe, 0x3c, 0xf7, 0x9b, 0xed, 0x99, 0x66, 0x09, 0x87, 0x83, 0xed, 0xec, 0x5f, - 0x8f, 0x78, 0xba, 0xd7, 0xce, 0xa6, 0xff, 0x7e, 0x44, 0xdf, 0x74, 0x17, 0xc5, 0x94, 0x78, 0xfe, - 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, 0xab, 0x71, 0x34, 0x36, 0x0e, 0x00, 0x00, + // 1479 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x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x45, 0xc6, 0xb4, 0xf0, 0x7d, 0x5e, 0x4a, 0x1b, 0x42, 0x58, 0x71, 0xdd, 0x8a, 0xe7, 0x45, + 0x17, 0x95, 0x0e, 0x91, 0x2f, 0x95, 0xb2, 0x17, 0x95, 0x5e, 0x20, 0x5f, 0x28, 0x7d, 0x05, 0x60, + 0x8f, 0x04, 0x83, 0x9c, 0xaa, 0x56, 0xcd, 0x7d, 0x71, 0xab, 0xd6, 0x03, 0x66, 0xeb, 0x3d, 0x12, + 0xa8, 0x12, 0x54, 0x64, 0xd3, 0xee, 0x80, 0xdc, 0x99, 0x69, 0x33, 0x66, 0x4c, 0x6d, 0x6d, 0xfa, + 0xaa, 0xee, 0xad, 0x45, 0xe8, 0x55, 0x53, 0x21, 0x55, 0x52, 0xb2, 0xde, 0xc8, 0x1e, 0x6c, 0x80, + 0x99, 0xb3, 0x23, 0x69, 0xcc, 0x0a, 0xbe, 0xab, 0xb2, 0xcc, 0xb1, 0x4d, 0x05, 0x55, 0x84, 0xb9, + 0x70, 0x74, 0x13, 0xda, 0x00, 0xf6, 0x83, 0x36, 0x0d, 0x3c, 0x12, 0x74, 0x9c, 0xe4, 0xe8, 0x32, + 0x74, 0xc1, 0xba, 0x5c, 0x92, 0x67, 0x57, 0x29, 0x39, 0xbb, 0x4a, 0x35, 0x05, 0xd8, 0x4c, 0x73, + 0xae, 0xef, 0x7e, 0x2d, 0x6a, 0xf6, 0xdc, 0x40, 0x3d, 0x11, 0xc2, 0x36, 0x58, 0xec, 0xa1, 0x23, + 0x67, 0xc8, 0x8b, 0x03, 0x16, 0x11, 0x1c, 0x1b, 0x73, 0x37, 0xca, 0xea, 0x7c, 0x0f, 0x1d, 0xed, + 0x25, 0x5c, 0x96, 0xa4, 0x82, 0xff, 0x01, 0x39, 0x9f, 0xba, 0xaa, 0xbe, 0x38, 0x8e, 0x0d, 0x28, + 0xb8, 0x8d, 0x9f, 0x7e, 0xdc, 0x58, 0x50, 0x67, 0x64, 0x45, 0x4a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x0d, 0x00, 0x00, } func (m *FeeTaker) Marshal() (dAtA []byte, err error) { @@ -769,13 +727,6 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x80 } - if m.ClosingStep != 0 { - i = encodeVarintPool(dAtA, i, uint64(m.ClosingStep)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xf8 - } if len(m.FeeTakers) > 0 { for iNdEx := len(m.FeeTakers) - 1; iNdEx >= 0; iNdEx-- { { @@ -1210,9 +1161,6 @@ func (m *Pool) Size() (n int) { n += 2 + l + sovPool(uint64(l)) } } - if m.ClosingStep != 0 { - n += 2 + sovPool(uint64(m.ClosingStep)) - } if m.State != 0 { n += 2 + sovPool(uint64(m.State)) } @@ -2268,25 +2216,6 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 31: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ClosingStep", wireType) - } - m.ClosingStep = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ClosingStep |= PoolClosingStep(b&0x7F) << shift - if b < 0x80 { - break - } - } case 32: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) diff --git a/x/millions/types/proposal_close_pool.go b/x/millions/types/proposal_close_pool.go new file mode 100644 index 00000000..c729d892 --- /dev/null +++ b/x/millions/types/proposal_close_pool.go @@ -0,0 +1,53 @@ +package types + +import ( + "fmt" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +const ( + ProposalTypeClosePool = "ClosePool" +) + +var ( + _ govtypes.Content = &ProposalClosePool{} +) + +func init() { + govtypes.RegisterProposalType(ProposalTypeClosePool) +} + +func NewClosePoolProposal(title string, description string, poolID uint64) govtypes.Content { + return &ProposalClosePool{ + Title: title, + Description: description, + PoolId: poolID, + } +} + +func (p *ProposalClosePool) ProposalRoute() string { return RouterKey } + +func (p *ProposalClosePool) ProposalType() string { + return ProposalTypeClosePool +} + +func (p *ProposalClosePool) ValidateBasic() error { + // Validate root proposal content + err := govtypes.ValidateAbstract(p) + if err != nil { + return err + } + + return nil +} + +func (p ProposalClosePool) String() string { + // Return the string + return fmt.Sprintf(`Register Pool Proposal: + Title: %s + Description: %s + PoolID: %d + `, + p.Title, p.Description, p.PoolId, + ) +} From b4e3b5b5edfedf2ea88dea0273c5cf3de787eade Mon Sep 17 00:00:00 2001 From: Segfault <5221072+Segfaultd@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:13:32 +0100 Subject: [PATCH 03/11] Fix formatting --- x/millions/types/proposal_close_pool.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/millions/types/proposal_close_pool.go b/x/millions/types/proposal_close_pool.go index c729d892..62613434 100644 --- a/x/millions/types/proposal_close_pool.go +++ b/x/millions/types/proposal_close_pool.go @@ -2,6 +2,7 @@ package types import ( "fmt" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) From 82220674dd8c14b667dcc520e5002fe4fe29b0ce Mon Sep 17 00:00:00 2001 From: Fabrice Bascoulergue Date: Wed, 6 Mar 2024 11:12:35 +0100 Subject: [PATCH 04/11] Make close pool procedure more deterministic --- x/millions/handler_proposal.go | 2 +- x/millions/keeper/keeper_deposit.go | 9 ++ x/millions/keeper/keeper_draw.go | 22 +++- x/millions/keeper/keeper_pool.go | 168 +++++++++++++------------ x/millions/keeper/keeper_withdrawal.go | 15 ++- 5 files changed, 128 insertions(+), 88 deletions(-) diff --git a/x/millions/handler_proposal.go b/x/millions/handler_proposal.go index a5539ad5..cf96b090 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.ProposalClosePool: { - return k.ClosePool(ctx, c.PoolId, false) + return k.ClosePool(ctx, c.PoolId) } case *types.ProposalUpdatePool: { diff --git a/x/millions/keeper/keeper_deposit.go b/x/millions/keeper/keeper_deposit.go index 085f12a9..e1def476 100644 --- a/x/millions/keeper/keeper_deposit.go +++ b/x/millions/keeper/keeper_deposit.go @@ -120,6 +120,15 @@ func (k Keeper) OnDelegateDepositOnRemoteZoneCompleted(ctx sdk.Context, poolID u pool.ApplySplitDelegate(ctx, splits) k.updatePool(ctx, &pool) k.UpdateDepositStatus(ctx, poolID, depositID, types.DepositState_Success, false) + + if pool.State == types.PoolState_Closing { + // Continue closing procedure + // voluntary ignore errors + if err := k.ClosePool(ctx, poolID); err != nil { + k.Logger(ctx).With("ctx", "deposit_completed", "pool_id", poolID).Error("Silently failed to continue close pool procedure: %v", err) + } + } + return nil } diff --git a/x/millions/keeper/keeper_draw.go b/x/millions/keeper/keeper_draw.go index cbecf8b5..dceae109 100644 --- a/x/millions/keeper/keeper_draw.go +++ b/x/millions/keeper/keeper_draw.go @@ -408,11 +408,23 @@ func (k Keeper) ExecuteDraw(ctx sdk.Context, poolID uint64, drawID uint64) (*typ draw.PrizePoolRemainsAmount = pool.AvailablePrizePool.Amount draw.PrizePool = draw.PrizePool.Add(pool.AvailablePrizePool) + prizeStrat := pool.PrizeStrategy + + if pool.State == types.PoolState_Closing { + // Pool is unfortunately closing but some people will be lucky + // Modify prize distribution to distribute the full prize pool in one draw + // which is equal to making all batches not unique and with a 100% draw probability + for i := range prizeStrat.PrizeBatches { + prizeStrat.PrizeBatches[i].IsUnique = false + prizeStrat.PrizeBatches[i].DrawProbability = sdk.OneDec() + } + } + // Draw prizes dRes, err := k.RunDrawPrizes( ctx, draw.PrizePool, - pool.PrizeStrategy, + prizeStrat, depositorsTWB, draw.RandSeed, ) @@ -505,11 +517,11 @@ func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw * pool.LastDrawState = draw.State k.updatePool(ctx, pool) - // If the pool is in closing state, notify the close method - // Discard the error here since we do not want to return an error on a successful draw if pool.State == types.PoolState_Closing { - if err := k.ClosePool(ctx, pool.PoolId, true); err != nil { - return draw, nil + // Continue closing procedure + // voluntary ignore errors + if err := k.ClosePool(ctx, pool.GetPoolId()); err != nil { + k.Logger(ctx).With("ctx", "draw_completed", "pool_id", pool.GetPoolId()).Error("Silently failed to continue close pool procedure: %v", err) } } return draw, err diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index b159aa6e..123028a3 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -479,109 +479,121 @@ func (k Keeper) UpdatePool( return nil } -// ClosePool It is a deterministic method that proceed with pool closure steps based on the current pool state -func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64, finalStep bool) error { +// ClosePool iterate through many stages to close a Pool based on its local state, deposits and withdrawals +// +// Closing procedure steps: +// 1. Move pool into state Closing +// 2. Launch the final Draw +// 3. Launch the withdrawal of all the deposits +// 4. Wait for all withdrawals to complete +func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { + logger := k.Logger(ctx).With("ctx", "close_pool", "pool_id", poolID) + // Make sure we always have a valid pool entity pool, err := k.GetPool(ctx, poolID) if err != nil { return err } - // Make sure the pool is not already closed - if pool.State == types.PoolState_Closed { + // Make sure the pool can be closed or is already closing + if pool.State != types.PoolState_Ready && + pool.State != types.PoolState_Paused && + pool.State != types.PoolState_Closing { return types.ErrPoolClosed } - // If the pool is in state "ready", it means we are in the very first step of the closure process - if pool.State == types.PoolState_Ready { - // Update the pool state to "Closing" + // Step 1: Pool is not yet in closing state - launch closing procedure + if pool.State != types.PoolState_Closing { + logger.Info("Update pool to state closing") pool.State = types.PoolState_Closing + pool.UpdatedAt = ctx.BlockTime() + pool.UpdatedAtHeight = ctx.BlockHeight() k.updatePool(ctx, &pool) - k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state closing", poolID)) - - // Acquire all deposits - deposits := k.ListPoolDeposits(ctx, poolID) - // Update the prize strategy now to distribute 100% of the prize pool to the depositors - // Do it now because once you create a withdrawal, you delete deposit - pool.PrizeStrategy = types.PrizeStrategy{ - PrizeBatches: []types.PrizeBatch{ - {Quantity: uint64(len(deposits)), PoolPercent: 1, DrawProbability: sdk.NewDec(1), IsUnique: true}, - }, + // Launch step 2 final draw + logger.Info("Launch final draw") + if _, err := k.LaunchNewDraw(ctx, poolID); err != nil { + logger.Error(fmt.Sprintf("Error while launching final draw: %v", err)) + return err } - k.updatePool(ctx, &pool) - k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d prize strategy to distribute 100%% of the prize pool to the depositors", poolID)) + } - // Iterate over all deposits - for _, deposit := range deposits { - // Make sure the deposit can be withdrawn - if deposit.State != types.DepositState_Success { - continue - } + // Step 2: Launch final Draw and wait for its completion + if pool.LastDrawState != types.DrawState_Success { + return nil + } - // Trigger the withdrawal - withdrawal := types.Withdrawal{ - PoolId: poolID, - DepositId: deposit.DepositId, - WithdrawalId: k.GetNextWithdrawalIdAndIncrement(ctx), - State: types.WithdrawalState_Pending, - DepositorAddress: deposit.GetDepositorAddress(), - ToAddress: deposit.GetDepositorAddress(), - Amount: deposit.Amount, - CreatedAtHeight: ctx.BlockHeight(), - UpdatedAtHeight: ctx.BlockHeight(), - CreatedAt: ctx.BlockTime(), - UpdatedAt: ctx.BlockTime(), + // Step 3: Initiate the withdrawal of all the deposits + deposits := k.ListPoolDeposits(ctx, poolID) + if len(deposits) > 0 { + logger.Info("Initiate the withdrawal of all deposits") + // As long as we have deposits we will keep trying to withdraw them before moving forward + serv := msgServer{Keeper: k} + for _, deposit := range deposits { + if deposit.State == types.DepositState_Failure { + // Force retry deposits in error states + logger.Info(fmt.Sprintf("Retrying deposit with ID %d in error state %s", deposit.GetDepositId(), deposit.GetErrorState().String())) + _, err := serv.DepositRetry(ctx, &types.MsgDepositRetry{ + PoolId: deposit.GetPoolId(), + DepositId: deposit.GetDepositId(), + DepositorAddress: deposit.GetDepositorAddress(), + }) + if err != nil { + logger.Error(fmt.Sprintf("Error while forcing retry for deposit %d: %v", deposit.GetDepositId(), err)) + return err + } + } else { + // Withdraw deposits in success state + logger.Info(fmt.Sprintf("Withdrawing deposit with ID %d", deposit.GetDepositId())) + _, err := serv.WithdrawDeposit(ctx.Context(), types.NewMsgWithdrawDeposit( + deposit.GetDepositorAddress(), + deposit.GetDepositorAddress(), + deposit.GetPoolId(), + deposit.GetDepositId(), + )) + if err != nil { + logger.Error(fmt.Sprintf("Error while launching withdrawal for deposit with ID %d: %v", deposit.GetDepositId(), err)) + return err + } } - - // Adds the withdrawal and remove the deposit - k.AddWithdrawal(ctx, withdrawal) - k.RemoveDeposit(ctx, &deposit) } + return nil + } - k.Logger(ctx).Info(fmt.Sprintf("Created %d withdrawals for pool %d", len(deposits), poolID)) - } else if pool.State == types.PoolState_Closing { - if !finalStep { - // Acquire the withdrawals and make sure we have none - withdrawals := k.ListPoolWithdrawals(ctx, poolID) - if len(withdrawals) > 0 { - k.Logger(ctx).Debug(fmt.Sprintf("Pool %d has %d withdrawals pending", poolID, len(withdrawals))) - return nil - } - - // If the last draw state is success, it means we haven't launched the final draw yet - if pool.LastDrawState == types.DrawState_Success { - draw, err := k.LaunchNewDraw(ctx, poolID) + // Step 4: Wait for all withdrawals to complete + withdrawals := k.ListPoolWithdrawals(ctx, poolID) + if len(withdrawals) > 0 { + serv := msgServer{Keeper: k} + for _, withdrawal := range withdrawals { + if withdrawal.State == types.WithdrawalState_Failure { + // Force retry withdrawals in error state + logger.Info(fmt.Sprintf("Retrying withdrawal with ID %d in error state %s", withdrawal.GetWithdrawalId(), withdrawal.GetErrorState().String())) + _, err := serv.WithdrawDepositRetry(ctx, &types.MsgWithdrawDepositRetry{ + PoolId: withdrawal.GetPoolId(), + WithdrawalId: withdrawal.GetWithdrawalId(), + DepositorAddress: withdrawal.GetDepositorAddress(), + }) if err != nil { + logger.Error(fmt.Sprintf("Error while forcing retry for withdrawal with ID %d: %v", withdrawal.GetWithdrawalId(), err)) return err } - k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to launch draw with drawID %d", poolID, draw.DrawId)) - } - } else { - // Only proceed if the final draw succeeded - if pool.LastDrawState == types.DrawState_Success { - // Transfer the remaining dust on local module account to community pool - // This is to avoid having dust on the module account - // This is not a critical step, so we don't need to return an error if it fails - currentLocalBalance := k.BankKeeper.GetBalance(ctx, sdk.MustAccAddressFromBech32(pool.LocalAddress), pool.Denom) - if currentLocalBalance.IsPositive() { - if err := k.BankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, distribtypes.ModuleName, sdk.NewCoins(currentLocalBalance)); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Failed to transfer dust from pool %d local module account to community pool: %v", poolID, err)) - } - } - - // Once everything is done, we can update the state to closed - pool.State = types.PoolState_Closed - k.updatePool(ctx, &pool) - k.Logger(ctx).Info(fmt.Sprintf("Updated pool %d to state closed", poolID)) - } else { - k.Logger(ctx).Error(fmt.Sprintf("Pool %d cannot be closed because the last draw state is not success", poolID)) } } - } else { - return types.ErrPoolNotClosing + return nil } + // Step 5: Clear module dust and close Pool + balance := k.BankKeeper.GetBalance(ctx, sdk.MustAccAddressFromBech32(pool.LocalAddress), pool.Denom) + if balance.IsPositive() { + if err := k.BankKeeper.SendCoinsFromAccountToModule(ctx, sdk.MustAccAddressFromBech32(pool.GetLocalAddress()), authtypes.FeeCollectorName, sdk.NewCoins(balance)); err != nil { + logger.Error(fmt.Sprintf("Failed to transfer dust from pool with ID %d local account to fee collector: %v", poolID, err)) + } + } + logger.Info("Update pool to state closed") + pool.State = types.PoolState_Closed + pool.UpdatedAt = ctx.BlockTime() + pool.UpdatedAtHeight = ctx.BlockHeight() + k.updatePool(ctx, &pool) return nil } diff --git a/x/millions/keeper/keeper_withdrawal.go b/x/millions/keeper/keeper_withdrawal.go index 2279abb0..81cc9706 100644 --- a/x/millions/keeper/keeper_withdrawal.go +++ b/x/millions/keeper/keeper_withdrawal.go @@ -137,6 +137,10 @@ func (k Keeper) TransferWithdrawalToRecipient(ctx sdk.Context, poolID uint64, wi // - To the local chain response if it's a transfer to local chain // - To the native chain if it's BankSend for a native pool with a native destination address func (k Keeper) OnTransferWithdrawalToRecipientCompleted(ctx sdk.Context, poolID uint64, withdrawalID uint64, isError bool) error { + pool, err := k.GetPool(ctx, poolID) + if err != nil { + return err + } withdrawal, err := k.GetPoolWithdrawal(ctx, poolID, withdrawalID) if err != nil { return err @@ -155,11 +159,14 @@ func (k Keeper) OnTransferWithdrawalToRecipientCompleted(ctx sdk.Context, poolID return err } - // Notify the closing method to check if the step can continue - // Discard any error here to avoid blocking the process on relaying side - if err := k.ClosePool(ctx, poolID, false); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("ClosePool %v", err.Error())) + if pool.State == types.PoolState_Closing { + // Continue closing procedure + // voluntary ignore errors + if err := k.ClosePool(ctx, poolID); err != nil { + k.Logger(ctx).With("ctx", "withdrawal_completed", "pool_id", poolID).Error("Silently failed to continue close pool procedure: %v", err) + } } + return nil } From 4abf0a9e10f5f45a72a35f937e7f603a9d1bf9ec Mon Sep 17 00:00:00 2001 From: Fabrice Bascoulergue Date: Wed, 6 Mar 2024 11:24:24 +0100 Subject: [PATCH 05/11] Fix closing procedure --- x/millions/keeper/keeper_draw.go | 2 -- x/millions/keeper/keeper_pool.go | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x/millions/keeper/keeper_draw.go b/x/millions/keeper/keeper_draw.go index dceae109..04016a18 100644 --- a/x/millions/keeper/keeper_draw.go +++ b/x/millions/keeper/keeper_draw.go @@ -496,7 +496,6 @@ func (k Keeper) ExecuteDraw(ctx sdk.Context, poolID uint64, drawID uint64) (*typ // OnExecuteDrawCompleted wrappers for draw state update upon drawing phase completion // returns the error specified in parameters and does not produce any internal error func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw *types.Draw, err error) (*types.Draw, error) { - // If it's a failure, we do not update the pool state if err != nil { draw.State = types.DrawState_Failure draw.ErrorState = types.DrawState_Drawing @@ -508,7 +507,6 @@ func (k Keeper) OnExecuteDrawCompleted(ctx sdk.Context, pool *types.Pool, draw * return draw, err } - // Update draw state draw.State = types.DrawState_Success draw.ErrorState = types.DrawState_Unspecified draw.UpdatedAtHeight = ctx.BlockHeight() diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index 123028a3..f8169580 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -499,7 +499,8 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused && pool.State != types.PoolState_Closing { - return types.ErrPoolClosed + logger.Error(fmt.Sprintf("Impossible state change requested due to pool state %s", pool.State)) + return types.ErrPoolStateChangeNotAllowed } // Step 1: Pool is not yet in closing state - launch closing procedure @@ -518,7 +519,7 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { } } - // Step 2: Launch final Draw and wait for its completion + // Step 2: Wait for final draw completion if pool.LastDrawState != types.DrawState_Success { return nil } @@ -542,7 +543,7 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { logger.Error(fmt.Sprintf("Error while forcing retry for deposit %d: %v", deposit.GetDepositId(), err)) return err } - } else { + } else if deposit.State == types.DepositState_Success { // Withdraw deposits in success state logger.Info(fmt.Sprintf("Withdrawing deposit with ID %d", deposit.GetDepositId())) _, err := serv.WithdrawDeposit(ctx.Context(), types.NewMsgWithdrawDeposit( From 3db66fc949a887a9a1fd83409c4039761533cedb Mon Sep 17 00:00:00 2001 From: Fabrice Bascoulergue Date: Wed, 6 Mar 2024 11:36:15 +0100 Subject: [PATCH 06/11] Ensure state checks are done --- x/millions/keeper/keeper_pool.go | 6 +++--- x/millions/keeper/keeper_prize.go | 2 ++ x/millions/keeper/msg_server_pool.go | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index f8169580..68fed5ad 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -608,7 +608,7 @@ func (k Keeper) RebalanceValidatorsBondings(ctx sdk.Context, poolID uint64) erro } // Make sure pool is ready - if pool.State == types.PoolState_Created || pool.State == types.PoolState_Unspecified { + if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { return types.ErrPoolNotReady } @@ -633,7 +633,7 @@ func (k Keeper) RedelegateToActiveValidatorsOnRemoteZone(ctx sdk.Context, poolID } // Make sure pool is ready - if pool.State == types.PoolState_Created || pool.State == types.PoolState_Unspecified { + if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { return types.ErrPoolNotReady } @@ -685,7 +685,7 @@ func (k Keeper) OnRedelegateToActiveValidatorsOnRemoteZoneCompleted(ctx sdk.Cont } // Make sure pool is ready - if pool.State == types.PoolState_Created || pool.State == types.PoolState_Unspecified { + if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { return types.ErrPoolNotReady } diff --git a/x/millions/keeper/keeper_prize.go b/x/millions/keeper/keeper_prize.go index 61607ce3..71b6b0eb 100644 --- a/x/millions/keeper/keeper_prize.go +++ b/x/millions/keeper/keeper_prize.go @@ -23,6 +23,8 @@ func (k Keeper) ClawBackPrize(ctx sdk.Context, poolID uint64, drawID uint64, pri // If the pool is in closing or closed state, we do not process any prize clawback // We want all user to be able to claim their prize, no matter the state if pool.State == types.PoolState_Closing || pool.State == types.PoolState_Closed { + // Since clawback is triggered by a queue we simulate a successful clawback and the queue will never retry it + // = infinite prize claim duration return nil } diff --git a/x/millions/keeper/msg_server_pool.go b/x/millions/keeper/msg_server_pool.go index 45bbdc8a..17815b6b 100644 --- a/x/millions/keeper/msg_server_pool.go +++ b/x/millions/keeper/msg_server_pool.go @@ -20,7 +20,7 @@ func (k msgServer) RestoreInterchainAccounts(goCtx context.Context, msg *types.M } // We always want our pool to be ready - if pool.State == types.PoolState_Created { + if pool.State == types.PoolState_Created || pool.State == types.PoolState_Unspecified { return nil, types.ErrPoolNotReady } From 488a8b529289c192e2c11c43ab5ed2d0e39a0e1f Mon Sep 17 00:00:00 2001 From: Fabrice Bascoulergue Date: Wed, 6 Mar 2024 11:38:15 +0100 Subject: [PATCH 07/11] Remove useless state check --- x/millions/keeper/keeper_pool.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index 68fed5ad..dd48f129 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -684,11 +684,6 @@ func (k Keeper) OnRedelegateToActiveValidatorsOnRemoteZoneCompleted(ctx sdk.Cont return err } - // Make sure pool is ready - if pool.State != types.PoolState_Ready && pool.State != types.PoolState_Paused { - return types.ErrPoolNotReady - } - // Get the validator valIdx := pool.GetValidatorsMapIndex() index, found := valIdx[valSrcAddr] From 67c3532f4b4680e1c0dcbe4b11f14b597c311e7c Mon Sep 17 00:00:00 2001 From: Segfault <5221072+Segfaultd@users.noreply.github.com> Date: Wed, 6 Mar 2024 18:13:06 +0100 Subject: [PATCH 08/11] Fix used contexts --- x/millions/keeper/keeper_pool.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/millions/keeper/keeper_pool.go b/x/millions/keeper/keeper_pool.go index dd48f129..853247b8 100644 --- a/x/millions/keeper/keeper_pool.go +++ b/x/millions/keeper/keeper_pool.go @@ -534,7 +534,7 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { if deposit.State == types.DepositState_Failure { // Force retry deposits in error states logger.Info(fmt.Sprintf("Retrying deposit with ID %d in error state %s", deposit.GetDepositId(), deposit.GetErrorState().String())) - _, err := serv.DepositRetry(ctx, &types.MsgDepositRetry{ + _, err := serv.DepositRetry(sdk.WrapSDKContext(ctx), &types.MsgDepositRetry{ PoolId: deposit.GetPoolId(), DepositId: deposit.GetDepositId(), DepositorAddress: deposit.GetDepositorAddress(), @@ -546,7 +546,7 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { } else if deposit.State == types.DepositState_Success { // Withdraw deposits in success state logger.Info(fmt.Sprintf("Withdrawing deposit with ID %d", deposit.GetDepositId())) - _, err := serv.WithdrawDeposit(ctx.Context(), types.NewMsgWithdrawDeposit( + _, err := serv.WithdrawDeposit(sdk.WrapSDKContext(ctx), types.NewMsgWithdrawDeposit( deposit.GetDepositorAddress(), deposit.GetDepositorAddress(), deposit.GetPoolId(), @@ -569,7 +569,7 @@ func (k Keeper) ClosePool(ctx sdk.Context, poolID uint64) error { if withdrawal.State == types.WithdrawalState_Failure { // Force retry withdrawals in error state logger.Info(fmt.Sprintf("Retrying withdrawal with ID %d in error state %s", withdrawal.GetWithdrawalId(), withdrawal.GetErrorState().String())) - _, err := serv.WithdrawDepositRetry(ctx, &types.MsgWithdrawDepositRetry{ + _, err := serv.WithdrawDepositRetry(sdk.WrapSDKContext(ctx), &types.MsgWithdrawDepositRetry{ PoolId: withdrawal.GetPoolId(), WithdrawalId: withdrawal.GetWithdrawalId(), DepositorAddress: withdrawal.GetDepositorAddress(), From a1f6426fc3e06dd93f454c4df6726ebf74c3d9b7 Mon Sep 17 00:00:00 2001 From: Segfault <5221072+Segfaultd@users.noreply.github.com> Date: Wed, 6 Mar 2024 18:22:59 +0100 Subject: [PATCH 09/11] Introduce ClosePool unit test --- x/millions/keeper/keeper_pool_test.go | 134 ++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index 58ab53e9..df3fb6e4 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -955,6 +955,140 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { suite.Require().Equal(sdk.ZeroInt(), pool.Validators[0].BondedAmount) } +func (suite *KeeperTestSuite) TestPool_ClosePool() { + app := suite.app + ctx := suite.ctx + frequency := uint64(4) + var now = time.Now().UTC() + + // Set up the base pool + poolID, err := app.MillionsKeeper.RegisterPool(ctx, + millionstypes.PoolType_Staking, + "ulum", + "ulum", + testChainID, + "", + "", + []string{suite.valAddrs[0].String()}, + "lum", + "lumvaloper", + app.MillionsKeeper.GetParams(ctx).MinDepositAmount, + time.Duration(millionstypes.DefaultUnbondingDuration), + 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) + + // Initialize the balance + balanceBefore := app.BankKeeper.GetBalance(ctx, suite.addrs[0], localPoolDenom) + suite.Require().Equal(int64(1_000_000_000_0), balanceBefore.Amount.Int64()) + + // Make sure the pool is in the ready state + _, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + withdrawalsBefore := app.MillionsKeeper.ListAccountWithdrawals(ctx, suite.addrs[0]) + suite.Require().Len(withdrawalsBefore, 0) + withdrawals := app.MillionsKeeper.ListAccountWithdrawals(ctx, suite.addrs[0]) + suite.Require().Len(withdrawals, 0) + + // Add 3 deposits + for i := 0; i < 3; i++ { + // Create a new deposit and add it to the state + app.MillionsKeeper.AddDeposit(ctx, &millionstypes.Deposit{ + PoolId: poolID, + DepositorAddress: suite.addrs[0].String(), + WinnerAddress: suite.addrs[0].String(), + State: millionstypes.DepositState_Success, + Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + }) + } + + // Pool should have 3 deposits + deposits := app.MillionsKeeper.ListDeposits(ctx) + suite.Require().Len(deposits, 3) + + // Pool should have no withdrawals for now + withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) + suite.Require().Len(withdrawals, 0) + + // Run the first step of closing the pool + err = app.MillionsKeeper.ClosePool(ctx, poolID) + suite.Require().NoError(err) + + // Pool should be in state closing, and have a succeeded draw + pool, err := app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(millionstypes.PoolState_Closing, pool.State) + suite.Require().Equal(millionstypes.DrawState_Success, pool.LastDrawState) + + // Advance close pool step + err = app.MillionsKeeper.ClosePool(ctx, poolID) + suite.Require().NoError(err) + + // Pool should have 3 withdrawals, and no deposits + withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) + suite.Require().Len(withdrawals, 3) + deposits = app.MillionsKeeper.ListDeposits(ctx) + suite.Require().Len(deposits, 0) + + for _, w := range withdrawals { + err = app.MillionsKeeper.AddEpochUnbonding(ctx, w, false) + suite.Require().NoError(err) + } + + // Get the millions internal module tracker + epochTracker, err := app.MillionsKeeper.GetEpochTracker(ctx, epochstypes.DAY_EPOCH, millionstypes.WithdrawalTrackerType) + suite.Require().NoError(err) + + // Get epoch unbonding + currentEpochUnbonding, err := app.MillionsKeeper.GetEpochPoolUnbonding(ctx, epochTracker.EpochNumber+frequency, 1) + suite.Require().NoError(err) + + // Trigger undelegation flow + err = app.MillionsKeeper.UndelegateWithdrawalsOnRemoteZone(ctx, currentEpochUnbonding) + suite.Require().NoError(err) + + // Test that the balance should remain unchanged + balance := app.BankKeeper.GetBalance(ctx, suite.addrs[0], localPoolDenom) + suite.Require().Equal(balanceBefore.Amount.Int64()-2_000_000, balance.Amount.Int64()) + + ctx = ctx.WithBlockTime(now.Add(21 * 24 * time.Hour)) + _, err = app.StakingKeeper.CompleteUnbonding(ctx, sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), suite.valAddrs[0]) + suite.Require().NoError(err) + + // There should be no withdrawals to dequeue + maturedWithdrawals := app.MillionsKeeper.DequeueMaturedWithdrawalQueue(ctx, ctx.BlockTime()) + suite.Require().Len(maturedWithdrawals, 2) + + // Dequeue matured withdrawals and trigger the transfer to the local chain + for i, mw := range maturedWithdrawals { + app.MillionsKeeper.UpdateWithdrawalStatus(ctx, mw.GetPoolId(), mw.GetWithdrawalId(), millionstypes.WithdrawalState_IbcTransfer, withdrawals[i].UnbondingEndsAt, false) + err = app.MillionsKeeper.TransferWithdrawalToRecipient(ctx, mw.GetPoolId(), mw.GetWithdrawalId()) + // Test that there should be no error + suite.Require().NoError(err) + } + + // Test that there should be no matured withdrawal left + maturedWithdrawals = app.MillionsKeeper.DequeueMaturedWithdrawalQueue(ctx, ctx.BlockTime()) + suite.Require().Len(maturedWithdrawals, 0) + + // Test that the balance should compensate 2 deposits transfered back + balance = app.BankKeeper.GetBalance(ctx, suite.addrs[0], localPoolDenom) + suite.Require().Equal(balanceBefore.Amount.Int64(), balance.Amount.Int64()) + + // Close pool again + err = app.MillionsKeeper.ClosePool(ctx, poolID) + + // Get the pool and make sure it's in the closed state + pool, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(millionstypes.PoolState_Closed, pool.State) +} + // TestPool_UpdatePool tests the different conditions for a proposal pool update func (suite *KeeperTestSuite) TestPool_UpdatePool() { app := suite.app From c24ebb402ad8b8a44efa4d0887648f681d37a861 Mon Sep 17 00:00:00 2001 From: Fabrice Bascoulergue Date: Thu, 7 Mar 2024 15:21:08 +0100 Subject: [PATCH 10/11] Fix unittests --- x/millions/keeper/keeper_pool_test.go | 82 +++++++++++++++------------ 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index df3fb6e4..f163bc67 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -958,7 +958,8 @@ func (suite *KeeperTestSuite) TestPool_ValidatorsSplitConsistency() { func (suite *KeeperTestSuite) TestPool_ClosePool() { app := suite.app ctx := suite.ctx - frequency := uint64(4) + goCtx := sdk.WrapSDKContext(ctx) + msgServer := millionskeeper.NewMsgServerImpl(*app.MillionsKeeper) var now = time.Now().UTC() // Set up the base pool @@ -988,8 +989,9 @@ func (suite *KeeperTestSuite) TestPool_ClosePool() { suite.Require().Equal(int64(1_000_000_000_0), balanceBefore.Amount.Int64()) // Make sure the pool is in the ready state - _, err = app.MillionsKeeper.GetPool(ctx, poolID) + pool, err := app.MillionsKeeper.GetPool(ctx, poolID) suite.Require().NoError(err) + suite.Require().Equal(millionstypes.PoolState_Ready, pool.State) withdrawalsBefore := app.MillionsKeeper.ListAccountWithdrawals(ctx, suite.addrs[0]) suite.Require().Len(withdrawalsBefore, 0) withdrawals := app.MillionsKeeper.ListAccountWithdrawals(ctx, suite.addrs[0]) @@ -998,18 +1000,22 @@ func (suite *KeeperTestSuite) TestPool_ClosePool() { // Add 3 deposits for i := 0; i < 3; i++ { // Create a new deposit and add it to the state - app.MillionsKeeper.AddDeposit(ctx, &millionstypes.Deposit{ + _, err := msgServer.Deposit(goCtx, &millionstypes.MsgDeposit{ PoolId: poolID, + Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_100_000)), DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), - State: millionstypes.DepositState_Success, - Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_000_000)), + IsSponsor: false, }) + suite.Require().NoError(err) } - // Pool should have 3 deposits + // Pool should have 3 active deposits deposits := app.MillionsKeeper.ListDeposits(ctx) suite.Require().Len(deposits, 3) + for _, d := range deposits { + suite.Require().Equal(millionstypes.DepositState_Success, d.State) + } // Pool should have no withdrawals for now withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) @@ -1020,68 +1026,74 @@ func (suite *KeeperTestSuite) TestPool_ClosePool() { suite.Require().NoError(err) // Pool should be in state closing, and have a succeeded draw - pool, err := app.MillionsKeeper.GetPool(ctx, poolID) + pool, err = app.MillionsKeeper.GetPool(ctx, poolID) suite.Require().NoError(err) suite.Require().Equal(millionstypes.PoolState_Closing, pool.State) suite.Require().Equal(millionstypes.DrawState_Success, pool.LastDrawState) - // Advance close pool step - err = app.MillionsKeeper.ClosePool(ctx, poolID) - suite.Require().NoError(err) - // Pool should have 3 withdrawals, and no deposits withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) suite.Require().Len(withdrawals, 3) + for _, w := range withdrawals { + suite.Require().Equal(millionstypes.WithdrawalState_Pending, w.State) + } deposits = app.MillionsKeeper.ListDeposits(ctx) suite.Require().Len(deposits, 0) - for _, w := range withdrawals { - err = app.MillionsKeeper.AddEpochUnbonding(ctx, w, false) - suite.Require().NoError(err) - } + // Calling ClosePool should have no effect untill withdrawals finish their unbonding + err = app.MillionsKeeper.ClosePool(ctx, poolID) + suite.Require().NoError(err) + pool, err = app.MillionsKeeper.GetPool(ctx, poolID) + suite.Require().NoError(err) + suite.Require().Equal(millionstypes.PoolState_Closing, pool.State) - // Get the millions internal module tracker + // Launch withdrawal unbonding epochTracker, err := app.MillionsKeeper.GetEpochTracker(ctx, epochstypes.DAY_EPOCH, millionstypes.WithdrawalTrackerType) suite.Require().NoError(err) + nextEpochUnbonding := pool.GetNextEpochUnbonding(epochTracker) + epochUnbondings := app.MillionsKeeper.GetEpochUnbondings(ctx, nextEpochUnbonding) + for _, e := range epochUnbondings { + err = app.MillionsKeeper.UndelegateWithdrawalsOnRemoteZone(ctx, e) + suite.Require().NoError(err) + } + withdrawals = app.MillionsKeeper.ListWithdrawals(ctx) + suite.Require().Len(withdrawals, 3) + for _, w := range withdrawals { + suite.Require().Equal(millionstypes.WithdrawalState_IcaUnbonding, w.State) + } - // Get epoch unbonding - currentEpochUnbonding, err := app.MillionsKeeper.GetEpochPoolUnbonding(ctx, epochTracker.EpochNumber+frequency, 1) + // Calling ClosePool should have no effect untill withdrawals finish their unbonding + err = app.MillionsKeeper.ClosePool(ctx, poolID) suite.Require().NoError(err) - - // Trigger undelegation flow - err = app.MillionsKeeper.UndelegateWithdrawalsOnRemoteZone(ctx, currentEpochUnbonding) + pool, err = app.MillionsKeeper.GetPool(ctx, poolID) suite.Require().NoError(err) + suite.Require().Equal(millionstypes.PoolState_Closing, pool.State) // Test that the balance should remain unchanged balance := app.BankKeeper.GetBalance(ctx, suite.addrs[0], localPoolDenom) - suite.Require().Equal(balanceBefore.Amount.Int64()-2_000_000, balance.Amount.Int64()) + suite.Require().Equal(balanceBefore.Amount.Int64()-3_300_000, balance.Amount.Int64()) ctx = ctx.WithBlockTime(now.Add(21 * 24 * time.Hour)) _, err = app.StakingKeeper.CompleteUnbonding(ctx, sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), suite.valAddrs[0]) suite.Require().NoError(err) - // There should be no withdrawals to dequeue - maturedWithdrawals := app.MillionsKeeper.DequeueMaturedWithdrawalQueue(ctx, ctx.BlockTime()) - suite.Require().Len(maturedWithdrawals, 2) - // Dequeue matured withdrawals and trigger the transfer to the local chain - for i, mw := range maturedWithdrawals { - app.MillionsKeeper.UpdateWithdrawalStatus(ctx, mw.GetPoolId(), mw.GetWithdrawalId(), millionstypes.WithdrawalState_IbcTransfer, withdrawals[i].UnbondingEndsAt, false) - err = app.MillionsKeeper.TransferWithdrawalToRecipient(ctx, mw.GetPoolId(), mw.GetWithdrawalId()) - // Test that there should be no error - suite.Require().NoError(err) - } + s, e := app.MillionsKeeper.BlockWithdrawalUpdates(ctx) + suite.Require().Equal(3, s) + suite.Require().Equal(0, e) // Test that there should be no matured withdrawal left - maturedWithdrawals = app.MillionsKeeper.DequeueMaturedWithdrawalQueue(ctx, ctx.BlockTime()) - suite.Require().Len(maturedWithdrawals, 0) + s, e = app.MillionsKeeper.BlockWithdrawalUpdates(ctx) + suite.Require().Equal(0, s) + suite.Require().Equal(0, e) - // Test that the balance should compensate 2 deposits transfered back + // Test that the balance should compensate 3 deposits transfered back balance = app.BankKeeper.GetBalance(ctx, suite.addrs[0], localPoolDenom) suite.Require().Equal(balanceBefore.Amount.Int64(), balance.Amount.Int64()) // Close pool again err = app.MillionsKeeper.ClosePool(ctx, poolID) + suite.Require().Error(err, millionstypes.ErrPoolStateChangeNotAllowed) // Get the pool and make sure it's in the closed state pool, err = app.MillionsKeeper.GetPool(ctx, poolID) From ead05cc4612095cbf19b7dd255ce2aadd662ce0e Mon Sep 17 00:00:00 2001 From: Segfault <5221072+Segfaultd@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:23:42 +0100 Subject: [PATCH 11/11] Missing unit tests --- x/millions/keeper/keeper_pool_test.go | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/x/millions/keeper/keeper_pool_test.go b/x/millions/keeper/keeper_pool_test.go index f163bc67..62940930 100644 --- a/x/millions/keeper/keeper_pool_test.go +++ b/x/millions/keeper/keeper_pool_test.go @@ -1002,7 +1002,7 @@ func (suite *KeeperTestSuite) TestPool_ClosePool() { // Create a new deposit and add it to the state _, err := msgServer.Deposit(goCtx, &millionstypes.MsgDeposit{ PoolId: poolID, - Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_100_000)), + Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_100_000_000)), DepositorAddress: suite.addrs[0].String(), WinnerAddress: suite.addrs[0].String(), IsSponsor: false, @@ -1071,7 +1071,7 @@ func (suite *KeeperTestSuite) TestPool_ClosePool() { // Test that the balance should remain unchanged balance := app.BankKeeper.GetBalance(ctx, suite.addrs[0], localPoolDenom) - suite.Require().Equal(balanceBefore.Amount.Int64()-3_300_000, balance.Amount.Int64()) + suite.Require().Equal(balanceBefore.Amount.Int64()-3_300_000_000, balance.Amount.Int64()) ctx = ctx.WithBlockTime(now.Add(21 * 24 * time.Hour)) _, err = app.StakingKeeper.CompleteUnbonding(ctx, sdk.MustAccAddressFromBech32(pool.IcaDepositAddress), suite.valAddrs[0]) @@ -1091,14 +1091,35 @@ func (suite *KeeperTestSuite) TestPool_ClosePool() { balance = app.BankKeeper.GetBalance(ctx, suite.addrs[0], localPoolDenom) suite.Require().Equal(balanceBefore.Amount.Int64(), balance.Amount.Int64()) - // Close pool again - err = app.MillionsKeeper.ClosePool(ctx, poolID) - suite.Require().Error(err, millionstypes.ErrPoolStateChangeNotAllowed) - // Get the pool and make sure it's in the closed state pool, err = app.MillionsKeeper.GetPool(ctx, poolID) suite.Require().NoError(err) suite.Require().Equal(millionstypes.PoolState_Closed, pool.State) + + // Close pool again - It shouldn't work + err = app.MillionsKeeper.ClosePool(ctx, poolID) + suite.Require().Error(err, millionstypes.ErrPoolStateChangeNotAllowed) + + // Try to make a deposit - It shouldn't work + _, err = msgServer.Deposit(goCtx, &millionstypes.MsgDeposit{ + PoolId: poolID, + Amount: sdk.NewCoin(localPoolDenom, sdk.NewInt(1_100_000_000)), + DepositorAddress: suite.addrs[0].String(), + WinnerAddress: suite.addrs[0].String(), + IsSponsor: false, + }) + suite.Require().Error(err) + + // Try to claim the prizes - It should work even with a closed pool + prizes := app.MillionsKeeper.ListAccountPrizes(ctx, suite.addrs[0]) + for _, p := range prizes { + _, err = msgServer.ClaimPrize(goCtx, &millionstypes.MsgClaimPrize{ + PoolId: poolID, + DrawId: p.DrawId, + PrizeId: p.PrizeId, + }) + suite.Require().NoError(err) + } } // TestPool_UpdatePool tests the different conditions for a proposal pool update