From 777a1939193e207c5938337d8790e20a2d6757cc Mon Sep 17 00:00:00 2001 From: yutianwu Date: Thu, 8 Jun 2023 14:35:29 +0800 Subject: [PATCH 01/11] fix: fix the security issues (#279) --- x/bridge/keeper/cross_app.go | 6 ++++++ x/challenge/keeper/msg_server_attest.go | 4 +++- x/challenge/types/params.go | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/x/bridge/keeper/cross_app.go b/x/bridge/keeper/cross_app.go index 3442240fe..3063eed5b 100644 --- a/x/bridge/keeper/cross_app.go +++ b/x/bridge/keeper/cross_app.go @@ -115,6 +115,12 @@ func (app *TransferOutApp) ExecuteFailAckPackage(ctx sdk.Context, appCtx *sdk.Cr } } + if transferOutPackage.Amount.Cmp(big.NewInt(0)) < 0 { + return sdk.ExecuteResult{ + Err: errors.Wrapf(types.ErrInvalidAmount, "amount to refund should not be negative"), + } + } + denom := app.bridgeKeeper.stakingKeeper.BondDenom(ctx) // only support native token so far err = app.bridgeKeeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, crosschaintypes.ModuleName, transferOutPackage.RefundAddress, sdk.Coins{ diff --git a/x/challenge/keeper/msg_server_attest.go b/x/challenge/keeper/msg_server_attest.go index d2677389e..b844a2e3f 100644 --- a/x/challenge/keeper/msg_server_attest.go +++ b/x/challenge/keeper/msg_server_attest.go @@ -226,12 +226,14 @@ func (k msgServer) doHeartbeatAndRewards(ctx sdk.Context, challengeId uint64, vo validatorReward, submitterReward := sdkmath.NewInt(0), sdkmath.NewInt(0) if !totalAmount.IsZero() { validatorReward, submitterReward = k.calculateHeartbeatRewards(ctx, totalAmount) - if validatorReward.IsPositive() && submitterReward.IsPositive() { + if validatorReward.IsPositive() { distModuleAcc := authtypes.NewModuleAddress(distributiontypes.ModuleName) err = k.paymentKeeper.Withdraw(ctx, paymentmoduletypes.ValidatorTaxPoolAddress, distModuleAcc, validatorReward) if err != nil { return err } + } + if submitterReward.IsPositive() { err = k.paymentKeeper.Withdraw(ctx, paymentmoduletypes.ValidatorTaxPoolAddress, submitter, submitterReward) if err != nil { return err diff --git a/x/challenge/types/params.go b/x/challenge/types/params.go index fc0260d80..163a99fa3 100644 --- a/x/challenge/types/params.go +++ b/x/challenge/types/params.go @@ -188,7 +188,7 @@ func (p Params) Validate() error { } if p.RewardValidatorRatio.Add(p.RewardSubmitterRatio).GT(sdk.NewDec(1)) { - return errors.New("the sum of validator and challenger reward ratio should be equal to or less than one") + return errors.New("the sum of validator and submitter reward ratio should be equal to or less than one") } if err := validateHeartbeatInterval(p.HeartbeatInterval); err != nil { From f642e7cb1272c8d1089e6cd15d1b2e0d1f4ea60d Mon Sep 17 00:00:00 2001 From: yutianwu Date: Tue, 13 Jun 2023 14:03:01 +0800 Subject: [PATCH 02/11] fix: update go.mod to be compatible with ignite (#280) --- .github/workflows/buf.yml | 1 - Makefile | 2 +- e2e/tests/bridge_test.go | 1 + go.mod | 3 ++- go.sum | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/buf.yml b/.github/workflows/buf.yml index dab496263..ea9c372e6 100644 --- a/.github/workflows/buf.yml +++ b/.github/workflows/buf.yml @@ -26,5 +26,4 @@ jobs: - name: Test protobuf changes generates new go files run: | export PATH="$PATH:$(go env GOPATH)/bin" - go get github.com/ghodss/yaml make tools proto-gen-check diff --git a/Makefile b/Makefile index a0c80eb3a..35bf7edfc 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ tools: go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway proto-gen: - cd proto && buf generate && cp -r github.com/bnb-chain/greenfield/x/* ../x && cp -r github.com/bnb-chain/greenfield/types/* ../types &&rm -rf github.com && go mod tidy + cd proto && buf generate && cp -r github.com/bnb-chain/greenfield/x/* ../x && cp -r github.com/bnb-chain/greenfield/types/* ../types && rm -rf github.com && go mod tidy proto-swagger-gen: sh ./scripts/protoc-swagger-gen.sh diff --git a/e2e/tests/bridge_test.go b/e2e/tests/bridge_test.go index ce1cd8bf2..b26320cd1 100644 --- a/e2e/tests/bridge_test.go +++ b/e2e/tests/bridge_test.go @@ -7,6 +7,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + _ "github.com/ghodss/yaml" "github.com/stretchr/testify/suite" "github.com/bnb-chain/greenfield/e2e/core" diff --git a/go.mod b/go.mod index 4500e554d..76bffc023 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/cometbft/cometbft v0.37.1 github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.47.0-rc2.0.20230220103612-f094a0c33410 + github.com/cosmos/cosmos-sdk v0.47.2 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogoproto v1.4.8 github.com/ethereum/go-ethereum v1.10.22 @@ -32,6 +32,7 @@ require ( require ( cosmossdk.io/api v0.4.0 + github.com/ghodss/yaml v1.0.0 github.com/golang/mock v1.6.0 github.com/rakyll/statik v0.1.7 ) diff --git a/go.sum b/go.sum index b0d3876cb..1dcb906b1 100644 --- a/go.sum +++ b/go.sum @@ -385,6 +385,7 @@ github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= From 320ee1f54467c78e895716914e3781ae728696d4 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Fri, 16 Jun 2023 15:32:42 +0800 Subject: [PATCH 03/11] feat: add versioned parameters to payment module (#281) --- deployment/localup/localup.sh | 2 +- e2e/tests/payment_test.go | 363 +++++++++++ e2e/tests/sp_test.go | 1 + e2e/tests/storage_test.go | 9 +- proto/greenfield/payment/params.proto | 11 +- proto/greenfield/payment/query.proto | 17 + sdk/client/tx.go | 3 +- .../keeper/grpc_query_params_by_timestamp.go | 32 + x/payment/keeper/params.go | 37 ++ x/payment/keeper/storage_fee_charge.go | 2 +- x/payment/keeper/storage_fee_charge_test.go | 6 +- x/payment/keeper/stream_record.go | 4 +- x/payment/types/keys.go | 8 + x/payment/types/params.go | 33 +- x/payment/types/params.pb.go | 284 ++++++-- x/payment/types/query.pb.go | 558 +++++++++++++--- x/payment/types/query.pb.gw.go | 101 +++ x/storage/keeper/payment.go | 14 +- x/storage/keeper/payment_test.go | 4 +- x/storage/types/expected_keepers.go | 1 + x/storage/types/expected_keepers_mocks.go | 616 +++++++++--------- 21 files changed, 1620 insertions(+), 486 deletions(-) create mode 100644 x/payment/keeper/grpc_query_params_by_timestamp.go diff --git a/deployment/localup/localup.sh b/deployment/localup/localup.sh index 99d89c9b2..d61362fb4 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\": \"50\"/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/payment_test.go b/e2e/tests/payment_test.go index 1b8e8f453..cce1f0435 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,355 @@ 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] + // 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, 10000) + 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, 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] + + secondarySPs := []sdk.AccAddress{ + sp.OperatorKey.GetAddr(), sp.OperatorKey.GetAddr(), + sp.OperatorKey.GetAddr(), sp.OperatorKey.GetAddr(), + sp.OperatorKey.GetAddr(), sp.OperatorKey.GetAddr(), + } + msgSealObject := storagetypes.NewMsgSealObject(sp.SealKey.GetAddr(), bucketName, objectName, secondarySPs, 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 e1513a663..343968a36 100644 --- a/e2e/tests/sp_test.go +++ b/e2e/tests/sp_test.go @@ -129,6 +129,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) diff --git a/e2e/tests/storage_test.go b/e2e/tests/storage_test.go index 55577b2c3..b3831f4a3 100644 --- a/e2e/tests/storage_test.go +++ b/e2e/tests/storage_test.go @@ -492,7 +492,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(usr.NetflowRate.Abs(), userTotalRate) expectedOutFlows := []paymenttypes.OutFlow{ @@ -560,7 +560,7 @@ 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)) s.Require().Equal(expectedLockedBalance.String(), userStreamAccountAfterCreateObj.LockBalance.String()) // seal object @@ -672,7 +672,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(), @@ -681,7 +681,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)) @@ -1772,6 +1772,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 aa05ae48b..9392301fc 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. @@ -19,8 +18,14 @@ message Params { uint64 max_auto_force_settle_num = 4 [(gogoproto.moretags) = "yaml:\"max_auto_force_settle_num\""]; // The denom of fee charged in payment module string fee_denom = 5 [(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 = 6 [ + 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 7f4956202..73028a67b 100644 --- a/proto/greenfield/payment/query.proto +++ b/proto/greenfield/payment/query.proto @@ -23,6 +23,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 StreamRecord(QueryGetStreamRecordRequest) returns (QueryGetStreamRecordResponse) { option (google.api.http).get = "/greenfield/payment/stream_record/{account}"; @@ -78,6 +83,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 QueryGetStreamRecordRequest { 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 b142648ef..3ced8d9f8 100644 --- a/x/payment/keeper/storage_fee_charge.go +++ b/x/payment/keeper/storage_fee_charge.go @@ -70,7 +70,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 53e85e06c..4b62da6c7 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 73eb7fae3..5a3ccadfb 100644 --- a/x/payment/keeper/stream_record.go +++ b/x/payment/keeper/stream_record.go @@ -150,7 +150,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) @@ -282,7 +282,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 totalRates := sdkmath.ZeroInt() for _, flow := range streamRecord.OutFlows { diff --git a/x/payment/types/keys.go b/x/payment/types/keys.go index 84c4ad0fe..26edf5225 100644 --- a/x/payment/types/keys.go +++ b/x/payment/types/keys.go @@ -26,6 +26,7 @@ var ( PaymentAccountCountKeyPrefix = []byte{0x03} PaymentAccountKeyPrefix = []byte{0x04} ParamsKey = []byte{0x05} + VersionedParamsKeyPrefix = []byte{0x06} ) // AutoSettleRecordKey returns the store key to retrieve a AutoSettleRecord from the index fields @@ -71,3 +72,10 @@ func StreamRecordKey( ) []byte { return account } + +// 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 3cde15de3..4a67fa1c6 100644 --- a/x/payment/types/params.go +++ b/x/payment/types/params.go @@ -17,12 +17,13 @@ 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 - DefaultMaxAutoForceSettleNum 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 + DefaultMaxAutoForceSettleNum uint64 = 100 + DefaultFeeDenom string = "BNB" ) // ParamKeyTable the param key table for launch module @@ -33,19 +34,18 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams creates a new Params instance func NewParams( reserveTime uint64, + validatorTaxRate sdk.Dec, forcedSettleTime uint64, paymentAccountCountLimit uint64, maxAutoForceSettleNum uint64, feeDenom string, - validatorTaxRate sdk.Dec, ) Params { return Params{ - ReserveTime: reserveTime, + VersionedParams: VersionedParams{ReserveTime: reserveTime, ValidatorTaxRate: validatorTaxRate}, ForcedSettleTime: forcedSettleTime, PaymentAccountCountLimit: paymentAccountCountLimit, MaxAutoForceSettleNum: maxAutoForceSettleNum, FeeDenom: feeDenom, - ValidatorTaxRate: validatorTaxRate, } } @@ -53,29 +53,33 @@ func NewParams( func DefaultParams() Params { return NewParams( DefaultReserveTime, + DefaultValidatorTaxRate, DefaultForcedSettleTime, DefaultPaymentAccountCountLimit, DefaultMaxAutoForceSettleNum, 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(KeyMaxAutoForceSettleNum, &p.MaxAutoForceSettleNum, validateMaxAutoForceSettleNum), 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 } @@ -95,9 +99,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 3d14d2ac6..cd37e93ad 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. @@ -38,8 +37,6 @@ type Params struct { MaxAutoForceSettleNum uint64 `protobuf:"varint,4,opt,name=max_auto_force_settle_num,json=maxAutoForceSettleNum,proto3" json:"max_auto_force_settle_num,omitempty" yaml:"max_auto_force_settle_num"` // The denom of fee charged in payment module FeeDenom string `protobuf:"bytes,5,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,6,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{} } @@ -75,11 +72,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 { @@ -110,42 +107,94 @@ 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{ - // 443 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x4f, 0x8b, 0xd3, 0x40, - 0x18, 0xc6, 0x1b, 0x77, 0x2d, 0xee, 0xe8, 0xa1, 0x8c, 0x2b, 0xa6, 0x2b, 0x26, 0x25, 0xc8, 0xb2, - 0x97, 0x36, 0x88, 0xb7, 0xc5, 0xcb, 0xd6, 0x22, 0x88, 0x22, 0x12, 0xf7, 0xe4, 0xc1, 0x61, 0x3a, - 0x79, 0xdb, 0x1d, 0xcd, 0x64, 0xc2, 0x64, 0xb2, 0xa4, 0xdf, 0xc2, 0x0f, 0xe3, 0x87, 0xd8, 0xe3, - 0xe2, 0x49, 0x3c, 0x04, 0x69, 0xbf, 0x41, 0x2e, 0x5e, 0x25, 0x33, 0xb3, 0xb5, 0x20, 0x7a, 0x99, - 0x3f, 0xef, 0xf3, 0xcc, 0xef, 0x7d, 0x60, 0x5e, 0x14, 0x2e, 0x15, 0x40, 0xbe, 0xe0, 0x90, 0xa5, - 0x71, 0x41, 0x57, 0x02, 0x72, 0x1d, 0x17, 0x54, 0x51, 0x51, 0x4e, 0x0a, 0x25, 0xb5, 0xc4, 0xf8, - 0x8f, 0x61, 0xe2, 0x0c, 0x47, 0x43, 0x26, 0x4b, 0x21, 0x4b, 0x62, 0x1c, 0xb1, 0xbd, 0x58, 0xfb, - 0xd1, 0xe1, 0x52, 0x2e,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x00, 0xcc, 0xba, 0x23, 0xfe, 0x84, - 0xf0, 0x25, 0xcd, 0x78, 0x4a, 0xb5, 0x54, 0x44, 0xd3, 0x9a, 0x28, 0xaa, 0xc1, 0xef, 0x9b, 0xb7, - 0xcf, 0xaf, 0x9a, 0xb0, 0xf7, 0xa3, 0x09, 0x8f, 0x97, 0x5c, 0x5f, 0x54, 0xf3, 0x09, 0x93, 0xc2, - 0x7d, 0xb0, 0xdb, 0xc6, 0x65, 0xfa, 0x39, 0xd6, 0xab, 0x02, 0xca, 0xc9, 0x0c, 0xd8, 0xb7, 0xaf, - 0x63, 0xe4, 0xfe, 0x7f, 0x06, 0x2c, 0x19, 0x6c, 0xb9, 0xe7, 0xb4, 0x4e, 0xa8, 0x86, 0xe9, 0xab, - 0xab, 0x75, 0xe0, 0x5d, 0xaf, 0x03, 0xef, 0xe7, 0x3a, 0xf0, 0xbe, 0x6c, 0x82, 0xde, 0xf5, 0x26, - 0xe8, 0x7d, 0xdf, 0x04, 0xbd, 0x0f, 0xf1, 0x4e, 0x87, 0x79, 0x3e, 0x1f, 0xb3, 0x0b, 0xca, 0xf3, - 0x78, 0x67, 0x1c, 0xeb, 0xed, 0x40, 0x9a, 0x76, 0xf3, 0xbe, 0x99, 0xa5, 0x67, 0xbf, 0x03, 0x00, - 0x00, 0xff, 0xff, 0xf9, 0xa8, 0xba, 0xd4, 0xb3, 0x02, 0x00, 0x00, + // 488 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0x6e, 0x58, 0x99, 0xa8, 0x87, 0xb4, 0xca, 0x0c, 0x91, 0x0e, 0x91, 0x54, 0x01, 0x4d, 0xbd, + 0x34, 0x11, 0x70, 0x9b, 0xb8, 0x2c, 0x54, 0x48, 0x08, 0x84, 0x50, 0xa8, 0x38, 0x70, 0xc0, 0x72, + 0x93, 0xbf,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0xdd, + 0xb4, 0x11, 0x84, 0x41, 0xf7, 0xca, 0x77, 0x4c, 0xcb, 0x80, 0x0a, 0xf0, 0x9f, 0x5f, 0xac, 0x2c, + 0xe3, 0x72, 0x65, 0x19, 0x3f, 0x57, 0x96, 0xf1, 0x69, 0x6d, 0xb5, 0x2e, 0xd7, 0x56, 0xeb, 0xfb, + 0xda, 0x6a, 0xbd, 0xf3, 0xb6, 0x12, 0x26, 0xe9, 0x64, 0x18, 0x9e, 0xd3, 0x38, 0xf5, 0xb6, 0x8a, + 0x5f, 0x5e, 0x55, 0x5f, 0xc6, 0x4d, 0xf6, 0x65, 0x6b, 0x1f, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, + 0x0c, 0xc8, 0xf7, 0x19, 0x1d, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -168,16 +217,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] = 0x32 if len(m.FeeDenom) > 0 { i -= len(m.FeeDenom) copy(dAtA[i:], m.FeeDenom) @@ -200,6 +239,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-- @@ -225,9 +307,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)) } @@ -241,6 +322,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 @@ -282,10 +375,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 @@ -295,11 +388,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) @@ -389,7 +496,76 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.FeeDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + 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 d3715c1ff..3c4a0c385 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 QueryGetStreamRecordRequest struct { Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` } @@ -123,7 +215,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{2} + return fileDescriptor_f62e6684473ccf4a, []int{4} } func (m *QueryGetStreamRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -167,7 +259,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{3} + return fileDescriptor_f62e6684473ccf4a, []int{5} } func (m *QueryGetStreamRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -211,7 +303,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{4} + return fileDescriptor_f62e6684473ccf4a, []int{6} } func (m *QueryAllStreamRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -256,7 +348,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{5} + return fileDescriptor_f62e6684473ccf4a, []int{7} } func (m *QueryAllStreamRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -307,7 +399,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{6} + return fileDescriptor_f62e6684473ccf4a, []int{8} } func (m *QueryGetPaymentAccountCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -351,7 +443,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{7} + return fileDescriptor_f62e6684473ccf4a, []int{9} } func (m *QueryGetPaymentAccountCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -395,7 +487,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{8} + return fileDescriptor_f62e6684473ccf4a, []int{10} } func (m *QueryAllPaymentAccountCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -440,7 +532,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{9} + return fileDescriptor_f62e6684473ccf4a, []int{11} } func (m *QueryAllPaymentAccountCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -491,7 +583,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{10} + return fileDescriptor_f62e6684473ccf4a, []int{12} } func (m *QueryGetPaymentAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -535,7 +627,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{11} + return fileDescriptor_f62e6684473ccf4a, []int{13} } func (m *QueryGetPaymentAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -579,7 +671,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{12} + return fileDescriptor_f62e6684473ccf4a, []int{14} } func (m *QueryAllPaymentAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -624,7 +716,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{13} + return fileDescriptor_f62e6684473ccf4a, []int{15} } func (m *QueryAllPaymentAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -675,7 +767,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{14} + return fileDescriptor_f62e6684473ccf4a, []int{16} } func (m *QueryDynamicBalanceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -732,7 +824,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{15} + return fileDescriptor_f62e6684473ccf4a, []int{17} } func (m *QueryDynamicBalanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -783,7 +875,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{16} + return fileDescriptor_f62e6684473ccf4a, []int{18} } func (m *QueryGetPaymentAccountsByOwnerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -829,7 +921,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{17} + return fileDescriptor_f62e6684473ccf4a, []int{19} } func (m *QueryGetPaymentAccountsByOwnerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -873,7 +965,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{18} + return fileDescriptor_f62e6684473ccf4a, []int{20} } func (m *QueryAllAutoSettleRecordRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -918,7 +1010,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{19} + return fileDescriptor_f62e6684473ccf4a, []int{21} } func (m *QueryAllAutoSettleRecordResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -964,6 +1056,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((*QueryGetStreamRecordRequest)(nil), "greenfield.payment.QueryGetStreamRecordRequest") proto.RegisterType((*QueryGetStreamRecordResponse)(nil), "greenfield.payment.QueryGetStreamRecordResponse") proto.RegisterType((*QueryAllStreamRecordRequest)(nil), "greenfield.payment.QueryAllStreamRecordRequest") @@ -987,82 +1081,86 @@ func init() { func init() { proto.RegisterFile("greenfield/payment/query.proto", fileDescriptor_f62e6684473ccf4a) } var fileDescriptor_f62e6684473ccf4a = []byte{ - // 1196 bytes of a gzipped FileDescriptorProto + // 1253 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xe6, 0xab, 0xca,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x02, 0x2e, 0xab, 0x09, 0xdf, - 0x0c, 0xb9, 0x10, 0x2e, 0x37, 0x03, 0x6e, 0xf9, 0x41, 0x19, 0x85, 0x97, 0x15, 0xc2, 0x55, 0x16, - 0xb0, 0x4a, 0x62, 0x6d, 0x5d, 0x29, 0x20, 0x3f, 0x4d, 0x66, 0x59, 0x7e, 0xcd, 0x13, 0x28, 0x69, - 0xf4, 0x96, 0x34, 0x9b, 0xe5, 0x73, 0x0a, 0xf9, 0x50, 0x04, 0x9c, 0x55, 0x5a, 0x20, 0xea, 0x0b, - 0x40, 0xee, 0x46, 0x01, 0x3c, 0x90, 0xb0, 0x8a, 0xfc, 0x41, 0x8d, 0x87, 0x42, 0xbf, 0x03, 0xf3, - 0x2d, 0xbb, 0x61, 0xd5, 0xf7, 0x42, 0x4e, 0xde, 0x82, 0xf1, 0x18, 0xfe, 0xa2, 0xb6, 0xa2, 0xad, - 0x4f, 0x6e, 0x35, 0xa3, 0x4a, 0x92, 0x63, 0xc4, 0x3a, 0x7b, 0xa3, 0x4f, 0x9e, 0x2d, 0x0f, 0x15, - 0x51, 0x5e, 0xbf, 0x01, 0x2f, 0x49, 0x83, 0xb7, 0xb9, 0xb8, 0x27, 0x51, 0x14, 0x25, 0x08, 0xf4, - 0x47, 0x16, 0xe1, 0x12, 0x92, 0x90, 0x96, 0x27, 0x8a, 0xc9, 0x52, 0x3f, 0x82, 0x25, 0xb5, 0x22, - 0x42, 0xfa, 0x00, 0x2e, 0xb7, 0xd0, 0x42, 0x64, 0x2b, 0x2a, 0x64, 0xcd, 0x06, 0x10, 0xdf, 0x54, - 0xd8, 0xb4, 0xa7, 0x73, 0x44, 0x59, 0x70, 0x5d, 0x15, 0xca, 0x5b, 0x00, 0xcf, 0xcb, 0x0b, 0x1d, - 0xe5, 0x0c, 0x2c, 0xa9, 0xa8, 0x16, 0x8d, 0xb8, 0x70, 0xb1, 0x16, 0x8d, 0x03, 0x66, 0x73, 0xd4, - 0x2d, 0x36, 0x69, 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, 0x7f, 0x9d, 0xe4, 0x87, 0xee, 0x29, + 0x21, 0xcd, 0x56, 0xb3, 0x6a, 0x1b, 0xda, 0x3e, 0x35, 0xac, 0x70, 0xd4, 0xcf, 0x3a, 0x71, 0x85, + 0x80, 0xab, 0x8d, 0x89, 0xff, 0x85, 0x6d, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0x2b, 0xc3, 0x40, + 0xb9, 0x8c, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1079,6 +1177,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. StreamRecord(ctx context.Context, in *QueryGetStreamRecordRequest, opts ...grpc.CallOption) (*QueryGetStreamRecordResponse, error) // Queries a list of StreamRecord items. @@ -1116,6 +1216,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) StreamRecord(ctx context.Context, in *QueryGetStreamRecordRequest, opts ...grpc.CallOption) (*QueryGetStreamRecordResponse, error) { out := new(QueryGetStreamRecordResponse) err := c.cc.Invoke(ctx, "/greenfield.payment.Query/StreamRecord", in, out, opts...) @@ -1201,6 +1310,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. StreamRecord(context.Context, *QueryGetStreamRecordRequest) (*QueryGetStreamRecordResponse, error) // Queries a list of StreamRecord items. @@ -1228,6 +1339,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) StreamRecord(ctx context.Context, req *QueryGetStreamRecordRequest) (*QueryGetStreamRecordResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StreamRecord not implemented") } @@ -1278,6 +1392,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_StreamRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryGetStreamRecordRequest) if err := dec(in); err != nil { @@ -1448,6 +1580,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "ParamsByTimestamp", + Handler: _Query_ParamsByTimestamp_Handler, + }, { MethodName: "StreamRecord", Handler: _Query_StreamRecord_Handler, @@ -1545,6 +1681,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 *QueryGetStreamRecordRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2281,6 +2478,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 *QueryGetStreamRecordRequest) Size() (n int) { if m == nil { return 0 @@ -2685,6 +2905,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 *QueryGetStreamRecordRequest) 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 1f1ff3dc0..9178ec63e 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_StreamRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetStreamRecordRequest var metadata runtime.ServerMetadata @@ -494,6 +548,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_StreamRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -762,6 +839,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_StreamRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -948,6 +1045,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_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))) pattern_Query_StreamRecordAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"greenfield", "payment", "stream_record"}, "", runtime.AssumeColonVerbOpt(false))) @@ -970,6 +1069,8 @@ var ( var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_ParamsByTimestamp_0 = runtime.ForwardResponseMessage + forward_Query_StreamRecord_0 = runtime.ForwardResponseMessage forward_Query_StreamRecordAll_0 = runtime.ForwardResponseMessage diff --git a/x/storage/keeper/payment.go b/x/storage/keeper/payment.go index f83d4ef7c..39e460964 100644 --- a/x/storage/keeper/payment.go +++ b/x/storage/keeper/payment.go @@ -195,8 +195,11 @@ func (k Keeper) GetBucketBill(ctx sdk.Context, bucketInfo *storagetypes.BucketIn }) totalUserOutRate = totalUserOutRate.Add(rate) } - params := k.paymentKeeper.GetParams(ctx) - validatorTaxRate := params.ValidatorTaxRate.MulInt(totalUserOutRate).TruncateInt() + 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(totalUserOutRate).TruncateInt() if validatorTaxRate.IsPositive() { userFlows.Flows = append(userFlows.Flows, types.OutFlow{ ToAddress: types.ValidatorTaxPoolAddress.String(), @@ -309,8 +312,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 9450f09cb..66c5af5c9 100644 --- a/x/storage/keeper/payment_test.go +++ b/x/storage/keeper/payment_test.go @@ -76,7 +76,7 @@ func (s *IntegrationTestSuiteWithoutMock) SetupTest() { s.T().Logf("s.UserAddr: %s, balance: %s", s.UserAddr, balance) } -func (s *IntegrationTestSuiteWithoutMock) TestCreateCreateBucket_Payment() { +func (s *IntegrationTestSuiteWithoutMock) TestCreateBucket_Payment() { ctx := s.ctx.WithBlockTime(time.Now()) // mock create bucket ChargedReadQuota := uint64(1000) @@ -99,7 +99,7 @@ func (s *IntegrationTestSuiteWithoutMock) TestCreateCreateBucket_Payment() { // mock add a object t2 := t1 + 5000 ctx = ctx.WithBlockTime(ctx.BlockTime().Add(time.Duration(t2) * time.Second)) - bucket.BillingInfo.PriceTime = t2 + bucket.BillingInfo.PriceTime = ctx.BlockTime().Unix() object := types.ObjectInfo{ PayloadSize: 100, CreateAt: ctx.BlockTime().Unix(), diff --git a/x/storage/types/expected_keepers.go b/x/storage/types/expected_keepers.go index 4896e7532..3b60191ea 100644 --- a/x/storage/types/expected_keepers.go +++ b/x/storage/types/expected_keepers.go @@ -42,6 +42,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 90407d30f..3b545f9b3 100644 --- a/x/storage/types/expected_keepers_mocks.go +++ b/x/storage/types/expected_keepers_mocks.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: x/storage/types/expected_keepers.go +// Source: expected_keepers.go // Package types is a generated GoMock package. package types @@ -9,682 +9,696 @@ import ( reflect "reflect" math "cosmossdk.io/math" - types2 "github.com/cosmos/cosmos-sdk/types" - types3 "github.com/cosmos/cosmos-sdk/x/auth/types" - gomock "github.com/golang/mock/gomock" - resource "github.com/bnb-chain/greenfield/types/resource" types "github.com/bnb-chain/greenfield/x/payment/types" types0 "github.com/bnb-chain/greenfield/x/permission/types" types1 "github.com/bnb-chain/greenfield/x/sp/types" + types2 "github.com/cosmos/cosmos-sdk/types" + types3 "github.com/cosmos/cosmos-sdk/x/auth/types" + gomock "github.com/golang/mock/gomock" ) -// MockAccountKeeper is a mock of AccountKeeper interface +// MockAccountKeeper is a mock of AccountKeeper interface. type MockAccountKeeper struct { ctrl *gomock.Controller recorder *MockAccountKeeperMockRecorder } -// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper +// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. type MockAccountKeeperMockRecorder struct { mock *MockAccountKeeper } -// NewMockAccountKeeper creates a new mock instance +// NewMockAccountKeeper creates a new mock instance. func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { mock := &MockAccountKeeper{ctrl: ctrl} mock.recorder = &MockAccountKeeperMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { return m.recorder } -// GetAccount mocks base method -func (m *MockAccountKeeper) GetAccount(arg0 types2.Context, arg1 types2.AccAddress) types3.AccountI { +// GetAccount mocks base method. +func (m *MockAccountKeeper) GetAccount(ctx types2.Context, addr types2.AccAddress) types3.AccountI { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAccount", arg0, arg1) + ret := m.ctrl.Call(m, "GetAccount", ctx, addr) ret0, _ := ret[0].(types3.AccountI) return ret0 } -// GetAccount indicates an expected call of GetAccount -func (mr *MockAccountKeeperMockRecorder) GetAccount(arg0, arg1 interface{}) *gomock.Call { +// GetAccount indicates an expected call of GetAccount. +func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr) } -// GetModuleAddress mocks base method -func (m *MockAccountKeeper) GetModuleAddress(arg0 string) types2.AccAddress { +// GetModuleAddress mocks base method. +func (m *MockAccountKeeper) GetModuleAddress(name string) types2.AccAddress { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetModuleAddress", arg0) + ret := m.ctrl.Call(m, "GetModuleAddress", name) ret0, _ := ret[0].(types2.AccAddress) return ret0 } -// GetModuleAddress indicates an expected call of GetModuleAddress -func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(arg0 interface{}) *gomock.Call { +// GetModuleAddress indicates an expected call of GetModuleAddress. +func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), name) } -// MockBankKeeper is a mock of BankKeeper interface +// MockBankKeeper is a mock of BankKeeper interface. type MockBankKeeper struct { ctrl *gomock.Controller recorder *MockBankKeeperMockRecorder } -// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. type MockBankKeeperMockRecorder struct { mock *MockBankKeeper } -// NewMockBankKeeper creates a new mock instance +// NewMockBankKeeper creates a new mock instance. func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { mock := &MockBankKeeper{ctrl: ctrl} mock.recorder = &MockBankKeeperMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { return m.recorder } -// GetAllBalances mocks base method -func (m *MockBankKeeper) GetAllBalances(arg0 types2.Context, arg1 types2.AccAddress) types2.Coins { +// GetAllBalances mocks base method. +func (m *MockBankKeeper) GetAllBalances(ctx types2.Context, addr types2.AccAddress) types2.Coins { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAllBalances", arg0, arg1) + ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr) ret0, _ := ret[0].(types2.Coins) return ret0 } -// GetAllBalances indicates an expected call of GetAllBalances -func (mr *MockBankKeeperMockRecorder) GetAllBalances(arg0, arg1 interface{}) *gomock.Call { +// GetAllBalances indicates an expected call of GetAllBalances. +func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllBalances", reflect.TypeOf((*MockBankKeeper)(nil).GetAllBalances), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllBalances", reflect.TypeOf((*MockBankKeeper)(nil).GetAllBalances), ctx, addr) } -// GetBalance mocks base method -func (m *MockBankKeeper) GetBalance(arg0 types2.Context, arg1 types2.AccAddress, arg2 string) types2.Coin { +// GetBalance mocks base method. +func (m *MockBankKeeper) GetBalance(ctx types2.Context, addr types2.AccAddress, denom string) types2.Coin { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetBalance", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetBalance", ctx, addr, denom) ret0, _ := ret[0].(types2.Coin) return ret0 } -// GetBalance indicates an expected call of GetBalance -func (mr *MockBankKeeperMockRecorder) GetBalance(arg0, arg1, arg2 interface{}) *gomock.Call { +// GetBalance indicates an expected call of GetBalance. +func (mr *MockBankKeeperMockRecorder) GetBalance(ctx, addr, denom interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalance", reflect.TypeOf((*MockBankKeeper)(nil).GetBalance), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBalance", reflect.TypeOf((*MockBankKeeper)(nil).GetBalance), ctx, addr, denom) } -// SendCoinsFromModuleToAccount mocks base method -func (m *MockBankKeeper) SendCoinsFromModuleToAccount(arg0 types2.Context, arg1 string, arg2 types2.AccAddress, arg3 types2.Coins) error { +// SendCoinsFromModuleToAccount mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types2.Context, senderModule string, recipientAddr types2.AccAddress, amt types2.Coins) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) ret0, _ := ret[0].(error) return ret0 } -// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount -func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) } -// SpendableCoins mocks base method -func (m *MockBankKeeper) SpendableCoins(arg0 types2.Context, arg1 types2.AccAddress) types2.Coins { +// SpendableCoins mocks base method. +func (m *MockBankKeeper) SpendableCoins(ctx types2.Context, addr types2.AccAddress) types2.Coins { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SpendableCoins", arg0, arg1) + ret := m.ctrl.Call(m, "SpendableCoins", ctx, addr) ret0, _ := ret[0].(types2.Coins) return ret0 } -// SpendableCoins indicates an expected call of SpendableCoins -func (mr *MockBankKeeperMockRecorder) SpendableCoins(arg0, arg1 interface{}) *gomock.Call { +// SpendableCoins indicates an expected call of SpendableCoins. +func (mr *MockBankKeeperMockRecorder) SpendableCoins(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpendableCoins", reflect.TypeOf((*MockBankKeeper)(nil).SpendableCoins), ctx, addr) } -// MockSpKeeper is a mock of SpKeeper interface +// MockSpKeeper is a mock of SpKeeper interface. type MockSpKeeper struct { ctrl *gomock.Controller recorder *MockSpKeeperMockRecorder } -// MockSpKeeperMockRecorder is the mock recorder for MockSpKeeper +// MockSpKeeperMockRecorder is the mock recorder for MockSpKeeper. type MockSpKeeperMockRecorder struct { mock *MockSpKeeper } -// NewMockSpKeeper creates a new mock instance +// NewMockSpKeeper creates a new mock instance. func NewMockSpKeeper(ctrl *gomock.Controller) *MockSpKeeper { mock := &MockSpKeeper{ctrl: ctrl} mock.recorder = &MockSpKeeperMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockSpKeeper) EXPECT() *MockSpKeeperMockRecorder { return m.recorder } -// GetSpStoragePriceByTime mocks base method -func (m *MockSpKeeper) GetSpStoragePriceByTime(arg0 types2.Context, arg1 types2.AccAddress, arg2 int64) (types1.SpStoragePrice, error) { +// GetSpStoragePriceByTime mocks base method. +func (m *MockSpKeeper) GetSpStoragePriceByTime(ctx types2.Context, spAddr types2.AccAddress, time int64) (types1.SpStoragePrice, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetSpStoragePriceByTime", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "GetSpStoragePriceByTime", ctx, spAddr, time) ret0, _ := ret[0].(types1.SpStoragePrice) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetSpStoragePriceByTime indicates an expected call of GetSpStoragePriceByTime -func (mr *MockSpKeeperMockRecorder) GetSpStoragePriceByTime(arg0, arg1, arg2 interface{}) *gomock.Call { +// GetSpStoragePriceByTime indicates an expected call of GetSpStoragePriceByTime. +func (mr *MockSpKeeperMockRecorder) GetSpStoragePriceByTime(ctx, spAddr, time interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpStoragePriceByTime", reflect.TypeOf((*MockSpKeeper)(nil).GetSpStoragePriceByTime), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpStoragePriceByTime", reflect.TypeOf((*MockSpKeeper)(nil).GetSpStoragePriceByTime), ctx, spAddr, time) } -// GetStorageProvider mocks base method -func (m *MockSpKeeper) GetStorageProvider(arg0 types2.Context, arg1 types2.AccAddress) (*types1.StorageProvider, bool) { +// GetStorageProvider mocks base method. +func (m *MockSpKeeper) GetStorageProvider(ctx types2.Context, addr types2.AccAddress) (*types1.StorageProvider, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStorageProvider", arg0, arg1) + ret := m.ctrl.Call(m, "GetStorageProvider", ctx, addr) ret0, _ := ret[0].(*types1.StorageProvider) ret1, _ := ret[1].(bool) return ret0, ret1 } -// GetStorageProvider indicates an expected call of GetStorageProvider -func (mr *MockSpKeeperMockRecorder) GetStorageProvider(arg0, arg1 interface{}) *gomock.Call { +// GetStorageProvider indicates an expected call of GetStorageProvider. +func (mr *MockSpKeeperMockRecorder) GetStorageProvider(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageProvider", reflect.TypeOf((*MockSpKeeper)(nil).GetStorageProvider), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageProvider", reflect.TypeOf((*MockSpKeeper)(nil).GetStorageProvider), ctx, addr) } -// GetStorageProviderByGcAddr mocks base method -func (m *MockSpKeeper) GetStorageProviderByGcAddr(arg0 types2.Context, arg1 types2.AccAddress) (*types1.StorageProvider, bool) { +// GetStorageProviderByGcAddr mocks base method. +func (m *MockSpKeeper) GetStorageProviderByGcAddr(ctx types2.Context, gcAddr types2.AccAddress) (*types1.StorageProvider, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStorageProviderByGcAddr", arg0, arg1) + ret := m.ctrl.Call(m, "GetStorageProviderByGcAddr", ctx, gcAddr) ret0, _ := ret[0].(*types1.StorageProvider) ret1, _ := ret[1].(bool) return ret0, ret1 } -// GetStorageProviderByGcAddr indicates an expected call of GetStorageProviderByGcAddr -func (mr *MockSpKeeperMockRecorder) GetStorageProviderByGcAddr(arg0, arg1 interface{}) *gomock.Call { +// GetStorageProviderByGcAddr indicates an expected call of GetStorageProviderByGcAddr. +func (mr *MockSpKeeperMockRecorder) GetStorageProviderByGcAddr(ctx, gcAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageProviderByGcAddr", reflect.TypeOf((*MockSpKeeper)(nil).GetStorageProviderByGcAddr), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageProviderByGcAddr", reflect.TypeOf((*MockSpKeeper)(nil).GetStorageProviderByGcAddr), ctx, gcAddr) } -// GetStorageProviderBySealAddr mocks base method -func (m *MockSpKeeper) GetStorageProviderBySealAddr(arg0 types2.Context, arg1 types2.AccAddress) (*types1.StorageProvider, bool) { +// GetStorageProviderBySealAddr mocks base method. +func (m *MockSpKeeper) GetStorageProviderBySealAddr(ctx types2.Context, sealAddr types2.AccAddress) (*types1.StorageProvider, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStorageProviderBySealAddr", arg0, arg1) + ret := m.ctrl.Call(m, "GetStorageProviderBySealAddr", ctx, sealAddr) ret0, _ := ret[0].(*types1.StorageProvider) ret1, _ := ret[1].(bool) return ret0, ret1 } -// GetStorageProviderBySealAddr indicates an expected call of GetStorageProviderBySealAddr -func (mr *MockSpKeeperMockRecorder) GetStorageProviderBySealAddr(arg0, arg1 interface{}) *gomock.Call { +// GetStorageProviderBySealAddr indicates an expected call of GetStorageProviderBySealAddr. +func (mr *MockSpKeeperMockRecorder) GetStorageProviderBySealAddr(ctx, sealAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageProviderBySealAddr", reflect.TypeOf((*MockSpKeeper)(nil).GetStorageProviderBySealAddr), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStorageProviderBySealAddr", reflect.TypeOf((*MockSpKeeper)(nil).GetStorageProviderBySealAddr), ctx, sealAddr) } -// IsStorageProviderExistAndInService mocks base method -func (m *MockSpKeeper) IsStorageProviderExistAndInService(arg0 types2.Context, arg1 types2.AccAddress) error { +// IsStorageProviderExistAndInService mocks base method. +func (m *MockSpKeeper) IsStorageProviderExistAndInService(ctx types2.Context, addr types2.AccAddress) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsStorageProviderExistAndInService", arg0, arg1) + ret := m.ctrl.Call(m, "IsStorageProviderExistAndInService", ctx, addr) ret0, _ := ret[0].(error) return ret0 } -// IsStorageProviderExistAndInService indicates an expected call of IsStorageProviderExistAndInService -func (mr *MockSpKeeperMockRecorder) IsStorageProviderExistAndInService(arg0, arg1 interface{}) *gomock.Call { +// IsStorageProviderExistAndInService indicates an expected call of IsStorageProviderExistAndInService. +func (mr *MockSpKeeperMockRecorder) IsStorageProviderExistAndInService(ctx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsStorageProviderExistAndInService", reflect.TypeOf((*MockSpKeeper)(nil).IsStorageProviderExistAndInService), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsStorageProviderExistAndInService", reflect.TypeOf((*MockSpKeeper)(nil).IsStorageProviderExistAndInService), ctx, addr) } -// SetSecondarySpStorePrice mocks base method -func (m *MockSpKeeper) SetSecondarySpStorePrice(arg0 types2.Context, arg1 types1.SecondarySpStorePrice) { +// SetSecondarySpStorePrice mocks base method. +func (m *MockSpKeeper) SetSecondarySpStorePrice(ctx types2.Context, secondarySpStorePrice types1.SecondarySpStorePrice) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetSecondarySpStorePrice", arg0, arg1) + m.ctrl.Call(m, "SetSecondarySpStorePrice", ctx, secondarySpStorePrice) } -// SetSecondarySpStorePrice indicates an expected call of SetSecondarySpStorePrice -func (mr *MockSpKeeperMockRecorder) SetSecondarySpStorePrice(arg0, arg1 interface{}) *gomock.Call { +// SetSecondarySpStorePrice indicates an expected call of SetSecondarySpStorePrice. +func (mr *MockSpKeeperMockRecorder) SetSecondarySpStorePrice(ctx, secondarySpStorePrice interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSecondarySpStorePrice", reflect.TypeOf((*MockSpKeeper)(nil).SetSecondarySpStorePrice), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSecondarySpStorePrice", reflect.TypeOf((*MockSpKeeper)(nil).SetSecondarySpStorePrice), ctx, secondarySpStorePrice) } -// SetSpStoragePrice mocks base method -func (m *MockSpKeeper) SetSpStoragePrice(arg0 types2.Context, arg1 types1.SpStoragePrice) { +// SetSpStoragePrice mocks base method. +func (m *MockSpKeeper) SetSpStoragePrice(ctx types2.Context, SpStoragePrice types1.SpStoragePrice) { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetSpStoragePrice", arg0, arg1) + m.ctrl.Call(m, "SetSpStoragePrice", ctx, SpStoragePrice) } -// SetSpStoragePrice indicates an expected call of SetSpStoragePrice -func (mr *MockSpKeeperMockRecorder) SetSpStoragePrice(arg0, arg1 interface{}) *gomock.Call { +// SetSpStoragePrice indicates an expected call of SetSpStoragePrice. +func (mr *MockSpKeeperMockRecorder) SetSpStoragePrice(ctx, SpStoragePrice interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSpStoragePrice", reflect.TypeOf((*MockSpKeeper)(nil).SetSpStoragePrice), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSpStoragePrice", reflect.TypeOf((*MockSpKeeper)(nil).SetSpStoragePrice), ctx, SpStoragePrice) } -// MockPaymentKeeper is a mock of PaymentKeeper interface +// MockPaymentKeeper is a mock of PaymentKeeper interface. type MockPaymentKeeper struct { ctrl *gomock.Controller recorder *MockPaymentKeeperMockRecorder } -// MockPaymentKeeperMockRecorder is the mock recorder for MockPaymentKeeper +// MockPaymentKeeperMockRecorder is the mock recorder for MockPaymentKeeper. type MockPaymentKeeperMockRecorder struct { mock *MockPaymentKeeper } -// NewMockPaymentKeeper creates a new mock instance +// NewMockPaymentKeeper creates a new mock instance. func NewMockPaymentKeeper(ctrl *gomock.Controller) *MockPaymentKeeper { mock := &MockPaymentKeeper{ctrl: ctrl} mock.recorder = &MockPaymentKeeperMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockPaymentKeeper) EXPECT() *MockPaymentKeeperMockRecorder { return m.recorder } -// ApplyUserFlowsList mocks base method -func (m *MockPaymentKeeper) ApplyUserFlowsList(arg0 types2.Context, arg1 []types.UserFlows) error { +// ApplyUserFlowsList mocks base method. +func (m *MockPaymentKeeper) ApplyUserFlowsList(ctx types2.Context, userFlows []types.UserFlows) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ApplyUserFlowsList", arg0, arg1) + ret := m.ctrl.Call(m, "ApplyUserFlowsList", ctx, userFlows) ret0, _ := ret[0].(error) return ret0 } -// ApplyUserFlowsList indicates an expected call of ApplyUserFlowsList -func (mr *MockPaymentKeeperMockRecorder) ApplyUserFlowsList(arg0, arg1 interface{}) *gomock.Call { +// ApplyUserFlowsList indicates an expected call of ApplyUserFlowsList. +func (mr *MockPaymentKeeperMockRecorder) ApplyUserFlowsList(ctx, userFlows interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyUserFlowsList", reflect.TypeOf((*MockPaymentKeeper)(nil).ApplyUserFlowsList), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplyUserFlowsList", reflect.TypeOf((*MockPaymentKeeper)(nil).ApplyUserFlowsList), ctx, userFlows) } -// GetParams mocks base method -func (m *MockPaymentKeeper) GetParams(arg0 types2.Context) types.Params { +// GetParams mocks base method. +func (m *MockPaymentKeeper) GetParams(ctx types2.Context) types.Params { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetParams", arg0) + ret := m.ctrl.Call(m, "GetParams", ctx) ret0, _ := ret[0].(types.Params) return ret0 } -// GetParams indicates an expected call of GetParams -func (mr *MockPaymentKeeperMockRecorder) GetParams(arg0 interface{}) *gomock.Call { +// GetParams indicates an expected call of GetParams. +func (mr *MockPaymentKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockPaymentKeeper)(nil).GetParams), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockPaymentKeeper)(nil).GetParams), ctx) } -// GetStoragePrice mocks base method -func (m *MockPaymentKeeper) GetStoragePrice(arg0 types2.Context, arg1 types.StoragePriceParams) (types.StoragePrice, error) { +// GetStoragePrice mocks base method. +func (m *MockPaymentKeeper) GetStoragePrice(ctx types2.Context, params types.StoragePriceParams) (types.StoragePrice, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStoragePrice", arg0, arg1) + ret := m.ctrl.Call(m, "GetStoragePrice", ctx, params) ret0, _ := ret[0].(types.StoragePrice) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetStoragePrice indicates an expected call of GetStoragePrice -func (mr *MockPaymentKeeperMockRecorder) GetStoragePrice(arg0, arg1 interface{}) *gomock.Call { +// GetStoragePrice indicates an expected call of GetStoragePrice. +func (mr *MockPaymentKeeperMockRecorder) GetStoragePrice(ctx, params interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStoragePrice", reflect.TypeOf((*MockPaymentKeeper)(nil).GetStoragePrice), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStoragePrice", reflect.TypeOf((*MockPaymentKeeper)(nil).GetStoragePrice), ctx, params) } -// GetStreamRecord mocks base method -func (m *MockPaymentKeeper) GetStreamRecord(arg0 types2.Context, arg1 types2.AccAddress) (*types.StreamRecord, bool) { +// GetStreamRecord mocks base method. +func (m *MockPaymentKeeper) GetStreamRecord(ctx types2.Context, account types2.AccAddress) (*types.StreamRecord, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetStreamRecord", arg0, arg1) + ret := m.ctrl.Call(m, "GetStreamRecord", ctx, account) ret0, _ := ret[0].(*types.StreamRecord) ret1, _ := ret[1].(bool) return ret0, ret1 } -// GetStreamRecord indicates an expected call of GetStreamRecord -func (mr *MockPaymentKeeperMockRecorder) GetStreamRecord(arg0, arg1 interface{}) *gomock.Call { +// GetStreamRecord indicates an expected call of GetStreamRecord. +func (mr *MockPaymentKeeperMockRecorder) GetStreamRecord(ctx, account interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStreamRecord", reflect.TypeOf((*MockPaymentKeeper)(nil).GetStreamRecord), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStreamRecord", reflect.TypeOf((*MockPaymentKeeper)(nil).GetStreamRecord), ctx, account) } -// IsPaymentAccountOwner mocks base method -func (m *MockPaymentKeeper) IsPaymentAccountOwner(arg0 types2.Context, arg1, arg2 types2.AccAddress) bool { +// GetVersionedParamsWithTs mocks base method. +func (m *MockPaymentKeeper) GetVersionedParamsWithTs(ctx types2.Context, time int64) (types.VersionedParams, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsPaymentAccountOwner", arg0, arg1, arg2) + 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 types2.Context, addr, owner types2.AccAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsPaymentAccountOwner", ctx, addr, owner) ret0, _ := ret[0].(bool) return ret0 } -// IsPaymentAccountOwner indicates an expected call of IsPaymentAccountOwner -func (mr *MockPaymentKeeperMockRecorder) IsPaymentAccountOwner(arg0, arg1, arg2 interface{}) *gomock.Call { +// IsPaymentAccountOwner indicates an expected call of IsPaymentAccountOwner. +func (mr *MockPaymentKeeperMockRecorder) IsPaymentAccountOwner(ctx, addr, owner interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsPaymentAccountOwner", reflect.TypeOf((*MockPaymentKeeper)(nil).IsPaymentAccountOwner), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsPaymentAccountOwner", reflect.TypeOf((*MockPaymentKeeper)(nil).IsPaymentAccountOwner), ctx, addr, owner) } -// UpdateStreamRecordByAddr mocks base method -func (m *MockPaymentKeeper) UpdateStreamRecordByAddr(arg0 types2.Context, arg1 *types.StreamRecordChange) (*types.StreamRecord, error) { +// UpdateStreamRecordByAddr mocks base method. +func (m *MockPaymentKeeper) UpdateStreamRecordByAddr(ctx types2.Context, change *types.StreamRecordChange) (*types.StreamRecord, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UpdateStreamRecordByAddr", arg0, arg1) + ret := m.ctrl.Call(m, "UpdateStreamRecordByAddr", ctx, change) ret0, _ := ret[0].(*types.StreamRecord) ret1, _ := ret[1].(error) return ret0, ret1 } -// UpdateStreamRecordByAddr indicates an expected call of UpdateStreamRecordByAddr -func (mr *MockPaymentKeeperMockRecorder) UpdateStreamRecordByAddr(arg0, arg1 interface{}) *gomock.Call { +// UpdateStreamRecordByAddr indicates an expected call of UpdateStreamRecordByAddr. +func (mr *MockPaymentKeeperMockRecorder) UpdateStreamRecordByAddr(ctx, change interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStreamRecordByAddr", reflect.TypeOf((*MockPaymentKeeper)(nil).UpdateStreamRecordByAddr), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateStreamRecordByAddr", reflect.TypeOf((*MockPaymentKeeper)(nil).UpdateStreamRecordByAddr), ctx, change) } -// MockPermissionKeeper is a mock of PermissionKeeper interface +// MockPermissionKeeper is a mock of PermissionKeeper interface. type MockPermissionKeeper struct { ctrl *gomock.Controller recorder *MockPermissionKeeperMockRecorder } -// MockPermissionKeeperMockRecorder is the mock recorder for MockPermissionKeeper +// MockPermissionKeeperMockRecorder is the mock recorder for MockPermissionKeeper. type MockPermissionKeeperMockRecorder struct { mock *MockPermissionKeeper } -// NewMockPermissionKeeper creates a new mock instance +// NewMockPermissionKeeper creates a new mock instance. func NewMockPermissionKeeper(ctrl *gomock.Controller) *MockPermissionKeeper { mock := &MockPermissionKeeper{ctrl: ctrl} mock.recorder = &MockPermissionKeeperMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockPermissionKeeper) EXPECT() *MockPermissionKeeperMockRecorder { return m.recorder } -// AddGroupMember mocks base method -func (m *MockPermissionKeeper) AddGroupMember(arg0 types2.Context, arg1 math.Uint, arg2 types2.AccAddress) error { +// AddGroupMember mocks base method. +func (m *MockPermissionKeeper) AddGroupMember(ctx types2.Context, groupID math.Uint, member types2.AccAddress) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddGroupMember", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "AddGroupMember", ctx, groupID, member) ret0, _ := ret[0].(error) return ret0 } -// AddGroupMember indicates an expected call of AddGroupMember -func (mr *MockPermissionKeeperMockRecorder) AddGroupMember(arg0, arg1, arg2 interface{}) *gomock.Call { +// AddGroupMember indicates an expected call of AddGroupMember. +func (mr *MockPermissionKeeperMockRecorder) AddGroupMember(ctx, groupID, member interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).AddGroupMember), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).AddGroupMember), ctx, groupID, member) } -// DeletePolicy mocks base method -func (m *MockPermissionKeeper) DeletePolicy(arg0 types2.Context, arg1 *types0.Principal, arg2 resource.ResourceType, arg3 math.Uint) (math.Uint, error) { +// DeletePolicy mocks base method. +func (m *MockPermissionKeeper) DeletePolicy(ctx types2.Context, principal *types0.Principal, resourceType resource.ResourceType, resourceID math.Uint) (math.Uint, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeletePolicy", arg0, arg1, arg2, arg3) + ret := m.ctrl.Call(m, "DeletePolicy", ctx, principal, resourceType, resourceID) ret0, _ := ret[0].(math.Uint) ret1, _ := ret[1].(error) return ret0, ret1 } -// DeletePolicy indicates an expected call of DeletePolicy -func (mr *MockPermissionKeeperMockRecorder) DeletePolicy(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +// DeletePolicy indicates an expected call of DeletePolicy. +func (mr *MockPermissionKeeperMockRecorder) DeletePolicy(ctx, principal, resourceType, resourceID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicy", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeletePolicy", reflect.TypeOf((*MockPermissionKeeper)(nil).DeletePolicy), ctx, principal, resourceType, resourceID) } -// GetGroupMember mocks base method -func (m *MockPermissionKeeper) GetGroupMember(arg0 types2.Context, arg1 math.Uint, arg2 types2.AccAddress) (*types0.GroupMember, bool) { +// ExistAccountPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ExistAccountPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetGroupMember", arg0, arg1, arg2) - ret0, _ := ret[0].(*types0.GroupMember) - ret1, _ := ret[1].(bool) - return ret0, ret1 + ret := m.ctrl.Call(m, "ExistAccountPolicyForResource", ctx, resourceType, resourceID) + ret0, _ := ret[0].(bool) + return ret0 } -// GetGroupMember indicates an expected call of GetGroupMember -func (mr *MockPermissionKeeperMockRecorder) GetGroupMember(arg0, arg1, arg2 interface{}) *gomock.Call { +// ExistAccountPolicyForResource indicates an expected call of ExistAccountPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ExistAccountPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).GetGroupMember), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistAccountPolicyForResource), ctx, resourceType, resourceID) } -// GetGroupMemberByID mocks base method -func (m *MockPermissionKeeper) GetGroupMemberByID(arg0 types2.Context, arg1 math.Uint) (*types0.GroupMember, bool) { +// ExistGroupMemberForGroup mocks base method. +func (m *MockPermissionKeeper) ExistGroupMemberForGroup(ctx types2.Context, groupId math.Uint) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetGroupMemberByID", arg0, arg1) - ret0, _ := ret[0].(*types0.GroupMember) - ret1, _ := ret[1].(bool) - return ret0, ret1 + ret := m.ctrl.Call(m, "ExistGroupMemberForGroup", ctx, groupId) + ret0, _ := ret[0].(bool) + return ret0 } -// GetGroupMemberByID indicates an expected call of GetGroupMemberByID -func (mr *MockPermissionKeeperMockRecorder) GetGroupMemberByID(arg0, arg1 interface{}) *gomock.Call { +// ExistGroupMemberForGroup indicates an expected call of ExistGroupMemberForGroup. +func (mr *MockPermissionKeeperMockRecorder) ExistGroupMemberForGroup(ctx, groupId interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMemberByID", reflect.TypeOf((*MockPermissionKeeper)(nil).GetGroupMemberByID), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistGroupMemberForGroup", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistGroupMemberForGroup), ctx, groupId) } -// GetPolicyByID mocks base method -func (m *MockPermissionKeeper) GetPolicyByID(arg0 types2.Context, arg1 math.Uint) (*types0.Policy, bool) { +// ExistGroupPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ExistGroupPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPolicyByID", arg0, arg1) - ret0, _ := ret[0].(*types0.Policy) - ret1, _ := ret[1].(bool) - return ret0, ret1 + ret := m.ctrl.Call(m, "ExistGroupPolicyForResource", ctx, resourceType, resourceID) + ret0, _ := ret[0].(bool) + return ret0 } -// GetPolicyByID indicates an expected call of GetPolicyByID -func (mr *MockPermissionKeeperMockRecorder) GetPolicyByID(arg0, arg1 interface{}) *gomock.Call { +// ExistGroupPolicyForResource indicates an expected call of ExistGroupPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ExistGroupPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyByID", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyByID), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistGroupPolicyForResource), ctx, resourceType, resourceID) } -// GetPolicyForAccount mocks base method -func (m *MockPermissionKeeper) GetPolicyForAccount(arg0 types2.Context, arg1 math.Uint, arg2 resource.ResourceType, arg3 types2.AccAddress) (*types0.Policy, bool) { +// ForceDeleteAccountPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ForceDeleteAccountPolicyForResource(ctx types2.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPolicyForAccount", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*types0.Policy) + ret := m.ctrl.Call(m, "ForceDeleteAccountPolicyForResource", ctx, maxDelete, deletedCount, resourceType, resourceID) + ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(bool) return ret0, ret1 } -// GetPolicyForAccount indicates an expected call of GetPolicyForAccount -func (mr *MockPermissionKeeperMockRecorder) GetPolicyForAccount(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +// ForceDeleteAccountPolicyForResource indicates an expected call of ForceDeleteAccountPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteAccountPolicyForResource(ctx, maxDelete, deletedCount, resourceType, resourceID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyForAccount", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyForAccount), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteAccountPolicyForResource), ctx, maxDelete, deletedCount, resourceType, resourceID) } -// GetPolicyForGroup mocks base method -func (m *MockPermissionKeeper) GetPolicyForGroup(arg0 types2.Context, arg1 math.Uint, arg2 resource.ResourceType, arg3 math.Uint) (*types0.Policy, bool) { +// ForceDeleteGroupMembers mocks base method. +func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, maxDelete, deletedTotal uint64, groupId math.Uint) (uint64, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetPolicyForGroup", arg0, arg1, arg2, arg3) - ret0, _ := ret[0].(*types0.Policy) + ret := m.ctrl.Call(m, "ForceDeleteGroupMembers", ctx, maxDelete, deletedTotal, groupId) + ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(bool) return ret0, ret1 } -// GetPolicyForGroup indicates an expected call of GetPolicyForGroup -func (mr *MockPermissionKeeperMockRecorder) GetPolicyForGroup(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { +// ForceDeleteGroupMembers indicates an expected call of ForceDeleteGroupMembers. +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, maxDelete, deletedTotal, groupId interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyForGroup", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyForGroup), arg0, arg1, arg2, arg3) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupMembers), ctx, maxDelete, deletedTotal, groupId) } -// PutPolicy mocks base method -func (m *MockPermissionKeeper) PutPolicy(arg0 types2.Context, arg1 *types0.Policy) (math.Uint, error) { +// ForceDeleteGroupPolicyForResource mocks base method. +func (m *MockPermissionKeeper) ForceDeleteGroupPolicyForResource(ctx types2.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "PutPolicy", arg0, arg1) - ret0, _ := ret[0].(math.Uint) - ret1, _ := ret[1].(error) + ret := m.ctrl.Call(m, "ForceDeleteGroupPolicyForResource", ctx, maxDelete, deletedCount, resourceType, resourceID) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(bool) return ret0, ret1 } -// PutPolicy indicates an expected call of PutPolicy -func (mr *MockPermissionKeeperMockRecorder) PutPolicy(arg0, arg1 interface{}) *gomock.Call { +// ForceDeleteGroupPolicyForResource indicates an expected call of ForceDeleteGroupPolicyForResource. +func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ctx, maxDelete, deletedCount, resourceType, resourceID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutPolicy", reflect.TypeOf((*MockPermissionKeeper)(nil).PutPolicy), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupPolicyForResource), ctx, maxDelete, deletedCount, resourceType, resourceID) } -// RemoveGroupMember mocks base method -func (m *MockPermissionKeeper) RemoveGroupMember(arg0 types2.Context, arg1 math.Uint, arg2 types2.AccAddress) error { +// GetGroupMember mocks base method. +func (m *MockPermissionKeeper) GetGroupMember(ctx types2.Context, groupID math.Uint, member types2.AccAddress) (*types0.GroupMember, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveGroupMember", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 + ret := m.ctrl.Call(m, "GetGroupMember", ctx, groupID, member) + ret0, _ := ret[0].(*types0.GroupMember) + ret1, _ := ret[1].(bool) + return ret0, ret1 } -// RemoveGroupMember indicates an expected call of RemoveGroupMember -func (mr *MockPermissionKeeperMockRecorder) RemoveGroupMember(arg0, arg1, arg2 interface{}) *gomock.Call { +// GetGroupMember indicates an expected call of GetGroupMember. +func (mr *MockPermissionKeeperMockRecorder) GetGroupMember(ctx, groupID, member interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).RemoveGroupMember), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).GetGroupMember), ctx, groupID, member) } -// VerifyPolicy mocks base method -func (m *MockPermissionKeeper) VerifyPolicy(arg0 types2.Context, arg1 math.Uint, arg2 resource.ResourceType, arg3 types2.AccAddress, arg4 types0.ActionType, arg5 *types0.VerifyOptions) types0.Effect { +// GetGroupMemberByID mocks base method. +func (m *MockPermissionKeeper) GetGroupMemberByID(ctx types2.Context, groupMemberID math.Uint) (*types0.GroupMember, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyPolicy", arg0, arg1, arg2, arg3, arg4, arg5) - ret0, _ := ret[0].(types0.Effect) - return ret0 + ret := m.ctrl.Call(m, "GetGroupMemberByID", ctx, groupMemberID) + ret0, _ := ret[0].(*types0.GroupMember) + ret1, _ := ret[1].(bool) + return ret0, ret1 } -// VerifyPolicy indicates an expected call of VerifyPolicy -func (mr *MockPermissionKeeperMockRecorder) VerifyPolicy(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +// GetGroupMemberByID indicates an expected call of GetGroupMemberByID. +func (mr *MockPermissionKeeperMockRecorder) GetGroupMemberByID(ctx, groupMemberID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyPolicy", reflect.TypeOf((*MockPermissionKeeper)(nil).VerifyPolicy), arg0, arg1, arg2, arg3, arg4, arg5) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGroupMemberByID", reflect.TypeOf((*MockPermissionKeeper)(nil).GetGroupMemberByID), ctx, groupMemberID) } -// MockCrossChainKeeper is a mock of CrossChainKeeper interface -type MockCrossChainKeeper struct { - ctrl *gomock.Controller - recorder *MockCrossChainKeeperMockRecorder -} - -// MockCrossChainKeeperMockRecorder is the mock recorder for MockCrossChainKeeper -type MockCrossChainKeeperMockRecorder struct { - mock *MockCrossChainKeeper -} - -// NewMockCrossChainKeeper creates a new mock instance -func NewMockCrossChainKeeper(ctrl *gomock.Controller) *MockCrossChainKeeper { - mock := &MockCrossChainKeeper{ctrl: ctrl} - mock.recorder = &MockCrossChainKeeperMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockCrossChainKeeper) EXPECT() *MockCrossChainKeeperMockRecorder { - return m.recorder -} - -// CreateRawIBCPackageWithFee mocks base method -func (m *MockCrossChainKeeper) CreateRawIBCPackageWithFee(arg0 types2.Context, arg1 types2.ChannelID, arg2 types2.CrossChainPackageType, arg3 []byte, arg4, arg5 *big.Int) (uint64, error) { +// GetPolicyByID mocks base method. +func (m *MockPermissionKeeper) GetPolicyByID(ctx types2.Context, policyID math.Uint) (*types0.Policy, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateRawIBCPackageWithFee", arg0, arg1, arg2, arg3, arg4, arg5) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(error) + ret := m.ctrl.Call(m, "GetPolicyByID", ctx, policyID) + ret0, _ := ret[0].(*types0.Policy) + ret1, _ := ret[1].(bool) return ret0, ret1 } -// CreateRawIBCPackageWithFee indicates an expected call of CreateRawIBCPackageWithFee -func (mr *MockCrossChainKeeperMockRecorder) CreateRawIBCPackageWithFee(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { +// GetPolicyByID indicates an expected call of GetPolicyByID. +func (mr *MockPermissionKeeperMockRecorder) GetPolicyByID(ctx, policyID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRawIBCPackageWithFee", reflect.TypeOf((*MockCrossChainKeeper)(nil).CreateRawIBCPackageWithFee), arg0, arg1, arg2, arg3, arg4, arg5) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyByID", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyByID), ctx, policyID) } -// RegisterChannel mocks base method -func (m *MockCrossChainKeeper) RegisterChannel(arg0 string, arg1 types2.ChannelID, arg2 types2.CrossChainApplication) error { +// GetPolicyForAccount mocks base method. +func (m *MockPermissionKeeper) GetPolicyForAccount(ctx types2.Context, resourceID math.Uint, resourceType resource.ResourceType, addr types2.AccAddress) (*types0.Policy, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RegisterChannel", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 + ret := m.ctrl.Call(m, "GetPolicyForAccount", ctx, resourceID, resourceType, addr) + ret0, _ := ret[0].(*types0.Policy) + ret1, _ := ret[1].(bool) + return ret0, ret1 } -// RegisterChannel indicates an expected call of RegisterChannel -func (mr *MockCrossChainKeeperMockRecorder) RegisterChannel(arg0, arg1, arg2 interface{}) *gomock.Call { +// GetPolicyForAccount indicates an expected call of GetPolicyForAccount. +func (mr *MockPermissionKeeperMockRecorder) GetPolicyForAccount(ctx, resourceID, resourceType, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterChannel", reflect.TypeOf((*MockCrossChainKeeper)(nil).RegisterChannel), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyForAccount", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyForAccount), ctx, resourceID, resourceType, addr) } -// ForceDeleteAccountPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ForceDeleteAccountPolicyForResource(ctx types2.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { +// GetPolicyForGroup mocks base method. +func (m *MockPermissionKeeper) GetPolicyForGroup(ctx types2.Context, resourceID math.Uint, resourceType resource.ResourceType, groupID math.Uint) (*types0.Policy, bool) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ForceDeleteAccountPolicyForResource", ctx, resourceType, resourceID) - ret0, _ := ret[0].(uint64) + ret := m.ctrl.Call(m, "GetPolicyForGroup", ctx, resourceID, resourceType, groupID) + ret0, _ := ret[0].(*types0.Policy) ret1, _ := ret[1].(bool) return ret0, ret1 } -// ForceDeleteAccountPolicyForResource indicates an expected call of ForceDeleteAccountPolicyForResource. -func (mr *MockPermissionKeeperMockRecorder) ForceDeleteAccountPolicyForResource(ctx, maxDelete, deletedCount, resourceType, resourceID interface{}) *gomock.Call { +// GetPolicyForGroup indicates an expected call of GetPolicyForGroup. +func (mr *MockPermissionKeeperMockRecorder) GetPolicyForGroup(ctx, resourceID, resourceType, groupID interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteAccountPolicyForResource), ctx, maxDelete, deletedCount, resourceType, resourceID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPolicyForGroup", reflect.TypeOf((*MockPermissionKeeper)(nil).GetPolicyForGroup), ctx, resourceID, resourceType, groupID) } -// ForceDeleteGroupPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ForceDeleteGroupPolicyForResource(ctx types2.Context, maxDelete, deletedCount uint64, resourceType resource.ResourceType, resourceID math.Uint) (uint64, bool) { +// PutPolicy mocks base method. +func (m *MockPermissionKeeper) PutPolicy(ctx types2.Context, policy *types0.Policy) (math.Uint, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ForceDeleteGroupPolicyForResource", ctx, resourceType, resourceID) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(bool) + ret := m.ctrl.Call(m, "PutPolicy", ctx, policy) + ret0, _ := ret[0].(math.Uint) + ret1, _ := ret[1].(error) return ret0, ret1 } -// ForceDeleteGroupPolicyForResource indicates an expected call of ForceDeleteGroupPolicyForResource. -func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupPolicyForResource(ctx, maxDelete, deletedCount, resourceType, resourceID interface{}) *gomock.Call { +// PutPolicy indicates an expected call of PutPolicy. +func (mr *MockPermissionKeeperMockRecorder) PutPolicy(ctx, policy interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupPolicyForResource), ctx, maxDelete, deletedCount, resourceType, resourceID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutPolicy", reflect.TypeOf((*MockPermissionKeeper)(nil).PutPolicy), ctx, policy) } -// ForceDeleteGroupMembers mocks base method. -func (m *MockPermissionKeeper) ForceDeleteGroupMembers(ctx types2.Context, maxDelete, deletedCount uint64, groupId math.Uint) (uint64, bool) { +// RemoveGroupMember mocks base method. +func (m *MockPermissionKeeper) RemoveGroupMember(ctx types2.Context, groupID math.Uint, member types2.AccAddress) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ForceDeleteGroupMembers", ctx, groupId) - ret0, _ := ret[0].(uint64) - ret1, _ := ret[1].(bool) - return ret0, ret1 + ret := m.ctrl.Call(m, "RemoveGroupMember", ctx, groupID, member) + ret0, _ := ret[0].(error) + return ret0 } -// ForceDeleteGroupMembers indicates an expected call of ForceDeleteGroupMembers. -func (mr *MockPermissionKeeperMockRecorder) ForceDeleteGroupMembers(ctx, maxDelete, deletedCount, groupId interface{}) *gomock.Call { +// RemoveGroupMember indicates an expected call of RemoveGroupMember. +func (mr *MockPermissionKeeperMockRecorder) RemoveGroupMember(ctx, groupID, member interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceDeleteGroupMembers", reflect.TypeOf((*MockPermissionKeeper)(nil).ForceDeleteGroupMembers), ctx, maxDelete, deletedCount, groupId) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveGroupMember", reflect.TypeOf((*MockPermissionKeeper)(nil).RemoveGroupMember), ctx, groupID, member) } -// ExistAccountPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ExistAccountPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { +// VerifyPolicy mocks base method. +func (m *MockPermissionKeeper) VerifyPolicy(ctx types2.Context, resourceID math.Uint, resourceType resource.ResourceType, operator types2.AccAddress, action types0.ActionType, opts *types0.VerifyOptions) types0.Effect { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExistAccountPolicyForResource", ctx, resourceType, resourceID) - ret0, _ := ret[0].(bool) + ret := m.ctrl.Call(m, "VerifyPolicy", ctx, resourceID, resourceType, operator, action, opts) + ret0, _ := ret[0].(types0.Effect) return ret0 } -// ExistAccountPolicyForResource indicates an expected call of ExistAccountPolicyForResource. -func (mr *MockPermissionKeeperMockRecorder) ExistAccountPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { +// VerifyPolicy indicates an expected call of VerifyPolicy. +func (mr *MockPermissionKeeperMockRecorder) VerifyPolicy(ctx, resourceID, resourceType, operator, action, opts interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistAccountPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistAccountPolicyForResource), ctx, resourceType, resourceID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyPolicy", reflect.TypeOf((*MockPermissionKeeper)(nil).VerifyPolicy), ctx, resourceID, resourceType, operator, action, opts) } -// ExistGroupPolicyForResource mocks base method. -func (m *MockPermissionKeeper) ExistGroupPolicyForResource(ctx types2.Context, resourceType resource.ResourceType, resourceID math.Uint) bool { +// MockCrossChainKeeper is a mock of CrossChainKeeper interface. +type MockCrossChainKeeper struct { + ctrl *gomock.Controller + recorder *MockCrossChainKeeperMockRecorder +} + +// MockCrossChainKeeperMockRecorder is the mock recorder for MockCrossChainKeeper. +type MockCrossChainKeeperMockRecorder struct { + mock *MockCrossChainKeeper +} + +// NewMockCrossChainKeeper creates a new mock instance. +func NewMockCrossChainKeeper(ctrl *gomock.Controller) *MockCrossChainKeeper { + mock := &MockCrossChainKeeper{ctrl: ctrl} + mock.recorder = &MockCrossChainKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockCrossChainKeeper) EXPECT() *MockCrossChainKeeperMockRecorder { + return m.recorder +} + +// CreateRawIBCPackageWithFee mocks base method. +func (m *MockCrossChainKeeper) CreateRawIBCPackageWithFee(ctx types2.Context, channelID types2.ChannelID, packageType types2.CrossChainPackageType, packageLoad []byte, relayerFee, ackRelayerFee *big.Int) (uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExistGroupPolicyForResource", ctx, resourceType, resourceID) - ret0, _ := ret[0].(bool) - return ret0 + ret := m.ctrl.Call(m, "CreateRawIBCPackageWithFee", ctx, channelID, packageType, packageLoad, relayerFee, ackRelayerFee) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// ExistGroupPolicyForResource indicates an expected call of ExistGroupPolicyForResource. -func (mr *MockPermissionKeeperMockRecorder) ExistGroupPolicyForResource(ctx, resourceType, resourceID interface{}) *gomock.Call { +// CreateRawIBCPackageWithFee indicates an expected call of CreateRawIBCPackageWithFee. +func (mr *MockCrossChainKeeperMockRecorder) CreateRawIBCPackageWithFee(ctx, channelID, packageType, packageLoad, relayerFee, ackRelayerFee interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistGroupPolicyForResource", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistGroupPolicyForResource), ctx, resourceType, resourceID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateRawIBCPackageWithFee", reflect.TypeOf((*MockCrossChainKeeper)(nil).CreateRawIBCPackageWithFee), ctx, channelID, packageType, packageLoad, relayerFee, ackRelayerFee) } -// ExistGroupMemberForGroup mocks base method. -func (m *MockPermissionKeeper) ExistGroupMemberForGroup(ctx types2.Context, groupID math.Uint) bool { +// RegisterChannel mocks base method. +func (m *MockCrossChainKeeper) RegisterChannel(name string, id types2.ChannelID, app types2.CrossChainApplication) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ExistGroupMemberForGroup", ctx, groupID) - ret0, _ := ret[0].(bool) + ret := m.ctrl.Call(m, "RegisterChannel", name, id, app) + ret0, _ := ret[0].(error) return ret0 } -// ExistGroupMemberForGroup indicates an expected call of ExistGroupMemberForGroup. -func (mr *MockPermissionKeeperMockRecorder) ExistGroupMemberForGroup(ctx, groupID interface{}) *gomock.Call { +// RegisterChannel indicates an expected call of RegisterChannel. +func (mr *MockCrossChainKeeperMockRecorder) RegisterChannel(name, id, app interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ExistGroupMemberForGroup", reflect.TypeOf((*MockPermissionKeeper)(nil).ExistGroupMemberForGroup), ctx, groupID) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterChannel", reflect.TypeOf((*MockCrossChainKeeper)(nil).RegisterChannel), name, id, app) } From 7eb142a14d290219e2e7d4699eabe2adbf3b1549 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Fri, 16 Jun 2023 15:33:16 +0800 Subject: [PATCH 04/11] fix: update storage discontinue param's default value (#286) --- x/storage/keeper/keeper.go | 10 ++++++---- x/storage/types/params.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 1c6e4d7a7..be0e563ee 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1455,7 +1455,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)) @@ -1463,7 +1463,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 @@ -1471,12 +1471,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 @@ -1485,6 +1485,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/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 From 2d05f86d2a31a7f574f8bafcd8a0f2b4ecad295e Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Fri, 16 Jun 2023 15:33:38 +0800 Subject: [PATCH 05/11] feat: use median store price for secondary sp price (#287) --- e2e/tests/sp_test.go | 15 ++++++++++++--- x/sp/keeper/sp_storage_price.go | 20 ++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/e2e/tests/sp_test.go b/e2e/tests/sp_test.go index 343968a36..3359c035f 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" @@ -277,7 +278,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, @@ -285,11 +286,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/x/sp/keeper/sp_storage_price.go b/x/sp/keeper/sp_storage_price.go index ee1d03165..79297015b 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, From 19487337fecf6468a4b5c6c8c96475295828f88c Mon Sep 17 00:00:00 2001 From: Alexxxxxx <118710506+alexgao001@users.noreply.github.com> Date: Sun, 25 Jun 2023 15:59:19 +0800 Subject: [PATCH 06/11] add missing field to event (#295) --- proto/greenfield/storage/tx.proto | 2 +- x/storage/keeper/keeper.go | 1 + x/storage/types/tx.pb.go | 239 +++++++++++++++--------------- 3 files changed, 121 insertions(+), 121 deletions(-) diff --git a/proto/greenfield/storage/tx.proto b/proto/greenfield/storage/tx.proto index fa092a7cc..2b6ed2d27 100644 --- a/proto/greenfield/storage/tx.proto +++ b/proto/greenfield/storage/tx.proto @@ -287,7 +287,7 @@ message MsgUpdateGroupExtra { // group_name defines the name of the group which to be updated string group_name = 3; // extra defines extra info for the group to update - string Extra = 4; + string extra = 4; } message MsgUpdateGroupExtraResponse {} diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index be0e563ee..8848487a4 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1102,6 +1102,7 @@ func (k Keeper) CreateGroup( GroupId: groupInfo.Id, SourceType: groupInfo.SourceType, Members: opts.Members, + Extra: opts.Extra, }); err != nil { return sdkmath.ZeroUint(), err } diff --git a/x/storage/types/tx.pb.go b/x/storage/types/tx.pb.go index f486dc476..33ad302be 100644 --- a/x/storage/types/tx.pb.go +++ b/x/storage/types/tx.pb.go @@ -1396,7 +1396,7 @@ type MsgUpdateGroupExtra struct { // group_name defines the name of the group which to be updated GroupName string `protobuf:"bytes,3,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` // extra defines extra info for the group to update - Extra string `protobuf:"bytes,4,opt,name=Extra,proto3" json:"Extra,omitempty"` + Extra string `protobuf:"bytes,4,opt,name=extra,proto3" json:"extra,omitempty"` } func (m *MsgUpdateGroupExtra) Reset() { *m = MsgUpdateGroupExtra{} } @@ -2574,130 +2574,129 @@ func init() { func init() { proto.RegisterFile("greenfield/storage/tx.proto", fileDescriptor_ddb71b028305a3cc) } var fileDescriptor_ddb71b028305a3cc = []byte{ - // 1954 bytes of a gzipped FileDescriptorProto + // 1949 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4f, 0x6f, 0x1b, 0xc7, - 0x15, 0xf7, 0x8a, 0x94, 0x2c, 0x3e, 0xca, 0x92, 0xbd, 0x51, 0x2c, 0x86, 0x8e, 0x25, 0x99, 0x01, - 0x12, 0x26, 0xae, 0x49, 0x47, 0x0d, 0x8c, 0x54, 0x87, 0xa0, 0x96, 0x93, 0x16, 0x42, 0xcd, 0x58, + 0x15, 0xf7, 0x8a, 0xb4, 0x2c, 0x3e, 0xca, 0x92, 0xbd, 0x51, 0x2c, 0x86, 0x8e, 0x25, 0x99, 0x01, + 0x12, 0x26, 0xae, 0x49, 0x47, 0x0d, 0x8c, 0x54, 0x87, 0xa0, 0x96, 0xd3, 0x16, 0x42, 0xcd, 0x58, 0x59, 0xda, 0x29, 0x90, 0xa2, 0x60, 0x96, 0xbb, 0xe3, 0xd5, 0x26, 0xdc, 0x9d, 0xed, 0xcc, 0xd2, 0x36, 0x73, 0xec, 0x27, 0x08, 0xd0, 0x1e, 0x7a, 0x28, 0x0c, 0x14, 0xe8, 0xa1, 0xb7, 0x16, 0x45, 0x6e, 0x3d, 0xb4, 0x28, 0x50, 0xc0, 0xe8, 0xc9, 0xc8, 0xa9, 0xe8, 0xc1, 0x0d, 0xec, 0x43, 0xbf, - 0x46, 0xb0, 0x33, 0xb3, 0xbb, 0xb3, 0xff, 0x19, 0x59, 0x42, 0x7c, 0xb2, 0x77, 0xe6, 0x37, 0x6f, - 0xde, 0xff, 0xf7, 0xe6, 0x51, 0x70, 0xc1, 0x22, 0x08, 0xb9, 0x77, 0x6d, 0x34, 0x31, 0xfb, 0xd4, - 0xc7, 0x44, 0xb7, 0x50, 0xdf, 0x7f, 0xd0, 0xf3, 0x08, 0xf6, 0xb1, 0xaa, 0xc6, 0x9b, 0x3d, 0xb1, - 0xd9, 0xde, 0x30, 0x30, 0x75, 0x30, 0xed, 0x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, 0x60, 0x35, 0xca, 0xbd, 0x3f, 0x25, 0x78, 0xea, 0x1d, 0xa9, 0x7c, 0x5f, - 0x04, 0xb0, 0x82, 0xc3, 0xb2, 0xa4, 0x0d, 0xb6, 0xc2, 0x04, 0xdd, 0x81, 0xd3, 0x0e, 0x72, 0xc6, - 0x88, 0x84, 0x52, 0x96, 0x90, 0x14, 0x40, 0x75, 0x1d, 0x16, 0xd1, 0x03, 0x9f, 0xe8, 0x42, 0x3e, - 0xfe, 0x91, 0x2a, 0x1c, 0x07, 0x70, 0x3e, 0xc9, 0x7c, 0xe4, 0xba, 0xd7, 0x60, 0x99, 0x33, 0x34, - 0x9f, 0xe7, 0x9e, 0x66, 0xe0, 0x7d, 0xb3, 0xe3, 0x33, 0x75, 0x70, 0xef, 0xe0, 0xea, 0x38, 0x9a, - 0xed, 0xcb, 0x15, 0x92, 0xb6, 0x52, 0x8b, 0xc9, 0x21, 0xdd, 0x1a, 0xdb, 0x67, 0x81, 0xb9, 0xe4, - 0x1d, 0xcf, 0x0c, 0x45, 0x1c, 0x30, 0xfd, 0x1c, 0x91, 0xad, 0x1f, 0x41, 0x93, 0xb3, 0x85, 0xef, - 0xbb, 0x88, 0x70, 0xbe, 0x4a, 0x0e, 0x72, 0x19, 0x6e, 0x05, 0xd8, 0x94, 0x44, 0xb5, 0xb4, 0x89, - 0xdf, 0x83, 0x55, 0x61, 0xb9, 0x91, 0x8f, 0x83, 0x12, 0x57, 0x59, 0xdc, 0x56, 0x04, 0xfe, 0x36, - 0xbe, 0x6e, 0x9a, 0xea, 0xfb, 0x70, 0x4e, 0x3a, 0x6f, 0x32, 0x55, 0xb0, 0x72, 0x56, 0x46, 0x62, - 0x2d, 0x22, 0xc1, 0x75, 0x97, 0xef, 0xfd, 0x19, 0xe5, 0x45, 0xda, 0xfd, 0x37, 0xaf, 0x74, 0x12, - 0xe0, 0x83, 0xc0, 0xcb, 0x5e, 0x38, 0xe5, 0xae, 0xc3, 0xe2, 0x07, 0x72, 0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, 0x1e, 0xc8, 0x6d, 0x77, 0xc0, 0x7e, 0x21, - 0x50, 0xaf, 0x41, 0x43, 0x9f, 0xfa, 0x87, 0x98, 0x04, 0xea, 0xab, 0xe2, 0x3f, 0x86, 0xaa, 0xef, - 0xc2, 0x12, 0xff, 0x8d, 0x41, 0x64, 0x9b, 0x76, 0x9e, 0xce, 0xf9, 0x1d, 0x7b, 0xf5, 0x40, 0x40, - 0x4d, 0xe0, 0x77, 0x57, 0x03, 0x76, 0x63, 0x4a, 0x42, 0xdd, 0x32, 0x53, 0x21, 0xc3, 0x3b, 0x0f, - 0x55, 0xa8, 0x0d, 0xa8, 0xa5, 0x7e, 0x0a, 0x2b, 0x89, 0x1f, 0x2f, 0x5e, 0xcb, 0xbb, 0x2c, 0x35, - 0x20, 0x6f, 0x5f, 0x9e, 0x03, 0x14, 0x65, 0xae, 0x4f, 0x61, 0x25, 0x31, 0x08, 0x2f, 0xba, 0x41, - 0x06, 0x15, 0xde, 0x90, 0x37, 0xd9, 0x56, 0x27, 0x70, 0x36, 0xd3, 0xb0, 0xbd, 0x51, 0x40, 0x20, - 0x0d, 0x6c, 0xf7, 0xe7, 0x04, 0xca, 0xf2, 0x24, 0x12, 0x4d, 0x91, 0x3c, 0x32, 0xa8, 0x50, 0x9e, - 0xbc, 0x50, 0x50, 0x31, 0x9c, 0xcb, 0x4e, 0xe9, 0xbb, 0x45, 0x1a, 0x49, 0x23, 0xdb, 0x57, 0xe7, - 0x45, 0xca, 0x22, 0x25, 0x3a, 0xaf, 0x72, 0x27, 0xe0, 0xa0, 0x0a, 0x27, 0x48, 0x0d, 0x7a, 0x3e, - 0x01, 0x90, 0xe6, 0x7c, 0x97, 0x0a, 0x8e, 0xc6, 0x90, 0xf6, 0x9b, 0x95, 0x10, 0xd9, 0xfc, 0x99, - 0x49, 0x62, 0x91, 0xf9, 0xd3, 0xc0, 0x42, 0xf3, 0x17, 0x4d, 0xff, 0x02, 0x49, 0xa4, 0xc9, 0x5f, - 0x91, 0x24, 0x31, 0xa4, 0x50, 0x92, 0x9c, 0x71, 0x58, 0x14, 0x2a, 0x15, 0x76, 0x90, 0x41, 0x15, - 0xa1, 0x92, 0xba, 0x81, 0x80, 0x9a, 0xd3, 0x69, 0x17, 0xb2, 0x98, 0x81, 0xb6, 0xdf, 0x9e, 0x1b, - 0x9a, 0x0d, 0x98, 0x0a, 0xa9, 0x64, 0x50, 0x45, 0xc0, 0xa4, 0x6e, 0x48, 0x06, 0x8c, 0xb8, 0x66, - 0x8e, 0x80, 0x11, 0x77, 0x5d, 0x9d, 0x17, 0x99, 0xcd, 0x38, 0x52, 0x99, 0x2e, 0xcf, 0x38, 0x31, - 0xb0, 0x22, 0xe3, 0x64, 0x1b, 0x03, 0xf5, 0x97, 0xd0, 0x94, 0xc7, 0x67, 0x9d, 0xd2, 0xc0, 0x63, - 0x98, 0xf6, 0x5b, 0xd5, 0x18, 0x99, 0xbc, 0x3c, 0x8e, 0xea, 0x94, 0xfa, 0x53, 0x39, 0xf9, 0x9c, - 0x01, 0x53, 0x60, 0x9c, 0xec, 0x70, 0xa9, 0x5b, 0xaa, 0x03, 0x09, 0x59, 0x68, 0x9c, 0xc2, 0x99, - 0x4b, 0x6c, 0x1c, 0x69, 0xde, 0xf2, 0x46, 0x35, 0x15, 0x06, 0xac, 0x30, 0x4e, 0x76, 0xea, 0x11, - 0xe4, 0x03, 0x69, 0xe2, 0x51, 0x94, 0x0f, 0x62, 0x48, 0x61, 0x3e, 0xc8, 0x4e, 0x23, 0x02, 0xcb, - 0xc8, 0xfd, 0x50, 0xa7, 0x34, 0x26, 0xca, 0x2d, 0x93, 0xd3, 0xb4, 0xa8, 0x3f, 0x87, 0x46, 0xfc, - 0x68, 0xdd, 0x2e, 0x38, 0x18, 0x21, 0xda, 0xdd, 0x2a, 0x44, 0x36, 0x8f, 0x09, 0xda, 0xe5, 0x79, - 0x4c, 0x90, 0xbf, 0x3c, 0x07, 0x48, 0xbe, 0x21, 0xd1, 0x6b, 0xbd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x6f, 0x15, 0x10, 0x48, 0x03, 0xdb, 0xfd, 0x39, 0x81, + 0xb2, 0x3c, 0x89, 0x44, 0x53, 0x24, 0x8f, 0x0c, 0x2a, 0x94, 0x27, 0x2f, 0x14, 0x54, 0x0c, 0xe7, + 0xb3, 0x53, 0xfa, 0x6e, 0x91, 0x46, 0xd2, 0xc8, 0xf6, 0xb5, 0x79, 0x91, 0xb2, 0x48, 0x89, 0xce, + 0xab, 0xdc, 0x09, 0x38, 0xa8, 0xc2, 0x09, 0x52, 0x83, 0x9e, 0x4f, 0x01, 0xa4, 0x39, 0xdf, 0xe5, + 0x82, 0xa3, 0x31, 0xa4, 0xfd, 0x76, 0x25, 0x44, 0x36, 0x7f, 0x66, 0x92, 0x58, 0x64, 0xfe, 0x34, + 0xb0, 0xd0, 0xfc, 0x45, 0xd3, 0xbf, 0x40, 0x12, 0x69, 0xf2, 0x57, 0x24, 0x49, 0x0c, 0x29, 0x94, + 0x24, 0x67, 0x1c, 0x16, 0x85, 0x4a, 0x85, 0x1d, 0x64, 0x50, 0x45, 0xa8, 0xa4, 0x6e, 0x20, 0xa0, + 0xe6, 0x74, 0xda, 0x85, 0x2c, 0x66, 0xa0, 0xed, 0x77, 0xe7, 0x86, 0x66, 0x03, 0xa6, 0x42, 0x2a, + 0x19, 0x54, 0x11, 0x30, 0xa9, 0x1b, 0x92, 0x01, 0x23, 0xae, 0x99, 0x23, 0x60, 0xc4, 0x5d, 0xd7, + 0xe6, 0x45, 0x66, 0x33, 0x8e, 0x54, 0xa6, 0xcb, 0x33, 0x4e, 0x0c, 0xac, 0xc8, 0x38, 0xd9, 0xc6, + 0x40, 0xfd, 0x05, 0x34, 0xe5, 0xf1, 0x59, 0xa7, 0x34, 0xf0, 0x18, 0xa6, 0xfd, 0x4e, 0x35, 0x46, + 0x26, 0x2f, 0x8f, 0xa3, 0x3a, 0xa5, 0xfe, 0x54, 0x4e, 0x3e, 0x67, 0xc0, 0x14, 0x18, 0x27, 0x3b, + 0x5c, 0xea, 0x96, 0xea, 0x40, 0x42, 0x16, 0x1a, 0xa7, 0x70, 0xe6, 0x12, 0x1b, 0x47, 0x9a, 0xb7, + 0xbc, 0x55, 0x4d, 0x85, 0x01, 0x2b, 0x8c, 0x93, 0x9d, 0x7a, 0x04, 0xf9, 0x40, 0x9a, 0x78, 0x14, + 0xe5, 0x83, 0x18, 0x52, 0x98, 0x0f, 0xb2, 0xd3, 0x88, 0xc0, 0x32, 0x72, 0x3f, 0xd4, 0x29, 0x8d, + 0x89, 0x72, 0xcb, 0xe4, 0x34, 0x2d, 0xea, 0xcf, 0xa0, 0x11, 0x3f, 0x5a, 0xb7, 0x0a, 0x0e, 0x46, + 0x88, 0x76, 0xb7, 0x0a, 0x91, 0xcd, 0x63, 0x82, 0x76, 0x79, 0x1e, 0x13, 0xe4, 0xaf, 0xcc, 0x01, + 0x92, 0x6f, 0x48, 0xf4, 0x5a, 0x6f, 0x94, 0x9a, 0x8d, 0x83, 0x0a, 0x6f, 0xc8, 0x6b, 0x90, 0x76, + 0xf7, 0x1e, 0x3f, 0xdb, 0x50, 0x9e, 0x3c, 0xdb, 0x50, 0xbe, 0x7d, 0xb6, 0xa1, 0x7c, 0xf5, 0x7c, + 0xe3, 0xd4, 0x93, 0xe7, 0x1b, 0xa7, 0xfe, 0xfd, 0x7c, 0xe3, 0xd4, 0xa7, 0x7d, 0xcb, 0xf6, 0x0f, + 0xa6, 0xe3, 0x9e, 0x81, 0x9d, 0xfe, 0xd8, 0x1d, 0x5f, 0x35, 0x0e, 0x74, 0xdb, 0xed, 0x4b, 0x7f, + 0x29, 0xf2, 0x30, 0xfe, 0x6b, 0x99, 0x99, 0x87, 0xe8, 0x78, 0x91, 0x3d, 0x8d, 0xbf, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x3d, 0x6f, 0x23, 0x50, 0x23, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From edd4e9af3117421e24d7c001ece7970c2ec243d5 Mon Sep 17 00:00:00 2001 From: Raina <1007411869@qq.com> Date: Sun, 25 Jun 2023 19:55:00 +0800 Subject: [PATCH 07/11] feat: allows for setting a custom http client when NewGreenfieldClient (#292) Co-authored-by: reneecok --- go.mod | 16 ++++++++++------ go.sum | 38 ++++++++++++++++++++++++++------------ sdk/client/gnfd_client.go | 26 ++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 76bffc023..4ea36ae86 100644 --- a/go.mod +++ b/go.mod @@ -4,14 +4,14 @@ go 1.19 require ( cosmossdk.io/errors v1.0.0-beta.7 - cosmossdk.io/math v1.0.0 + cosmossdk.io/math v1.0.1 github.com/bits-and-blooms/bitset v1.2.0 github.com/cometbft/cometbft v0.37.1 github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.47.2 github.com/cosmos/go-bip39 v1.0.0 - github.com/cosmos/gogoproto v1.4.8 + github.com/cosmos/gogoproto v1.4.10 github.com/ethereum/go-ethereum v1.10.22 github.com/golang/protobuf v1.5.3 github.com/grpc-ecosystem/grpc-gateway v1.16.0 @@ -24,7 +24,7 @@ require ( github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.8.2 google.golang.org/genproto v0.0.0-20230320184635-7606e756e683 - google.golang.org/grpc v1.54.0 + google.golang.org/grpc v1.55.0 google.golang.org/protobuf v1.30.0 gopkg.in/yaml.v2 v2.4.0 sigs.k8s.io/yaml v1.3.0 @@ -40,6 +40,7 @@ require ( require ( cosmossdk.io/core v0.6.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.3 // indirect + cosmossdk.io/log v1.1.0 // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -83,10 +84,11 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.0.0 // indirect + github.com/golang/glog v1.1.0 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect @@ -115,6 +117,7 @@ require ( github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.18 // indirect github.com/mattn/go-runewidth v0.0.10 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect @@ -136,6 +139,7 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/rs/cors v1.8.3 // indirect + github.com/rs/zerolog v1.29.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sirupsen/logrus v1.9.0 // indirect @@ -160,7 +164,7 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect golang.org/x/crypto v0.8.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/net v0.9.0 // indirect golang.org/x/sys v0.7.0 // indirect golang.org/x/term v0.7.0 // indirect @@ -177,6 +181,6 @@ replace ( github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0 github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-alpha.1 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-0.20230625115018-2d8301b63df1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) diff --git a/go.sum b/go.sum index 1dcb906b1..048f2024e 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= +cosmossdk.io/log v1.1.0 h1:v0ogPHYeTzPcBTcPR1A3j1hkei4pZama8kz8LKlCMv0= +cosmossdk.io/log v1.1.0/go.mod h1:6zjroETlcDs+mm62gd8Ig7mZ+N+fVOZS91V17H+M4N4= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= @@ -161,8 +163,8 @@ github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edY github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/bnb-chain/greenfield-cometbft v0.0.1 h1:pX8S9oZKjWJCrxH07l6rbU3zee9txZ11+UwO9stsNMQ= github.com/bnb-chain/greenfield-cometbft v0.0.1/go.mod h1:9q11eHNRY9FDwFH+4pompzPNGv//Z3VcfvkELaHJPMs= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-alpha.1 h1:wYD0aJOjrra9f2a3CjycpLgRUy4I1Iz6jLdYX2fBo/o= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-alpha.1/go.mod h1:6pVENKv7drpk0k46nuyvAeD1SMnQUuXD9WY0tyc060A= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-0.20230625115018-2d8301b63df1 h1:9Ik/IUDCXmMH3UvEUfK7zVgWLsfZpEipRh5ex4Hl9qk= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-0.20230625115018-2d8301b63df1/go.mod h1:ePxSdTXosDo5YE9TRxqzmXv8T0PH7AVqTfofRf81aRo= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 h1:6fLpmmI0EZvDTfPvI0zy5dBaaTUboHnEkoC5/p/w8TQ= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:rbc4o84RSEvhf09o2+4Qiazsv0snRJLiEZdk17HeIDw= github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 h1:1ZdK+iR1Up02bOa2YTZCml7PBpP//kcdamOcK6aWO/s= @@ -246,6 +248,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= @@ -259,8 +262,8 @@ github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4x github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= -github.com/cosmos/gogoproto v1.4.8 h1:BrHKc6WFZt8+jRV71vKSQE+JrfF+JAnzrKo2VP7wIZ4= -github.com/cosmos/gogoproto v1.4.8/go.mod h1:hnb0DIEWTv+wdNzNcqus5xCQXq5+CXauq1FJuurRfVY= +github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= +github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38= github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= github.com/cosmos/ledger-cosmos-go v0.13.0 h1:ex0CvCxToSR7j5WjrghPu2Bu9sSXKikjnVvUryNnx4s= @@ -432,8 +435,8 @@ github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -448,9 +451,11 @@ github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.3.0+incompatible h1:CaSVZxm5B+7o45rtab4jC2G37WGYX1zQfuU2i6DSvnc= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= @@ -468,8 +473,8 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/gddo v0.0.0-20200528160355-8d077c1d8f4c/go.mod h1:sam69Hju0uq+5uvLJUMDlsKlQ21Vrs1Kd/1YFPNYdOU= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= +github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -938,6 +943,9 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-isatty v0.0.2/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -950,6 +958,7 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -1231,6 +1240,9 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= +github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= @@ -1516,8 +1528,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= +golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1733,6 +1745,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1741,6 +1754,7 @@ golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1968,8 +1982,8 @@ google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/sdk/client/gnfd_client.go b/sdk/client/gnfd_client.go index f924aed7f..31aa07aa3 100644 --- a/sdk/client/gnfd_client.go +++ b/sdk/client/gnfd_client.go @@ -2,8 +2,10 @@ package client import ( _ "encoding/json" + "net/http" "strings" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" sdkclient "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" @@ -144,6 +146,25 @@ type GreenfieldClient struct { // NewGreenfieldClient is used to create a new GreenfieldClient structure. func NewGreenfieldClient(rpcAddr, chainId string, opts ...GreenfieldClientOption) (*GreenfieldClient, error) { + rpcClient, err := sdkclient.NewClientFromNode(rpcAddr) + if err != nil { + return nil, err + } + + return newGreenfieldClient(rpcAddr, chainId, rpcClient, opts...) +} + +// NewCustomGreenfieldClient is used to create a new GreenfieldClient structure, allows for setting a custom http client +func NewCustomGreenfieldClient(rpcAddr, chainId string, customDialer func(string) (*http.Client, error), opts ...GreenfieldClientOption) (*GreenfieldClient, error) { + rpcClient, err := sdkclient.NewCustomClientFromNode(rpcAddr, customDialer) + if err != nil { + return nil, err + } + + return newGreenfieldClient(rpcAddr, chainId, rpcClient, opts...) +} + +func newGreenfieldClient(rpcAddr, chainId string, rpcClient *rpchttp.HTTP, opts ...GreenfieldClientOption) (*GreenfieldClient, error) { cdc := types.Codec() client := &GreenfieldClient{ chainId: chainId, @@ -159,10 +180,7 @@ func NewGreenfieldClient(rpcAddr, chainId string, opts ...GreenfieldClientOption if len(strings.TrimSpace(rpcAddr)) == 0 { return nil, types.RpcAddressNotProvidedError } - rpcClient, err := sdkclient.NewClientFromNode(rpcAddr) - if err != nil { - return nil, err - } + txConfig := authtx.NewTxConfig(cdc, []signing.SignMode{signing.SignMode_SIGN_MODE_EIP_712}) clientCtx := sdkclient.Context{}. WithCodec(cdc). From 0899864500138ca5e7d6da5203c1b8d6a535d4b0 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 26 Jun 2023 10:03:50 +0800 Subject: [PATCH 08/11] fix: ACTION_UPDATE_OBJECT_INFO not allowed to be used on object's bug (#285) --- x/permission/types/types.go | 13 +++++++------ x/storage/keeper/keeper.go | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/x/permission/types/types.go b/x/permission/types/types.go index 0aa36bf05..2eb47303b 100644 --- a/x/permission/types/types.go +++ b/x/permission/types/types.go @@ -36,12 +36,13 @@ var ( ACTION_TYPE_ALL: true, } ObjectAllowedActions = map[ActionType]bool{ - ACTION_CREATE_OBJECT: true, - ACTION_DELETE_OBJECT: true, - ACTION_GET_OBJECT: true, - ACTION_COPY_OBJECT: true, - ACTION_EXECUTE_OBJECT: true, - ACTION_LIST_OBJECT: true, + ACTION_UPDATE_OBJECT_INFO: true, + ACTION_CREATE_OBJECT: true, + ACTION_DELETE_OBJECT: true, + ACTION_GET_OBJECT: true, + ACTION_COPY_OBJECT: true, + ACTION_EXECUTE_OBJECT: true, + ACTION_LIST_OBJECT: true, ACTION_TYPE_ALL: true, } diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 8848487a4..9882ca947 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1056,6 +1056,7 @@ func (k Keeper) UpdateObjectInfo(ctx sdk.Context, operator sdk.AccAddress, bucke BucketName: bucketName, ObjectName: objectName, Visibility: visibility, + ObjectId: objectInfo.Id, }); err != nil { return err } From 9c1e3bdc7d45d413e66392bf8823df5d7a7dce94 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Mon, 26 Jun 2023 13:07:30 +0800 Subject: [PATCH 09/11] feat: limit the interval for updating quota (#288) --- proto/greenfield/storage/params.proto | 2 + x/storage/keeper/keeper.go | 39 +++++++- x/storage/types/errors.go | 1 + x/storage/types/keys.go | 6 ++ x/storage/types/params.go | 15 ++++ x/storage/types/params.pb.go | 125 +++++++++++++++++--------- 6 files changed, 143 insertions(+), 45 deletions(-) diff --git a/proto/greenfield/storage/params.proto b/proto/greenfield/storage/params.proto index a0e8244c1..da7e49111 100644 --- a/proto/greenfield/storage/params.proto +++ b/proto/greenfield/storage/params.proto @@ -38,6 +38,8 @@ message Params { uint64 discontinue_deletion_max = 14; // The max number for deleting policy in each end block uint64 stale_policy_cleanup_max = 15; + // The min interval for making quota smaller in seconds + uint64 min_quota_update_interval = 16; } // VersionedParams defines the parameters for the storage module with multi version, each version store with different timestamp. diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 9882ca947..2dd3b5a5c 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -182,9 +182,9 @@ func (k Keeper) DeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketNam func (k Keeper) doDeleteBucket(ctx sdk.Context, operator sdk.AccAddress, bucketInfo *types.BucketInfo) error { store := ctx.KVStore(k.storeKey) - bucketKey := types.GetBucketKey(bucketInfo.BucketName) - store.Delete(bucketKey) + store.Delete(types.GetBucketKey(bucketInfo.BucketName)) store.Delete(types.GetBucketByIDKey(bucketInfo.Id)) + store.Delete(types.GetQuotaKey(bucketInfo.Id)) if err := k.appendResourceIdForGarbageCollection(ctx, resource.RESOURCE_TYPE_BUCKET, bucketInfo.Id); err != nil { return err @@ -284,6 +284,21 @@ func (k Keeper) UpdateBucketInfo(ctx sdk.Context, operator sdk.AccAddress, bucke // handle fields not changed if opts.ChargedReadQuota == nil { opts.ChargedReadQuota = &bucketInfo.ChargedReadQuota + } else if *opts.ChargedReadQuota != bucketInfo.ChargedReadQuota { + blockTime := uint64(ctx.BlockTime().Unix()) + if *opts.ChargedReadQuota < bucketInfo.ChargedReadQuota { + minInterval := k.GetParams(ctx).MinQuotaUpdateInterval + lastUpdateTime, found := k.getQuotaUpdateTime(ctx, bucketInfo.Id) + if !found { + return types.ErrUpdateQuotaFailed + } + if lastUpdateTime+minInterval > blockTime { + return types.ErrUpdateQuotaFailed.Wrapf("The quota can be updated to a smaller value before %d timestamp", + lastUpdateTime+minInterval) + } + } + // save quota update time + k.setQuotaUpdateTime(ctx, bucketInfo.Id, blockTime) } if opts.Visibility != types.VISIBILITY_TYPE_UNSPECIFIED { @@ -1653,3 +1668,23 @@ func (k Keeper) garbageCollectionForResource(ctx sdk.Context, deleteStalePolicie } return deletedTotal, true } + +func (k Keeper) setQuotaUpdateTime(ctx sdk.Context, bucketId types.Uint, timestamp uint64) { + store := ctx.KVStore(k.storeKey) + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, timestamp) + store.Set(types.GetQuotaKey(bucketId), bz) +} + +func (k Keeper) getQuotaUpdateTime(ctx sdk.Context, bucketId types.Uint) (uint64, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.GetQuotaKey(bucketId)) + if bz != nil { + return binary.BigEndian.Uint64(bz), true + } + bucketInfo, found := k.GetBucketInfoById(ctx, bucketId) + if !found { + return 0, false + } + return uint64(bucketInfo.CreateAt), true +} diff --git a/x/storage/types/errors.go b/x/storage/types/errors.go index bf4f38caf..69b99f8ac 100644 --- a/x/storage/types/errors.go +++ b/x/storage/types/errors.go @@ -25,6 +25,7 @@ var ( ErrInvalidApproval = errors.Register(ModuleName, 1116, "Invalid approval of sp") ErrChargeFailed = errors.Register(ModuleName, 1117, "charge failed error") ErrInvalidVisibility = errors.Register(ModuleName, 1118, "Invalid type of visibility") + ErrUpdateQuotaFailed = errors.Register(ModuleName, 1119, "Update quota failed") ErrNoSuchPolicy = errors.Register(ModuleName, 1120, "No such Policy") ErrInvalidParameter = errors.Register(ModuleName, 1121, "Invalid parameter") diff --git a/x/storage/types/keys.go b/x/storage/types/keys.go index 4b0f3e0ac..05d7c6c96 100644 --- a/x/storage/types/keys.go +++ b/x/storage/types/keys.go @@ -35,6 +35,7 @@ var ( BucketPrefix = []byte{0x11} ObjectPrefix = []byte{0x12} GroupPrefix = []byte{0x13} + QuotaPrefix = []byte{0x14} BucketByIDPrefix = []byte{0x21} ObjectByIDPrefix = []byte{0x22} @@ -133,3 +134,8 @@ func GetDeleteStalePoliciesKey(height int64) []byte { binary.BigEndian.PutUint64(bz, uint64(height)) return append(DeleteStalePoliciesPrefix, bz...) } + +// GetQuotaKey return the quota store key +func GetQuotaKey(bucketId math.Uint) []byte { + return append(QuotaPrefix, sequence.EncodeSequence(bucketId)...) +} diff --git a/x/storage/types/params.go b/x/storage/types/params.go index 11c9bce8e..e62d84071 100644 --- a/x/storage/types/params.go +++ b/x/storage/types/params.go @@ -23,6 +23,7 @@ const ( DefaultDiscontinueConfirmPeriod int64 = 604800 // 7 days (in second) DefaultDiscontinueDeletionMax uint64 = 100 DefaultStalePolicyCleanupMax uint64 = 200 + DefaultMinUpdateQuotaInterval uint64 = 2592000 // 30 days (in second) DefaultMirrorBucketRelayerFee = "250000000000000" // 0.00025 DefaultMirrorBucketAckRelayerFee = "250000000000000" // 0.00025 @@ -45,6 +46,7 @@ var ( KeyDiscontinueConfirmPeriod = []byte("DiscontinueConfirmPeriod") KeyDiscontinueDeletionMax = []byte("DiscontinueDeletionMax") KeyStalePolicyCleanupMax = []byte("StalePolicyCleanupMax") + KeyMinUpdateQuotaInterval = []byte("MinUpdateQuotaInterval") KeyMirrorBucketRelayerFee = []byte("MirrorBucketRelayerFee") KeyMirrorBucketAckRelayerFee = []byte("MirrorBucketAckRelayerFee") KeyMirrorObjectRelayerFee = []byte("MirrorObjectRelayerFee") @@ -71,6 +73,7 @@ func NewParams( discontinueConfirmPeriod int64, discontinueDeletionMax uint64, stalePoliesCleanupMax uint64, + minUpdateQuotaInterval uint64, ) Params { return Params{ VersionedParams: VersionedParams{ @@ -93,6 +96,7 @@ func NewParams( DiscontinueConfirmPeriod: discontinueConfirmPeriod, DiscontinueDeletionMax: discontinueDeletionMax, StalePolicyCleanupMax: stalePoliesCleanupMax, + MinQuotaUpdateInterval: minUpdateQuotaInterval, } } @@ -106,6 +110,7 @@ func DefaultParams() Params { DefaultMirrorGroupRelayerFee, DefaultMirrorGroupAckRelayerFee, DefaultDiscontinueCountingWindow, DefaultDiscontinueObjectMax, DefaultDiscontinueBucketMax, DefaultDiscontinueConfirmPeriod, DefaultDiscontinueDeletionMax, DefaultStalePolicyCleanupMax, + DefaultMinUpdateQuotaInterval, ) } @@ -131,6 +136,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyDiscontinueConfirmPeriod, &p.DiscontinueConfirmPeriod, validateDiscontinueConfirmPeriod), paramtypes.NewParamSetPair(KeyDiscontinueDeletionMax, &p.DiscontinueDeletionMax, validateDiscontinueDeletionMax), paramtypes.NewParamSetPair(KeyStalePolicyCleanupMax, &p.StalePolicyCleanupMax, validateStalePolicyCleanupMax), + paramtypes.NewParamSetPair(KeyMinUpdateQuotaInterval, &p.MinQuotaUpdateInterval, validateMinUpdateQuotaInterval), } } @@ -391,3 +397,12 @@ func validateStalePolicyCleanupMax(i interface{}) error { } return nil } + +func validateMinUpdateQuotaInterval(i interface{}) error { + _, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + return nil +} diff --git a/x/storage/types/params.pb.go b/x/storage/types/params.pb.go index 399e07c41..1a3fc0d9d 100644 --- a/x/storage/types/params.pb.go +++ b/x/storage/types/params.pb.go @@ -54,6 +54,8 @@ type Params struct { DiscontinueDeletionMax uint64 `protobuf:"varint,14,opt,name=discontinue_deletion_max,json=discontinueDeletionMax,proto3" json:"discontinue_deletion_max,omitempty"` // The max number for deleting policy in each end block StalePolicyCleanupMax uint64 `protobuf:"varint,15,opt,name=stale_policy_cleanup_max,json=stalePolicyCleanupMax,proto3" json:"stale_policy_cleanup_max,omitempty"` + // The min interval for making quota smaller in seconds + MinQuotaUpdateInterval uint64 `protobuf:"varint,16,opt,name=min_quota_update_interval,json=minQuotaUpdateInterval,proto3" json:"min_quota_update_interval,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -193,6 +195,13 @@ func (m *Params) GetStalePolicyCleanupMax() uint64 { return 0 } +func (m *Params) GetMinQuotaUpdateInterval() uint64 { + if m != nil { + return m.MinQuotaUpdateInterval + } + return 0 +} + // VersionedParams defines the parameters for the storage module with multi version, each version store with different timestamp. type VersionedParams struct { // max_segment_size is the maximum size of a segment. default: 16M @@ -273,49 +282,50 @@ func init() { func init() { proto.RegisterFile("greenfield/storage/params.proto", fileDescriptor_127b8b1511d84eca) } var fileDescriptor_127b8b1511d84eca = []byte{ - // 657 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0x4d, 0x4f, 0xdb, 0x4e, - 0x10, 0xc6, 0xe3, 0x3f, 0xf9, 0x43, 0x59, 0x1a, 0x82, 0x2c, 0x5e, 0x0c, 0x6d, 0x43, 0x44, 0xa5, - 0x2a, 0x97, 0x26, 0x52, 0x5f, 0x44, 0xdf, 0x84, 0x0a, 0x41, 0xad, 0x7a, 0xa0, 0x8d, 0x42, 0x45, - 0xa5, 0x5e, 0x56, 0x1b, 0x7b, 0x70, 0xb6, 0xb1, 0x77, 0xad, 0xf5, 0x1a, 0x1c, 0x3e, 0x45, 0x2f, - 0x95, 0x7a, 0xec, 0xc7, 0xe1, 0xc8, 0xb1, 0xa7, 0xb6, 0x82, 0x2f, 0x52, 0x79, 0xd6, 0x0d, 0x36, - 0x70, 0xb3, 0xe6, 0x79, 0x7e, 0xfb, 0x8c, 0x67, 0x35, 0x4b, 0xd6, 0x7d, 0x05, 0x20, 0x0e, 0x39, - 0x04, 0x5e, 0x27, 0xd6, 0x52, 0x31, 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 0x37, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x69, 0xb0, 0xdc, 0x18, 0x05, 0x00, - 0x00, + // 687 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0x4d, 0x4f, 0xdb, 0x4a, + 0x14, 0x86, 0xe3, 0x4b, 0x2e, 0x5c, 0x86, 0x1b, 0x82, 0x2c, 0x3e, 0x0c, 0xf7, 0x36, 0x44, 0x54, + 0xaa, 0xb2, 0x69, 0x22, 0xf5, 0x43, 0xf4, 0x4b, 0xa8, 0x10, 0xd4, 0x8a, 0x45, 0xdb, 0xd4, 0xb4, + 0x54, 0xea, 0x66, 0x34, 0xb1, 0x0f, 0xce, 0x34, 0xf6, 0x8c, 0x3b, 0x1e, 0x43, 0xc2, 0xaf, 0xe8, + 0xb2, 0xcb, 0xfe, 0x1c, 0x96, 0x2c, 0xbb, 0x6a, 0x2b, 0xf8, 0x23, 0x95, 0xcf, 0xb8, 0xc1, 0x06, + 0x76, 0xd6, 0x79, 0xdf, 0x67, 0xde, 0x33, 0x33, 0x3e, 0x43, 0xd6, 0x03, 0x05, 0x20, 0x0e, 0x39, + 0x84, 0x7e, 0x27, 0xd1, 0x52, 0xb1, 0x00, 0x3a, 0x31, 0x53, 0x2c, 0x4a, 0xda, 0xb1, 0x92, 0x5a, + 0xda, 0xf6, 0xa5, 0xa1, 0x9d, 0x1b, 0xd6, 0x16, 0x03, 0x19, 0x48, 0x94, 0x3b, 0xd9, 0x97, 0x71, + 0x6e, 0x9c, 0xcd, 0x90, 0xe9, 0x1e, 0xa2, 0xf6, 0x3b, 0xb2, 0x70, 0x04, 0x2a, 0xe1, 0x52, 0x80, + 0x4f, 0xcd, 0x72, 0x8e, 0xd5, 0xb4, 0x5a, 0x73, 0xf7, 0x6e, 0xb7, 0xaf, 0xaf, 0xd7, 0x3e, 0xf8, + 0xe3, 0x35, 0xf8, 0x4e, 0xf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x44, 0x20, 0xb4, 0x99, 0x42, 0x6b, 0x32, 0x85, 0xfb, 0xa6, 0x8c, 0x53, 0xb8, 0x49, 0x1c, 0x05, + 0x7e, 0x2a, 0x7c, 0x26, 0x34, 0xf5, 0x99, 0x66, 0xd4, 0x1b, 0xa4, 0x62, 0x48, 0x45, 0x1a, 0xe1, + 0xdc, 0xd6, 0xdc, 0xa5, 0x89, 0xbe, 0xcb, 0x34, 0xeb, 0x66, 0xea, 0xeb, 0x34, 0xb2, 0x9f, 0x92, + 0xb5, 0x4b, 0x30, 0x66, 0x8a, 0xeb, 0x71, 0x01, 0x9d, 0x42, 0x74, 0x65, 0xe2, 0xe8, 0xa1, 0x61, + 0x02, 0xdf, 0x21, 0xf5, 0x6c, 0xd3, 0xde, 0x80, 0xa9, 0x00, 0x4c, 0x7b, 0x55, 0x6c, 0xaf, 0x16, + 0x71, 0xd1, 0xc5, 0x6a, 0xd6, 0x9d, 0xd9, 0xe1, 0xce, 0xde, 0xe9, 0x79, 0xc3, 0x3a, 0x3b, 0x6f, + 0x58, 0xbf, 0xce, 0x1b, 0xd6, 0x97, 0x8b, 0x46, 0xe5, 0xec, 0xa2, 0x51, 0xf9, 0x7e, 0xd1, 0xa8, + 0x7c, 0xec, 0x04, 0x5c, 0x0f, 0xd2, 0x7e, 0xdb, 0x93, 0x51, 0xa7, 0x2f, 0xfa, 0x77, 0xbd, 0x01, + 0xe3, 0xa2, 0x53, 0x78, 0x2e, 0x47, 0x93, 0x07, 0x53, 0x8f, 0x63, 0x48, 0xfa, 0xd3, 0xf8, 0x0c, + 0xde, 0xff, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xde, 0x9a, 0xf5, 0x53, 0x05, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -338,6 +348,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MinQuotaUpdateInterval != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MinQuotaUpdateInterval)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 + } if m.StalePolicyCleanupMax != 0 { i = encodeVarintParams(dAtA, i, uint64(m.StalePolicyCleanupMax)) i-- @@ -543,6 +560,9 @@ func (m *Params) Size() (n int) { if m.StalePolicyCleanupMax != 0 { n += 1 + sovParams(uint64(m.StalePolicyCleanupMax)) } + if m.MinQuotaUpdateInterval != 0 { + n += 2 + sovParams(uint64(m.MinQuotaUpdateInterval)) + } return n } @@ -979,6 +999,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinQuotaUpdateInterval", wireType) + } + m.MinQuotaUpdateInterval = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinQuotaUpdateInterval |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) From 5d3de69c065b534d635f3c4145fa51214543dec6 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Mon, 26 Jun 2023 14:27:25 +0800 Subject: [PATCH 10/11] feat: refine payment and update default parameter (#297) --- x/sp/types/params.go | 6 +++--- x/storage/keeper/keeper.go | 13 ++++++++----- x/storage/keeper/payment.go | 3 ++- x/storage/types/types.go | 6 ------ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/x/sp/types/params.go b/x/sp/types/params.go index 273309622..16e53d4b6 100644 --- a/x/sp/types/params.go +++ b/x/sp/types/params.go @@ -14,15 +14,15 @@ import ( // SP params default values const ( - // Dafault deposit denom + // Default deposit denom DefaultDepositDenom = "BNB" ) var ( // DefaultMinDeposit defines the minimum deposit amount for all storage provider DefaultMinDeposit = math.NewIntFromBigInt(new(big.Int).Mul(big.NewInt(10000), big.NewInt(1e18))) - // DefaultSecondarySpStorePriceRatio is 65% - DefaultSecondarySpStorePriceRatio = sdk.NewDecFromIntWithPrec(sdk.NewInt(65), 2) + // DefaultSecondarySpStorePriceRatio is 12% + DefaultSecondarySpStorePriceRatio = sdk.NewDecFromIntWithPrec(sdk.NewInt(12), 2) ) var ( diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 2dd3b5a5c..043f62c53 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -472,10 +472,13 @@ func (k Keeper) CreateObject( return sdkmath.ZeroUint(), errors.Wrapf(types.ErrInvalidApproval, "The approval of sp is expired.") } - err := k.VerifySPAndSignature(ctx, sdk.MustAccAddressFromHex(bucketInfo.PrimarySpAddress), opts.ApprovalMsgBytes, - opts.PrimarySpApproval.Sig) - if err != nil { - return sdkmath.ZeroUint(), err + var err error + if !ctx.IsCheckTx() { // no signature verification for simulation + err = k.VerifySPAndSignature(ctx, sdk.MustAccAddressFromHex(bucketInfo.PrimarySpAddress), opts.ApprovalMsgBytes, + opts.PrimarySpApproval.Sig) + if err != nil { + return sdkmath.ZeroUint(), err + } } objectKey := types.GetObjectKey(bucketName, objectName) @@ -530,7 +533,7 @@ func (k Keeper) CreateObject( store.Set(objectKey, sequence.EncodeSequence(objectInfo.Id)) store.Set(types.GetObjectByIDKey(objectInfo.Id), obz) - if err := ctx.EventManager().EmitTypedEvents(&types.EventCreateObject{ + if err = ctx.EventManager().EmitTypedEvents(&types.EventCreateObject{ Creator: operator.String(), Owner: objectInfo.Owner, BucketName: bucketInfo.BucketName, diff --git a/x/storage/keeper/payment.go b/x/storage/keeper/payment.go index 39e460964..75e8a7c8d 100644 --- a/x/storage/keeper/payment.go +++ b/x/storage/keeper/payment.go @@ -311,7 +311,8 @@ func (k Keeper) GetObjectLockFee(ctx sdk.Context, primarySpAddress string, price if err != nil { return amount, fmt.Errorf("get charge size error: %w", err) } - rate := price.PrimaryStorePrice.Add(price.SecondaryStorePrice.MulInt64(storagetypes.SecondarySPNum)).MulInt(sdkmath.NewIntFromUint64(chargeSize)).TruncateInt() + secondarySPNum := int64(k.GetExpectSecondarySPNumForECObject(ctx)) + rate := price.PrimaryStorePrice.Add(price.SecondaryStorePrice.MulInt64(secondarySPNum)).MulInt(sdkmath.NewIntFromUint64(chargeSize)).TruncateInt() versionedParams, err := k.paymentKeeper.GetVersionedParamsWithTs(ctx, priceTime) if err != nil { return amount, fmt.Errorf("get versioned reserve time error: %w", err) diff --git a/x/storage/types/types.go b/x/storage/types/types.go index c5b0f7469..9fd708905 100644 --- a/x/storage/types/types.go +++ b/x/storage/types/types.go @@ -7,12 +7,6 @@ import ( sdkmath "cosmossdk.io/math" ) -const ( - SecondarySPNum = 6 - // MinChargeSize is the minimum size to charge for a storage object - MinChargeSize = 1024 -) - type ( Int = sdkmath.Int Uint = sdkmath.Uint From 74f66072e45d21b68373e9ac00db55937a9aee2d Mon Sep 17 00:00:00 2001 From: randyahx <62416962+randyahx@users.noreply.github.com> Date: Mon, 26 Jun 2023 14:00:43 +0700 Subject: [PATCH 11/11] release: draft release for v0.2.3-alpha.1 (#298) --- CHANGELOG.md | 40 +++++++++++++++++++++++++++++++++++++++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfc0eef56..c063b2998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,43 @@ # Changelog +## v0.2.3-alpha.1 +This release enables several features and bugfixes: + +Features +* [#281](https://github.com/bnb-chain/greenfield/pull/281) feat: add versioned parameters to payment module +* [#287](https://github.com/bnb-chain/greenfield/pull/287) feat: use median store price for secondary sp price +* [#292](https://github.com/bnb-chain/greenfield/pull/292) feat: allows for setting a custom http client when NewGreenfieldClient +* [#288](https://github.com/bnb-chain/greenfield/pull/288) feat: limit the interval for updating quota +* [#297](https://github.com/bnb-chain/greenfield/pull/297) feat: refine payment and update default parameter + +Bugfixes +* [#279](https://github.com/bnb-chain/greenfield/pull/279) fix: fix the security issues +* [#280](https://github.com/bnb-chain/greenfield/pull/280) fix: update go.mod to be compatible with ignite +* [#286](https://github.com/bnb-chain/greenfield/pull/286) fix: update storage discontinue param's default value +* [#295](https://github.com/bnb-chain/greenfield/pull/295) add missing field to event +* [#285](https://github.com/bnb-chain/greenfield/pull/285) fix: ACTION_UPDATE_OBJECT_INFO not allowed to be used on object's bug + +## v0.2.2 +This release enables several features and some bugfix: + +Features +* [#249](https://github.com/bnb-chain/greenfield/pull/249) feat: support multiple messages in single tx for EIP712 +* [#250](https://github.com/bnb-chain/greenfield/pull/250) feat: allow mirror bucket/object/group using name +* [#268](https://github.com/bnb-chain/greenfield/pull/268) feat: record challenge attestation result +* [#276](https://github.com/bnb-chain/greenfield/pull/276) feat: allow user to pass keyManager into Txopt + +Bugfix +* [#248](https://github.com/bnb-chain/greenfield/pull/248) fix: add versioned params e2e's test +* [#252](https://github.com/bnb-chain/greenfield/pull/252) fix: remove paramsclient from sdk and swagger +* [#254](https://github.com/bnb-chain/greenfield/pull/254) fix: fix potential int64 multiplication overflow +* [#255](https://github.com/bnb-chain/greenfield/pull/255) fix: verify permission openapi params +* [#263](https://github.com/bnb-chain/greenfield/pull/263) fix: QueryGetSecondarySpStorePriceByTime may wrong data +* [#267](https://github.com/bnb-chain/greenfield/pull/267) chore: update swagger +* [#271](https://github.com/bnb-chain/greenfield/pull/271) fix: check every module's Msg +* [#270](https://github.com/bnb-chain/greenfield/pull/270) fix: sp check when reject seal object +* [#269](https://github.com/bnb-chain/greenfield/pull/269) fix: fix wrong link in readme +* [#274](https://github.com/bnb-chain/greenfield/pull/274) fix: add sp address check when deposit + ## v0.2.2-alpha.2 This release enables 2 features: @@ -16,7 +54,7 @@ This release enables 2 features: ## v0.2.1-alpha.1 -This release enable two features: +This release[CHANGELOG.md](CHANGELOG.md) enable two features: - support multiple messages in single tx - allow mirror bucket/object/group using name diff --git a/go.mod b/go.mod index 4ea36ae86..58e365c17 100644 --- a/go.mod +++ b/go.mod @@ -181,6 +181,6 @@ replace ( github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0 github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-0.20230625115018-2d8301b63df1 + github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) diff --git a/go.sum b/go.sum index 048f2024e..5e9b4b971 100644 --- a/go.sum +++ b/go.sum @@ -163,8 +163,8 @@ github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edY github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/bnb-chain/greenfield-cometbft v0.0.1 h1:pX8S9oZKjWJCrxH07l6rbU3zee9txZ11+UwO9stsNMQ= github.com/bnb-chain/greenfield-cometbft v0.0.1/go.mod h1:9q11eHNRY9FDwFH+4pompzPNGv//Z3VcfvkELaHJPMs= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-0.20230625115018-2d8301b63df1 h1:9Ik/IUDCXmMH3UvEUfK7zVgWLsfZpEipRh5ex4Hl9qk= -github.com/bnb-chain/greenfield-cosmos-sdk v0.2.2-0.20230625115018-2d8301b63df1/go.mod h1:ePxSdTXosDo5YE9TRxqzmXv8T0PH7AVqTfofRf81aRo= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.1 h1:woVNr3N+h/dY7sTZaKscTHARJv4RHLh0+qhniqkF734= +github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3-alpha.1/go.mod h1:ePxSdTXosDo5YE9TRxqzmXv8T0PH7AVqTfofRf81aRo= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9 h1:6fLpmmI0EZvDTfPvI0zy5dBaaTUboHnEkoC5/p/w8TQ= github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9/go.mod h1:rbc4o84RSEvhf09o2+4Qiazsv0snRJLiEZdk17HeIDw= github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9 h1:1ZdK+iR1Up02bOa2YTZCml7PBpP//kcdamOcK6aWO/s=