diff --git a/go.mod b/go.mod index 7cdc58aa..e519e8a9 100644 --- a/go.mod +++ b/go.mod @@ -63,7 +63,7 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v0.20.0 // indirect - github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect + github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/creachadair/taskgroup v0.4.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -152,8 +152,8 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.6.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect - github.com/zondax/hid v0.9.1 // indirect - github.com/zondax/ledger-go v0.14.1 // indirect + github.com/zondax/hid v0.9.2 // indirect + github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.11.0 // indirect diff --git a/go.sum b/go.sum index 645d6237..5ecbcd80 100644 --- a/go.sum +++ b/go.sum @@ -400,8 +400,8 @@ github.com/cosmos/ibc-go/v7 v7.2.0 h1:dx0DLUl7rxdyZ8NiT6UsrbzKOJx/w7s+BOaewFRH6c github.com/cosmos/ibc-go/v7 v7.2.0/go.mod h1:OOcjKIRku/j1Xs1RgKK0yvKRrJ5iFuZYMetR1n3yMlc= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= -github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= -github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= +github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= +github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M= github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzUGSKFTcM= github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -1160,10 +1160,10 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= -github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -github.com/zondax/ledger-go v0.14.1 h1:Pip65OOl4iJ84WTpA4BKChvOufMhhbxED3BaihoZN4c= -github.com/zondax/ledger-go v0.14.1/go.mod h1:fZ3Dqg6qcdXWSOJFKMG8GCTnD7slO/RL2feOQv8K320= +github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= +github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= +github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw= diff --git a/proto/lum/network/millions/genesis.proto b/proto/lum/network/millions/genesis.proto index 28974bc7..024d64d1 100644 --- a/proto/lum/network/millions/genesis.proto +++ b/proto/lum/network/millions/genesis.proto @@ -29,4 +29,6 @@ message GenesisState { repeated Prize prizes = 9 [ (gogoproto.nullable) = false ]; repeated Withdrawal withdrawals = 10 [ (gogoproto.nullable) = false ]; repeated EpochTracker epoch_trackers = 11 [ (gogoproto.nullable) = false ]; + repeated EpochUnbonding epoch_unbondings = 12 + [ (gogoproto.nullable) = false ]; } diff --git a/x/millions/genesis.go b/x/millions/genesis.go index 01366ba4..bc9162bb 100644 --- a/x/millions/genesis.go +++ b/x/millions/genesis.go @@ -47,6 +47,9 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetEpochTracker(ctx, epochTracker, types.WithdrawalTrackerType) } + for _, epochUnbonding := range genState.EpochUnbondings { + k.SetEpochUnbonding(ctx, epochUnbonding) + } } func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { @@ -63,5 +66,6 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { Prizes: k.ListPrizes(ctx), Withdrawals: k.ListWithdrawals(ctx), EpochTrackers: k.ListEpochTrackers(ctx), + EpochUnbondings: k.ListEpochUnbondings(ctx), } } diff --git a/x/millions/genesis_test.go b/x/millions/genesis_test.go index 6b2ae5bd..7c1bfc07 100644 --- a/x/millions/genesis_test.go +++ b/x/millions/genesis_test.go @@ -109,6 +109,9 @@ var testGenesis = millionstypes.GenesisState{ EpochTrackers: []millionstypes.EpochTracker{ {EpochTrackerType: epochstypes.DAY_EPOCH, EpochIdentifier: epochstypes.DAY_EPOCH, NextEpochNumber: uint64(2), PreviousEpochNumber: uint64(0), NextEpochStartTime: future}, }, + EpochUnbondings: []millionstypes.EpochUnbonding{ + {PoolId: 1, EpochIdentifier: "test", EpochNumber: 1, TotalAmount: sdk.NewCoin("ulum", sdk.NewInt(1000000)), WithdrawalIds: []uint64{1, 2}, WithdrawalIdsCount: 2}, + }, } func TestInitGenesis(t *testing.T) { @@ -298,6 +301,16 @@ func TestInitGenesis(t *testing.T) { require.Equal(t, testGenesis.EpochTrackers[i].NextEpochStartTime, epochTracker.NextEpochStartTime) } + // Make sure epoch unbondings have been imported + epochUnbondings := app.MillionsKeeper.ListEpochUnbondings(ctx) + require.Len(t, epochUnbondings, len(testGenesis.EpochUnbondings)) + for i, epochUnbonding := range epochUnbondings { + require.Equal(t, testGenesis.EpochUnbondings[i].EpochIdentifier, epochUnbonding.EpochIdentifier) + require.Equal(t, testGenesis.EpochUnbondings[i].EpochNumber, epochUnbonding.EpochNumber) + require.Equal(t, testGenesis.EpochUnbondings[i].WithdrawalIds, epochUnbonding.WithdrawalIds) + require.Equal(t, testGenesis.EpochUnbondings[i].WithdrawalIdsCount, epochUnbonding.WithdrawalIdsCount) + require.Equal(t, testGenesis.EpochUnbondings[i].TotalAmount.Amount.Int64(), epochUnbonding.TotalAmount.Amount.Int64()) + } } func TestExportGenesis(t *testing.T) { @@ -407,4 +420,14 @@ func TestExportGenesis(t *testing.T) { require.Equal(t, testGenesis.EpochTrackers[i].NextEpochNumber, epochTracker.NextEpochNumber) require.Equal(t, testGenesis.EpochTrackers[i].NextEpochStartTime, epochTracker.NextEpochStartTime) } + + // Test epoch unbondings export + require.Len(t, exportGenesis.EpochUnbondings, len(testGenesis.EpochUnbondings)) + for i, epochUnbonding := range testGenesis.EpochUnbondings { + require.Equal(t, testGenesis.EpochUnbondings[i].EpochIdentifier, epochUnbonding.EpochIdentifier) + require.Equal(t, testGenesis.EpochUnbondings[i].EpochNumber, epochUnbonding.EpochNumber) + require.Equal(t, testGenesis.EpochUnbondings[i].WithdrawalIds, epochUnbonding.WithdrawalIds) + require.Equal(t, testGenesis.EpochUnbondings[i].WithdrawalIdsCount, epochUnbonding.WithdrawalIdsCount) + require.Equal(t, testGenesis.EpochUnbondings[i].TotalAmount.Amount.Int64(), epochUnbonding.TotalAmount.Amount.Int64()) + } } diff --git a/x/millions/keeper/hooks.go b/x/millions/keeper/hooks.go index c27fd0e0..f2416168 100644 --- a/x/millions/keeper/hooks.go +++ b/x/millions/keeper/hooks.go @@ -22,6 +22,7 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInf } func (k Keeper) processEpochUnbondings(ctx sdk.Context, epochInfo epochstypes.EpochInfo, logger log.Logger) (successCount, errorCount, skippedCount int) { + // Update the epoch tracker epochTracker, err := k.UpdateEpochTracker(ctx, epochInfo, types.WithdrawalTrackerType) if err != nil { logger.Error( @@ -31,10 +32,15 @@ func (k Keeper) processEpochUnbondings(ctx sdk.Context, epochInfo epochstypes.Ep return } + // Create temporary context + cacheCtx, writeCache := ctx.CacheContext() + // Get epoch unbondings - epochUnbondings := k.GetEpochUnbondings(ctx, epochTracker.EpochNumber) + epochUnbondings := k.GetEpochUnbondings(cacheCtx, epochTracker.EpochNumber) + + // For each unbonding, try to proceed the undelegation otherwise, rollback the entire operation for _, epochUnbonding := range epochUnbondings { - success, err := k.processEpochUnbonding(ctx, epochUnbonding, epochTracker, logger) + success, err := k.processEpochUnbonding(cacheCtx, epochUnbonding, epochTracker, logger) if err != nil { logger.Error( fmt.Sprintf("Error processing epoch unbonding: %v", err), @@ -42,6 +48,7 @@ func (k Keeper) processEpochUnbondings(ctx sdk.Context, epochInfo epochstypes.Ep "epoch_number", epochUnbonding.GetEpochNumber(), ) errorCount++ + break } else if success { successCount++ } else { @@ -49,15 +56,61 @@ func (k Keeper) processEpochUnbondings(ctx sdk.Context, epochInfo epochstypes.Ep } } - if successCount+errorCount > 0 { + // If there was an error, we are supposed to cancel the entire operation + if errorCount > 0 { + // Log out the critical error + logger.Error( + "epoch unbonding undelegate processed with errors, cache not written", + "nbr_success", successCount, + "nbr_error", errorCount, + "nbr_skipped", skippedCount, + ) + + // Allocate new cache context + rollbackTmpCacheCtx, writeRollbackCache := ctx.CacheContext() + + // Get epoch unbondings + epochUnbondings = k.GetEpochUnbondings(rollbackTmpCacheCtx, epochTracker.EpochNumber) + + // Rollback the operations and put everything back up in the next epoch + // We explicitly use a custom tailored cache for this operation + for _, epochUnbonding := range epochUnbondings { + for _, wid := range epochUnbonding.WithdrawalIds { + withdrawal, err := k.GetPoolWithdrawal(rollbackTmpCacheCtx, epochUnbonding.PoolId, wid) + if err != nil { + logger.Error(fmt.Sprintf("Failure in getting the pool withdrawals for pool %d, err: %v", epochUnbonding.PoolId, err)) + return 0, 1, 0 + } + if err := k.AddEpochUnbonding(rollbackTmpCacheCtx, withdrawal, false); err != nil { + logger.Error(fmt.Sprintf("Failure in adding the withdrawal to epoch unbonding for pool %d, err: %v", epochUnbonding.PoolId, err)) + return 0, 1, 0 + } + } + + if err := k.RemoveEpochUnbonding(rollbackTmpCacheCtx, epochUnbonding); err != nil { + logger.Error(fmt.Sprintf("Failure in removing the epoch unbonding for pool %d, err: %v", epochUnbonding.PoolId, err)) + return 0, 1, 0 + } + } + + // Write the rollback cache + writeRollbackCache() logger.Info( - "epoch unbonding undelegate started", + "epoch unbonding processed with failure, rollback done", + "nbr_success", successCount, + "nbr_error", errorCount, + "nbr_skipped", skippedCount, + ) + } else { + // Write the operation succeed cache + writeCache() + logger.Info( + "epoch unbonding undelegate processed", "nbr_success", successCount, "nbr_error", errorCount, "nbr_skipped", skippedCount, ) } - return successCount, errorCount, skippedCount } diff --git a/x/millions/keeper/keeper_epoch.go b/x/millions/keeper/keeper_epoch.go index 3c063dff..9f1aabdc 100644 --- a/x/millions/keeper/keeper_epoch.go +++ b/x/millions/keeper/keeper_epoch.go @@ -395,6 +395,14 @@ func (k Keeper) GetEpochUnbondings(ctx sdk.Context, epochID uint64) (epochUnbond return } +// SetEpochUnbonding sets the internal epoch unbondings +func (k Keeper) SetEpochUnbonding(ctx sdk.Context, epochUnbonding types.EpochUnbonding) { + store := ctx.KVStore(k.storeKey) + key := types.GetEpochUnbondingsKey(epochUnbonding.GetEpochNumber()) + encodedEpochUnbonding := k.cdc.MustMarshal(&epochUnbonding) + store.Set(key, encodedEpochUnbonding) +} + func (k Keeper) ListEpochTrackers(ctx sdk.Context) (list []types.EpochTracker) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.EpochTrackerPrefix) @@ -408,3 +416,17 @@ func (k Keeper) ListEpochTrackers(ctx sdk.Context) (list []types.EpochTracker) { return } + +func (k Keeper) ListEpochUnbondings(ctx sdk.Context) (list []types.EpochUnbonding) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.EpochUnbondingPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.EpochUnbonding + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/millions/keeper/keeper_epoch_test.go b/x/millions/keeper/keeper_epoch_test.go index f184b26d..fc13d3c1 100644 --- a/x/millions/keeper/keeper_epoch_test.go +++ b/x/millions/keeper/keeper_epoch_test.go @@ -255,9 +255,12 @@ func (suite *KeeperTestSuite) TestEpoch_AddEpochUnbonding() { suite.Require().Equal([]uint64{1, 2}, epochUnbondingPool.WithdrawalIds) suite.Require().Equal(uint64(2), epochUnbondingPool.WithdrawalIdsCount) - // Same withdrawalID to the epoch unbonding should faild + // Same withdrawalID to the epoch unbonding should do nothing err = app.MillionsKeeper.AddEpochUnbonding(ctx, withdrawals[0], false) - suite.Require().ErrorIs(millionstypes.ErrEntityOverride, err) + suite.Require().NoError(err) + epochUnbondingPoolAfter, err := app.MillionsKeeper.GetEpochPoolUnbonding(ctx, epochTracker.EpochNumber+frequency, 1) + suite.Require().NoError(err) + suite.Require().Equal(epochUnbondingPool.WithdrawalIds, epochUnbondingPoolAfter.WithdrawalIds) // Trigger new deposits for new pool for i := 0; i < 3; i++ { diff --git a/x/millions/keeper/keeper_withdrawal.go b/x/millions/keeper/keeper_withdrawal.go index f5ebade5..22c64a24 100644 --- a/x/millions/keeper/keeper_withdrawal.go +++ b/x/millions/keeper/keeper_withdrawal.go @@ -82,13 +82,12 @@ func (k Keeper) OnUndelegateWithdrawalsOnRemoteZoneCompleted(ctx sdk.Context, po if err := k.AddEpochUnbonding(ctx, withdrawal, true); err != nil { return err } - continue + } else { + // Set the unbondingEndsAt and add withdrawal to matured queue + withdrawal.UnbondingEndsAt = unbondingEndsAt + k.UpdateWithdrawalStatus(ctx, withdrawal.PoolId, withdrawal.WithdrawalId, types.WithdrawalState_IcaUnbonding, unbondingEndsAt, false) + k.addWithdrawalToMaturedQueue(ctx, withdrawal) } - - // Set the unbondingEndsAt and add withdrawal to matured queue - withdrawal.UnbondingEndsAt = unbondingEndsAt - k.UpdateWithdrawalStatus(ctx, withdrawal.PoolId, withdrawal.WithdrawalId, types.WithdrawalState_IcaUnbonding, unbondingEndsAt, false) - k.addWithdrawalToMaturedQueue(ctx, withdrawal) } if isError { diff --git a/x/millions/keeper/msg_server_pool.go b/x/millions/keeper/msg_server_pool.go index 13113a71..58144c44 100644 --- a/x/millions/keeper/msg_server_pool.go +++ b/x/millions/keeper/msg_server_pool.go @@ -47,6 +47,7 @@ func (k msgServer) RestoreInterchainAccounts(goCtx context.Context, msg *types.M if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, pool.GetConnectionId(), icaDepositPortName, appVersion); err != nil { return nil, errorsmod.Wrapf(types.ErrFailedToRestorePool, fmt.Sprintf("Unable to trigger deposit account registration, err: %s", err.Error())) } + k.restoreICADepositEntities(ctx, pool.GetPoolId()) // Exit to prevent a double channel registration which might create unpredictable behaviours // The registration of the ICA PrizePool will either be automatically triggered once the ICA Deposit gets ACK (see keeper.OnSetupPoolICACompleted) // or can be restored by calling this method again @@ -65,7 +66,54 @@ func (k msgServer) RestoreInterchainAccounts(goCtx context.Context, msg *types.M if err := k.ICAControllerKeeper.RegisterInterchainAccount(ctx, pool.GetConnectionId(), icaPrizePoolPortName, appVersion); err != nil { return nil, errorsmod.Wrapf(types.ErrFailedToRestorePool, fmt.Sprintf("Unable to trigger prizepool account registration, err: %s", err.Error())) } + k.restoreICAPrizePoolEntities(ctx, pool.GetPoolId()) } return &types.MsgRestoreInterchainAccountsResponse{}, nil } + +// restoreICADepositEntities restores all blocked entities by putting them in error state instead of locked state +// thus leaving users the opportunity to retry the operation +func (k msgServer) restoreICADepositEntities(ctx sdk.Context, poolID uint64) { + // Restore deposits ICA locked operations on ICADeposit account + deposits := k.Keeper.ListPoolDeposits(ctx, poolID) + for _, d := range deposits { + if d.State == types.DepositState_IcaDelegate { + d.ErrorState = d.State + d.State = types.DepositState_Failure + k.Keeper.setPoolDeposit(ctx, &d) + } + } + // Restore withdrawals ICA locked operations on ICADeposit account + withdrawals := k.Keeper.ListPoolWithdrawals(ctx, poolID) + for _, w := range withdrawals { + if w.State == types.WithdrawalState_IcaUndelegate { + w.ErrorState = w.State + w.State = types.WithdrawalState_Failure + k.Keeper.setPoolWithdrawal(ctx, w) + } + } + // Restore draws ICA locked operations on ICADeposit account + draws := k.Keeper.ListPoolDraws(ctx, poolID) + for _, d := range draws { + if d.State == types.DrawState_IcaWithdrawRewards { + d.ErrorState = d.State + d.State = types.DrawState_Failure + k.Keeper.SetPoolDraw(ctx, d) + } + } +} + +// restoreICAPrizePoolEntities restores all blocked entities by putting them in error state instead of locked state +// thus leaving users the opportunity to retry the operation +func (k msgServer) restoreICAPrizePoolEntities(ctx sdk.Context, poolID uint64) { + // Restore draws ICQ locked operations on ICAPrizePool account + draws := k.Keeper.ListPoolDraws(ctx, poolID) + for _, d := range draws { + if d.State == types.DrawState_IcqBalance { + d.ErrorState = d.State + d.State = types.DrawState_Failure + k.Keeper.SetPoolDraw(ctx, d) + } + } +} diff --git a/x/millions/keeper/msg_server_withdrawal.go b/x/millions/keeper/msg_server_withdrawal.go index ae00912c..ef86e744 100644 --- a/x/millions/keeper/msg_server_withdrawal.go +++ b/x/millions/keeper/msg_server_withdrawal.go @@ -130,6 +130,13 @@ func (k msgServer) WithdrawDepositRetry(goCtx context.Context, msg *types.MsgWit if err := k.TransferWithdrawalToRecipient(ctx, withdrawal.PoolId, withdrawal.WithdrawalId); err != nil { return nil, err } + } else if withdrawal.ErrorState == types.WithdrawalState_IcaUndelegate { + // Only possible following a restore account which put entities in this error state + // otherwise the retry is automatically triggered by the ICA callback + err := k.AddEpochUnbonding(ctx, withdrawal, true) + if err != nil { + return nil, err + } } else { return nil, errorsmod.Wrapf( types.ErrInvalidWithdrawalState, diff --git a/x/millions/types/genesis.pb.go b/x/millions/types/genesis.pb.go index 3a93d1b8..a078966b 100644 --- a/x/millions/types/genesis.pb.go +++ b/x/millions/types/genesis.pb.go @@ -25,17 +25,18 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` - NextPoolId uint64 `protobuf:"varint,2,opt,name=next_pool_id,json=nextPoolId,proto3" json:"next_pool_id,omitempty"` - NextDepositId uint64 `protobuf:"varint,3,opt,name=next_deposit_id,json=nextDepositId,proto3" json:"next_deposit_id,omitempty"` - NextPrizeId uint64 `protobuf:"varint,4,opt,name=next_prize_id,json=nextPrizeId,proto3" json:"next_prize_id,omitempty"` - NextWithdrawalId uint64 `protobuf:"varint,5,opt,name=next_withdrawal_id,json=nextWithdrawalId,proto3" json:"next_withdrawal_id,omitempty"` - Pools []Pool `protobuf:"bytes,6,rep,name=pools,proto3" json:"pools"` - Deposits []Deposit `protobuf:"bytes,7,rep,name=deposits,proto3" json:"deposits"` - Draws []Draw `protobuf:"bytes,8,rep,name=draws,proto3" json:"draws"` - Prizes []Prize `protobuf:"bytes,9,rep,name=prizes,proto3" json:"prizes"` - Withdrawals []Withdrawal `protobuf:"bytes,10,rep,name=withdrawals,proto3" json:"withdrawals"` - EpochTrackers []EpochTracker `protobuf:"bytes,11,rep,name=epoch_trackers,json=epochTrackers,proto3" json:"epoch_trackers"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params" yaml:"params"` + NextPoolId uint64 `protobuf:"varint,2,opt,name=next_pool_id,json=nextPoolId,proto3" json:"next_pool_id,omitempty"` + NextDepositId uint64 `protobuf:"varint,3,opt,name=next_deposit_id,json=nextDepositId,proto3" json:"next_deposit_id,omitempty"` + NextPrizeId uint64 `protobuf:"varint,4,opt,name=next_prize_id,json=nextPrizeId,proto3" json:"next_prize_id,omitempty"` + NextWithdrawalId uint64 `protobuf:"varint,5,opt,name=next_withdrawal_id,json=nextWithdrawalId,proto3" json:"next_withdrawal_id,omitempty"` + Pools []Pool `protobuf:"bytes,6,rep,name=pools,proto3" json:"pools"` + Deposits []Deposit `protobuf:"bytes,7,rep,name=deposits,proto3" json:"deposits"` + Draws []Draw `protobuf:"bytes,8,rep,name=draws,proto3" json:"draws"` + Prizes []Prize `protobuf:"bytes,9,rep,name=prizes,proto3" json:"prizes"` + Withdrawals []Withdrawal `protobuf:"bytes,10,rep,name=withdrawals,proto3" json:"withdrawals"` + EpochTrackers []EpochTracker `protobuf:"bytes,11,rep,name=epoch_trackers,json=epochTrackers,proto3" json:"epoch_trackers"` + EpochUnbondings []EpochUnbonding `protobuf:"bytes,12,rep,name=epoch_unbondings,json=epochUnbondings,proto3" json:"epoch_unbondings"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -148,6 +149,13 @@ func (m *GenesisState) GetEpochTrackers() []EpochTracker { return nil } +func (m *GenesisState) GetEpochUnbondings() []EpochUnbonding { + if m != nil { + return m.EpochUnbondings + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "lum.network.millions.GenesisState") } @@ -157,38 +165,40 @@ func init() { } var fileDescriptor_ff43331bdfdad888 = []byte{ - // 487 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x41, 0x6b, 0x13, 0x41, - 0x18, 0x86, 0xb3, 0x36, 0x8d, 0x75, 0xb6, 0x51, 0x19, 0x2a, 0x2c, 0x51, 0x37, 0xeb, 0x82, 0x92, - 0x83, 0xdd, 0x85, 0x0a, 0x82, 0x5e, 0x84, 0x50, 0xa9, 0xc1, 0x83, 0x25, 0x0a, 0x82, 0x97, 0x30, - 0xcd, 0x0e, 0xc9, 0xd0, 0xd9, 0x9d, 0x65, 0x66, 0x42, 0x5a, 0x7f, 0x85, 0x3f, 0xab, 0xc7, 0x1e, - 0x3d, 0x15, 0x49, 0xfe, 0x81, 0x3f, 0x40, 0xe4, 0x9b, 0x99, 0x34, 0x3d, 0x4c, 0x72, 0x5b, 0xbe, - 0x7d, 0xde, 0x77, 0xde, 0xef, 0xe5, 0x43, 0x29, 0x9f, 0x95, 0x79, 0x45, 0xf5, 0x5c, 0xc8, 0xf3, - 0xbc, 0x64, 0x9c, 0x33, 0x51, 0xa9, 0x7c, 0x42, 0x2b, 0xaa, 0x98, 0xca, 0x6a, 0x29, 0xb4, 0xc0, - 0x07, 0x7c, 0x56, 0x66, 0x8e, 0xc9, 0x56, 0x4c, 0xe7, 0x60, 0x22, 0x26, 0xc2, 0x00, 0x39, 0x7c, - 0x59, 0xb6, 0xe3, 0xf7, 0x2b, 0x68, 0x2d, 0x14, 0xd3, 0x8e, 0xe9, 0xfa, 0x19, 0x49, 0xe6, 0x0e, - 0x78, 0xe1, 0x05, 0x6a, 0x22, 0x49, 0xa9, 0xb6, 0x7a, 0xd4, 0x42, 0x70, 0x07, 0x24, 0x7e, 0x40, - 0xb2, 0x9f, 0xd4, 0x11, 0x2f, 0xbd, 0xc4, 0x9c, 0xe9, 0x29, 0x44, 0x21, 0xdb, 0x8d, 0x68, 0x2d, - 0xc6, 0x53, 0x4b, 0xa4, 0xff, 0x9a, 0x68, 0xff, 0xc4, 0x36, 0xf6, 0x55, 0x13, 0x4d, 0xf1, 0x67, - 0xd4, 0xb2, 0x61, 0xa3, 0x20, 0x09, 0x7a, 0xe1, 0xd1, 0xb3, 0xcc, 0xd7, 0x60, 0x76, 0x6a, 0x98, - 0xfe, 0x93, 0xab, 0x9b, 0x6e, 0xe3, 0xef, 0x4d, 0xb7, 0x7d, 0x49, 0x4a, 0xfe, 0x3e, 0xb5, 0xca, - 0x74, 0xe8, 0x2c, 0x70, 0x82, 0xf6, 0x2b, 0x7a, 0xa1, 0x47, 0xb0, 0xdb, 0x88, 0x15, 0xd1, 0xbd, - 0x24, 0xe8, 0x35, 0x87, 0x08, 0x66, 0xa7, 0x42, 0xf0, 0x41, 0x81, 0x5f, 0xa1, 0x47, 0x86, 0x70, - 0x2d, 0x03, 0xb4, 0x63, 0xa0, 0x36, 0x8c, 0x8f, 0xed, 0x74, 0x50, 0xe0, 0x14, 0xb5, 0xad, 0x13, - 0x94, 0x00, 0x54, 0xd3, 0x50, 0xa1, 0xb1, 0x82, 0xd9, 0xa0, 0xc0, 0xaf, 0x11, 0x36, 0xcc, 0xba, - 0x06, 0x00, 0x77, 0x0d, 0xf8, 0x18, 0xfe, 0x7c, 0xbf, 0xfd, 0x31, 0x28, 0xf0, 0x5b, 0xb4, 0x0b, - 0xb1, 0x54, 0xd4, 0x4a, 0x76, 0x7a, 0xe1, 0x51, 0x67, 0xc3, 0x9e, 0x42, 0xf0, 0x7e, 0x13, 0xb6, - 0x1c, 0x5a, 0x1c, 0x7f, 0x40, 0x7b, 0x2e, 0xac, 0x8a, 0xee, 0x1b, 0xe9, 0x73, 0xbf, 0xd4, 0x85, - 0x77, 0xea, 0x5b, 0x11, 0x3c, 0x0c, 0x21, 0x54, 0xb4, 0xb7, 0xed, 0xe1, 0x63, 0x49, 0xe6, 0xab, - 0x87, 0x0d, 0x8e, 0xdf, 0xa1, 0x96, 0xd9, 0x5e, 0x45, 0x0f, 0x8c, 0xf0, 0xe9, 0x86, 0xc4, 0xc0, - 0x38, 0xa5, 0x13, 0xe0, 0x4f, 0x28, 0x5c, 0x97, 0xa2, 0x22, 0x64, 0xf4, 0x89, 0x5f, 0xbf, 0x2e, - 0xc9, 0x99, 0xdc, 0x95, 0xe2, 0x2f, 0xe8, 0xa1, 0x39, 0x9f, 0x91, 0x96, 0x64, 0x7c, 0x4e, 0xa5, - 0x8a, 0x42, 0x63, 0x96, 0xfa, 0xcd, 0x3e, 0x02, 0xfb, 0xcd, 0xa2, 0xce, 0xae, 0x4d, 0xef, 0xcc, - 0x54, 0xff, 0xe4, 0x6a, 0x11, 0x07, 0xd7, 0x8b, 0x38, 0xf8, 0xb3, 0x88, 0x83, 0x5f, 0xcb, 0xb8, - 0x71, 0xbd, 0x8c, 0x1b, 0xbf, 0x97, 0x71, 0xe3, 0xc7, 0xe1, 0x84, 0xe9, 0xe9, 0xec, 0x2c, 0x1b, - 0x8b, 0x32, 0xe7, 0xb3, 0xf2, 0x70, 0x75, 0xc7, 0xe3, 0x29, 0x61, 0x55, 0x7e, 0xb1, 0xbe, 0x67, - 0x7d, 0x59, 0x53, 0x75, 0xd6, 0x32, 0x07, 0xfd, 0xe6, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe4, - 0xff, 0xe6, 0xac, 0x16, 0x04, 0x00, 0x00, + // 515 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0x4f, 0x6b, 0x13, 0x41, + 0x18, 0x87, 0xb3, 0xb6, 0x89, 0x75, 0x36, 0xb1, 0x65, 0xa8, 0x30, 0x44, 0xdd, 0xac, 0x8b, 0x4a, + 0x0e, 0x76, 0x17, 0x2a, 0x08, 0x7a, 0x11, 0x42, 0xa5, 0x06, 0x0f, 0x96, 0x68, 0x11, 0xbc, 0x84, + 0x49, 0x76, 0xd8, 0x0c, 0x9d, 0xdd, 0x59, 0x76, 0x66, 0x49, 0xeb, 0xa7, 0xf0, 0x63, 0xf5, 0xd8, + 0x8b, 0xe0, 0xa9, 0x48, 0xf2, 0x0d, 0xfc, 0x04, 0x32, 0x7f, 0xd2, 0x54, 0x98, 0xe6, 0xb6, 0xbc, + 0xf3, 0xfc, 0x9e, 0x79, 0xdf, 0x97, 0x1d, 0x10, 0xb1, 0x3a, 0x4f, 0x0a, 0x22, 0xe7, 0xbc, 0x3a, + 0x4b, 0x72, 0xca, 0x18, 0xe5, 0x85, 0x48, 0x32, 0x52, 0x10, 0x41, 0x45, 0x5c, 0x56, 0x5c, 0x72, + 0xb8, 0xcf, 0xea, 0x3c, 0xb6, 0x4c, 0xbc, 0x62, 0xba, 0xfb, 0x19, 0xcf, 0xb8, 0x06, 0x12, 0xf5, + 0x65, 0xd8, 0xae, 0xdb, 0x97, 0x92, 0x92, 0x0b, 0x2a, 0x2d, 0xd3, 0x73, 0x33, 0x15, 0x9e, 0x5b, + 0xe0, 0x99, 0x13, 0x28, 0x71, 0x85, 0x73, 0xb1, 0xd1, 0x51, 0x72, 0xce, 0x2c, 0x10, 0xba, 0x81, + 0x8a, 0xfe, 0x20, 0x96, 0x78, 0xe1, 0x24, 0xe6, 0x54, 0xce, 0x54, 0x2b, 0x78, 0xb3, 0x88, 0x94, + 0x7c, 0x3a, 0x33, 0x44, 0xf4, 0xab, 0x09, 0xda, 0xc7, 0x66, 0x63, 0x5f, 0x24, 0x96, 0x04, 0x7e, + 0x02, 0x2d, 0xd3, 0x2c, 0xf2, 0x42, 0xaf, 0xef, 0x1f, 0x3e, 0x89, 0x5d, 0x1b, 0x8c, 0x4f, 0x34, + 0x33, 0x78, 0x74, 0x79, 0xdd, 0x6b, 0xfc, 0xbd, 0xee, 0x75, 0x2e, 0x70, 0xce, 0xde, 0x45, 0x26, + 0x19, 0x8d, 0xac, 0x02, 0x86, 0xa0, 0x5d, 0x90, 0x73, 0x39, 0x56, 0xb3, 0x8d, 0x69, 0x8a, 0xee, + 0x85, 0x5e, 0x7f, 0x7b, 0x04, 0x54, 0xed, 0x84, 0x73, 0x36, 0x4c, 0xe1, 0x4b, 0xb0, 0xab, 0x09, + 0xbb, 0x65, 0x05, 0x6d, 0x69, 0xa8, 0xa3, 0xca, 0x47, 0xa6, 0x3a, 0x4c, 0x61, 0x04, 0x3a, 0xc6, + 0xa4, 0x96, 0xa0, 0xa8, 0x6d, 0x4d, 0xf9, 0x5a, 0xa5, 0x6a, 0xc3, 0x14, 0xbe, 0x02, 0x50, 0x33, + 0xeb, 0x35, 0x28, 0xb0, 0xa9, 0xc1, 0x3d, 0x75, 0xf2, 0xed, 0xe6, 0x60, 0x98, 0xc2, 0x37, 0xa0, + 0xa9, 0xda, 0x12, 0xa8, 0x15, 0x6e, 0xf5, 0xfd, 0xc3, 0xee, 0x1d, 0x73, 0x72, 0xce, 0x06, 0xdb, + 0x6a, 0xca, 0x91, 0xc1, 0xe1, 0x7b, 0xb0, 0x63, 0x9b, 0x15, 0xe8, 0xbe, 0x8e, 0x3e, 0x75, 0x47, + 0x6d, 0xf3, 0x36, 0x7d, 0x13, 0x52, 0x17, 0xab, 0x26, 0x04, 0xda, 0xd9, 0x74, 0xf1, 0x51, 0x85, + 0xe7, 0xab, 0x8b, 0x35, 0x0e, 0xdf, 0x82, 0x96, 0x9e, 0x5e, 0xa0, 0x07, 0x3a, 0xf8, 0xf8, 0x8e, + 0x8e, 0x15, 0x63, 0x93, 0x36, 0x00, 0x3f, 0x02, 0x7f, 0xbd, 0x14, 0x81, 0x80, 0xce, 0x87, 0xee, + 0xfc, 0x7a, 0x49, 0x56, 0x72, 0x3b, 0x0a, 0x3f, 0x83, 0x87, 0xfa, 0xf7, 0x19, 0xcb, 0x0a, 0x4f, + 0xcf, 0x48, 0x25, 0x90, 0xaf, 0x65, 0x91, 0x5b, 0xf6, 0x41, 0xb1, 0x5f, 0x0d, 0x6a, 0x75, 0x1d, + 0x72, 0xab, 0x26, 0xe0, 0x29, 0xd8, 0x33, 0xc2, 0xba, 0x98, 0xf0, 0x22, 0xa5, 0x45, 0x26, 0x50, + 0x5b, 0x2b, 0x9f, 0x6f, 0x50, 0x9e, 0xae, 0x60, 0x2b, 0xdd, 0x25, 0xff, 0x55, 0xc5, 0xe0, 0xf8, + 0x72, 0x11, 0x78, 0x57, 0x8b, 0xc0, 0xfb, 0xb3, 0x08, 0xbc, 0x9f, 0xcb, 0xa0, 0x71, 0xb5, 0x0c, + 0x1a, 0xbf, 0x97, 0x41, 0xe3, 0xfb, 0x41, 0x46, 0xe5, 0xac, 0x9e, 0xc4, 0x53, 0x9e, 0x27, 0xac, + 0xce, 0x0f, 0x56, 0xcf, 0x63, 0x3a, 0xc3, 0xb4, 0x48, 0xce, 0xd7, 0xcf, 0x44, 0x5e, 0x94, 0x44, + 0x4c, 0x5a, 0xfa, 0x9d, 0xbc, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x25, 0xb2, 0x31, 0xe9, 0x6d, + 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -211,6 +221,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.EpochUnbondings) > 0 { + for iNdEx := len(m.EpochUnbondings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.EpochUnbondings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } + } if len(m.EpochTrackers) > 0 { for iNdEx := len(m.EpochTrackers) - 1; iNdEx >= 0; iNdEx-- { { @@ -395,6 +419,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.EpochUnbondings) > 0 { + for _, e := range m.EpochUnbondings { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -746,6 +776,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochUnbondings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EpochUnbondings = append(m.EpochUnbondings, EpochUnbonding{}) + if err := m.EpochUnbondings[len(m.EpochUnbondings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:])