diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index 1d8dc7571..a016fd60c 100644 --- a/deployment/localup/localup.sh +++ b/deployment/localup/localup.sh @@ -147,7 +147,7 @@ function generate_genesis() { sed -i -e "s/\"challenge_keep_alive_period\": \"300\"/\"challenge_keep_alive_period\": \"10\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"heartbeat_interval\": \"1000\"/\"heartbeat_interval\": \"100\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"attestation_inturn_interval\": \"120\"/\"attestation_inturn_interval\": \"10\"/g" ${workspace}/.local/validator${i}/config/genesis.json - sed -i -e "s/\"discontinue_confirm_period\": \"604800\"/\"discontinue_confirm_period\": \"15\"/g" ${workspace}/.local/validator${i}/config/genesis.json + sed -i -e "s/\"discontinue_confirm_period\": \"604800\"/\"discontinue_confirm_period\": \"5\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"discontinue_deletion_max\": \"10000\"/\"discontinue_deletion_max\": \"1\"/g" ${workspace}/.local/validator${i}/config/genesis.json sed -i -e "s/\"voting_period\": \"30s\"/\"voting_period\": \"10s\"/g" ${workspace}/.local/validator${i}/config/genesis.json done diff --git a/e2e/tests/challenge_test.go b/e2e/tests/challenge_test.go index 2ae607758..429064ce5 100644 --- a/e2e/tests/challenge_test.go +++ b/e2e/tests/challenge_test.go @@ -113,8 +113,6 @@ func (s *ChallengeTestSuite) createObject() (string, string, sdk.AccAddress, []s err = storagetypes.VerifySignature(sp.ApprovalKey.GetAddr(), sdk.Keccak256(sr.GetSignBytes()), secondarySig) s.Require().NoError(err) - s.Require().NoError(err) - secondarySigs := [][]byte{secondarySig, secondarySig, secondarySig, secondarySig, secondarySig, secondarySig} msgSealObject.SecondarySpSignatures = secondarySigs s.SendTxBlock(sp.SealKey, msgSealObject) diff --git a/e2e/tests/payment_test.go b/e2e/tests/payment_test.go index 1b8e8f453..9eded0c0a 100644 --- a/e2e/tests/payment_test.go +++ b/e2e/tests/payment_test.go @@ -1,13 +1,27 @@ package tests import ( + "bytes" "context" + "fmt" + "math" + "strconv" "testing" + "time" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/stretchr/testify/suite" "github.com/bnb-chain/greenfield/e2e/core" + "github.com/bnb-chain/greenfield/sdk/keys" + "github.com/bnb-chain/greenfield/sdk/types" + storagetestutil "github.com/bnb-chain/greenfield/testutil/storage" paymenttypes "github.com/bnb-chain/greenfield/x/payment/types" + storagetypes "github.com/bnb-chain/greenfield/x/storage/types" ) type PaymentTestSuite struct { @@ -59,6 +73,358 @@ func (s *PaymentTestSuite) TestPaymentAccount() { s.Require().Equal(false, paymentAccount.PaymentAccount.Refundable) } +func (s *PaymentTestSuite) updateParams(params paymenttypes.Params) { + var err error + validator := s.Validator.GetAddr() + + ctx := context.Background() + + ts := time.Now().Unix() + queryParamsRequest := &paymenttypes.QueryParamsRequest{} + queryParamsResponse, err := s.Client.PaymentQueryClient.Params(ctx, queryParamsRequest) + s.Require().NoError(err) + + msgUpdateParams := &paymenttypes.MsgUpdateParams{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Params: params, + } + + msgProposal, err := govtypesv1.NewMsgSubmitProposal( + []sdk.Msg{msgUpdateParams}, + sdk.Coins{sdk.NewCoin(s.BaseSuite.Config.Denom, types.NewIntFromInt64WithDecimal(100, types.DecimalBNB))}, + validator.String(), + "test", "test", "test", + ) + s.Require().NoError(err) + + txRes := s.SendTxBlock(s.Validator, msgProposal) + s.Require().Equal(txRes.Code, uint32(0)) + + // 3. query proposal and get proposal ID + var proposalId uint64 + for _, event := range txRes.Logs[0].Events { + if event.Type == "submit_proposal" { + for _, attr := range event.Attributes { + if attr.Key == "proposal_id" { + proposalId, err = strconv.ParseUint(attr.Value, 10, 0) + s.Require().NoError(err) + break + } + } + break + } + } + s.Require().True(proposalId != 0) + + queryProposal := &govtypesv1.QueryProposalRequest{ProposalId: proposalId} + _, err = s.Client.GovQueryClientV1.Proposal(ctx, queryProposal) + s.Require().NoError(err) + + // 4. submit MsgVote and wait the proposal exec + msgVote := govtypesv1.NewMsgVote(validator, proposalId, govtypesv1.OptionYes, "test") + txRes = s.SendTxBlock(s.Validator, msgVote) + s.Require().Equal(txRes.Code, uint32(0)) + + queryVoteParamsReq := govtypesv1.QueryParamsRequest{ParamsType: "voting"} + queryVoteParamsResp, err := s.Client.GovQueryClientV1.Params(ctx, &queryVoteParamsReq) + s.Require().NoError(err) + + // 5. wait a voting period and confirm that the proposal success. + s.T().Logf("voting period %s", *queryVoteParamsResp.Params.VotingPeriod) + time.Sleep(*queryVoteParamsResp.Params.VotingPeriod) + time.Sleep(1 * time.Second) + proposalRes, err := s.Client.GovQueryClientV1.Proposal(ctx, queryProposal) + s.Require().NoError(err) + s.Require().Equal(proposalRes.Proposal.Status, govtypesv1.ProposalStatus_PROPOSAL_STATUS_PASSED) + + queryParamsByTimestampRequest := &paymenttypes.QueryParamsByTimestampRequest{Timestamp: ts} + queryParamsByTimestampResponse, err := s.Client.PaymentQueryClient.ParamsByTimestamp(ctx, queryParamsByTimestampRequest) + s.Require().NoError(err) + s.Require().Equal(queryParamsResponse.Params.VersionedParams.ReserveTime, + queryParamsByTimestampResponse.Params.VersionedParams.ReserveTime) +} + +func (s *PaymentTestSuite) createObject() (keys.KeyManager, string, string, storagetypes.Uint, []byte) { + var err error + sp := s.StorageProviders[0] + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + + // CreateBucket + user := s.GenAndChargeAccounts(1, 1000000)[0] + bucketName := "ch" + storagetestutil.GenRandomBucketName() + msgCreateBucket := storagetypes.NewMsgCreateBucket( + user.GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PRIVATE, sp.OperatorKey.GetAddr(), + nil, math.MaxUint, nil, 0) + msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId + msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxBlock(user, msgCreateBucket) + + // CreateObject + objectName := storagetestutil.GenRandomObjectName() + // create test buffer + var buffer bytes.Buffer + line := `1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890,1234567890, + 1234567890,1234567890,1234567890,123` + // Create 1MiB content where each line contains 1024 characters. + for i := 0; i < 1024; i++ { + buffer.WriteString(fmt.Sprintf("[%05d] %s\n", i, line)) + } + payloadSize := buffer.Len() + checksum := sdk.Keccak256(buffer.Bytes()) + expectChecksum := [][]byte{checksum, checksum, checksum, checksum, checksum, checksum, checksum} + contextType := "text/event-stream" + msgCreateObject := storagetypes.NewMsgCreateObject(user.GetAddr(), bucketName, objectName, uint64(payloadSize), + storagetypes.VISIBILITY_TYPE_PRIVATE, expectChecksum, contextType, + storagetypes.REDUNDANCY_EC_TYPE, math.MaxUint, nil) + msgCreateObject.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateObject.GetApprovalBytes()) + s.Require().NoError(err) + s.SendTxBlock(user, msgCreateObject) + + // HeadObject + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(context.Background(), &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectName, objectName) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.BucketName, bucketName) + + return user, bucketName, objectName, queryHeadObjectResponse.ObjectInfo.Id, checksum +} + +func (s *PaymentTestSuite) sealObject(bucketName, objectName string, objectId storagetypes.Uint, checksum []byte) { + sp := s.StorageProviders[0] + gvg, found := sp.GetFirstGlobalVirtualGroup() + s.Require().True(found) + + msgSealObject := storagetypes.NewMsgSealObject(sp.SealKey.GetAddr(), bucketName, objectName, gvg.Id, nil) + sr := storagetypes.NewSecondarySpSignDoc(sp.OperatorKey.GetAddr(), objectId, checksum) + secondarySig, err := sp.ApprovalKey.Sign(sr.GetSignBytes()) + s.Require().NoError(err) + err = storagetypes.VerifySignature(sp.ApprovalKey.GetAddr(), sdk.Keccak256(sr.GetSignBytes()), secondarySig) + s.Require().NoError(err) + + secondarySigs := [][]byte{secondarySig, secondarySig, secondarySig, secondarySig, secondarySig, secondarySig} + msgSealObject.SecondarySpSignatures = secondarySigs + s.SendTxBlock(sp.SealKey, msgSealObject) + + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(context.Background(), &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectName, objectName) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.BucketName, bucketName) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_SEALED) +} + +// TestVersionedParams_SealAfterReserveTimeChange will cover the following case: +// create an object, increase the reserve time, seal the object without error. +func (s *PaymentTestSuite) TestVersionedParams_SealObjectAfterReserveTimeChange() { + ctx := context.Background() + queryParamsRequest := paymenttypes.QueryParamsRequest{} + queryParamsResponse, err := s.Client.PaymentQueryClient.Params(ctx, &queryParamsRequest) + s.Require().NoError(err) + + // create bucket, create object + user, bucketName, objectName, objectId, checksum := s.createObject() + + // update params + params := queryParamsResponse.GetParams() + oldReserveTime := params.VersionedParams.ReserveTime + oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate + s.T().Logf("params, ReserveTime: %d, ValidatorTaxRate: %s", oldReserveTime, oldValidatorTaxRate) + + params.VersionedParams.ReserveTime = oldReserveTime * 2 + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) + + s.updateParams(params) + queryParamsResponse, err = s.Client.PaymentQueryClient.Params(ctx, &queryParamsRequest) + s.Require().NoError(err) + params = queryParamsResponse.GetParams() + s.T().Logf("params, ReserveTime: %d, ValidatorTaxRate: %s", params.VersionedParams.ReserveTime, params.VersionedParams.ValidatorTaxRate) + + // seal object + s.sealObject(bucketName, objectName, objectId, checksum) + + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_SEALED) + + // delete object + msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName) + s.SendTxBlock(user, msgDeleteObject) + + // delete bucket + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) + s.SendTxBlock(user, msgDeleteBucket) + + // revert params + params.VersionedParams.ReserveTime = oldReserveTime + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate + s.updateParams(params) +} + +// TestVersionedParams_DeleteAfterValidatorTaxRateChange will cover the following case: +// create a bucket with non-zero read quota, change the validator tax rate, delete the bucket. +// The rate of the validator tax address should be correct. +func (s *PaymentTestSuite) TestVersionedParams_DeleteBucketAfterValidatorTaxRateChange() { + ctx := context.Background() + queryParamsRequest := paymenttypes.QueryParamsRequest{} + queryParamsResponse, err := s.Client.PaymentQueryClient.Params(ctx, &queryParamsRequest) + s.Require().NoError(err) + + queryStreamRequest := paymenttypes.QueryGetStreamRecordRequest{Account: paymenttypes.ValidatorTaxPoolAddress.String()} + queryStreamResponse, err := s.Client.PaymentQueryClient.StreamRecord(ctx, &queryStreamRequest) + s.Require().NoError(err) + validatorTaxPoolRate := queryStreamResponse.StreamRecord.NetflowRate + s.T().Logf("netflow, validatorTaxPoolRate: %s", validatorTaxPoolRate) + + // create bucket, create object + user, bucketName, objectName, objectId, checksum := s.createObject() + + // seal object + s.sealObject(bucketName, objectName, objectId, checksum) + + // update params + params := queryParamsResponse.GetParams() + oldReserveTime := params.VersionedParams.ReserveTime + oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate + s.T().Logf("params, ReserveTime: %d, ValidatorTaxRate: %s", oldReserveTime, oldValidatorTaxRate) + + params.VersionedParams.ReserveTime = oldReserveTime / 2 + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) + + s.updateParams(params) + queryParamsResponse, err = s.Client.PaymentQueryClient.Params(ctx, &queryParamsRequest) + s.Require().NoError(err) + params = queryParamsResponse.GetParams() + s.T().Logf("params, ReserveTime: %d, ValidatorTaxRate: %s", params.VersionedParams.ReserveTime, params.VersionedParams.ValidatorTaxRate) + + // delete object + msgDeleteObject := storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName) + s.SendTxBlock(user, msgDeleteObject) + + // delete bucket + msgDeleteBucket := storagetypes.NewMsgDeleteBucket(user.GetAddr(), bucketName) + s.SendTxBlock(user, msgDeleteBucket) + + queryStreamResponse, err = s.Client.PaymentQueryClient.StreamRecord(ctx, &queryStreamRequest) + s.Require().NoError(err) + s.Require().Equal(validatorTaxPoolRate, queryStreamResponse.StreamRecord.NetflowRate) + + // revert params + params.VersionedParams.ReserveTime = oldReserveTime + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate + s.updateParams(params) +} + +// TestVersionedParams_DeleteObjectAfterReserveTimeChange will cover the following case: +// create an object, change the reserve time, the object can be force deleted even the object's own has no enough balance. +func (s *PaymentTestSuite) TestVersionedParams_DeleteObjectAfterReserveTimeChange() { + ctx := context.Background() + queryParamsRequest := paymenttypes.QueryParamsRequest{} + queryParamsResponse, err := s.Client.PaymentQueryClient.Params(ctx, &queryParamsRequest) + s.Require().NoError(err) + + // create bucket, create object + user, bucketName, objectName, objectId, checksum := s.createObject() + + // seal object + s.sealObject(bucketName, objectName, objectId, checksum) + + // for payment + time.Sleep(2 * time.Second) + + queryBalanceRequest := banktypes.QueryBalanceRequest{Denom: s.Config.Denom, Address: user.GetAddr().String()} + queryBalanceResponse, err := s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + + msgSend := banktypes.NewMsgSend(user.GetAddr(), core.GenRandomAddr(), sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.SubRaw(5*types.DecimalGwei)), + )) + + simulateResponse := s.SimulateTx(msgSend, user) + gasLimit := simulateResponse.GasInfo.GetGasUsed() + gasPrice, err := sdk.ParseCoinNormalized(simulateResponse.GasInfo.GetMinGasPrice()) + s.Require().NoError(err) + + msgSend.Amount = sdk.NewCoins( + sdk.NewCoin(s.Config.Denom, queryBalanceResponse.Balance.Amount.Sub(gasPrice.Amount.Mul(sdk.NewInt(int64(gasLimit))))), + ) + s.SendTxBlock(user, msgSend) + queryBalanceResponse, err = s.Client.BankQueryClient.Balance(ctx, &queryBalanceRequest) + s.Require().NoError(err) + s.Require().Equal(int64(0), queryBalanceResponse.Balance.Amount.Int64()) + + // update params + params := queryParamsResponse.GetParams() + oldReserveTime := params.VersionedParams.ReserveTime + oldValidatorTaxRate := params.VersionedParams.ValidatorTaxRate + s.T().Logf("params, ReserveTime: %d, ValidatorTaxRate: %s", oldReserveTime, oldValidatorTaxRate) + + params.VersionedParams.ReserveTime = oldReserveTime * 2 + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate.MulInt64(2) + + s.updateParams(params) + queryParamsResponse, err = s.Client.PaymentQueryClient.Params(ctx, &queryParamsRequest) + s.Require().NoError(err) + params = queryParamsResponse.GetParams() + s.T().Logf("params, ReserveTime: %d, ValidatorTaxRate: %s", params.VersionedParams.ReserveTime, params.VersionedParams.ValidatorTaxRate) + + queryHeadObjectRequest := storagetypes.QueryHeadObjectRequest{ + BucketName: bucketName, + ObjectName: objectName, + } + queryHeadObjectResponse, err := s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().NoError(err) + s.Require().Equal(queryHeadObjectResponse.ObjectInfo.ObjectStatus, storagetypes.OBJECT_STATUS_SEALED) + + sp := s.StorageProviders[0] + + // force delete bucket + msgDiscontinueBucket := storagetypes.NewMsgDiscontinueBucket(sp.GcKey.GetAddr(), bucketName, "test") + txRes := s.SendTxBlock(sp.GcKey, msgDiscontinueBucket) + deleteAt := filterDiscontinueBucketEventFromTx(txRes).DeleteAt + + for { + time.Sleep(200 * time.Millisecond) + statusRes, err := s.TmClient.TmClient.Status(context.Background()) + s.Require().NoError(err) + blockTime := statusRes.SyncInfo.LatestBlockTime.Unix() + + s.T().Logf("current blockTime: %d, delete blockTime: %d", blockTime, deleteAt) + + if blockTime > deleteAt { + break + } + } + + _, err = s.Client.HeadObject(ctx, &queryHeadObjectRequest) + s.Require().ErrorContains(err, "No such object") + + // revert params + params.VersionedParams.ReserveTime = oldReserveTime + params.VersionedParams.ValidatorTaxRate = oldValidatorTaxRate + s.updateParams(params) +} + func TestPaymentTestSuite(t *testing.T) { suite.Run(t, new(PaymentTestSuite)) } diff --git a/e2e/tests/sp_test.go b/e2e/tests/sp_test.go index 4b4f2c29d..969876133 100644 --- a/e2e/tests/sp_test.go +++ b/e2e/tests/sp_test.go @@ -2,6 +2,7 @@ package tests import ( "context" + "sort" "strconv" "testing" "time" @@ -129,6 +130,7 @@ func (s *StorageProviderTestSuite) TestCreateStorageProvider() { // 5. wait a voting period and confirm that the proposal success. s.T().Logf("voting period %s", *queryVoteParamsResp.Params.VotingPeriod) time.Sleep(*queryVoteParamsResp.Params.VotingPeriod) + time.Sleep(1 * time.Second) proposalRes, err := s.Client.GovQueryClientV1.Proposal(ctx, queryProposal) s.Require().NoError(err) s.Require().Equal(proposalRes.Proposal.Status, govtypesv1.ProposalStatus_PROPOSAL_STATUS_PASSED) @@ -285,7 +287,7 @@ func (s *StorageProviderTestSuite) CheckSecondarySpPrice() { s.Require().NoError(err) s.T().Logf("sps: %s", sps) spNum := int64(sps.Pagination.Total) - total := sdk.ZeroDec() + prices := make([]sdk.Dec, 0) for _, sp := range sps.Sps { spStoragePrice, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ SpAddr: sp.OperatorAddress, @@ -293,11 +295,19 @@ func (s *StorageProviderTestSuite) CheckSecondarySpPrice() { }) s.Require().NoError(err) s.T().Logf("sp: %s, storage price: %s", sp.OperatorAddress, core.YamlString(spStoragePrice.SpStoragePrice)) - total = total.Add(spStoragePrice.SpStoragePrice.StorePrice) + prices = append(prices, spStoragePrice.SpStoragePrice.StorePrice) } + sort.Slice(prices, func(i, j int) bool { return prices[i].LT(prices[j]) }) + var median sdk.Dec + if spNum%2 == 0 { + median = prices[spNum/2-1].Add(prices[spNum/2]).QuoInt64(2) + } else { + median = prices[spNum/2] + } + params, err := s.Client.SpQueryClient.Params(ctx, &sptypes.QueryParamsRequest{}) s.Require().NoError(err) - expectedSecondarySpStorePrice := params.Params.SecondarySpStorePriceRatio.Mul(total).QuoInt64(spNum) + expectedSecondarySpStorePrice := params.Params.SecondarySpStorePriceRatio.Mul(median) s.Require().Equal(expectedSecondarySpStorePrice, queryGetSecondarySpStorePriceByTimeResp.SecondarySpStorePrice.StorePrice) } diff --git a/e2e/tests/storage_test.go b/e2e/tests/storage_test.go index 28b363291..36e551350 100644 --- a/e2e/tests/storage_test.go +++ b/e2e/tests/storage_test.go @@ -496,7 +496,7 @@ func (s *StorageTestSuite) TestPayment_Smoke() { readPrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.ReadPrice readChargeRate := readPrice.MulInt(sdk.NewIntFromUint64(queryHeadBucketResponse.BucketInfo.ChargedReadQuota)).TruncateInt() s.T().Logf("readPrice: %s, readChargeRate: %s", readPrice, readChargeRate) - userTaxRate := paymentParams.Params.ValidatorTaxRate.MulInt(readChargeRate).TruncateInt() + userTaxRate := paymentParams.Params.VersionedParams.ValidatorTaxRate.MulInt(readChargeRate).TruncateInt() userTotalRate := readChargeRate.Add(userTaxRate) s.Require().Equal(userStreamRecord.NetflowRate.Abs(), userTotalRate) expectedOutFlows := []paymenttypes.OutFlow{ @@ -564,11 +564,12 @@ func (s *StorageTestSuite) TestPayment_Smoke() { secondaryStorePrice := queryGetSecondarySpStorePriceByTime.SecondarySpStorePrice.StorePrice chargeSize := s.GetChargeSize(queryHeadObjectResponse.ObjectInfo.PayloadSize) expectedChargeRate := primaryStorePrice.Add(secondaryStorePrice.MulInt64(6)).MulInt(sdk.NewIntFromUint64(chargeSize)).TruncateInt() - expectedLockedBalance := expectedChargeRate.Mul(sdkmath.NewIntFromUint64(paymentParams.Params.ReserveTime)) + expectedLockedBalance := expectedChargeRate.Mul(sdkmath.NewIntFromUint64(paymentParams.Params.VersionedParams.ReserveTime)) streamRecordsAfterCreateObject := s.GetStreamRecords(streamAddresses) s.T().Logf("streamRecordsAfterCreateObject %s", core.YamlString(streamRecordsAfterCreateObject)) userStreamAccountAfterCreateObj := streamRecordsAfterCreateObject.User + s.Require().Equal(expectedLockedBalance.String(), userStreamAccountAfterCreateObj.LockBalance.String()) // seal object @@ -693,7 +694,7 @@ func (s *StorageTestSuite) TestPayment_AutoSettle() { paymentParams, err := s.Client.PaymentQueryClient.Params(ctx, &paymenttypes.QueryParamsRequest{}) s.T().Logf("paymentParams %s, err: %v", paymentParams, err) s.Require().NoError(err) - reserveTime := paymentParams.Params.ReserveTime + reserveTime := paymentParams.Params.VersionedParams.ReserveTime forcedSettleTime := paymentParams.Params.ForcedSettleTime queryGetSpStoragePriceByTimeResp, err := s.Client.QueryGetSpStoragePriceByTime(ctx, &sptypes.QueryGetSpStoragePriceByTimeRequest{ SpAddr: sp.OperatorKey.GetAddr().String(), @@ -702,7 +703,7 @@ func (s *StorageTestSuite) TestPayment_AutoSettle() { s.Require().NoError(err) readPrice := queryGetSpStoragePriceByTimeResp.SpStoragePrice.ReadPrice totalUserRate := readPrice.MulInt(sdkmath.NewIntFromUint64(bucketChargedReadQuota)).TruncateInt() - taxRateParam := paymentParams.Params.ValidatorTaxRate + taxRateParam := paymentParams.Params.VersionedParams.ValidatorTaxRate taxStreamRate := taxRateParam.MulInt(totalUserRate).TruncateInt() expectedRate := totalUserRate.Add(taxStreamRate) paymentAccountBNBNeeded := expectedRate.Mul(sdkmath.NewIntFromUint64(reserveTime)) @@ -1799,6 +1800,7 @@ func (s *StorageTestSuite) TestUpdateParams() { // 5. wait a voting period and confirm that the proposal success. s.T().Logf("voting period %s", *queryVoteParamsResp.Params.VotingPeriod) time.Sleep(*queryVoteParamsResp.Params.VotingPeriod) + time.Sleep(1 * time.Second) proposalRes, err := s.Client.GovQueryClientV1.Proposal(ctx, queryProposal) s.Require().NoError(err) s.Require().Equal(proposalRes.Proposal.Status, govtypesv1.ProposalStatus_PROPOSAL_STATUS_PASSED) diff --git a/proto/greenfield/payment/params.proto b/proto/greenfield/payment/params.proto index 94e10bc93..cafc4dbf2 100644 --- a/proto/greenfield/payment/params.proto +++ b/proto/greenfield/payment/params.proto @@ -8,8 +8,7 @@ option go_package = "github.com/bnb-chain/greenfield/x/payment/types"; // Params defines the parameters for the module. message Params { - // Time duration which the buffer balance need to be reserved for NetOutFlow e.g. 6 month - uint64 reserve_time = 1 [(gogoproto.moretags) = "yaml:\"reserve_time\""]; + VersionedParams versioned_params = 1 [(gogoproto.nullable) = false]; // The maximum number of payment accounts that can be created by one user uint64 payment_account_count_limit = 2 [(gogoproto.moretags) = "yaml:\"payment_account_count_limit\""]; // Time duration threshold of forced settlement. @@ -21,8 +20,14 @@ message Params { uint64 max_auto_resume_flow_count = 5 [(gogoproto.moretags) = "yaml:\"max_auto_resume_flow_count\""]; // The denom of fee charged in payment module string fee_denom = 6 [(gogoproto.moretags) = "yaml:\"fee_denom\""]; +} + +// VersionedParams defines the parameters with multiple versions, each version is stored with different timestamp. +message VersionedParams { + // Time duration which the buffer balance need to be reserved for NetOutFlow e.g. 6 month + uint64 reserve_time = 1 [(gogoproto.moretags) = "yaml:\"reserve_time\""]; // The tax rate to pay for validators in storage payment. The default value is 1%(0.01) - string validator_tax_rate = 7 [ + string validator_tax_rate = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false diff --git a/proto/greenfield/payment/query.proto b/proto/greenfield/payment/query.proto index fd19d57f1..59b032402 100644 --- a/proto/greenfield/payment/query.proto +++ b/proto/greenfield/payment/query.proto @@ -24,6 +24,11 @@ service Query { option (google.api.http).get = "/greenfield/payment/params"; } + // ParamsByTimestamp queries the parameters of the module. + rpc ParamsByTimestamp(QueryParamsByTimestampRequest) returns (QueryParamsByTimestampResponse) { + option (google.api.http).get = "/greenfield/payment/params/{timestamp}"; + } + // Queries a StreamRecord by index. rpc OutFlows(QueryOutFlowsRequest) returns (QueryOutFlowsResponse) { option (google.api.http).get = "/greenfield/payment/out_flows/{account}"; @@ -84,6 +89,18 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } +// QueryParamsByTimestampRequest is request type for the Query/ParamsByTimestamp RPC method with timestamp. +message QueryParamsByTimestampRequest { + // the timestamp of the block time you want to query + int64 timestamp = 1; +} + +// QueryParamsByTimestampResponse is response type for the Query/ParamsByTimestamp RPC method with timestamp. +message QueryParamsByTimestampResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + message QueryOutFlowsRequest { string account = 1; } diff --git a/sdk/client/tx.go b/sdk/client/tx.go index 4b950e096..712cd1700 100644 --- a/sdk/client/tx.go +++ b/sdk/client/tx.go @@ -3,8 +3,6 @@ package client import ( "context" - "github.com/bnb-chain/greenfield/sdk/keys" - "github.com/cosmos/cosmos-sdk/client" clitx "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,6 +13,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "google.golang.org/grpc" + "github.com/bnb-chain/greenfield/sdk/keys" "github.com/bnb-chain/greenfield/sdk/types" ) diff --git a/x/payment/keeper/grpc_query_params_by_timestamp.go b/x/payment/keeper/grpc_query_params_by_timestamp.go new file mode 100644 index 000000000..80a156fd0 --- /dev/null +++ b/x/payment/keeper/grpc_query_params_by_timestamp.go @@ -0,0 +1,32 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bnb-chain/greenfield/x/payment/types" +) + +func (k Keeper) ParamsByTimestamp(c context.Context, req *types.QueryParamsByTimestampRequest) (*types.QueryParamsByTimestampResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + ts := req.GetTimestamp() + if ts == 0 { + ts = ctx.BlockTime().Unix() + } + + params := k.GetParams(ctx) + versionedParams, err := k.GetVersionedParamsWithTs(ctx, ts) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + params.VersionedParams = versionedParams + + return &types.QueryParamsByTimestampResponse{Params: params}, nil +} diff --git a/x/payment/keeper/params.go b/x/payment/keeper/params.go index 54b1ce4f5..0567c46e2 100644 --- a/x/payment/keeper/params.go +++ b/x/payment/keeper/params.go @@ -1,6 +1,9 @@ package keeper import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/bnb-chain/greenfield/x/payment/types" @@ -22,9 +25,43 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { if err := params.Validate(); err != nil { return err } + store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(¶ms) store.Set(types.ParamsKey, bz) + // store versioned params + err := k.SetVersionedParamsWithTs(ctx, params.VersionedParams) + if err != nil { + return err + } + + return nil +} + +func (k Keeper) SetVersionedParamsWithTs(ctx sdk.Context, verParams types.VersionedParams) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VersionedParamsKeyPrefix) + key := types.VersionedParamsKey(ctx.BlockTime().Unix()) + + b := k.cdc.MustMarshal(&verParams) + store.Set(key, b) + return nil } + +// GetVersionedParamsWithTs find the latest params before and equal than the specific timestamp +func (k Keeper) GetVersionedParamsWithTs(ctx sdk.Context, ts int64) (verParams types.VersionedParams, err error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.VersionedParamsKeyPrefix) + + // ReverseIterator will exclusive end, so we increment ts by 1 + startKey := types.VersionedParamsKey(ts + 1) + iterator := store.ReverseIterator(nil, startKey) + defer iterator.Close() + if !iterator.Valid() { + return verParams, fmt.Errorf("no versioned params found") + } + + k.cdc.MustUnmarshal(iterator.Value(), &verParams) + + return verParams, nil +} diff --git a/x/payment/keeper/storage_fee_charge.go b/x/payment/keeper/storage_fee_charge.go index 99f95f592..5b1bfa546 100644 --- a/x/payment/keeper/storage_fee_charge.go +++ b/x/payment/keeper/storage_fee_charge.go @@ -72,7 +72,7 @@ func (k Keeper) ApplyUserFlowsList(ctx sdk.Context, userFlowsList []types.UserFl streamRecordChange := types.NewDefaultStreamRecordChangeWithAddr(from).WithRateChange(totalRate.Neg()) // storage fee preview if ctx.IsCheckTx() { - reserveTime := k.GetParams(ctx).ReserveTime + reserveTime := k.GetParams(ctx).VersionedParams.ReserveTime changeRate := totalRate.Neg() event := &types.EventFeePreview{ Account: from.String(), diff --git a/x/payment/keeper/storage_fee_charge_test.go b/x/payment/keeper/storage_fee_charge_test.go index 21878c90c..7b3cbe293 100644 --- a/x/payment/keeper/storage_fee_charge_test.go +++ b/x/payment/keeper/storage_fee_charge_test.go @@ -107,7 +107,7 @@ func TestAutoForceSettle(t *testing.T) { user := sample.RandAccAddress() rate := sdkmath.NewInt(100) sp := sample.RandAccAddress() - userInitBalance := sdkmath.NewInt(int64(100*params.ReserveTime) + 1) // just enough for reserve + userInitBalance := sdkmath.NewInt(int64(100*params.VersionedParams.ReserveTime) + 1) // just enough for reserve // init balance streamRecordChanges := []types.StreamRecordChange{ *types.NewDefaultStreamRecordChangeWithAddr(user).WithStaticBalanceChange(userInitBalance), @@ -139,7 +139,7 @@ func TestAutoForceSettle(t *testing.T) { t.Logf("auto settle queue: %+v", autoSettleQueue) require.Equal(t, len(autoSettleQueue), 1) require.Equal(t, autoSettleQueue[0].Addr, user.String()) - require.Equal(t, autoSettleQueue[0].Timestamp, startTime+int64(params.ReserveTime)-int64(params.ForcedSettleTime)) + require.Equal(t, autoSettleQueue[0].Timestamp, startTime+int64(params.VersionedParams.ReserveTime)-int64(params.ForcedSettleTime)) // 1 day pass ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(86400) * time.Second)) // update and deposit to user for extra 100s @@ -161,7 +161,7 @@ func TestAutoForceSettle(t *testing.T) { t.Logf("auto settle queue: %+v", autoSettleQueue2) require.Equal(t, autoSettleQueue[0].Timestamp+100, autoSettleQueue2[0].Timestamp) // reverve time - forced settle time - 1 day + 101s pass - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(params.ReserveTime-params.ForcedSettleTime-86400+101) * time.Second)) + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(params.VersionedParams.ReserveTime-params.ForcedSettleTime-86400+101) * time.Second)) change = types.NewDefaultStreamRecordChangeWithAddr(user) usrBeforeForceSettle, _ := keeper.GetStreamRecord(ctx, user) t.Logf("usrBeforeForceSettle: %s", usrBeforeForceSettle) diff --git a/x/payment/keeper/stream_record.go b/x/payment/keeper/stream_record.go index ca5e35f16..ee0a330a9 100644 --- a/x/payment/keeper/stream_record.go +++ b/x/payment/keeper/stream_record.go @@ -149,7 +149,7 @@ func (k Keeper) UpdateStreamRecord(ctx sdk.Context, streamRecord *types.StreamRe streamRecord.NetflowRate = streamRecord.NetflowRate.Add(change.RateChange) newBufferBalance := sdkmath.ZeroInt() if streamRecord.NetflowRate.IsNegative() { - newBufferBalance = streamRecord.NetflowRate.Abs().Mul(sdkmath.NewIntFromUint64(params.ReserveTime)) + newBufferBalance = streamRecord.NetflowRate.Abs().Mul(sdkmath.NewIntFromUint64(params.VersionedParams.ReserveTime)) } if !newBufferBalance.Equal(streamRecord.BufferBalance) { streamRecord.StaticBalance = streamRecord.StaticBalance.Sub(newBufferBalance).Add(streamRecord.BufferBalance) @@ -346,7 +346,7 @@ func (k Keeper) TryResumeStreamRecord(ctx sdk.Context, streamRecord *types.Strea } streamRecord.StaticBalance = streamRecord.StaticBalance.Add(depositBalance) params := k.GetParams(ctx) - reserveTime := params.ReserveTime + reserveTime := params.VersionedParams.ReserveTime forcedSettleTime := params.ForcedSettleTime expectedBalanceToResume := streamRecord.FrozenNetflowRate.Mul(sdkmath.NewIntFromUint64(reserveTime)) diff --git a/x/payment/types/keys.go b/x/payment/types/keys.go index 117d30619..6c98456eb 100644 --- a/x/payment/types/keys.go +++ b/x/payment/types/keys.go @@ -30,6 +30,7 @@ var ( PaymentAccountKeyPrefix = []byte{0x05} OutFlowKeyPrefix = []byte{0x06} ParamsKey = []byte{0x07} + VersionedParamsKeyPrefix = []byte{0x08} ) // AutoSettleRecordKey returns the store key to retrieve a AutoSettleRecord from the index fields @@ -133,3 +134,10 @@ func ParseOutFlowValue(value []byte) sdkmath.Int { } return rate } + +// VersionedParamsKey return multi-version params store key +func VersionedParamsKey(timestamp int64) []byte { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, uint64(timestamp)) + return append(ParamsKey, bz...) +} diff --git a/x/payment/types/params.go b/x/payment/types/params.go index 9735fd2b1..13c9532f8 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -18,13 +18,14 @@ var ( KeyFeeDenom = []byte("FeeDenom") KeyValidatorTaxRate = []byte("ValidatorTaxRate") - DefaultReserveTime uint64 = 180 * 24 * 60 * 60 // 180 days - DefaultForcedSettleTime uint64 = 24 * 60 * 60 // 1 day - DefaultPaymentAccountCountLimit uint64 = 200 - DefaultMaxAutoSettleFlowCount uint64 = 100 - DefaultMaxAutoResumeFlowCount uint64 = 100 - DefaultFeeDenom string = "BNB" - DefaultValidatorTaxRate sdk.Dec = sdk.NewDecWithPrec(1, 2) // 1% + DefaultReserveTime uint64 = 180 * 24 * 60 * 60 // 180 days + DefaultValidatorTaxRate sdk.Dec = sdk.NewDecWithPrec(1, 2) // 1% + + DefaultForcedSettleTime uint64 = 24 * 60 * 60 // 1 day + DefaultPaymentAccountCountLimit uint64 = 200 + DefaultMaxAutoSettleFlowCount uint64 = 100 + DefaultMaxAutoResumeFlowCount uint64 = 100 + DefaultFeeDenom string = "BNB" ) // ParamKeyTable the param key table for launch module @@ -35,21 +36,20 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( reserveTime uint64, + validatorTaxRate sdk.Dec, forcedSettleTime uint64, paymentAccountCountLimit uint64, MaxAutoSettleFlowCount uint64, maxAutoResumeFlowCount uint64, feeDenom string, - validatorTaxRate sdk.Dec, ) Params { return Params{ - ReserveTime: reserveTime, + VersionedParams: VersionedParams{ReserveTime: reserveTime, ValidatorTaxRate: validatorTaxRate}, ForcedSettleTime: forcedSettleTime, PaymentAccountCountLimit: paymentAccountCountLimit, MaxAutoSettleFlowCount: MaxAutoSettleFlowCount, MaxAutoResumeFlowCount: maxAutoResumeFlowCount, FeeDenom: feeDenom, - ValidatorTaxRate: validatorTaxRate, } } @@ -57,31 +57,35 @@ func NewParams( func DefaultParams() Params { return NewParams( DefaultReserveTime, + DefaultValidatorTaxRate, DefaultForcedSettleTime, DefaultPaymentAccountCountLimit, DefaultMaxAutoSettleFlowCount, DefaultMaxAutoResumeFlowCount, DefaultFeeDenom, - DefaultValidatorTaxRate, ) } // ParamSetPairs get the params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyReserveTime, &p.ReserveTime, validateReserveTime), + paramtypes.NewParamSetPair(KeyReserveTime, &p.VersionedParams.ReserveTime, validateReserveTime), + paramtypes.NewParamSetPair(KeyValidatorTaxRate, &p.VersionedParams.ValidatorTaxRate, validateValidatorTaxRate), paramtypes.NewParamSetPair(KeyForcedSettleTime, &p.ForcedSettleTime, validateForcedSettleTime), paramtypes.NewParamSetPair(KeyPaymentAccountCountLimit, &p.PaymentAccountCountLimit, validatePaymentAccountCountLimit), paramtypes.NewParamSetPair(KeyMaxAutoSettleFlowCount, &p.MaxAutoSettleFlowCount, validateMaxAutoSettleFlowCount), paramtypes.NewParamSetPair(KeyMaxAutoResumeFlowCount, &p.MaxAutoResumeFlowCount, validateMaxAutoResumeFlowCount), paramtypes.NewParamSetPair(KeyFeeDenom, &p.FeeDenom, validateFeeDenom), - paramtypes.NewParamSetPair(KeyValidatorTaxRate, &p.ValidatorTaxRate, validateValidatorTaxRate), } } // Validate validates the set of params func (p Params) Validate() error { - if err := validateReserveTime(p.ReserveTime); err != nil { + if err := validateReserveTime(p.VersionedParams.ReserveTime); err != nil { + return err + } + + if err := validateValidatorTaxRate(p.VersionedParams.ValidatorTaxRate); err != nil { return err } @@ -105,9 +109,6 @@ func (p Params) Validate() error { return err } - if err := validateValidatorTaxRate(p.ValidatorTaxRate); err != nil { - return err - } return nil } diff --git a/x/payment/types/params.pb.go b/x/payment/types/params.pb.go index 3d7cf296b..b03031d4a 100644 --- a/x/payment/types/params.pb.go +++ b/x/payment/types/params.pb.go @@ -27,8 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - // Time duration which the buffer balance need to be reserved for NetOutFlow e.g. 6 month - ReserveTime uint64 `protobuf:"varint,1,opt,name=reserve_time,json=reserveTime,proto3" json:"reserve_time,omitempty" yaml:"reserve_time"` + VersionedParams VersionedParams `protobuf:"bytes,1,opt,name=versioned_params,json=versionedParams,proto3" json:"versioned_params"` // The maximum number of payment accounts that can be created by one user PaymentAccountCountLimit uint64 `protobuf:"varint,2,opt,name=payment_account_count_limit,json=paymentAccountCountLimit,proto3" json:"payment_account_count_limit,omitempty" yaml:"payment_account_count_limit"` // Time duration threshold of forced settlement. @@ -40,8 +39,6 @@ type Params struct { MaxAutoResumeFlowCount uint64 `protobuf:"varint,5,opt,name=max_auto_resume_flow_count,json=maxAutoResumeFlowCount,proto3" json:"max_auto_resume_flow_count,omitempty" yaml:"max_auto_resume_flow_count"` // The denom of fee charged in payment module FeeDenom string `protobuf:"bytes,6,opt,name=fee_denom,json=feeDenom,proto3" json:"fee_denom,omitempty" yaml:"fee_denom"` - // The tax rate to pay for validators in storage payment. The default value is 1%(0.01) - ValidatorTaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=validator_tax_rate,json=validatorTaxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validator_tax_rate"` } func (m *Params) Reset() { *m = Params{} } @@ -77,11 +74,11 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetReserveTime() uint64 { +func (m *Params) GetVersionedParams() VersionedParams { if m != nil { - return m.ReserveTime + return m.VersionedParams } - return 0 + return VersionedParams{} } func (m *Params) GetPaymentAccountCountLimit() uint64 { @@ -119,43 +116,95 @@ func (m *Params) GetFeeDenom() string { return "" } +// VersionedParams defines the parameters with multiple versions, each version is stored with different timestamp. +type VersionedParams struct { + // Time duration which the buffer balance need to be reserved for NetOutFlow e.g. 6 month + ReserveTime uint64 `protobuf:"varint,1,opt,name=reserve_time,json=reserveTime,proto3" json:"reserve_time,omitempty" yaml:"reserve_time"` + // The tax rate to pay for validators in storage payment. The default value is 1%(0.01) + ValidatorTaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=validator_tax_rate,json=validatorTaxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validator_tax_rate"` +} + +func (m *VersionedParams) Reset() { *m = VersionedParams{} } +func (m *VersionedParams) String() string { return proto.CompactTextString(m) } +func (*VersionedParams) ProtoMessage() {} +func (*VersionedParams) Descriptor() ([]byte, []int) { + return fileDescriptor_bd7d37632356c8f4, []int{1} +} +func (m *VersionedParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VersionedParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VersionedParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *VersionedParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_VersionedParams.Merge(m, src) +} +func (m *VersionedParams) XXX_Size() int { + return m.Size() +} +func (m *VersionedParams) XXX_DiscardUnknown() { + xxx_messageInfo_VersionedParams.DiscardUnknown(m) +} + +var xxx_messageInfo_VersionedParams proto.InternalMessageInfo + +func (m *VersionedParams) GetReserveTime() uint64 { + if m != nil { + return m.ReserveTime + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "greenfield.payment.Params") + proto.RegisterType((*VersionedParams)(nil), "greenfield.payment.VersionedParams") } func init() { proto.RegisterFile("greenfield/payment/params.proto", fileDescriptor_bd7d37632356c8f4) } var fileDescriptor_bd7d37632356c8f4 = []byte{ - // 460 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xc1, 0x6e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7, 0x62, 0x34, 0xc1, 0xe8, - 0xe7, 0x8f, 0x21, 0x31, 0x2d, 0x9b, 0x60, 0x14, 0xf6, 0xaf, 0x75, 0x4f, 0xa0, 0x0a, 0x41, 0xe2, - 0xf8, 0xfd, 0xc5, 0xd2, 0xb5, 0x2e, 0x97, 0xae, 0xf5, 0x77, 0xe9, 0x5a, 0xdf, 0x57, 0x6e, 0xe7, - 0x72, 0xe5, 0x76, 0x7e, 0xad, 0xdc, 0xce, 0x97, 0x60, 0xc3, 0x61, 0x9a, 0x4f, 0x87, 0xd1, 0x29, - 0xa4, 0x79, 0xb0, 0x51, 0xfa, 0xea, 0xba, 0xf6, 0xca, 0x6e, 0xda, 0x53, 0x8d, 0x7d, 0xfd, 0x2f, - 0x00, 0x00, 0xff, 0xff, 0x4a, 0x09, 0xc1, 0xf5, 0x19, 0x03, 0x00, 0x00, + // 509 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x8d, 0xbf, 0x2f, 0x44, 0x64, 0x8a, 0xd4, 0xc8, 0x54, 0xe0, 0x06, 0x61, 0x07, 0x23, 0xaa, + 0x6c, 0x62, 0x0b, 0xd8, 0x55, 0x6c, 0x6a, 0x22, 0x24, 0x04, 0x0b, 0x64, 0x22, 0x16, 0x6c, 0x46, + 0x13, 0xfb, 0x3a, 0x35, 0x78, 0x3c, 0xd1, 0x78, 0x9c, 0x3a, 0xcf, 0xc0, 0x86, 0x87, 0x61, 0xc3, + 0x1b, 0x74, 0x59, 0xb1, 0x42, 0x2c, 0x2c, 0x94, 0xbc, 0x81, 0x9f, 0x00, 0x65, 0xc6, 0x69, 0x12, + 0xa2, 0xb2, 0x99, 0x9f, 0x7b, 0xce, 0x9c, 0x73, 0x75, 0xe7, 0x5e, 0x64, 0x4d, 0x38, 0x40, 0x1a, + 0xc5, 0x90, 0x84, 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ae, 0x96, 0x66, 0xe3, 0xe7, 0xd2, 0x6c, 0x7c, 0x74, 0xb7, 0x1c, 0xc6, 0xe9, 0x78, 0x10, 0x9c, + 0x93, 0x38, 0x75, 0xb7, 0xc6, 0xab, 0xb8, 0x1e, 0x30, 0x69, 0x37, 0x6e, 0xc9, 0xd9, 0x78, 0xfe, + 0x27, 0x00, 0x00, 0xff, 0xff, 0xad, 0xa0, 0x65, 0x82, 0x83, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -178,16 +227,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.ValidatorTaxRate.Size() - i -= size - if _, err := m.ValidatorTaxRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a if len(m.FeeDenom) > 0 { i -= len(m.FeeDenom) copy(dAtA[i:], m.FeeDenom) @@ -215,6 +254,49 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } + { + size, err := m.VersionedParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *VersionedParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *VersionedParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VersionedParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.ValidatorTaxRate.Size() + i -= size + if _, err := m.ValidatorTaxRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if m.ReserveTime != 0 { i = encodeVarintParams(dAtA, i, uint64(m.ReserveTime)) i-- @@ -240,9 +322,8 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.ReserveTime != 0 { - n += 1 + sovParams(uint64(m.ReserveTime)) - } + l = m.VersionedParams.Size() + n += 1 + l + sovParams(uint64(l)) if m.PaymentAccountCountLimit != 0 { n += 1 + sovParams(uint64(m.PaymentAccountCountLimit)) } @@ -259,6 +340,18 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + return n +} + +func (m *VersionedParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ReserveTime != 0 { + n += 1 + sovParams(uint64(m.ReserveTime)) + } l = m.ValidatorTaxRate.Size() n += 1 + l + sovParams(uint64(l)) return n @@ -300,10 +393,10 @@ func (m *Params) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ReserveTime", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VersionedParams", wireType) } - m.ReserveTime = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -313,11 +406,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ReserveTime |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VersionedParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field PaymentAccountCountLimit", wireType) @@ -426,7 +533,76 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.FeeDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VersionedParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: VersionedParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VersionedParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReserveTime", wireType) + } + m.ReserveTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReserveTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ValidatorTaxRate", wireType) } diff --git a/x/payment/types/query.pb.go b/x/payment/types/query.pb.go index 33761a67a..a8e2869b2 100644 --- a/x/payment/types/query.pb.go +++ b/x/payment/types/query.pb.go @@ -115,6 +115,98 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +// QueryParamsByTimestampRequest is request type for the Query/ParamsByTimestamp RPC method with timestamp. +type QueryParamsByTimestampRequest struct { + // the timestamp of the block time you want to query + Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *QueryParamsByTimestampRequest) Reset() { *m = QueryParamsByTimestampRequest{} } +func (m *QueryParamsByTimestampRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsByTimestampRequest) ProtoMessage() {} +func (*QueryParamsByTimestampRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f62e6684473ccf4a, []int{2} +} +func (m *QueryParamsByTimestampRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsByTimestampRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsByTimestampRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsByTimestampRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsByTimestampRequest.Merge(m, src) +} +func (m *QueryParamsByTimestampRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsByTimestampRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsByTimestampRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsByTimestampRequest proto.InternalMessageInfo + +func (m *QueryParamsByTimestampRequest) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +// QueryParamsByTimestampResponse is response type for the Query/ParamsByTimestamp RPC method with timestamp. +type QueryParamsByTimestampResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsByTimestampResponse) Reset() { *m = QueryParamsByTimestampResponse{} } +func (m *QueryParamsByTimestampResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsByTimestampResponse) ProtoMessage() {} +func (*QueryParamsByTimestampResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f62e6684473ccf4a, []int{3} +} +func (m *QueryParamsByTimestampResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsByTimestampResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsByTimestampResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsByTimestampResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsByTimestampResponse.Merge(m, src) +} +func (m *QueryParamsByTimestampResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsByTimestampResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsByTimestampResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsByTimestampResponse proto.InternalMessageInfo + +func (m *QueryParamsByTimestampResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + type QueryOutFlowsRequest struct { Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` } @@ -123,7 +215,7 @@ func (m *QueryOutFlowsRequest) Reset() { *m = QueryOutFlowsRequest{} } func (m *QueryOutFlowsRequest) String() string { return proto.CompactTextString(m) } func (*QueryOutFlowsRequest) ProtoMessage() {} func (*QueryOutFlowsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{2} + return fileDescriptor_f62e6684473ccf4a, []int{4} } func (m *QueryOutFlowsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -167,7 +259,7 @@ func (m *QueryOutFlowsResponse) Reset() { *m = QueryOutFlowsResponse{} } func (m *QueryOutFlowsResponse) String() string { return proto.CompactTextString(m) } func (*QueryOutFlowsResponse) ProtoMessage() {} func (*QueryOutFlowsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{3} + return fileDescriptor_f62e6684473ccf4a, []int{5} } func (m *QueryOutFlowsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -211,7 +303,7 @@ func (m *QueryGetStreamRecordRequest) Reset() { *m = QueryGetStreamRecor func (m *QueryGetStreamRecordRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetStreamRecordRequest) ProtoMessage() {} func (*QueryGetStreamRecordRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{4} + return fileDescriptor_f62e6684473ccf4a, []int{6} } func (m *QueryGetStreamRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -255,7 +347,7 @@ func (m *QueryGetStreamRecordResponse) Reset() { *m = QueryGetStreamReco func (m *QueryGetStreamRecordResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetStreamRecordResponse) ProtoMessage() {} func (*QueryGetStreamRecordResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{5} + return fileDescriptor_f62e6684473ccf4a, []int{7} } func (m *QueryGetStreamRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -299,7 +391,7 @@ func (m *QueryAllStreamRecordRequest) Reset() { *m = QueryAllStreamRecor func (m *QueryAllStreamRecordRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllStreamRecordRequest) ProtoMessage() {} func (*QueryAllStreamRecordRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{6} + return fileDescriptor_f62e6684473ccf4a, []int{8} } func (m *QueryAllStreamRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -344,7 +436,7 @@ func (m *QueryAllStreamRecordResponse) Reset() { *m = QueryAllStreamReco func (m *QueryAllStreamRecordResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllStreamRecordResponse) ProtoMessage() {} func (*QueryAllStreamRecordResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{7} + return fileDescriptor_f62e6684473ccf4a, []int{9} } func (m *QueryAllStreamRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -395,7 +487,7 @@ func (m *QueryGetPaymentAccountCountRequest) Reset() { *m = QueryGetPaym func (m *QueryGetPaymentAccountCountRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetPaymentAccountCountRequest) ProtoMessage() {} func (*QueryGetPaymentAccountCountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{8} + return fileDescriptor_f62e6684473ccf4a, []int{10} } func (m *QueryGetPaymentAccountCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -439,7 +531,7 @@ func (m *QueryGetPaymentAccountCountResponse) Reset() { *m = QueryGetPay func (m *QueryGetPaymentAccountCountResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetPaymentAccountCountResponse) ProtoMessage() {} func (*QueryGetPaymentAccountCountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{9} + return fileDescriptor_f62e6684473ccf4a, []int{11} } func (m *QueryGetPaymentAccountCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -483,7 +575,7 @@ func (m *QueryAllPaymentAccountCountRequest) Reset() { *m = QueryAllPaym func (m *QueryAllPaymentAccountCountRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllPaymentAccountCountRequest) ProtoMessage() {} func (*QueryAllPaymentAccountCountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{10} + return fileDescriptor_f62e6684473ccf4a, []int{12} } func (m *QueryAllPaymentAccountCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -528,7 +620,7 @@ func (m *QueryAllPaymentAccountCountResponse) Reset() { *m = QueryAllPay func (m *QueryAllPaymentAccountCountResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllPaymentAccountCountResponse) ProtoMessage() {} func (*QueryAllPaymentAccountCountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{11} + return fileDescriptor_f62e6684473ccf4a, []int{13} } func (m *QueryAllPaymentAccountCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -579,7 +671,7 @@ func (m *QueryGetPaymentAccountRequest) Reset() { *m = QueryGetPaymentAc func (m *QueryGetPaymentAccountRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetPaymentAccountRequest) ProtoMessage() {} func (*QueryGetPaymentAccountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{12} + return fileDescriptor_f62e6684473ccf4a, []int{14} } func (m *QueryGetPaymentAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -623,7 +715,7 @@ func (m *QueryGetPaymentAccountResponse) Reset() { *m = QueryGetPaymentA func (m *QueryGetPaymentAccountResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetPaymentAccountResponse) ProtoMessage() {} func (*QueryGetPaymentAccountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{13} + return fileDescriptor_f62e6684473ccf4a, []int{15} } func (m *QueryGetPaymentAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -667,7 +759,7 @@ func (m *QueryAllPaymentAccountRequest) Reset() { *m = QueryAllPaymentAc func (m *QueryAllPaymentAccountRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllPaymentAccountRequest) ProtoMessage() {} func (*QueryAllPaymentAccountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{14} + return fileDescriptor_f62e6684473ccf4a, []int{16} } func (m *QueryAllPaymentAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -712,7 +804,7 @@ func (m *QueryAllPaymentAccountResponse) Reset() { *m = QueryAllPaymentA func (m *QueryAllPaymentAccountResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllPaymentAccountResponse) ProtoMessage() {} func (*QueryAllPaymentAccountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{15} + return fileDescriptor_f62e6684473ccf4a, []int{17} } func (m *QueryAllPaymentAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -763,7 +855,7 @@ func (m *QueryDynamicBalanceRequest) Reset() { *m = QueryDynamicBalanceR func (m *QueryDynamicBalanceRequest) String() string { return proto.CompactTextString(m) } func (*QueryDynamicBalanceRequest) ProtoMessage() {} func (*QueryDynamicBalanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{16} + return fileDescriptor_f62e6684473ccf4a, []int{18} } func (m *QueryDynamicBalanceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -820,7 +912,7 @@ func (m *QueryDynamicBalanceResponse) Reset() { *m = QueryDynamicBalance func (m *QueryDynamicBalanceResponse) String() string { return proto.CompactTextString(m) } func (*QueryDynamicBalanceResponse) ProtoMessage() {} func (*QueryDynamicBalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{17} + return fileDescriptor_f62e6684473ccf4a, []int{19} } func (m *QueryDynamicBalanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -871,7 +963,7 @@ func (m *QueryGetPaymentAccountsByOwnerRequest) Reset() { *m = QueryGetP func (m *QueryGetPaymentAccountsByOwnerRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetPaymentAccountsByOwnerRequest) ProtoMessage() {} func (*QueryGetPaymentAccountsByOwnerRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{18} + return fileDescriptor_f62e6684473ccf4a, []int{20} } func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -917,7 +1009,7 @@ func (m *QueryGetPaymentAccountsByOwnerResponse) Reset() { func (m *QueryGetPaymentAccountsByOwnerResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetPaymentAccountsByOwnerResponse) ProtoMessage() {} func (*QueryGetPaymentAccountsByOwnerResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{19} + return fileDescriptor_f62e6684473ccf4a, []int{21} } func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -961,7 +1053,7 @@ func (m *QueryAllAutoSettleRecordRequest) Reset() { *m = QueryAllAutoSet func (m *QueryAllAutoSettleRecordRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllAutoSettleRecordRequest) ProtoMessage() {} func (*QueryAllAutoSettleRecordRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{20} + return fileDescriptor_f62e6684473ccf4a, []int{22} } func (m *QueryAllAutoSettleRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1006,7 +1098,7 @@ func (m *QueryAllAutoSettleRecordResponse) Reset() { *m = QueryAllAutoSe func (m *QueryAllAutoSettleRecordResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllAutoSettleRecordResponse) ProtoMessage() {} func (*QueryAllAutoSettleRecordResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f62e6684473ccf4a, []int{21} + return fileDescriptor_f62e6684473ccf4a, []int{23} } func (m *QueryAllAutoSettleRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1052,6 +1144,8 @@ func (m *QueryAllAutoSettleRecordResponse) GetPagination() *query.PageResponse { func init() { proto.RegisterType((*QueryParamsRequest)(nil), "greenfield.payment.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "greenfield.payment.QueryParamsResponse") + proto.RegisterType((*QueryParamsByTimestampRequest)(nil), "greenfield.payment.QueryParamsByTimestampRequest") + proto.RegisterType((*QueryParamsByTimestampResponse)(nil), "greenfield.payment.QueryParamsByTimestampResponse") proto.RegisterType((*QueryOutFlowsRequest)(nil), "greenfield.payment.QueryOutFlowsRequest") proto.RegisterType((*QueryOutFlowsResponse)(nil), "greenfield.payment.QueryOutFlowsResponse") proto.RegisterType((*QueryGetStreamRecordRequest)(nil), "greenfield.payment.QueryGetStreamRecordRequest") @@ -1077,88 +1171,91 @@ func init() { func init() { proto.RegisterFile("greenfield/payment/query.proto", fileDescriptor_f62e6684473ccf4a) } var fileDescriptor_f62e6684473ccf4a = []byte{ - // 1284 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x98, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xc7, 0xb3, 0x75, 0x93, 0x36, 0x4f, 0x42, 0x5e, 0x26, 0x29, 0x4a, 0xdd, 0xe0, 0xa4, 0x1b, - 0xea, 0x38, 0x0d, 0xf1, 0xd4, 0x09, 0xa4, 0xa4, 0xbc, 0x48, 0x0e, 0x28, 0x55, 0xc4, 0x21, 0xa9, - 0x8b, 0x04, 0x02, 0xa1, 0xd5, 0xd8, 0x9e, 0x38, 0x56, 0xd6, 0x3b, 0xae, 0x77, 0xdc, 0x60, 0x45, - 0xb9, 0x70, 0x40, 0x1c, 0x2b, 0xf1, 0x01, 0xb8, 0x01, 0x12, 0x17, 0x0e, 0x3d, 0xf6, 0xc2, 0x01, - 0xa9, 0xc7, 0x02, 0x42, 0x42, 0x1c, 0x2a, 0x94, 0xf0, 0x15, 0xb8, 0xa3, 0x9d, 0x7d, 0xd6, 0xf5, - 0xcb, 0xac, 0xed, 0x04, 0x73, 0xb1, 0xbd, 0x33, 0xcf, 0xcb, 0xef, 0xff, 0xcc, 0xce, 0xec, 0xb3, - 0x86, 0x58, 0xa1, 0xc2, 0xb9, 0xb3, 0x57, 0xe4, 0x76, 0x9e, 0x96, 0x59, 0xad, 0xc4, 0x1d, 0x49, - 0x1f, 0x54, 0x79, 0xa5, 0x96, 0x2c, 0x57, 0x84, 0x14, 0x84, 0xbc, 0x98, 0x4f, 0xe2, 0x7c, 0xf4, - 0x66, 0x4e, 0xb8, 0x25, 0xe1, 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f, 0x9c, 0xc6, 0x06, 0x3e, 0xa1, 0x0d, 0x9d, - 0x59, 0xd6, 0xc9, 0xae, 0xe4, 0xf6, 0x59, 0xd1, 0x69, 0x8c, 0xfa, 0x79, 0x3d, 0xae, 0x6a, 0xd3, - 0xb2, 0x43, 0xea, 0x1f, 0xae, 0xb5, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x31, 0x6a, 0x7b, 0x70, - 0x85, 0x14, 0x00, 0x00, + // 1341 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xd6, 0x4d, 0xda, 0xbc, 0x94, 0x34, 0x9d, 0xa4, 0x28, 0xdd, 0x06, 0xa7, 0xdd, 0x52, + 0xc7, 0x69, 0x88, 0xb7, 0x4e, 0x20, 0x25, 0x85, 0x22, 0xd9, 0xa0, 0x54, 0x11, 0x87, 0xa4, 0x2e, + 0x12, 0xa8, 0x08, 0xad, 0xc6, 0xf6, 0xc4, 0xb1, 0xb2, 0xde, 0x75, 0xbd, 0xe3, 0x06, 0x2b, 0xca, + 0x85, 0x03, 0xe2, 0x58, 0x89, 0x3f, 0x00, 0x89, 0x03, 0x20, 0xb8, 0x70, 0xe8, 0xb1, 0x17, 0x0e, + 0x48, 0x3d, 0x16, 0x10, 0x12, 0xe2, 0x50, 0xa1, 0x84, 0x3f, 0x04, 0xed, 0xec, 0x5b, 0x67, 0x6d, + 0xcf, 0xee, 0x3a, 0xa9, 0xb9, 0x34, 0xde, 0xd9, 0xf7, 0xe3, 0xfb, 0xde, 0xdb, 0x79, 0xf3, 0x4d, + 0x21, 0x59, 0x69, 0x30, 0x66, 0x6d, 0x55, 0x99, 0x59, 0xd6, 0xeb, 0xb4, 0x55, 0x63, 0x16, 0xd7, + 0x1f, 0x36, 0x59, 0xa3, 0x95, 0xa9, 0x37, 0x6c, 0x6e, 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9, 0x09, 0x2e, + 0xef, 0x90, 0x55, 0x19, 0x97, 0x0a, 0xe3, 0x46, 0x57, 0xc1, 0x1d, 0xa3, 0xd8, 0x32, 0xc4, 0x96, + 0x6c, 0xef, 0xcc, 0x9f, 0x15, 0x98, 0xec, 0x3e, 0xe7, 0xdd, 0xcf, 0x65, 0x39, 0xaa, 0xf7, 0x21, + 0x72, 0x46, 0x7d, 0xf3, 0x78, 0x4e, 0xfd, 0x1c, 0x77, 0xbd, 0x8a, 0x25, 0xbf, 0xfe, 0xec, 0x20, + 0xa9, 0x3c, 0x3f, 0x48, 0x2a, 0xff, 0x1c, 0x24, 0x95, 0xc7, 0x87, 0xc9, 0xa1, 0xe7, 0x87, 0xc9, + 0xa1, 0xbf, 0x0e, 0x93, 0x43, 0x0f, 0xf4, 0x80, 0x8c, 0x2c, 0x5a, 0xc5, 0xc5, 0xd2, 0x36, 0xad, + 0x5a, 0xc1, 0xa8, 0x9f, 0xb7, 0xe3, 0x0a, 0x4d, 0x59, 0x1c, 0x11, 0xff, 0x53, 0xb8, 0xfc, 0x5f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x22, 0xc8, 0x6d, 0xad, 0xcd, 0x15, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1175,6 +1272,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ParamsByTimestamp queries the parameters of the module. + ParamsByTimestamp(ctx context.Context, in *QueryParamsByTimestampRequest, opts ...grpc.CallOption) (*QueryParamsByTimestampResponse, error) // Queries a StreamRecord by index. OutFlows(ctx context.Context, in *QueryOutFlowsRequest, opts ...grpc.CallOption) (*QueryOutFlowsResponse, error) // Queries a StreamRecord by index. @@ -1214,6 +1313,15 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) ParamsByTimestamp(ctx context.Context, in *QueryParamsByTimestampRequest, opts ...grpc.CallOption) (*QueryParamsByTimestampResponse, error) { + out := new(QueryParamsByTimestampResponse) + err := c.cc.Invoke(ctx, "/greenfield.payment.Query/ParamsByTimestamp", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) OutFlows(ctx context.Context, in *QueryOutFlowsRequest, opts ...grpc.CallOption) (*QueryOutFlowsResponse, error) { out := new(QueryOutFlowsResponse) err := c.cc.Invoke(ctx, "/greenfield.payment.Query/OutFlows", in, out, opts...) @@ -1308,6 +1416,8 @@ func (c *queryClient) AutoSettleRecordAll(ctx context.Context, in *QueryAllAutoS type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ParamsByTimestamp queries the parameters of the module. + ParamsByTimestamp(context.Context, *QueryParamsByTimestampRequest) (*QueryParamsByTimestampResponse, error) // Queries a StreamRecord by index. OutFlows(context.Context, *QueryOutFlowsRequest) (*QueryOutFlowsResponse, error) // Queries a StreamRecord by index. @@ -1337,6 +1447,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) ParamsByTimestamp(ctx context.Context, req *QueryParamsByTimestampRequest) (*QueryParamsByTimestampResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ParamsByTimestamp not implemented") +} func (*UnimplementedQueryServer) OutFlows(ctx context.Context, req *QueryOutFlowsRequest) (*QueryOutFlowsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OutFlows not implemented") } @@ -1390,6 +1503,24 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_ParamsByTimestamp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsByTimestampRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ParamsByTimestamp(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/greenfield.payment.Query/ParamsByTimestamp", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ParamsByTimestamp(ctx, req.(*QueryParamsByTimestampRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_OutFlows_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryOutFlowsRequest) if err := dec(in); err != nil { @@ -1578,6 +1709,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "ParamsByTimestamp", + Handler: _Query_ParamsByTimestamp_Handler, + }, { MethodName: "OutFlows", Handler: _Query_OutFlows_Handler, @@ -1679,6 +1814,67 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryParamsByTimestampRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsByTimestampRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsByTimestampRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryParamsByTimestampResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsByTimestampResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsByTimestampResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *QueryOutFlowsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2482,6 +2678,29 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryParamsByTimestampRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Timestamp != 0 { + n += 1 + sovQuery(uint64(m.Timestamp)) + } + return n +} + +func (m *QueryParamsByTimestampResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func (m *QueryOutFlowsRequest) Size() (n int) { if m == nil { return 0 @@ -2914,6 +3133,158 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryParamsByTimestampRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsByTimestampRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsByTimestampRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsByTimestampResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsByTimestampResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsByTimestampResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryOutFlowsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/payment/types/query.pb.gw.go b/x/payment/types/query.pb.gw.go index 3cc0cd419..3b840a38b 100644 --- a/x/payment/types/query.pb.gw.go +++ b/x/payment/types/query.pb.gw.go @@ -51,6 +51,60 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_ParamsByTimestamp_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsByTimestampRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["timestamp"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "timestamp") + } + + protoReq.Timestamp, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "timestamp", err) + } + + msg, err := client.ParamsByTimestamp(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ParamsByTimestamp_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsByTimestampRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["timestamp"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "timestamp") + } + + protoReq.Timestamp, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "timestamp", err) + } + + msg, err := server.ParamsByTimestamp(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_OutFlows_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryOutFlowsRequest var metadata runtime.ServerMetadata @@ -548,6 +602,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ParamsByTimestamp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ParamsByTimestamp_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ParamsByTimestamp_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_OutFlows_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -839,6 +916,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ParamsByTimestamp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ParamsByTimestamp_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ParamsByTimestamp_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_OutFlows_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1045,6 +1142,8 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie var ( pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ParamsByTimestamp_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "params", "timestamp"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_OutFlows_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "out_flows", "account"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_StreamRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"greenfield", "payment", "stream_record", "account"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1069,6 +1168,8 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_ParamsByTimestamp_0 = runtime.ForwardResponseMessage + forward_Query_OutFlows_0 = runtime.ForwardResponseMessage forward_Query_StreamRecord_0 = runtime.ForwardResponseMessage diff --git a/x/sp/keeper/sp_storage_price.go b/x/sp/keeper/sp_storage_price.go index a67b775a8..ccc815dda 100644 --- a/x/sp/keeper/sp_storage_price.go +++ b/x/sp/keeper/sp_storage_price.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "sort" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -119,9 +120,8 @@ func (k Keeper) SetSecondarySpStorePrice(ctx sdk.Context, secondarySpStorePrice // UpdateSecondarySpStorePrice calculate the price of secondary store by the average price of all sp store price func (k Keeper) UpdateSecondarySpStorePrice(ctx sdk.Context) error { sps := k.GetAllStorageProviders(ctx) - total := sdk.ZeroDec() current := ctx.BlockTime().Unix() - var spNumInService int64 + prices := make([]sdk.Dec, 0) for _, sp := range sps { if sp.Status != types.STATUS_IN_SERVICE { continue @@ -130,13 +130,21 @@ func (k Keeper) UpdateSecondarySpStorePrice(ctx sdk.Context) error { if err != nil { return err } - spNumInService++ - total = total.Add(price.StorePrice) + prices = append(prices, price.StorePrice) } - if spNumInService == 0 { + l := len(prices) + if l == 0 { return nil } - price := k.SecondarySpStorePriceRatio(ctx).Mul(total).QuoInt64(spNumInService) + + sort.Slice(prices, func(i, j int) bool { return prices[i].LT(prices[j]) }) + var median sdk.Dec + if l%2 == 0 { + median = prices[l/2-1].Add(prices[l/2]).QuoInt64(2) + } else { + median = prices[l/2] + } + price := k.SecondarySpStorePriceRatio(ctx).Mul(median) secondarySpStorePrice := types.SecondarySpStorePrice{ StorePrice: price, UpdateTimeSec: current, diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index c488bb240..aaa0ec4f4 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1482,7 +1482,7 @@ func (k Keeper) appendDiscontinueBucketIds(ctx sdk.Context, timestamp int64, buc store.Set(key, k.cdc.MustMarshal(&types.Ids{Id: bucketIds})) } -func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64, maxObjectsToDelete uint64) (uint64, error) { +func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64, maxToDelete uint64) (uint64, error) { store := ctx.KVStore(k.storeKey) key := types.GetDiscontinueBucketIdsKey(timestamp) iterator := store.Iterator(types.DiscontinueBucketIdsPrefix, storetypes.InclusiveEndBytes(key)) @@ -1490,7 +1490,7 @@ func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64, deleted := uint64(0) for ; iterator.Valid(); iterator.Next() { - if deleted >= maxObjectsToDelete { + if deleted >= maxToDelete { break } var ids types.Ids @@ -1498,12 +1498,12 @@ func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64, left := make([]types.Uint, 0) for _, id := range ids.Id { - if deleted >= maxObjectsToDelete { + if deleted >= maxToDelete { left = append(left, id) continue } - bucketDeleted, objectDeleted, err := k.ForceDeleteBucket(ctx, id, maxObjectsToDelete-deleted) + bucketDeleted, objectDeleted, err := k.ForceDeleteBucket(ctx, id, maxToDelete-deleted) if err != nil { ctx.Logger().Error("force delete bucket error", "err", err) return deleted, err @@ -1512,6 +1512,8 @@ func (k Keeper) DeleteDiscontinueBucketsUntil(ctx sdk.Context, timestamp int64, if !bucketDeleted { left = append(left, id) + } else { + deleted++ } } if len(left) > 0 { diff --git a/x/storage/keeper/payment.go b/x/storage/keeper/payment.go index 1a3437f97..8ddde7810 100644 --- a/x/storage/keeper/payment.go +++ b/x/storage/keeper/payment.go @@ -197,7 +197,6 @@ func (k Keeper) GetBucketBill(ctx sdk.Context, bucketInfo *storagetypes.BucketIn return userFlows, fmt.Errorf("get GVG family failed: %d", bucketInfo.GlobalVirtualGroupFamilyId) } - params := k.paymentKeeper.GetParams(ctx) // primary sp total rate primaryTotalFlowRate := price.ReadPrice.MulInt(sdkmath.NewIntFromUint64(bucketInfo.ChargedReadQuota)).TruncateInt() @@ -238,11 +237,16 @@ func (k Keeper) GetBucketBill(ctx sdk.Context, bucketInfo *storagetypes.BucketIn Rate: primaryTotalFlowRate, }) } - validatorTotalFlowRate := params.ValidatorTaxRate.MulInt(primaryTotalFlowRate.Add(secondaryTotalFlowRate)).TruncateInt() - if validatorTotalFlowRate.IsPositive() { + + versionedParams, err := k.paymentKeeper.GetVersionedParamsWithTs(ctx, bucketInfo.BillingInfo.PriceTime) + if err != nil { + return userFlows, fmt.Errorf("failed to get validator tax rate: %w, time: %d", err, bucketInfo.BillingInfo.PriceTime) + } + validatorTaxRate := versionedParams.ValidatorTaxRate.MulInt(primaryTotalFlowRate.Add(secondaryTotalFlowRate)).TruncateInt() + if validatorTaxRate.IsPositive() { userFlows.Flows = append(userFlows.Flows, types.OutFlow{ ToAddress: types.ValidatorTaxPoolAddress.String(), - Rate: validatorTotalFlowRate, + Rate: validatorTaxRate, }) } @@ -333,8 +337,11 @@ func (k Keeper) GetObjectLockFee(ctx sdk.Context, primarySpAddress string, price return amount, fmt.Errorf("get charge size error: %w", err) } rate := price.PrimaryStorePrice.Add(price.SecondaryStorePrice.MulInt64(storagetypes.SecondarySPNum)).MulInt(sdkmath.NewIntFromUint64(chargeSize)).TruncateInt() - reserveTime := k.paymentKeeper.GetParams(ctx).ReserveTime - amount = rate.Mul(sdkmath.NewIntFromUint64(reserveTime)) + versionedParams, err := k.paymentKeeper.GetVersionedParamsWithTs(ctx, priceTime) + if err != nil { + return amount, fmt.Errorf("get versioned reserve time error: %w", err) + } + amount = rate.Mul(sdkmath.NewIntFromUint64(versionedParams.ReserveTime)) return amount, nil } diff --git a/x/storage/keeper/payment_test.go b/x/storage/keeper/payment_test.go index 0b27e61ad..0c2589faa 100644 --- a/x/storage/keeper/payment_test.go +++ b/x/storage/keeper/payment_test.go @@ -121,7 +121,7 @@ func (s *TestSuite) TestGetObjectLockFee() { amount, err := s.storageKeeper.GetObjectLockFee(s.ctx, sample.RandAccAddress().String(), time.Now().Unix(), uint64(payloadSize)) s.Require().NoError(err) expectedAmount := price.PrimaryStorePrice.Add(price.SecondaryStorePrice.MulInt64(types.SecondarySPNum)). - MulInt64(payloadSize).MulInt64(int64(params.ReserveTime)).TruncateInt() + MulInt64(payloadSize).MulInt64(int64(params.VersionedParams.ReserveTime)).TruncateInt() s.Require().True(amount.Equal(expectedAmount)) } @@ -187,7 +187,7 @@ func (s *TestSuite) TestGetBucketBill() { readRate := price.ReadPrice.MulInt64(int64(bucketInfo.ChargedReadQuota)).TruncateInt() s.Require().Equal(flows.Flows[0].ToAddress, gvgFamily.VirtualPaymentAddress) s.Require().Equal(flows.Flows[0].Rate, readRate) - taxPoolRate := s.paymentKeeper.GetParams(s.ctx).ValidatorTaxRate.MulInt(readRate).TruncateInt() + taxPoolRate := s.paymentKeeper.GetParams(s.ctx).VersionedParams.ValidatorTaxRate.MulInt(readRate).TruncateInt() s.Require().Equal(flows.Flows[1].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String()) s.Require().Equal(flows.Flows[1].Rate, taxPoolRate) @@ -264,7 +264,7 @@ func (s *TestSuite) TestGetBucketBill() { s.Require().Equal(flows.Flows[2].Rate, readRate.Add(primaryStoreRate)) totalRate := readRate.Add(primaryStoreRate).Add(gvg1StoreRate).Add(gvg2StoreRate) - taxPoolRate = s.paymentKeeper.GetParams(s.ctx).ValidatorTaxRate.MulInt(totalRate).TruncateInt() + taxPoolRate = s.paymentKeeper.GetParams(s.ctx).VersionedParams.ValidatorTaxRate.MulInt(totalRate).TruncateInt() s.Require().Equal(flows.Flows[3].ToAddress, paymenttypes.ValidatorTaxPoolAddress.String()) s.Require().Equal(flows.Flows[3].Rate, taxPoolRate) } diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 3fc5cba9c..fe2b4de60 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -44,6 +44,7 @@ type SpKeeper interface { type PaymentKeeper interface { GetParams(ctx sdk.Context) paymenttypes.Params + GetVersionedParamsWithTs(ctx sdk.Context, time int64) (paymenttypes.VersionedParams, error) IsPaymentAccountOwner(ctx sdk.Context, addr, owner sdk.AccAddress) bool GetStoragePrice(ctx sdk.Context, params paymenttypes.StoragePriceParams) (price paymenttypes.StoragePrice, err error) ApplyUserFlowsList(ctx sdk.Context, userFlows []paymenttypes.UserFlows) (err error) diff --git a/x/storage/types/expected_keepers_mocks.go b/x/storage/types/expected_keepers_mocks.go index 83a46beb0..5ce2398bc 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -380,6 +380,21 @@ func (mr *MockPaymentKeeperMockRecorder) GetStreamRecord(ctx, account interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStreamRecord", reflect.TypeOf((*MockPaymentKeeper)(nil).GetStreamRecord), ctx, account) } +// GetVersionedParamsWithTs mocks base method. +func (m *MockPaymentKeeper) GetVersionedParamsWithTs(ctx types3.Context, time int64) (types.VersionedParams, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetVersionedParamsWithTs", ctx, time) + ret0, _ := ret[0].(types.VersionedParams) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetVersionedParamsWithTs indicates an expected call of GetVersionedParamsWithTs. +func (mr *MockPaymentKeeperMockRecorder) GetVersionedParamsWithTs(ctx, time interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVersionedParamsWithTs", reflect.TypeOf((*MockPaymentKeeper)(nil).GetVersionedParamsWithTs), ctx, time) +} + // IsPaymentAccountOwner mocks base method. func (m *MockPaymentKeeper) IsPaymentAccountOwner(ctx types3.Context, addr, owner types3.AccAddress) bool { m.ctrl.T.Helper() diff --git a/x/storage/types/params.go b/x/storage/types/params.go index d8e1686a1..11c9bce8e 100644 --- a/x/storage/types/params.go +++ b/x/storage/types/params.go @@ -21,7 +21,7 @@ const ( DefaultDiscontinueObjectMax uint64 = math.MaxUint64 DefaultDiscontinueBucketMax uint64 = math.MaxUint64 DefaultDiscontinueConfirmPeriod int64 = 604800 // 7 days (in second) - DefaultDiscontinueDeletionMax uint64 = 10000 + DefaultDiscontinueDeletionMax uint64 = 100 DefaultStalePolicyCleanupMax uint64 = 200 DefaultMirrorBucketRelayerFee = "250000000000000" // 0.00025