diff --git a/localnet/spn/genesis_template.json b/localnet/spn/genesis_template.json index 2843967ab..63f2ca67a 100644 --- a/localnet/spn/genesis_template.json +++ b/localnet/spn/genesis_template.json @@ -355,28 +355,28 @@ "participationTierList": [ { "tierID": 1, - "requiredAllocations": 1, + "requiredAllocations": "1", "benefits": { "maxBidAmount": "1000" } }, { "tierID": 2, - "requiredAllocations": 2, + "requiredAllocations": "2", "benefits": { "maxBidAmount": "2000" } }, { "tierID": 3, - "requiredAllocations": 5, + "requiredAllocations": "5", "benefits": { "maxBidAmount": "10000" } }, { "tierID": 4, - "requiredAllocations": 10, + "requiredAllocations": "10", "benefits": { "maxBidAmount": "30000" } diff --git a/localnet/testnet/genesis_template.json b/localnet/testnet/genesis_template.json index dc298dbb9..c7a9a7acc 100644 --- a/localnet/testnet/genesis_template.json +++ b/localnet/testnet/genesis_template.json @@ -362,28 +362,28 @@ "participationTierList": [ { "tierID": 1, - "requiredAllocations": 1, + "requiredAllocations": "1", "benefits": { "maxBidAmount": "1000" } }, { "tierID": 2, - "requiredAllocations": 2, + "requiredAllocations": "2", "benefits": { "maxBidAmount": "1000" } }, { "tierID": 3, - "requiredAllocations": 5, + "requiredAllocations": "5", "benefits": { "maxBidAmount": "1000" } }, { "tierID": 4, - "requiredAllocations": 10, + "requiredAllocations": "10", "benefits": { "maxBidAmount": "1000" } diff --git a/proto/participation/auction_used_allocations.proto b/proto/participation/auction_used_allocations.proto index 67819323a..ac14ca04f 100644 --- a/proto/participation/auction_used_allocations.proto +++ b/proto/participation/auction_used_allocations.proto @@ -1,12 +1,17 @@ syntax = "proto3"; package tendermint.spn.participation; +import "gogoproto/gogo.proto"; + option go_package = "github.com/tendermint/spn/x/participation/types"; // Allocations used by a user for a specific auction message AuctionUsedAllocations { string address = 1; uint64 auctionID = 2; - uint64 numAllocations = 3; - bool withdrawn = 4; + bool withdrawn = 3; + string numAllocations = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } diff --git a/proto/participation/events.proto b/proto/participation/events.proto index 634996106..05884b37c 100644 --- a/proto/participation/events.proto +++ b/proto/participation/events.proto @@ -8,7 +8,10 @@ option go_package = "github.com/tendermint/spn/x/participation/types"; message EventAllocationsUsed { string participant = 1; uint64 auctionID = 2; - uint64 numAllocations = 3; + string numAllocations = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message EventAllocationsWithdrawn { diff --git a/proto/participation/params.proto b/proto/participation/params.proto index 38740fd20..839a88e33 100644 --- a/proto/participation/params.proto +++ b/proto/participation/params.proto @@ -29,7 +29,10 @@ message AllocationPrice { // Matches a number of required allocations with benefits message Tier { uint64 tierID = 1; - uint64 requiredAllocations = 2; + string requiredAllocations = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; TierBenefits benefits = 3 [(gogoproto.nullable) = false]; } diff --git a/proto/participation/query.proto b/proto/participation/query.proto index 3eaeb2d00..d44607fb6 100644 --- a/proto/participation/query.proto +++ b/proto/participation/query.proto @@ -92,7 +92,10 @@ message QueryGetTotalAllocationsRequest { } message QueryGetTotalAllocationsResponse { - uint64 totalAllocations = 1; + string totalAllocations = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message QueryGetAvailableAllocationsRequest { @@ -100,7 +103,10 @@ message QueryGetAvailableAllocationsRequest { } message QueryGetAvailableAllocationsResponse { - uint64 availableAllocations = 1; + string availableAllocations = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } // QueryParamsRequest is request type for the Query/Params RPC method. diff --git a/proto/participation/used_allocations.proto b/proto/participation/used_allocations.proto index cef3c4f82..afb5b49d7 100644 --- a/proto/participation/used_allocations.proto +++ b/proto/participation/used_allocations.proto @@ -1,10 +1,15 @@ syntax = "proto3"; package tendermint.spn.participation; +import "gogoproto/gogo.proto"; + option go_package = "github.com/tendermint/spn/x/participation/types"; // Describes the number of allocations already used by a user for existing auctions message UsedAllocations { string address = 1; - uint64 numAllocations = 2; + string numAllocations = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } diff --git a/testutil/networksuite/networksuite.go b/testutil/networksuite/networksuite.go index 384b30094..71ffbdf9a 100644 --- a/testutil/networksuite/networksuite.go +++ b/testutil/networksuite/networksuite.go @@ -168,7 +168,7 @@ func populateClaim(r *rand.Rand, claimState claim.GenesisState) claim.GenesisSta for i := 0; i < 5; i++ { claimRecord := claim.ClaimRecord{ Address: sample.Address(r), - Claimable: sdk.NewInt(r.Int63()), + Claimable: sample.Int(r), } nullify.Fill(&claimRecord) claimState.ClaimRecords = append(claimState.ClaimRecords, claimRecord) @@ -234,7 +234,8 @@ func populateParticipation(r *rand.Rand, participationState participation.Genesi // add used allocations for i := 0; i < 5; i++ { usedAllocations := participation.UsedAllocations{ - Address: sample.Address(r), + Address: sample.Address(r), + NumAllocations: sample.Int(r), } nullify.Fill(&usedAllocations) participationState.UsedAllocationsList = append(participationState.UsedAllocationsList, usedAllocations) @@ -244,8 +245,9 @@ func populateParticipation(r *rand.Rand, participationState participation.Genesi address := sample.Address(r) for i := 0; i < 5; i++ { auctionUsedAllocations := participation.AuctionUsedAllocations{ - Address: address, - AuctionID: uint64(i), + Address: address, + AuctionID: uint64(i), + NumAllocations: sample.Int(r), } nullify.Fill(&auctionUsedAllocations) participationState.AuctionUsedAllocationsList = append(participationState.AuctionUsedAllocationsList, auctionUsedAllocations) diff --git a/testutil/sample/participation.go b/testutil/sample/participation.go index 4ae8b5f98..32caf14b1 100644 --- a/testutil/sample/participation.go +++ b/testutil/sample/participation.go @@ -17,7 +17,7 @@ func ParticipationParams(r *rand.Rand) participation.Params { tiers := make([]participation.Tier, 0) numTiers := uint64(r.Int63n(10) + 1) - allocCnt := uint64(r.Int63n(5) + 1) + allocCnt := sdk.NewInt(r.Int63n(5) + 1) maxBidCnt := sdk.NewInt(r.Int63n(10000) + 1) for i := uint64(1); i <= numTiers; i++ { tier := participation.Tier{ @@ -30,7 +30,7 @@ func ParticipationParams(r *rand.Rand) participation.Params { tiers = append(tiers, tier) // increment values for next tier - allocCnt += uint64(r.Int63n(5) + 1) + allocCnt = allocCnt.Add(sdk.NewInt(r.Int63n(5) + 1)) maxBidCnt = maxBidCnt.AddRaw(r.Int63n(10000) + 1) } @@ -57,17 +57,17 @@ func ParticipationGenesisStateWithAllocations(r *rand.Rand) participation.Genesi addr := Address(r) usedAllocs := participation.UsedAllocations{ Address: addr, - NumAllocations: 0, + NumAllocations: sdk.ZeroInt(), } for j := 0; j < 3; j++ { auctionUsedAllocs := participation.AuctionUsedAllocations{ Address: addr, AuctionID: uint64(j), - NumAllocations: uint64(r.Int63n(5) + 1), + NumAllocations: sdk.NewInt(r.Int63n(5) + 1), Withdrawn: false, } genState.AuctionUsedAllocationsList = append(genState.AuctionUsedAllocationsList, auctionUsedAllocs) - usedAllocs.NumAllocations += auctionUsedAllocs.NumAllocations + usedAllocs.NumAllocations = usedAllocs.NumAllocations.Mul(sdk.NewInt(2)) } genState.UsedAllocationsList = append(genState.UsedAllocationsList, usedAllocs) } diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 553cd85c3..7e5df2ad0 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -192,3 +192,8 @@ func Duration(r *rand.Rand) time.Duration { func DurationFromRange(r *rand.Rand, min, max time.Duration) time.Duration { return time.Duration(r.Int63n(int64(max-min))) + min } + +// Int returns a sample sdk.Int +func Int(r *rand.Rand) sdk.Int { + return sdk.NewInt(r.Int63()) +} diff --git a/x/claim/keeper/claim_record_test.go b/x/claim/keeper/claim_record_test.go index 174f43a96..44a13f404 100644 --- a/x/claim/keeper/claim_record_test.go +++ b/x/claim/keeper/claim_record_test.go @@ -17,7 +17,7 @@ func createNClaimRecord(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.C items := make([]types.ClaimRecord, n) for i := range items { items[i].Address = sample.Address(r) - items[i].Claimable = sdk.NewInt(r.Int63()) + items[i].Claimable = sample.Int(r) keeper.SetClaimRecord(ctx, items[i]) } diff --git a/x/claim/types/genesis_test.go b/x/claim/types/genesis_test.go index 8c9f72457..f2737a200 100644 --- a/x/claim/types/genesis_test.go +++ b/x/claim/types/genesis_test.go @@ -16,8 +16,8 @@ func TestGenesisState_Validate(t *testing.T) { require.NoError(t, err) claimAmts := []sdk.Int{ - sdk.NewInt(r.Int63()), - sdk.NewInt(r.Int63()), + sample.Int(r), + sample.Int(r), } for _, tt := range []struct { diff --git a/x/participation/keeper/auction_used_allocations_test.go b/x/participation/keeper/auction_used_allocations_test.go index aba0aa790..627bc9f54 100644 --- a/x/participation/keeper/auction_used_allocations_test.go +++ b/x/participation/keeper/auction_used_allocations_test.go @@ -19,7 +19,7 @@ func createNAuctionUsedAllocations(keeper *keeper.Keeper, ctx sdk.Context, n int for i := range items { items[i].Address = strconv.Itoa(i) items[i].AuctionID = uint64(i) - + items[i].NumAllocations = sample.Int(r) keeper.SetAuctionUsedAllocations(ctx, items[i]) } return items @@ -31,6 +31,7 @@ func createNAuctionUsedAllocationsWithSameAddress(keeper *keeper.Keeper, ctx sdk for i := range items { items[i].Address = address items[i].AuctionID = uint64(i) + items[i].NumAllocations = sample.Int(r) keeper.SetAuctionUsedAllocations(ctx, items[i]) } diff --git a/x/participation/keeper/available_allocations.go b/x/participation/keeper/available_allocations.go index 8da8535b0..9556d2d1c 100644 --- a/x/participation/keeper/available_allocations.go +++ b/x/participation/keeper/available_allocations.go @@ -5,10 +5,10 @@ import ( ) // GetAvailableAllocations returns the number of allocations that are unused -func (k Keeper) GetAvailableAllocations(ctx sdk.Context, address string) (uint64, error) { +func (k Keeper) GetAvailableAllocations(ctx sdk.Context, address string) (sdk.Int, error) { numTotalAlloc, err := k.GetTotalAllocations(ctx, address) if err != nil { - return 0, err + return sdk.ZeroInt(), err } usedAlloc, found := k.GetUsedAllocations(ctx, address) @@ -17,11 +17,11 @@ func (k Keeper) GetAvailableAllocations(ctx sdk.Context, address string) (uint64 } // return 0 if result would be negative - if usedAlloc.NumAllocations > numTotalAlloc { - return 0, nil + if usedAlloc.NumAllocations.GT(numTotalAlloc) { + return sdk.ZeroInt(), nil } - availableAlloc := numTotalAlloc - usedAlloc.NumAllocations + availableAlloc := numTotalAlloc.Sub(usedAlloc.NumAllocations) return availableAlloc, nil } diff --git a/x/participation/keeper/available_allocations_test.go b/x/participation/keeper/available_allocations_test.go index 04e16e73d..bb127256c 100644 --- a/x/participation/keeper/available_allocations_test.go +++ b/x/participation/keeper/available_allocations_test.go @@ -34,35 +34,35 @@ func TestAvailableAllocationsGet(t *testing.T) { tk.ParticipationKeeper.SetUsedAllocations(sdkCtx, types.UsedAllocations{ Address: validAddress, - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), }) // set used allocations to be greater than totalAllocations tk.ParticipationKeeper.SetUsedAllocations(sdkCtx, types.UsedAllocations{ Address: validAddressExtraUsed, - NumAllocations: 11, + NumAllocations: sdk.NewInt(11), }) for _, tc := range []struct { desc string address string - allocation uint64 + allocation sdk.Int wantError bool }{ { desc: "valid address with used allocations", address: validAddress, - allocation: 8, // (100 * 10 / 100) - 2 = 8 + allocation: sdk.NewInt(8), // (100 * 10 / 100) - 2 = 8 }, { desc: "valid address with no used allocations", address: validAddressNoUse, - allocation: 10, // (100 * 10 / 100) - 0 = 10 + allocation: sdk.NewInt(10), // (100 * 10 / 100) - 0 = 10 }, { desc: "return 0 when usedAllocations > totalAllocations", address: validAddressExtraUsed, - allocation: 0, // 11 > 10 - > return 0 + allocation: sdk.NewInt(0), // 11 > 10 - > return 0 }, { desc: "invalid address returns error", diff --git a/x/participation/keeper/grpc_available_allocations_test.go b/x/participation/keeper/grpc_available_allocations_test.go index 7e8589daf..c996a186c 100644 --- a/x/participation/keeper/grpc_available_allocations_test.go +++ b/x/participation/keeper/grpc_available_allocations_test.go @@ -38,7 +38,7 @@ func TestShowAvailableAllocationsQuery(t *testing.T) { request: &types.QueryGetAvailableAllocationsRequest{ Address: dels[0].DelegatorAddress, }, - response: &types.QueryGetAvailableAllocationsResponse{AvailableAllocations: 10}, + response: &types.QueryGetAvailableAllocationsResponse{AvailableAllocations: sdk.NewInt(10)}, }, { diff --git a/x/participation/keeper/grpc_total_allocations_test.go b/x/participation/keeper/grpc_total_allocations_test.go index 9f70fa804..e10f5908b 100644 --- a/x/participation/keeper/grpc_total_allocations_test.go +++ b/x/participation/keeper/grpc_total_allocations_test.go @@ -38,7 +38,7 @@ func TestShowTotalAllocationsQuery(t *testing.T) { request: &types.QueryGetTotalAllocationsRequest{ Address: dels[0].DelegatorAddress, }, - response: &types.QueryGetTotalAllocationsResponse{TotalAllocations: 10}, + response: &types.QueryGetTotalAllocationsResponse{TotalAllocations: sdk.NewInt(10)}, }, { diff --git a/x/participation/keeper/grpc_used_allocations.go b/x/participation/keeper/grpc_used_allocations.go index f9419e185..a9113d78f 100644 --- a/x/participation/keeper/grpc_used_allocations.go +++ b/x/participation/keeper/grpc_used_allocations.go @@ -57,7 +57,7 @@ func (k Keeper) UsedAllocations(c context.Context, req *types.QueryGetUsedAlloca return &types.QueryGetUsedAllocationsResponse{ UsedAllocations: types.UsedAllocations{ Address: req.Address, - NumAllocations: 0, + NumAllocations: sdk.ZeroInt(), }, }, nil } diff --git a/x/participation/keeper/grpc_used_allocations_test.go b/x/participation/keeper/grpc_used_allocations_test.go index f80216088..424925bb8 100644 --- a/x/participation/keeper/grpc_used_allocations_test.go +++ b/x/participation/keeper/grpc_used_allocations_test.go @@ -46,7 +46,7 @@ func TestUsedAllocationsQuerySingle(t *testing.T) { request: &types.QueryGetUsedAllocationsRequest{ Address: validAddr, }, - response: &types.QueryGetUsedAllocationsResponse{UsedAllocations: types.UsedAllocations{Address: validAddr, NumAllocations: 0}}, + response: &types.QueryGetUsedAllocationsResponse{UsedAllocations: types.UsedAllocations{Address: validAddr, NumAllocations: sdk.ZeroInt()}}, }, { desc: "InvalidAddress", diff --git a/x/participation/keeper/invariants.go b/x/participation/keeper/invariants.go index 11641b31f..64d9c3b4d 100644 --- a/x/participation/keeper/invariants.go +++ b/x/participation/keeper/invariants.go @@ -30,13 +30,13 @@ func MismatchUsedAllocationsInvariant(k Keeper) sdk.Invariant { all := k.GetAllUsedAllocations(ctx) for _, usedAllocs := range all { auctionUsedAllocs := k.GetAllAuctionUsedAllocationsByAddress(ctx, usedAllocs.Address) - sum := uint64(0) + sum := sdk.ZeroInt() for _, auction := range auctionUsedAllocs { if !auction.Withdrawn { - sum += auction.NumAllocations + sum = sum.Add(auction.NumAllocations) } } - if sum != usedAllocs.NumAllocations { + if !sum.Equal(usedAllocs.NumAllocations) { return sdk.FormatInvariant( types.ModuleName, mismatchUsedAllocationsRoute, "total used allocations not equal to sum of per-auction used allocations", diff --git a/x/participation/keeper/invariants_test.go b/x/participation/keeper/invariants_test.go index 6657d9e94..d40aa0845 100644 --- a/x/participation/keeper/invariants_test.go +++ b/x/participation/keeper/invariants_test.go @@ -3,6 +3,8 @@ package keeper_test import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" testkeeper "github.com/tendermint/spn/testutil/keeper" @@ -19,29 +21,29 @@ func TestMismatchUsedAllocationsInvariant(t *testing.T) { { Address: addr, AuctionID: 1, - NumAllocations: 1, + NumAllocations: sdk.OneInt(), Withdrawn: false, }, { Address: addr, AuctionID: 2, - NumAllocations: 1, + NumAllocations: sdk.OneInt(), Withdrawn: false, }, { Address: addr, AuctionID: 3, - NumAllocations: 5, + NumAllocations: sdk.NewInt(5), Withdrawn: true, }, } invalidUsedAllocs = types.UsedAllocations{ Address: addr, - NumAllocations: 7, + NumAllocations: sdk.NewInt(7), } validUsedAllocs = types.UsedAllocations{ Address: addr, - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), } ) diff --git a/x/participation/keeper/msg_participate.go b/x/participation/keeper/msg_participate.go index 834cf429e..873105612 100644 --- a/x/participation/keeper/msg_participate.go +++ b/x/participation/keeper/msg_participate.go @@ -49,7 +49,7 @@ func (k msgServer) Participate(goCtx context.Context, msg *types.MsgParticipate) } // check if user has enough available allocations to cover tier - if tier.RequiredAllocations > availableAlloc { + if tier.RequiredAllocations.GT(availableAlloc) { return nil, sdkerrors.Wrapf(types.ErrInsufficientAllocations, "available allocations %d is less than required allocations %d for tier %d", availableAlloc, tier.RequiredAllocations, tier.TierID) @@ -67,13 +67,13 @@ func (k msgServer) Participate(goCtx context.Context, msg *types.MsgParticipate) } // set used allocations - numUsedAllocations := uint64(0) + numUsedAllocations := sdk.ZeroInt() used, found := k.GetUsedAllocations(ctx, msg.Participant) if found { numUsedAllocations = used.NumAllocations } - numUsedAllocations += tier.RequiredAllocations + numUsedAllocations = numUsedAllocations.Add(tier.RequiredAllocations) k.SetUsedAllocations(ctx, types.UsedAllocations{ Address: msg.Participant, NumAllocations: numUsedAllocations, diff --git a/x/participation/keeper/msg_participate_test.go b/x/participation/keeper/msg_participate_test.go index bdb111dc9..50a401dda 100644 --- a/x/participation/keeper/msg_participate_test.go +++ b/x/participation/keeper/msg_participate_test.go @@ -18,8 +18,6 @@ func Test_msgServer_Participate(t *testing.T) { var ( sdkCtx, tk, ts = testkeeper.NewTestSetup(t) auctioneer = sample.Address(r) - sellingCoin1 = sample.Coin(r) - sellingCoin2 = sample.Coin(r) registrationPeriod = time.Hour * 5 // 5 hours before start startTime = sdkCtx.BlockTime().Add(time.Hour * 10) startTimeLowerRegistrationPeriod = time.Unix(int64((registrationPeriod - time.Hour).Seconds()), 0) @@ -27,7 +25,7 @@ func Test_msgServer_Participate(t *testing.T) { validRegistrationTime = sdkCtx.BlockTime().Add(time.Hour * 6) allocationPrice = types.AllocationPrice{Bonded: sdk.NewInt(100)} addrsWithDelsTier = []string{sample.Address(r), sample.Address(r), sample.Address(r), sample.Address(r)} - availableAllocsTier = make([]uint64, len(addrsWithDelsTier)) + availableAllocsTier = make([]sdk.Int, len(addrsWithDelsTier)) ) params := types.DefaultParams() @@ -35,6 +33,12 @@ func Test_msgServer_Participate(t *testing.T) { params.RegistrationPeriod = registrationPeriod tk.ParticipationKeeper.SetParams(sdkCtx, params) + sellingCoin1 := sample.CoinWithRange(r, params.ParticipationTierList[1].Benefits.MaxBidAmount.Int64(), + params.ParticipationTierList[1].Benefits.MaxBidAmount.Int64()+1000) + + sellingCoin2 := sample.CoinWithRange(r, params.ParticipationTierList[1].Benefits.MaxBidAmount.Int64(), + params.ParticipationTierList[1].Benefits.MaxBidAmount.Int64()+1000) + // initialize auction tk.Mint(sdkCtx, auctioneer, sdk.NewCoins(sellingCoin1)) auctionRegistrationPeriodID := tk.CreateFixedPriceAuction(sdkCtx, r, auctioneer, sellingCoin1, startTime, endTime) @@ -62,14 +66,14 @@ func Test_msgServer_Participate(t *testing.T) { var err error availableAllocsTier[i], err = tk.ParticipationKeeper.GetAvailableAllocations(sdkCtx, addrsWithDelsTier[i]) require.NoError(t, err) - require.EqualValues(t, 10, availableAllocsTier[i]) + require.EqualValues(t, sdk.NewInt(10), availableAllocsTier[i]) } tests := []struct { name string msg *types.MsgParticipate - desiredUsedAlloc uint64 - currentAvailableAlloc uint64 + desiredUsedAlloc sdk.Int + currentAvailableAlloc sdk.Int blockTime time.Time err error }{ @@ -80,7 +84,7 @@ func Test_msgServer_Participate(t *testing.T) { AuctionID: auctionRegistrationPeriodID, TierID: 1, }, - desiredUsedAlloc: 1, + desiredUsedAlloc: sdk.OneInt(), currentAvailableAlloc: availableAllocsTier[0], blockTime: validRegistrationTime, }, @@ -91,7 +95,7 @@ func Test_msgServer_Participate(t *testing.T) { AuctionID: auctionRegistrationPeriodID, TierID: 2, }, - desiredUsedAlloc: 2, + desiredUsedAlloc: sdk.NewInt(2), currentAvailableAlloc: availableAllocsTier[1], blockTime: validRegistrationTime, }, @@ -102,7 +106,7 @@ func Test_msgServer_Participate(t *testing.T) { AuctionID: auctionLowerRegistrationPeriodID, TierID: 1, }, - desiredUsedAlloc: 1, + desiredUsedAlloc: sdk.OneInt(), currentAvailableAlloc: availableAllocsTier[2], blockTime: time.Unix(1, 0), }, @@ -237,7 +241,7 @@ func Test_msgServer_Participate(t *testing.T) { availableAlloc, err := tk.ParticipationKeeper.GetAvailableAllocations(tmpSdkCtx, tt.msg.Participant) require.NoError(t, err) require.True(t, found) - require.EqualValues(t, tt.currentAvailableAlloc-tier.RequiredAllocations, availableAlloc) + require.EqualValues(t, tt.currentAvailableAlloc.Sub(tier.RequiredAllocations), availableAlloc) }) } } diff --git a/x/participation/keeper/msg_withdraw_allocations.go b/x/participation/keeper/msg_withdraw_allocations.go index ad6934457..c07a2fe44 100644 --- a/x/participation/keeper/msg_withdraw_allocations.go +++ b/x/participation/keeper/msg_withdraw_allocations.go @@ -42,10 +42,10 @@ func (k msgServer) WithdrawAllocations(goCtx context.Context, msg *types.MsgWith } // decrease totalUsedAllocations making sure subtraction is feasible - if totalUsedAllocations.NumAllocations < auctionUsedAllocations.NumAllocations { + if totalUsedAllocations.NumAllocations.LT(auctionUsedAllocations.NumAllocations) { return nil, spnerrors.Critical("number of total used allocations cannot become negative") } - totalUsedAllocations.NumAllocations -= auctionUsedAllocations.NumAllocations + totalUsedAllocations.NumAllocations = totalUsedAllocations.NumAllocations.Sub(auctionUsedAllocations.NumAllocations) auctionUsedAllocations.Withdrawn = true k.SetAuctionUsedAllocations(ctx, auctionUsedAllocations) diff --git a/x/participation/keeper/msg_withdraw_allocations_test.go b/x/participation/keeper/msg_withdraw_allocations_test.go index 03e8b62dd..11abdd4af 100644 --- a/x/participation/keeper/msg_withdraw_allocations_test.go +++ b/x/participation/keeper/msg_withdraw_allocations_test.go @@ -20,7 +20,6 @@ func Test_msgServer_WithdrawAllocations(t *testing.T) { auctioneer = sample.Address(r) validParticipant = sample.Address(r) invalidParticipant = sample.Address(r) - auctionSellingCoin = sample.Coin(r) auctionStartTime = sdkCtx.BlockTime().Add(time.Hour) auctionEndTime = sdkCtx.BlockTime().Add(time.Hour * 24 * 7) validWithdrawalTime = auctionStartTime.Add(time.Hour * 10) @@ -32,6 +31,9 @@ func Test_msgServer_WithdrawAllocations(t *testing.T) { params.AllocationPrice = types.AllocationPrice{Bonded: sdk.NewInt(100)} tk.ParticipationKeeper.SetParams(sdkCtx, params) + auctionSellingCoin := sample.CoinWithRange(r, params.ParticipationTierList[1].Benefits.MaxBidAmount.Int64(), + params.ParticipationTierList[1].Benefits.MaxBidAmount.Int64()+1000) + // delegate some coins so participant has some allocations to use tk.DelegateN(sdkCtx, r, validParticipant, 100, 10) @@ -65,7 +67,7 @@ func Test_msgServer_WithdrawAllocations(t *testing.T) { tk.ParticipationKeeper.SetAuctionUsedAllocations(sdkCtx, types.AuctionUsedAllocations{ Address: invalidParticipant, AuctionID: auctionID, - NumAllocations: 1, + NumAllocations: sdk.OneInt(), Withdrawn: true, // set withdrawn to true }) @@ -165,7 +167,8 @@ func Test_msgServer_WithdrawAllocations(t *testing.T) { // check usedAllocationEntry is correctly decreased postUsedAllocations, found := tk.ParticipationKeeper.GetUsedAllocations(tmpSdkCtx, tt.msg.Participant) require.True(t, found) - require.Equal(t, preUsedAllocations.NumAllocations-preAuctionUsedAllocations.NumAllocations, postUsedAllocations.NumAllocations) + calculated := preUsedAllocations.NumAllocations.Sub(preAuctionUsedAllocations.NumAllocations) + require.True(t, postUsedAllocations.NumAllocations.Equal(calculated), "numAlloc %s not equal to calculated %s", postUsedAllocations.NumAllocations, calculated) }) } } diff --git a/x/participation/keeper/total_allocations.go b/x/participation/keeper/total_allocations.go index c59cd947d..db735e0df 100644 --- a/x/participation/keeper/total_allocations.go +++ b/x/participation/keeper/total_allocations.go @@ -10,12 +10,12 @@ import ( ) // GetTotalAllocations returns the number of available allocations based on delegations -func (k Keeper) GetTotalAllocations(ctx sdk.Context, address string) (uint64, error) { +func (k Keeper) GetTotalAllocations(ctx sdk.Context, address string) (sdk.Int, error) { allocationPriceBondedDec := sdk.NewDecFromInt(k.AllocationPrice(ctx).Bonded) accAddr, err := sdk.AccAddressFromBech32(address) if err != nil { - return 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, err.Error()) + return sdk.ZeroInt(), sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, err.Error()) } // count total shares for account @@ -25,10 +25,10 @@ func (k Keeper) GetTotalAllocations(ctx sdk.Context, address string) (uint64, er totalDel = totalDel.Add(del.GetShares()) } - numAlloc := totalDel.Quo(allocationPriceBondedDec).TruncateInt64() - if numAlloc < 0 { - return 0, types.ErrInvalidAllocationAmount + numAlloc := totalDel.Quo(allocationPriceBondedDec) + if numAlloc.IsNegative() { + return sdk.ZeroInt(), types.ErrInvalidAllocationAmount } - return uint64(numAlloc), nil + return numAlloc.TruncateInt(), nil } diff --git a/x/participation/keeper/total_allocations_test.go b/x/participation/keeper/total_allocations_test.go index 80c80b441..93729840c 100644 --- a/x/participation/keeper/total_allocations_test.go +++ b/x/participation/keeper/total_allocations_test.go @@ -30,13 +30,13 @@ func TestTotalAllocationsGet(t *testing.T) { for _, tc := range []struct { desc string address string - allocation uint64 + allocation sdk.Int wantError bool }{ { desc: "valid address", address: validAddress, - allocation: 10, // 100 * 10 / 100 = 10 + allocation: sdk.NewInt(10), // 100 * 10 / 100 = 10 }, { desc: "invalid address returns error", diff --git a/x/participation/keeper/used_allocations.go b/x/participation/keeper/used_allocations.go index cfcdc6299..edbc209c5 100644 --- a/x/participation/keeper/used_allocations.go +++ b/x/participation/keeper/used_allocations.go @@ -24,6 +24,7 @@ func (k Keeper) GetUsedAllocations(ctx sdk.Context, address string) (val types.U } k.cdc.MustUnmarshal(b, &val) + return val, true } diff --git a/x/participation/keeper/used_allocations_test.go b/x/participation/keeper/used_allocations_test.go index ffe8c5ec2..4d66e589c 100644 --- a/x/participation/keeper/used_allocations_test.go +++ b/x/participation/keeper/used_allocations_test.go @@ -17,6 +17,7 @@ func createNUsedAllocations(keeper *keeper.Keeper, ctx sdk.Context, n int) []typ items := make([]types.UsedAllocations, n) for i := range items { items[i].Address = sample.Address(r) + items[i].NumAllocations = sample.Int(r) keeper.SetUsedAllocations(ctx, items[i]) } diff --git a/x/participation/simulation/store.go b/x/participation/simulation/store.go index 27b4127d2..9693c4c37 100644 --- a/x/participation/simulation/store.go +++ b/x/participation/simulation/store.go @@ -126,9 +126,9 @@ func RandomAuctionWithdrawEnabled( func RandomAccWithAvailableAllocations(ctx sdk.Context, r *rand.Rand, k keeper.Keeper, accs []simtypes.Account, - desired uint64, + desired sdk.Int, auctionID uint64, -) (simtypes.Account, uint64, bool) { +) (simtypes.Account, sdk.Int, bool) { // Randomize the set r.Shuffle(len(accs), func(i, j int) { accs[i], accs[j] = accs[j], accs[i] @@ -141,7 +141,7 @@ func RandomAccWithAvailableAllocations(ctx sdk.Context, r *rand.Rand, continue } - if amt >= desired { + if amt.GTE(desired) { _, found := k.GetAuctionUsedAllocations(ctx, acc.Address.String(), auctionID) if found { continue @@ -151,7 +151,7 @@ func RandomAccWithAvailableAllocations(ctx sdk.Context, r *rand.Rand, } } - return simtypes.Account{}, 0, false + return simtypes.Account{}, sdk.ZeroInt(), false } // RandomAccWithAuctionUsedAllocationsNotWithdrawn returns random account that has used allocations for the given diff --git a/x/participation/simulation/store_test.go b/x/participation/simulation/store_test.go index c098e303d..1ec580500 100644 --- a/x/participation/simulation/store_test.go +++ b/x/participation/simulation/store_test.go @@ -271,38 +271,38 @@ func TestRandomAccWithAvailableAllocations(t *testing.T) { tk.ParticipationKeeper.SetUsedAllocations(ctx, types.UsedAllocations{ Address: accs[1].Address.String(), - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), }) tk.ParticipationKeeper.SetAuctionUsedAllocations(ctx, types.AuctionUsedAllocations{ Address: accs[1].Address.String(), AuctionID: auctionID, - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), Withdrawn: false, }) tests := []struct { name string accounts []simulation.Account - desiredAllocations uint64 + desiredAllocations sdk.Int wantAccount simulation.Account found bool }{ { name: "no accounts with allocations", accounts: accs[2:], - desiredAllocations: 10, + desiredAllocations: sdk.NewInt(10), found: false, }, { name: "one account with insufficient allocations", accounts: accs[1:], - desiredAllocations: 10, + desiredAllocations: sdk.NewInt(10), found: false, }, { name: "one account has sufficient allocations", accounts: accs, - desiredAllocations: 10, + desiredAllocations: sdk.NewInt(10), wantAccount: accs[0], found: true, }, @@ -349,24 +349,24 @@ func TestRandomAccWithAuctionUsedAllocationsNotWithdrawn(t *testing.T) { // add withdrawn allocations for accs[1] tk.ParticipationKeeper.SetUsedAllocations(ctx, types.UsedAllocations{ Address: accs[1].Address.String(), - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), }) tk.ParticipationKeeper.SetAuctionUsedAllocations(ctx, types.AuctionUsedAllocations{ Address: accs[1].Address.String(), AuctionID: auctionID, - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), Withdrawn: true, }) // add used allocations not yet withdrawn for accs[2] tk.ParticipationKeeper.SetUsedAllocations(ctx, types.UsedAllocations{ Address: accs[2].Address.String(), - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), }) tk.ParticipationKeeper.SetAuctionUsedAllocations(ctx, types.AuctionUsedAllocations{ Address: accs[2].Address.String(), AuctionID: auctionID, - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), Withdrawn: false, }) @@ -419,7 +419,7 @@ func TestRandomTierFromList(t *testing.T) { tierList := []types.Tier{ { TierID: 1, - RequiredAllocations: 10, + RequiredAllocations: sdk.NewInt(10), Benefits: types.TierBenefits{}, }, } diff --git a/x/participation/types/auction_used_allocations.pb.go b/x/participation/types/auction_used_allocations.pb.go index c8ccce542..d7f5b9bc9 100644 --- a/x/participation/types/auction_used_allocations.pb.go +++ b/x/participation/types/auction_used_allocations.pb.go @@ -5,6 +5,8 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -24,10 +26,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Allocations used by a user for a specific auction type AuctionUsedAllocations struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - AuctionID uint64 `protobuf:"varint,2,opt,name=auctionID,proto3" json:"auctionID,omitempty"` - NumAllocations uint64 `protobuf:"varint,3,opt,name=numAllocations,proto3" json:"numAllocations,omitempty"` - Withdrawn bool `protobuf:"varint,4,opt,name=withdrawn,proto3" json:"withdrawn,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + AuctionID uint64 `protobuf:"varint,2,opt,name=auctionID,proto3" json:"auctionID,omitempty"` + Withdrawn bool `protobuf:"varint,3,opt,name=withdrawn,proto3" json:"withdrawn,omitempty"` + NumAllocations github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=numAllocations,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"numAllocations"` } func (m *AuctionUsedAllocations) Reset() { *m = AuctionUsedAllocations{} } @@ -77,13 +79,6 @@ func (m *AuctionUsedAllocations) GetAuctionID() uint64 { return 0 } -func (m *AuctionUsedAllocations) GetNumAllocations() uint64 { - if m != nil { - return m.NumAllocations - } - return 0 -} - func (m *AuctionUsedAllocations) GetWithdrawn() bool { if m != nil { return m.Withdrawn @@ -100,22 +95,25 @@ func init() { } var fileDescriptor_0dcb8de466150226 = []byte{ - // 234 bytes of a gzipped FileDescriptorProto + // 279 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x29, 0x48, 0x2c, 0x2a, 0xc9, 0x4c, 0xce, 0x2c, 0x48, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x4f, 0x2c, 0x4d, 0x06, 0xd1, 0xf1, 0xa5, 0xc5, 0xa9, 0x29, 0xf1, 0x89, 0x39, 0x39, 0xf9, 0xc9, 0x60, 0xf1, 0x62, 0xbd, 0x82, 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x99, 0x92, 0xd4, 0xbc, 0x94, 0xd4, 0xa2, 0xdc, 0xcc, 0xbc, 0x12, 0xbd, - 0xe2, 0x82, 0x3c, 0x3d, 0x14, 0xcd, 0x4a, 0xd3, 0x18, 0xb9, 0xc4, 0x1c, 0x21, 0x06, 0x84, 0x16, - 0xa7, 0xa6, 0x38, 0x22, 0xb4, 0x0b, 0x49, 0x70, 0xb1, 0x27, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, - 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, 0x42, 0x32, 0x5c, 0x9c, 0x50, 0x4b, 0x3d, - 0x5d, 0x24, 0x98, 0x14, 0x18, 0x35, 0x58, 0x82, 0x10, 0x02, 0x42, 0x6a, 0x5c, 0x7c, 0x79, 0xa5, - 0xb9, 0x48, 0x26, 0x49, 0x30, 0x83, 0x95, 0xa0, 0x89, 0x82, 0x4c, 0x29, 0xcf, 0x2c, 0xc9, 0x48, - 0x29, 0x4a, 0x2c, 0xcf, 0x93, 0x60, 0x51, 0x60, 0xd4, 0xe0, 0x08, 0x42, 0x08, 0x38, 0x79, 0x9e, - 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, - 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, 0x46, 0x69, - 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc2, 0x6f, 0xfa, 0xc5, 0x05, 0x79, 0xfa, 0x15, 0xfa, 0xa8, - 0x41, 0x53, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x08, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x59, 0x14, 0x03, 0x02, 0x38, 0x01, 0x00, 0x00, + 0xe2, 0x82, 0x3c, 0x3d, 0x14, 0xcd, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x85, 0xfa, 0x20, + 0x16, 0x44, 0x8f, 0xd2, 0x31, 0x46, 0x2e, 0x31, 0x47, 0x88, 0xb1, 0xa1, 0xc5, 0xa9, 0x29, 0x8e, + 0x08, 0x43, 0x85, 0x24, 0xb8, 0xd8, 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x25, 0x18, 0x15, + 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x21, 0x19, 0x2e, 0x4e, 0xa8, 0x53, 0x3c, 0x5d, 0x24, 0x98, + 0x14, 0x18, 0x35, 0x58, 0x82, 0x10, 0x02, 0x20, 0xd9, 0xf2, 0xcc, 0x92, 0x8c, 0x94, 0xa2, 0xc4, + 0xf2, 0x3c, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x8e, 0x20, 0x84, 0x80, 0x50, 0x18, 0x17, 0x5f, 0x5e, + 0x69, 0x2e, 0x92, 0x3d, 0x12, 0x2c, 0x20, 0xc3, 0x9d, 0xf4, 0x4e, 0xdc, 0x93, 0x67, 0xb8, 0x75, + 0x4f, 0x5e, 0x2d, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x39, 0xbf, + 0x38, 0x37, 0xbf, 0x18, 0x4a, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, + 0x79, 0xe6, 0x95, 0x04, 0xa1, 0x99, 0xe2, 0xe4, 0x79, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, + 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, + 0x72, 0x0c, 0x51, 0xfa, 0x48, 0x26, 0x22, 0x42, 0x48, 0xbf, 0xb8, 0x20, 0x4f, 0xbf, 0x42, 0x1f, + 0x35, 0x80, 0xc1, 0xc6, 0x27, 0xb1, 0x81, 0x83, 0xc6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x19, + 0x76, 0x38, 0x98, 0x7e, 0x01, 0x00, 0x00, } func (m *AuctionUsedAllocations) Marshal() (dAtA []byte, err error) { @@ -138,6 +136,16 @@ func (m *AuctionUsedAllocations) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + { + size := m.NumAllocations.Size() + i -= size + if _, err := m.NumAllocations.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAuctionUsedAllocations(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 if m.Withdrawn { i-- if m.Withdrawn { @@ -146,11 +154,6 @@ func (m *AuctionUsedAllocations) MarshalToSizedBuffer(dAtA []byte) (int, error) dAtA[i] = 0 } i-- - dAtA[i] = 0x20 - } - if m.NumAllocations != 0 { - i = encodeVarintAuctionUsedAllocations(dAtA, i, uint64(m.NumAllocations)) - i-- dAtA[i] = 0x18 } if m.AuctionID != 0 { @@ -192,12 +195,11 @@ func (m *AuctionUsedAllocations) Size() (n int) { if m.AuctionID != 0 { n += 1 + sovAuctionUsedAllocations(uint64(m.AuctionID)) } - if m.NumAllocations != 0 { - n += 1 + sovAuctionUsedAllocations(uint64(m.NumAllocations)) - } if m.Withdrawn { n += 2 } + l = m.NumAllocations.Size() + n += 1 + l + sovAuctionUsedAllocations(uint64(l)) return n } @@ -289,9 +291,9 @@ func (m *AuctionUsedAllocations) Unmarshal(dAtA []byte) error { } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NumAllocations", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Withdrawn", wireType) } - m.NumAllocations = 0 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAuctionUsedAllocations @@ -301,16 +303,17 @@ func (m *AuctionUsedAllocations) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumAllocations |= uint64(b&0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } } + m.Withdrawn = bool(v != 0) case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Withdrawn", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NumAllocations", wireType) } - var v int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAuctionUsedAllocations @@ -320,12 +323,26 @@ func (m *AuctionUsedAllocations) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.Withdrawn = bool(v != 0) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuctionUsedAllocations + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuctionUsedAllocations + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumAllocations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAuctionUsedAllocations(dAtA[iNdEx:]) diff --git a/x/participation/types/events.pb.go b/x/participation/types/events.pb.go index 8555c7f95..f0937111d 100644 --- a/x/participation/types/events.pb.go +++ b/x/participation/types/events.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -24,9 +25,9 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type EventAllocationsUsed struct { - Participant string `protobuf:"bytes,1,opt,name=participant,proto3" json:"participant,omitempty"` - AuctionID uint64 `protobuf:"varint,2,opt,name=auctionID,proto3" json:"auctionID,omitempty"` - NumAllocations uint64 `protobuf:"varint,3,opt,name=numAllocations,proto3" json:"numAllocations,omitempty"` + Participant string `protobuf:"bytes,1,opt,name=participant,proto3" json:"participant,omitempty"` + AuctionID uint64 `protobuf:"varint,2,opt,name=auctionID,proto3" json:"auctionID,omitempty"` + NumAllocations github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=numAllocations,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"numAllocations"` } func (m *EventAllocationsUsed) Reset() { *m = EventAllocationsUsed{} } @@ -76,13 +77,6 @@ func (m *EventAllocationsUsed) GetAuctionID() uint64 { return 0 } -func (m *EventAllocationsUsed) GetNumAllocations() uint64 { - if m != nil { - return m.NumAllocations - } - return 0 -} - type EventAllocationsWithdrawn struct { Participant string `protobuf:"bytes,1,opt,name=participant,proto3" json:"participant,omitempty"` AuctionID uint64 `protobuf:"varint,2,opt,name=auctionID,proto3" json:"auctionID,omitempty"` @@ -143,22 +137,24 @@ func init() { func init() { proto.RegisterFile("participation/events.proto", fileDescriptor_0c141e14bf03ed00) } var fileDescriptor_0c141e14bf03ed00 = []byte{ - // 236 bytes of a gzipped FileDescriptorProto + // 270 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x48, 0x2c, 0x2a, 0xc9, 0x4c, 0xce, 0x2c, 0x48, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x29, 0x49, 0xcd, 0x4b, 0x49, 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x2b, 0x2e, 0xc8, 0xd3, 0x43, 0x51, 0x2a, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, - 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x28, 0xd5, 0x71, 0x89, 0xb8, 0x82, 0xcc, 0x70, 0xcc, 0xc9, - 0xc9, 0x4f, 0x06, 0x2b, 0x2c, 0x0e, 0x2d, 0x4e, 0x4d, 0x11, 0x52, 0xe0, 0xe2, 0x86, 0x6b, 0xcf, - 0x2b, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x42, 0x16, 0x12, 0x92, 0xe1, 0xe2, 0x4c, 0x2c, - 0x4d, 0x06, 0xe9, 0xf0, 0x74, 0x91, 0x60, 0x52, 0x60, 0xd4, 0x60, 0x09, 0x42, 0x08, 0x08, 0xa9, - 0x71, 0xf1, 0xe5, 0x95, 0xe6, 0x22, 0x99, 0x2a, 0xc1, 0x0c, 0x56, 0x82, 0x26, 0xaa, 0x14, 0xcd, - 0x25, 0x89, 0x6e, 0x7f, 0x78, 0x66, 0x49, 0x46, 0x4a, 0x51, 0x62, 0x79, 0x1e, 0xa5, 0x8e, 0x70, - 0xf2, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, - 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xfd, 0xf4, 0xcc, 0x92, - 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x44, 0xa8, 0xe9, 0x17, 0x17, 0xe4, 0xe9, 0x57, - 0xe8, 0xa3, 0x06, 0x71, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xb8, 0x8c, 0x01, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x1c, 0xbd, 0xfb, 0x62, 0x80, 0x01, 0x00, 0x00, + 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x28, 0xad, 0x63, 0xe4, 0x12, 0x71, 0x05, 0x19, 0xe2, 0x98, + 0x93, 0x93, 0x9f, 0x0c, 0x56, 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 0x01, 0x00, 0x00, } func (m *EventAllocationsUsed) Marshal() (dAtA []byte, err error) { @@ -181,11 +177,16 @@ func (m *EventAllocationsUsed) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.NumAllocations != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.NumAllocations)) - i-- - dAtA[i] = 0x18 + { + size := m.NumAllocations.Size() + i -= size + if _, err := m.NumAllocations.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintEvents(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a if m.AuctionID != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.AuctionID)) i-- @@ -260,9 +261,8 @@ func (m *EventAllocationsUsed) Size() (n int) { if m.AuctionID != 0 { n += 1 + sovEvents(uint64(m.AuctionID)) } - if m.NumAllocations != 0 { - n += 1 + sovEvents(uint64(m.NumAllocations)) - } + l = m.NumAllocations.Size() + n += 1 + l + sovEvents(uint64(l)) return n } @@ -369,10 +369,10 @@ func (m *EventAllocationsUsed) Unmarshal(dAtA []byte) error { } } case 3: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NumAllocations", wireType) } - m.NumAllocations = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -382,11 +382,26 @@ func (m *EventAllocationsUsed) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumAllocations |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumAllocations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/x/participation/types/genesis.go b/x/participation/types/genesis.go index 7c097541a..432e56537 100644 --- a/x/participation/types/genesis.go +++ b/x/participation/types/genesis.go @@ -2,6 +2,8 @@ package types import ( "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" ) // DefaultIndex is the default capability global index @@ -32,10 +34,14 @@ func (gs GenesisState) Validate() error { } auctionUsedAllocationsIndexMap := make(map[string]struct{}) - auctionUsedAllocationsSum := make(map[string]uint64) + auctionUsedAllocationsSum := make(map[string]sdk.Int) for _, elem := range gs.AuctionUsedAllocationsList { index := string(AuctionUsedAllocationsKey(elem.Address, elem.AuctionID)) address := elem.Address + _, ok := auctionUsedAllocationsSum[address] + if !ok { + auctionUsedAllocationsSum[address] = sdk.ZeroInt() + } // Check for duplicated address in auctionUsedAllocations if _, ok := auctionUsedAllocationsIndexMap[index]; ok { @@ -50,13 +56,13 @@ func (gs GenesisState) Validate() error { // update total used allocations for address if !elem.Withdrawn { - auctionUsedAllocationsSum[address] += elem.NumAllocations + auctionUsedAllocationsSum[address] = auctionUsedAllocationsSum[address].Add(elem.NumAllocations) } } // check for consistency between UsedAllocationsList and AuctionUsedAllocationsList for _, elem := range gs.UsedAllocationsList { - if elem.NumAllocations != auctionUsedAllocationsSum[elem.Address] { + if !elem.NumAllocations.Equal(auctionUsedAllocationsSum[elem.Address]) { return fmt.Errorf("inconsistent total used auction allocations for address %v", elem.Address) } } diff --git a/x/participation/types/genesis_test.go b/x/participation/types/genesis_test.go index a29f05697..919f3474b 100644 --- a/x/participation/types/genesis_test.go +++ b/x/participation/types/genesis_test.go @@ -3,6 +3,8 @@ package types_test import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" "github.com/tendermint/spn/testutil/sample" @@ -33,20 +35,24 @@ func TestGenesisState_Validate(t *testing.T) { Params: types.DefaultParams(), UsedAllocationsList: []types.UsedAllocations{ { - Address: addr1, + Address: addr1, + NumAllocations: sdk.ZeroInt(), }, { - Address: addr2, + Address: addr2, + NumAllocations: sdk.ZeroInt(), }, }, AuctionUsedAllocationsList: []types.AuctionUsedAllocations{ { - Address: addr1, - AuctionID: auctionID1, + Address: addr1, + AuctionID: auctionID1, + NumAllocations: sdk.ZeroInt(), }, { - Address: addr2, - AuctionID: auctionID2, + Address: addr2, + AuctionID: auctionID2, + NumAllocations: sdk.ZeroInt(), }, }, // this line is used by starport scaffolding # types/genesis/validField @@ -60,20 +66,20 @@ func TestGenesisState_Validate(t *testing.T) { UsedAllocationsList: []types.UsedAllocations{ { Address: addr1, - NumAllocations: 5, + NumAllocations: sdk.NewInt(5), }, }, AuctionUsedAllocationsList: []types.AuctionUsedAllocations{ { Address: addr1, AuctionID: auctionID1, - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), Withdrawn: false, }, { Address: addr1, AuctionID: auctionID2, - NumAllocations: 3, + NumAllocations: sdk.NewInt(3), Withdrawn: false, }, }, @@ -85,10 +91,12 @@ func TestGenesisState_Validate(t *testing.T) { genState: &types.GenesisState{ UsedAllocationsList: []types.UsedAllocations{ { - Address: addr1, + Address: addr1, + NumAllocations: sdk.ZeroInt(), }, { - Address: addr1, + Address: addr1, + NumAllocations: sdk.ZeroInt(), }, }, }, @@ -99,17 +107,20 @@ func TestGenesisState_Validate(t *testing.T) { genState: &types.GenesisState{ UsedAllocationsList: []types.UsedAllocations{ { - Address: addr1, + Address: addr1, + NumAllocations: sdk.ZeroInt(), }, }, AuctionUsedAllocationsList: []types.AuctionUsedAllocations{ { - Address: addr1, - AuctionID: auctionID1, + Address: addr1, + AuctionID: auctionID1, + NumAllocations: sdk.ZeroInt(), }, { - Address: addr1, - AuctionID: auctionID1, + Address: addr1, + AuctionID: auctionID1, + NumAllocations: sdk.ZeroInt(), }, }, }, @@ -133,20 +144,20 @@ func TestGenesisState_Validate(t *testing.T) { UsedAllocationsList: []types.UsedAllocations{ { Address: addr1, - NumAllocations: 10, + NumAllocations: sdk.NewInt(10), }, }, AuctionUsedAllocationsList: []types.AuctionUsedAllocations{ { Address: addr1, AuctionID: auctionID1, - NumAllocations: 2, + NumAllocations: sdk.NewInt(2), Withdrawn: false, }, { Address: addr1, AuctionID: auctionID2, - NumAllocations: 8, + NumAllocations: sdk.NewInt(8), Withdrawn: true, }, }, diff --git a/x/participation/types/params.go b/x/participation/types/params.go index dddc81cf5..21229b37a 100644 --- a/x/participation/types/params.go +++ b/x/participation/types/params.go @@ -24,28 +24,28 @@ var ( DefaultParticipationTierList = []Tier{ { TierID: 1, - RequiredAllocations: 1, + RequiredAllocations: sdk.NewInt(1), Benefits: TierBenefits{ MaxBidAmount: sdk.NewInt(1000), }, }, { TierID: 2, - RequiredAllocations: 2, + RequiredAllocations: sdk.NewInt(2), Benefits: TierBenefits{ MaxBidAmount: sdk.NewInt(2000), }, }, { TierID: 3, - RequiredAllocations: 5, + RequiredAllocations: sdk.NewInt(5), Benefits: TierBenefits{ MaxBidAmount: sdk.NewInt(10000), }, }, { TierID: 4, - RequiredAllocations: 10, + RequiredAllocations: sdk.NewInt(10), Benefits: TierBenefits{ MaxBidAmount: sdk.NewInt(30000), }, @@ -155,7 +155,7 @@ func validateParticipationTierList(v interface{}) error { } tiersIndexMap[tier.TierID] = struct{}{} - if tier.RequiredAllocations <= 0 { + if tier.RequiredAllocations.LTE(sdk.ZeroInt()) { return errors.New("required allocations must be greater than zero") } diff --git a/x/participation/types/params.pb.go b/x/participation/types/params.pb.go index a6173f27a..82ce1431f 100644 --- a/x/participation/types/params.pb.go +++ b/x/participation/types/params.pb.go @@ -138,9 +138,9 @@ var xxx_messageInfo_AllocationPrice proto.InternalMessageInfo // Matches a number of required allocations with benefits type Tier struct { - TierID uint64 `protobuf:"varint,1,opt,name=tierID,proto3" json:"tierID,omitempty"` - RequiredAllocations uint64 `protobuf:"varint,2,opt,name=requiredAllocations,proto3" json:"requiredAllocations,omitempty"` - Benefits TierBenefits `protobuf:"bytes,3,opt,name=benefits,proto3" json:"benefits"` + TierID uint64 `protobuf:"varint,1,opt,name=tierID,proto3" json:"tierID,omitempty"` + RequiredAllocations github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=requiredAllocations,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"requiredAllocations"` + Benefits TierBenefits `protobuf:"bytes,3,opt,name=benefits,proto3" json:"benefits"` } func (m *Tier) Reset() { *m = Tier{} } @@ -183,13 +183,6 @@ func (m *Tier) GetTierID() uint64 { return 0 } -func (m *Tier) GetRequiredAllocations() uint64 { - if m != nil { - return m.RequiredAllocations - } - return 0 -} - func (m *Tier) GetBenefits() TierBenefits { if m != nil { return m.Benefits @@ -245,36 +238,36 @@ func init() { func init() { proto.RegisterFile("participation/params.proto", fileDescriptor_1941a0f9399e39d9) } var fileDescriptor_1941a0f9399e39d9 = []byte{ - // 457 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x93, 0x6d, 0x58, 0xea, 0xb4, 0xb0, 0x30, 0xfe, 0x21, 0x2e, 0x92, 0x2d, 0x39, 0x48, - 0x11, 0x3a, 0x23, 0xf5, 0xe6, 0xad, 0x61, 0x11, 0x16, 0x2a, 0x2c, 0xd1, 0x8b, 0x82, 0xc2, 0x24, - 0x33, 0x4d, 0x07, 0x93, 0x99, 0x38, 0x33, 0xa1, 0xed, 0xb7, 0xf0, 0xd8, 0x93, 0xf8, 0x71, 0x7a, - 0xec, 0x51, 0x3c, 0x54, 0xd9, 0xfd, 0x04, 0x7e, 0x03, 0xc9, 0x64, 0xb4, 0xcd, 0xb2, 0x94, 0xe2, - 0x29, 0x79, 0x79, 0x9f, 0xe7, 0xf7, 0xe6, 0x7d, 0x5e, 0x02, 0xc6, 0x35, 0x51, 0x86, 0xe7, 0xbc, - 0x26, 0x86, 0x4b, 0x81, 0x6b, 0xa2, 0x48, 0xa5, 0x51, 0xad, 0xa4, 0x91, 0xf0, 0x89, 0x61, 0x82, - 0x32, 0x55, 0x71, 0x61, 0x90, 0xae, 0x05, 0xea, 0x49, 0xc7, 0x0f, 0x0a, 0x59, 0x48, 0x2b, 0xc4, - 0xed, 0x5b, 0xe7, 0x19, 0x47, 0x85, 0x94, 0x45, 0xc9, 0xb0, 0xad, 0xb2, 0xe6, 0x08, 0xd3, 0x46, - 0x59, 0x7d, 0xd7, 0x8f, 0x7f, 0x0f, 0xc0, 0x70, 0x6e, 0x87, 0xc0, 0x0f, 0x60, 0x44, 0xca, 0x52, - 0xe6, 0xb6, 0x3d, 0x57, 0x3c, 0x67, 0xa1, 0xbf, 0xe3, 0xef, 0x6e, 0xed, 0xef, 0xa1, 0xdb, 0x06, - 0xa3, 0x83, 0xbe, 0x29, 0x09, 0x2e, 0xae, 0x26, 0x5e, 0xba, 0xca, 0x82, 0x1f, 0xc1, 0xc3, 0x9e, - 0xef, 0x2d, 0x67, 0xea, 0x90, 0x6b, 0x13, 0x0e, 0x76, 0x36, 0x76, 0xb7, 0xf6, 0xe3, 0xdb, 0x87, - 0xb4, 0x6a, 0x47, 0x5e, 0x8f, 0x81, 0x6f, 0x00, 0x54, 0xac, 0xe0, 0xda, 0x74, 0xfb, 0xcd, 0x99, - 0xe2, 0x92, 0x86, 0x1b, 0x76, 0x83, 0xc7, 0xa8, 0x8b, 0x01, 0xfd, 0x8d, 0x01, 0x4d, 0x5d, 0x0c, - 0xc9, 0x66, 0xcb, 0x3c, 0xff, 0x39, 0xf1, 0xd3, 0x35, 0x76, 0xf8, 0x1a, 0x8c, 0x4e, 0xb8, 0x39, - 0xa6, 0x8a, 0x9c, 0x90, 0x72, 0xca, 0x4a, 0x72, 0x16, 0x06, 0x77, 0x27, 0xae, 0x7a, 0x5f, 0x06, - 0xe7, 0xdf, 0x26, 0x5e, 0xfc, 0x0e, 0x8c, 0x56, 0x32, 0x83, 0xaf, 0xc0, 0x30, 0x93, 0x82, 0x32, - 0x6a, 0x23, 0xbf, 0x97, 0xa0, 0x96, 0xf1, 0xe3, 0x6a, 0xf2, 0xb4, 0xe0, 0xe6, 0xb8, 0xc9, 0x50, - 0x2e, 0x2b, 0x9c, 0x4b, 0x5d, 0x49, 0xed, 0x1e, 0x7b, 0x9a, 0x7e, 0xc2, 0xe6, 0xac, 0x66, 0x1a, - 0xcd, 0x84, 0x49, 0x9d, 0x3b, 0xfe, 0xea, 0x83, 0xa0, 0x4d, 0x04, 0x3e, 0x02, 0x43, 0xc3, 0x99, - 0x9a, 0x4d, 0x2d, 0x30, 0x48, 0x5d, 0x05, 0x9f, 0x83, 0xfb, 0x8a, 0x7d, 0x6e, 0xb8, 0x62, 0xf4, - 0xfa, 0x1b, 0x74, 0x38, 0xb0, 0xa2, 0x75, 0x2d, 0x78, 0x08, 0x36, 0x33, 0x26, 0xd8, 0x11, 0x37, - 0xda, 0xa5, 0xf9, 0xec, 0x0e, 0xa7, 0x72, 0x0e, 0x77, 0xb2, 0x7f, 0x84, 0x38, 0x03, 0xdb, 0x37, - 0xfb, 0x30, 0x05, 0xdb, 0x15, 0x39, 0x4d, 0x38, 0x3d, 0xa8, 0x64, 0x23, 0xcc, 0x7f, 0xae, 0xdf, - 0x63, 0x24, 0xb3, 0x8b, 0x45, 0xe4, 0x5f, 0x2e, 0x22, 0xff, 0xd7, 0x22, 0xf2, 0xbf, 0x2c, 0x23, - 0xef, 0x72, 0x19, 0x79, 0xdf, 0x97, 0x91, 0xf7, 0x1e, 0xdf, 0xe0, 0x5d, 0xef, 0x80, 0x75, 0x2d, - 0xf0, 0x29, 0xee, 0xff, 0x79, 0x16, 0x9e, 0x0d, 0xed, 0x79, 0x5f, 0xfc, 0x09, 0x00, 0x00, 0xff, - 0xff, 0x6a, 0x9b, 0x23, 0xc9, 0x97, 0x03, 0x00, 0x00, + // 459 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4f, 0x6b, 0xdb, 0x30, +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b, 0xf1, 0x35, 0x21, 0xce, 0xc0, + 0xf6, 0xed, 0x3a, 0x4c, 0xc1, 0x76, 0x45, 0x4e, 0x13, 0x4e, 0x0f, 0x2a, 0xd9, 0x08, 0xb3, 0x66, + 0x5c, 0x1d, 0x46, 0x32, 0xb9, 0x98, 0x45, 0xfe, 0xe5, 0x2c, 0xf2, 0xff, 0xcc, 0x22, 0xff, 0xdb, + 0x3c, 0xf2, 0x2e, 0xe7, 0x91, 0xf7, 0x73, 0x1e, 0x79, 0x1f, 0xf0, 0x2d, 0xde, 0xcd, 0x0c, 0x58, + 0xd7, 0x02, 0x9f, 0xe2, 0xee, 0x4d, 0xb5, 0xf0, 0xac, 0x6f, 0x7f, 0x87, 0x97, 0xff, 0x02, 0x00, + 0x00, 0xff, 0xff, 0xb5, 0xe2, 0xf1, 0x21, 0xc7, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -403,11 +396,16 @@ func (m *Tier) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - if m.RequiredAllocations != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.RequiredAllocations)) - i-- - dAtA[i] = 0x10 + { + size := m.RequiredAllocations.Size() + i -= size + if _, err := m.RequiredAllocations.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if m.TierID != 0 { i = encodeVarintParams(dAtA, i, uint64(m.TierID)) i-- @@ -501,9 +499,8 @@ func (m *Tier) Size() (n int) { if m.TierID != 0 { n += 1 + sovParams(uint64(m.TierID)) } - if m.RequiredAllocations != 0 { - n += 1 + sovParams(uint64(m.RequiredAllocations)) - } + l = m.RequiredAllocations.Size() + n += 1 + l + sovParams(uint64(l)) l = m.Benefits.Size() n += 1 + l + sovParams(uint64(l)) return n @@ -842,10 +839,10 @@ func (m *Tier) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RequiredAllocations", wireType) } - m.RequiredAllocations = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -855,11 +852,26 @@ func (m *Tier) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.RequiredAllocations |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RequiredAllocations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Benefits", wireType) diff --git a/x/participation/types/params_test.go b/x/participation/types/params_test.go index 671648e72..43d31fa56 100644 --- a/x/participation/types/params_test.go +++ b/x/participation/types/params_test.go @@ -36,7 +36,7 @@ func TestParamsValidate(t *testing.T) { []Tier{ { TierID: 0, - RequiredAllocations: 1, + RequiredAllocations: sdk.OneInt(), Benefits: TierBenefits{MaxBidAmount: sdk.ZeroInt()}, }, }, @@ -143,12 +143,12 @@ func TestValidateParticipationTierList(t *testing.T) { participationTierList: []Tier{ { TierID: 0, - RequiredAllocations: 1, + RequiredAllocations: sdk.OneInt(), Benefits: TierBenefits{MaxBidAmount: sdk.OneInt()}, }, { TierID: 0, - RequiredAllocations: 2, + RequiredAllocations: sdk.NewInt(2), Benefits: TierBenefits{MaxBidAmount: sdk.NewInt(2)}, }, }, @@ -159,7 +159,7 @@ func TestValidateParticipationTierList(t *testing.T) { participationTierList: []Tier{ { TierID: 0, - RequiredAllocations: 0, + RequiredAllocations: sdk.ZeroInt(), Benefits: TierBenefits{MaxBidAmount: sdk.OneInt()}, }, }, @@ -170,7 +170,7 @@ func TestValidateParticipationTierList(t *testing.T) { participationTierList: []Tier{ { TierID: 0, - RequiredAllocations: 1, + RequiredAllocations: sdk.OneInt(), Benefits: TierBenefits{MaxBidAmount: sdk.ZeroInt()}, }, }, @@ -185,12 +185,12 @@ func TestValidateParticipationTierList(t *testing.T) { participationTierList: []Tier{ { TierID: 0, - RequiredAllocations: 1, + RequiredAllocations: sdk.OneInt(), Benefits: TierBenefits{MaxBidAmount: sdk.OneInt()}, }, { TierID: 1, - RequiredAllocations: 2, + RequiredAllocations: sdk.NewInt(2), Benefits: TierBenefits{MaxBidAmount: sdk.NewInt(2)}, }, }, diff --git a/x/participation/types/query.pb.go b/x/participation/types/query.pb.go index 2d247100c..98624491f 100644 --- a/x/participation/types/query.pb.go +++ b/x/participation/types/query.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -463,7 +464,7 @@ func (m *QueryGetTotalAllocationsRequest) GetAddress() string { } type QueryGetTotalAllocationsResponse struct { - TotalAllocations uint64 `protobuf:"varint,1,opt,name=totalAllocations,proto3" json:"totalAllocations,omitempty"` + TotalAllocations github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=totalAllocations,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"totalAllocations"` } func (m *QueryGetTotalAllocationsResponse) Reset() { *m = QueryGetTotalAllocationsResponse{} } @@ -499,13 +500,6 @@ func (m *QueryGetTotalAllocationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetTotalAllocationsResponse proto.InternalMessageInfo -func (m *QueryGetTotalAllocationsResponse) GetTotalAllocations() uint64 { - if m != nil { - return m.TotalAllocations - } - return 0 -} - type QueryGetAvailableAllocationsRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } @@ -551,7 +545,7 @@ func (m *QueryGetAvailableAllocationsRequest) GetAddress() string { } type QueryGetAvailableAllocationsResponse struct { - AvailableAllocations uint64 `protobuf:"varint,1,opt,name=availableAllocations,proto3" json:"availableAllocations,omitempty"` + AvailableAllocations github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=availableAllocations,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"availableAllocations"` } func (m *QueryGetAvailableAllocationsResponse) Reset() { *m = QueryGetAvailableAllocationsResponse{} } @@ -587,13 +581,6 @@ func (m *QueryGetAvailableAllocationsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetAvailableAllocationsResponse proto.InternalMessageInfo -func (m *QueryGetAvailableAllocationsResponse) GetAvailableAllocations() uint64 { - if m != nil { - return m.AvailableAllocations - } - return 0 -} - // QueryParamsRequest is request type for the Query/Params RPC method. type QueryParamsRequest struct { } @@ -696,58 +683,59 @@ func init() { func init() { proto.RegisterFile("participation/query.proto", fileDescriptor_3b6d9d472596bad2) } var fileDescriptor_3b6d9d472596bad2 = []byte{ - // 803 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xc1, 0x4f, 0xd4, 0x4e, - 0x14, 0xde, 0x01, 0x7e, 0xfc, 0xc2, 0x70, 0x80, 0x8c, 0x1b, 0x02, 0x0d, 0x29, 0xa4, 0xae, 0x68, - 0x08, 0xb6, 0x80, 0xc6, 0x28, 0x88, 0xd0, 0x05, 0x41, 0x12, 0x43, 0x70, 0x83, 0x07, 0x49, 0x0c, - 0x99, 0xdd, 0x9d, 0x94, 0x26, 0xdd, 0x4e, 0xe9, 0x74, 0x89, 0x84, 0x90, 0x18, 0x6f, 0xde, 0x4c, - 0x3c, 0xea, 0x1f, 0x04, 0x37, 0x12, 0x3d, 0x78, 0x32, 0x06, 0xf0, 0xae, 0x47, 0x6f, 0x66, 0xa7, - 0xb3, 0xac, 0xad, 0x6d, 0x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 0x23, 0xd1, 0x17, 0xd7, 0xec, 0x5c, 0x4e, 0x67, - 0x48, 0xe7, 0xf2, 0x9b, 0x4e, 0x69, 0xe5, 0x09, 0x97, 0x9f, 0x47, 0x4b, 0x9d, 0xca, 0x47, 0x9f, - 0x01, 0x1c, 0x0c, 0x8f, 0x3b, 0x94, 0xf2, 0x85, 0x8a, 0x99, 0xb1, 0xd2, 0xa3, 0x76, 0xd3, 0x85, - 0x3a, 0x9d, 0xab, 0x9b, 0x47, 0x0f, 0x92, 0xd5, 0xf1, 0x89, 0x1b, 0x23, 0xeb, 0x02, 0xc0, 0x6c, - 0xd4, 0xd0, 0x44, 0x7a, 0xca, 0xf6, 0x8b, 0x9f, 0xd8, 0x52, 0xbe, 0x13, 0x08, 0x21, 0xf1, 0x31, - 0x97, 0xb8, 0x88, 0x16, 0x9a, 0x18, 0x58, 0xc7, 0x88, 0x91, 0xf9, 0x01, 0xc0, 0x5e, 0x7f, 0xdc, - 0xa2, 0xe9, 0x14, 0xac, 0x02, 0xd3, 0x5e, 0x9a, 0x69, 0x21, 0x43, 0xd0, 0x9e, 0xe2, 0xb4, 0x27, - 0x50, 0x2e, 0x99, 0xb6, 0x3f, 0xf3, 0xf3, 0xeb, 0xc7, 0x67, 0x32, 0x38, 0x3d, 0x93, 0xc1, 0xb7, - 0x33, 0x19, 0xbc, 0x3b, 0x97, 0x33, 0xa7, 0xe7, 0x72, 0xe6, 0xcb, 0xb9, 0x9c, 0xd9, 0xd6, 0x0c, - 0xd3, 0xdb, 0xad, 0x16, 0xd5, 0x12, 0xad, 0x84, 0x91, 0x5e, 0x85, 0x5d, 0x3e, 0x70, 0x08, 0x2b, - 0xf6, 0xf2, 0x5f, 0x12, 0x77, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x2a, 0xd0, 0x12, 0x9f, 0x54, - 0x0d, 0x00, 0x00, + // 830 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0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x10, 0xe7, 0xd0, 0x6c, 0x83, 0x02, 0xd6, 0x34, 0x02, 0x30, 0x3f, 0x01, 0xd8, 0xed, 0x8c, 0x5b, + 0x34, 0x11, 0x21, 0x2a, 0xd7, 0xb4, 0x57, 0x26, 0x9b, 0xf0, 0x90, 0x61, 0x8f, 0x89, 0xb0, 0x53, + 0x28, 0x19, 0x1e, 0xb6, 0x33, 0xf3, 0x33, 0x2b, 0xfb, 0xc7, 0x09, 0x70, 0x78, 0x9c, 0x00, 0x3f, + 0x8e, 0x13, 0xe0, 0xc3, 0x49, 0x22, 0x76, 0x78, 0x92, 0x88, 0x7d, 0x3b, 0x49, 0xc4, 0xd6, 0xf5, + 0x73, 0xcb, 0xcb, 0xa3, 0xf4, 0xca, 0x5b, 0xe5, 0xea, 0x26, 0xcb, 0x75, 0x8b, 0x7f, 0x55, 0x6e, + 0xfd, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xdd, 0x1d, 0x15, 0xb5, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1416,11 +1404,16 @@ func (m *QueryGetTotalAllocationsResponse) MarshalToSizedBuffer(dAtA []byte) (in _ = i var l int _ = l - if m.TotalAllocations != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.TotalAllocations)) - i-- - dAtA[i] = 0x8 + { + size := m.TotalAllocations.Size() + i -= size + if _, err := m.TotalAllocations.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1474,11 +1467,16 @@ func (m *QueryGetAvailableAllocationsResponse) MarshalToSizedBuffer(dAtA []byte) _ = i var l int _ = l - if m.AvailableAllocations != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.AvailableAllocations)) - i-- - dAtA[i] = 0x8 + { + size := m.AvailableAllocations.Size() + i -= size + if _, err := m.AvailableAllocations.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1687,9 +1685,8 @@ func (m *QueryGetTotalAllocationsResponse) Size() (n int) { } var l int _ = l - if m.TotalAllocations != 0 { - n += 1 + sovQuery(uint64(m.TotalAllocations)) - } + l = m.TotalAllocations.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -1712,9 +1709,8 @@ func (m *QueryGetAvailableAllocationsResponse) Size() (n int) { } var l int _ = l - if m.AvailableAllocations != 0 { - n += 1 + sovQuery(uint64(m.AvailableAllocations)) - } + l = m.AvailableAllocations.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -2649,10 +2645,10 @@ func (m *QueryGetTotalAllocationsResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TotalAllocations", wireType) } - m.TotalAllocations = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2662,11 +2658,26 @@ func (m *QueryGetTotalAllocationsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TotalAllocations |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalAllocations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -2800,10 +2811,10 @@ func (m *QueryGetAvailableAllocationsResponse) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AvailableAllocations", wireType) } - m.AvailableAllocations = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2813,11 +2824,26 @@ func (m *QueryGetAvailableAllocationsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AvailableAllocations |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AvailableAllocations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/participation/types/used_allocations.pb.go b/x/participation/types/used_allocations.pb.go index 00ffa5a40..1b1371667 100644 --- a/x/participation/types/used_allocations.pb.go +++ b/x/participation/types/used_allocations.pb.go @@ -5,6 +5,8 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -24,8 +26,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Describes the number of allocations already used by a user for existing auctions type UsedAllocations struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - NumAllocations uint64 `protobuf:"varint,2,opt,name=numAllocations,proto3" json:"numAllocations,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + NumAllocations github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=numAllocations,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"numAllocations"` } func (m *UsedAllocations) Reset() { *m = UsedAllocations{} } @@ -68,13 +70,6 @@ func (m *UsedAllocations) GetAddress() string { return "" } -func (m *UsedAllocations) GetNumAllocations() uint64 { - if m != nil { - return m.NumAllocations - } - return 0 -} - func init() { proto.RegisterType((*UsedAllocations)(nil), "tendermint.spn.participation.UsedAllocations") } @@ -84,19 +79,22 @@ func init() { } var fileDescriptor_3210f1039a9f28f1 = []byte{ - // 189 bytes of a gzipped FileDescriptorProto + // 233 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x29, 0x48, 0x2c, 0x2a, 0xc9, 0x4c, 0xce, 0x2c, 0x48, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x2d, 0x4e, 0x4d, 0x89, 0x4f, 0xcc, 0xc9, 0xc9, 0x4f, 0x06, 0xf3, 0x8b, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x64, 0x4a, 0x52, 0xf3, 0x52, 0x52, 0x8b, 0x72, 0x33, 0xf3, 0x4a, 0xf4, 0x8a, 0x0b, 0xf2, 0xf4, 0x50, 0x34, - 0x29, 0x05, 0x73, 0xf1, 0x87, 0x16, 0xa7, 0xa6, 0x38, 0x22, 0xb4, 0x09, 0x49, 0x70, 0xb1, 0x27, - 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, 0x42, - 0x6a, 0x5c, 0x7c, 0x79, 0xa5, 0xb9, 0x48, 0x6a, 0x25, 0x98, 0x14, 0x18, 0x35, 0x58, 0x82, 0xd0, - 0x44, 0x9d, 0x3c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, - 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x3f, 0x3d, - 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0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0x47, 0x0d, 0x15, 0xb0, 0xf1, 0x49, 0x6c, 0x60, 0x7f, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x7b, 0xb2, 0xda, 0x51, 0x33, 0x01, 0x00, 0x00, } func (m *UsedAllocations) Marshal() (dAtA []byte, err error) { @@ -119,11 +117,16 @@ func (m *UsedAllocations) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.NumAllocations != 0 { - i = encodeVarintUsedAllocations(dAtA, i, uint64(m.NumAllocations)) - i-- - dAtA[i] = 0x10 + { + size := m.NumAllocations.Size() + i -= size + if _, err := m.NumAllocations.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintUsedAllocations(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -155,9 +158,8 @@ func (m *UsedAllocations) Size() (n int) { if l > 0 { n += 1 + l + sovUsedAllocations(uint64(l)) } - if m.NumAllocations != 0 { - n += 1 + sovUsedAllocations(uint64(m.NumAllocations)) - } + l = m.NumAllocations.Size() + n += 1 + l + sovUsedAllocations(uint64(l)) return n } @@ -229,10 +231,10 @@ func (m *UsedAllocations) Unmarshal(dAtA []byte) error { m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NumAllocations", wireType) } - m.NumAllocations = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowUsedAllocations @@ -242,11 +244,26 @@ func (m *UsedAllocations) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NumAllocations |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthUsedAllocations + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthUsedAllocations + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NumAllocations.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipUsedAllocations(dAtA[iNdEx:])