From 243e67bb6c31ac3cf5e7f8fd38c5fe0860ffcbaf Mon Sep 17 00:00:00 2001 From: dreamer Date: Thu, 18 Apr 2024 17:37:33 +0800 Subject: [PATCH] the cosmos-sdk version has been rolled back to v0.47.9 --- go.mod | 2 +- go.sum | 4 ++-- modules/farm/keeper/proposal_hook.go | 36 +++++++++------------------- modules/farm/types/genesis.go | 18 +++----------- modules/farm/types/params.go | 13 ++++------ modules/service/types/params.go | 28 ++++++++-------------- 6 files changed, 32 insertions(+), 69 deletions(-) diff --git a/go.mod b/go.mod index 7c1ad6d4..a4a32fc6 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/cometbft/cometbft v0.37.4 github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-proto v1.0.0-beta.4 - github.com/cosmos/cosmos-sdk v0.47.9-ics-lsm + github.com/cosmos/cosmos-sdk v0.47.9 github.com/cosmos/gogoproto v1.4.10 github.com/ethereum/go-ethereum v1.10.26 github.com/golang/protobuf v1.5.3 diff --git a/go.sum b/go.sum index 07db6765..81ca75e7 100644 --- a/go.sum +++ b/go.sum @@ -334,8 +334,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU= github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co= -github.com/cosmos/cosmos-sdk v0.47.9-ics-lsm h1:IBZd1wBRSqlqrls+YzzQfR67HWBFLXyTqH6zwEsVpKU= -github.com/cosmos/cosmos-sdk v0.47.9-ics-lsm/go.mod h1:Vks1CurTEJIWcjLkXZ4hLpdXsnVRRBmBRr6tygK9vHc= +github.com/cosmos/cosmos-sdk v0.47.9 h1:D51VLkF59D53PMLsbNtp6JyWR+6MbetFyomrH88+y08= +github.com/cosmos/cosmos-sdk v0.47.9/go.mod h1:cmAawe8FV/52oPKbgeHLt4UpNkrNu8R5KD+kw0kxJFc= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= diff --git a/modules/farm/keeper/proposal_hook.go b/modules/farm/keeper/proposal_hook.go index eaed5bb7..0d8bbffe 100644 --- a/modules/farm/keeper/proposal_hook.go +++ b/modules/farm/keeper/proposal_hook.go @@ -4,8 +4,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - - "github.com/irisnet/irismod/modules/farm/types" ) var _ govtypes.GovHooks = GovHook{} @@ -22,61 +20,49 @@ func NewGovHook(k Keeper) GovHook { return GovHook{k} } -// AfterProposalFailedMinDeposit callback when the proposal is deleted due to insufficient collateral -func (h GovHook) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) error { +//AfterProposalFailedMinDeposit callback when the proposal is deleted due to insufficient collateral +func (h GovHook) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) { info, has := h.k.GetEscrowInfo(ctx, proposalID) if !has { - return types.ErrEscrowInfoNotFound + return } //execute refund logic h.k.refundEscrow(ctx, info) - return nil } -// AfterProposalVotingPeriodEnded callback when proposal voting is complete -func (h GovHook) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) error { +//AfterProposalVotingPeriodEnded callback when proposal voting is complete +func (h GovHook) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) { info, has := h.k.GetEscrowInfo(ctx, proposalID) if !has { - return types.ErrEscrowInfoNotFound + return } proposal, has := h.k.gk.GetProposal(ctx, proposalID) if !has { - return types.ErrInvalidProposal + return } //when the proposal is passed, the content of the proposal is executed by the gov module, which is not directly processed here if proposal.Status == v1.StatusPassed { h.k.deleteEscrowInfo(ctx, proposalID) - return types.ErrInvalidProposal + return } //when the proposal is not passed,execute refund logic h.k.refundEscrow(ctx, info) - - return nil } // AfterProposalSubmission description of the Go function. // // Takes in sdk.Context and uint64 as parameters. -// Returns an error. -func (h GovHook) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) error { - return nil -} +func (h GovHook) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) {} // AfterProposalDeposit is a function that... // // takes in ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress. -// Returns an error. -func (h GovHook) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) error { - return nil -} +func (h GovHook) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) {} // AfterProposalVote is a Go function. // // It takes parameters ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress. -// It returns an error. -func (h GovHook) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) error { - return nil -} +func (h GovHook) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) {} diff --git a/modules/farm/types/genesis.go b/modules/farm/types/genesis.go index 4e35fbbd..1b6185a7 100644 --- a/modules/farm/types/genesis.go +++ b/modules/farm/types/genesis.go @@ -6,16 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - defaultGenesisState = GenesisState{ - Params: Params{ - PoolCreationFee: DefaultPoolCreationFee, - TaxRate: DefaulttTaxRate, - MaxRewardCategories: DefaultMaxRewardCategories, - }, - } -) - // NewGenesisState constructs a new GenesisState instance func NewGenesisState(params Params, pools []FarmPool, farmInfos []FarmInfo, sequence uint64, escrow []EscrowInfo) *GenesisState { return &GenesisState{ @@ -25,11 +15,9 @@ func NewGenesisState(params Params, pools []FarmPool, farmInfos []FarmInfo, sequ // DefaultGenesisState gets the default genesis state for testing func DefaultGenesisState() *GenesisState { - return &defaultGenesisState -} - -func SetDefaultGenesisState(state GenesisState) { - defaultGenesisState = state + return &GenesisState{ + Params: DefaultParams(), + } } // ValidateGenesis validates the provided farm genesis state to ensure the diff --git a/modules/farm/types/params.go b/modules/farm/types/params.go index d6ff9475..72818e58 100644 --- a/modules/farm/types/params.go +++ b/modules/farm/types/params.go @@ -8,13 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// Farm params default values -var ( - DefaultPoolCreationFee = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)) // 5000stake - DefaulttTaxRate = sdk.NewDecWithPrec(4, 1) // 0.4 (40%) - DefaultMaxRewardCategories = uint32(2) -) - // NewParams creates a new Params instance func NewParams(createPoolFee sdk.Coin, maxRewardCategories uint32, taxRate sdk.Dec) Params { return Params{ @@ -26,7 +19,11 @@ func NewParams(createPoolFee sdk.Coin, maxRewardCategories uint32, taxRate sdk.D // DefaultParams returns a default set of parameters. func DefaultParams() Params { - return NewParams(DefaultPoolCreationFee, DefaultMaxRewardCategories, DefaulttTaxRate) + return NewParams( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), + 2, + sdk.NewDecWithPrec(4, 1) , + ) } // Validate validates a set of params diff --git a/modules/service/types/params.go b/modules/service/types/params.go index 45320525..020527b3 100644 --- a/modules/service/types/params.go +++ b/modules/service/types/params.go @@ -11,23 +11,13 @@ import ( // Service params default values var ( - DefaultMaxRequestTimeout = int64(100) - DefaultMinDepositMultiple = int64(1000) - DefaultMinDeposit = sdk.NewCoins( - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), - ) // 5000stake - DefaultServiceFeeTax = sdk.NewDecWithPrec( - 5, - 2, - ) // 5% - DefaultSlashFraction = sdk.NewDecWithPrec( - 1, - 3, - ) // 0.1% - DefaultComplaintRetrospect = 15 * 24 * time.Hour // 15 days - DefaultArbitrationTimeLimit = 5 * 24 * time.Hour // 5 days + DefaultMaxRequestTimeout = int64(100) + DefaultMinDepositMultiple = int64(1000) + DefaultServiceFeeTax = sdk.NewDecWithPrec(5, 2) // 5% + DefaultSlashFraction = sdk.NewDecWithPrec(1, 3) // 0.1% + DefaultComplaintRetrospect = 15 * 24 * time.Hour // 15 days + DefaultArbitrationTimeLimit = 5 * 24 * time.Hour // 5 days DefaultTxSizeLimit = uint64(4000) - DefaultBaseDenom = sdk.DefaultBondDenom DefaultRestrictedServiceFeeDenom = false ) @@ -63,13 +53,15 @@ func DefaultParams() Params { return NewParams( DefaultMaxRequestTimeout, DefaultMinDepositMultiple, - DefaultMinDeposit, + sdk.NewCoins( + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), + ), DefaultServiceFeeTax, DefaultSlashFraction, DefaultComplaintRetrospect, DefaultArbitrationTimeLimit, DefaultTxSizeLimit, - DefaultBaseDenom, + sdk.DefaultBondDenom, DefaultRestrictedServiceFeeDenom, ) }