Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: rolled back the cosmos-sdk version to v0.47.9 #405

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions contracts/erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"github.com/irisnet/irismod/contracts"
)


func TestERC20(t *testing.T) {
for k,v := range contracts.ERC20TokenContract.ABI.Events {
t.Logf("event:%s ,id: %s", k,v.ID)
for k, v := range contracts.ERC20TokenContract.ABI.Events {
t.Logf("event:%s ,id: %s", k, v.ID)
}
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
34 changes: 9 additions & 25 deletions modules/farm/keeper/proposal_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ package keeper

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{}

// GovHook implements govtypes.GovHooks
type GovHook struct {
k Keeper
Expand All @@ -23,60 +18,49 @@ func NewGovHook(k Keeper) GovHook {
}

// AfterProposalFailedMinDeposit callback when the proposal is deleted due to insufficient collateral
func (h GovHook) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) error {
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 {
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) {}
18 changes: 3 additions & 15 deletions modules/farm/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down
13 changes: 5 additions & 8 deletions modules/farm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down
28 changes: 10 additions & 18 deletions modules/service/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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,
)
}
Expand Down
1 change: 0 additions & 1 deletion modules/token/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ type TokenOutputs struct {

TokenKeeper keeper.Keeper
Module appmodule.AppModule

}

// ProvideModule provides a module for the token with the given inputs and returns the token keeper and module.
Expand Down
2 changes: 1 addition & 1 deletion modules/token/keeper/erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (suite *KeeperTestSuite) TestSwapToERC20() {
sender := token.GetOwner()
receiver := common.BytesToAddress(sender.Bytes())

balanceBefore := suite.bk.GetBalance(suite.ctx, sender,token.MinUnit)
balanceBefore := suite.bk.GetBalance(suite.ctx, sender, token.MinUnit)
suite.Run("swap to erc20", func() {
amount := sdk.NewCoin(token.MinUnit, sdk.NewInt(1e18))

Expand Down
4 changes: 2 additions & 2 deletions modules/token/keeper/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (k Keeper) CallEVM(
method string,
args ...interface{},
) (*types.Result, error) {
data, err := contractABI.Pack(method, args...)
data, err := contractABI.Pack(method, args...)
if err != nil {
return nil, errorsmod.Wrap(
tokentypes.ErrABIPack,
Expand Down Expand Up @@ -123,4 +123,4 @@ func (k Keeper) CallEVMWithData(
}

return res, nil
}
}
8 changes: 4 additions & 4 deletions modules/token/keeper/evm_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (hook erc20Hook) PostTxProcessing(ctx sdk.Context, msg core.Message, receip

if len(eventArgs) != 3 {
return errorsmod.Wrapf(
types.ErrInvalidContract,
types.ErrInvalidContract,
"swapToNative event has wrong number of parameters, expected 3, actual: %d",
len(eventArgs),
)
Expand All @@ -70,15 +70,15 @@ func (hook erc20Hook) PostTxProcessing(ctx sdk.Context, msg core.Message, receip
to, ok := eventArgs[1].(string)
if !ok || len(to) == 0 {
return errorsmod.Wrap(
types.ErrInvalidContract,
types.ErrInvalidContract,
"swapToNative event `to` parameters is invalid, expected string",
)
}

receiver, err := sdk.AccAddressFromBech32(to)
if err != nil {
return errorsmod.Wrapf(
types.ErrInvalidContract,
types.ErrInvalidContract,
"swapToNative event `to` parameters is invalid, expected iaa address, actual: %s",
to,
)
Expand All @@ -87,7 +87,7 @@ func (hook erc20Hook) PostTxProcessing(ctx sdk.Context, msg core.Message, receip
amount, ok := eventArgs[2].(*big.Int)
if !ok || amount.Cmp(big.NewInt(0)) == 0 {
return errorsmod.Wrap(
types.ErrInvalidContract,
types.ErrInvalidContract,
"swapToNative event `amount` parameters is invalid, expected `*big.Int`",
)
}
Expand Down
6 changes: 3 additions & 3 deletions modules/token/keeper/legacy_msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func (m legacyMsgServer) MintToken(goCtx context.Context, msg *v1beta1.MsgMintTo
return &v1beta1.MsgMintTokenResponse{}, err
}
_, err = m.server.MintToken(goCtx, &v1.MsgMintToken{
Coin: coin,
Receiver: msg.To,
Owner: msg.Owner,
Coin: coin,
Receiver: msg.To,
Owner: msg.Owner,
})
return &v1beta1.MsgMintTokenResponse{}, err
}
Expand Down
3 changes: 1 addition & 2 deletions modules/token/keeper/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func (k Keeper) HasMinUint(ctx sdk.Context, minUint string) bool {
return store.Has(types.KeyMinUint(minUint))
}


// HasContract asserts a token exists by contract
func (k Keeper) HasContract(ctx sdk.Context, contract string) bool {
store := ctx.KVStore(k.storeKey)
Expand Down Expand Up @@ -320,7 +319,7 @@ func (k Keeper) setDenomMetaData(ctx sdk.Context, token v1.Token) {
k.bankKeeper.SetDenomMetaData(ctx, denomMetaData)
}

func(k Keeper) assertTokenValid(ctx sdk.Context, token v1.Token) error {
func (k Keeper) assertTokenValid(ctx sdk.Context, token v1.Token) error {
if k.HasSymbol(ctx, token.Symbol) {
return errorsmod.Wrapf(
types.ErrSymbolAlreadyExists,
Expand Down
4 changes: 2 additions & 2 deletions modules/token/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func SimulateMintToken(
Denom: token.GetMinUnit(),
Amount: sdkmath.NewIntWithDecimal(100, int(token.GetScale())),
},
Receiver: simToAccount.Address.String(),
Owner: token.GetOwner().String(),
Receiver: simToAccount.Address.String(),
Owner: token.GetOwner().String(),
}

ownerAccount, found := simtypes.FindAccount(accs, token.GetOwner())
Expand Down
5 changes: 2 additions & 3 deletions modules/token/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ type EVMKeeper interface {
}

// ICS20Keeper defines the expected keeper of ICS20
type ICS20Keeper interface{
type ICS20Keeper interface {
HasTrace(ctx sdk.Context, denom string) bool
}

// Hook defines the hook interface
type Hook interface {
PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error
PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error
}

6 changes: 3 additions & 3 deletions simapp/mocks/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
// Returns a tokentypes.EVMKeeper.
func ProvideEVMKeeper() tokentypes.EVMKeeper {
return &evm{
erc20s: make(map[common.Address]*erc20),
}
erc20s: make(map[common.Address]*erc20),
}
}

// ProvideICS20Keeper returns an instance of tokentypes.ICS20Keeper.
Expand All @@ -22,4 +22,4 @@ func ProvideEVMKeeper() tokentypes.EVMKeeper {
// Returns a tokentypes.ICS20Keeper.
func ProvideICS20Keeper() tokentypes.ICS20Keeper {
return &transferKeeper{}
}
}
6 changes: 3 additions & 3 deletions simapp/mocks/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (e *evm) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogge
balance: make(map[common.Address]*big.Int),
}
return &types.Result{
Hash: contractAddr.Hex(),
Hash: contractAddr.Hex(),
}, nil
}

Expand Down Expand Up @@ -114,14 +114,14 @@ func (erc20 erc20) call(method *abi.Method, data []byte) ([]byte, error) {
case "decimals":
return method.Outputs.Pack(erc20.scale)
case "balanceOf":
balance,ok := erc20.balance[args[0].(common.Address)]
balance, ok := erc20.balance[args[0].(common.Address)]
if !ok {
return method.Outputs.Pack(big.NewInt(0))
}
return method.Outputs.Pack(balance)
case "mint":
to := args[0].(common.Address)
balance,ok := erc20.balance[args[0].(common.Address)]
balance, ok := erc20.balance[args[0].(common.Address)]
if !ok {
balance = big.NewInt(0)
}
Expand Down
Loading
Loading