From 094b4a87feda4a80382063f9d26e1d91f1cdd93b Mon Sep 17 00:00:00 2001 From: dreamer Date: Wed, 17 Apr 2024 18:53:18 +0800 Subject: [PATCH 01/12] refactor token module --- app/keepers/keepers.go | 39 ++++++++------- go.mod | 2 +- go.sum | 4 +- modules/token/wrapper.go | 105 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 20 deletions(-) create mode 100644 modules/token/wrapper.go diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 6b65ec441..0597f78b2 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -110,6 +110,7 @@ import ( "github.com/irisnet/irishub/v3/modules/internft" mintkeeper "github.com/irisnet/irishub/v3/modules/mint/keeper" minttypes "github.com/irisnet/irishub/v3/modules/mint/types" + iristoken "github.com/irisnet/irishub/v3/modules/token" iristypes "github.com/irisnet/irishub/v3/types" ) @@ -440,23 +441,6 @@ func New( appKeepers.keys[guardiantypes.StoreKey], ) - appKeepers.TokenKeeper = tokenkeeper.NewKeeper( - appCodec, - appKeepers.keys[tokentypes.StoreKey], - appKeepers.BankKeeper, - authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ).WithSwapRegistry(tokenv1.SwapRegistry{ - iristypes.NativeToken.MinUnit: tokenv1.SwapParams{ - MinUnit: iristypes.EvmToken.MinUnit, - Ratio: sdk.OneDec(), - }, - iristypes.EvmToken.MinUnit: tokenv1.SwapParams{ - MinUnit: iristypes.NativeToken.MinUnit, - Ratio: sdk.OneDec(), - }, - }) - appKeepers.RecordKeeper = recordkeeper.NewKeeper( appCodec, appKeepers.keys[recordtypes.StoreKey], @@ -561,6 +545,27 @@ func New( cast.ToString(appOpts.Get(srvflags.EVMTracer)), appKeepers.GetSubspace(evmtypes.ModuleName), ) + + appKeepers.TokenKeeper = tokenkeeper.NewKeeper( + appCodec, + appKeepers.keys[tokentypes.StoreKey], + appKeepers.BankKeeper, + appKeepers.AccountKeeper, + iristoken.WrapEVMKeeper(appKeepers.EvmKeeper), + iristoken.WrapICS20Keeper(appKeepers.IBCTransferKeeper), + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ).WithSwapRegistry(tokenv1.SwapRegistry{ + iristypes.NativeToken.MinUnit: tokenv1.SwapParams{ + MinUnit: iristypes.EvmToken.MinUnit, + Ratio: sdk.OneDec(), + }, + iristypes.EvmToken.MinUnit: tokenv1.SwapParams{ + MinUnit: iristypes.NativeToken.MinUnit, + Ratio: sdk.OneDec(), + }, + }) + appKeepers.EvmKeeper = appKeepers.EvmKeeper.SetHooks(appKeepers.TokenKeeper.Hooks()) return appKeepers } diff --git a/go.mod b/go.mod index e703ec7ac..dec033d74 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/cosmos/iavl v0.20.1 // indirect github.com/cosmos/ibc-go/v7 v7.3.0 github.com/evmos/ethermint v0.22.0 - github.com/irisnet/irismod v1.8.1-0.20240304075720-718d99d97674 //release/v1.8.0-lsm + github.com/irisnet/irismod v1.8.1-0.20240416092250-4018d9c74e78 //release/v1.8.0-lsm ) require ( diff --git a/go.sum b/go.sum index 37f0bf16d..cdd261627 100644 --- a/go.sum +++ b/go.sum @@ -846,8 +846,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/irisnet/irismod v1.8.1-0.20240304075720-718d99d97674 h1:7fBGecB0olPrkoeY0Y7wn202BQ4Q2zF8o+KwYFzNYQs= -github.com/irisnet/irismod v1.8.1-0.20240304075720-718d99d97674/go.mod h1:kvPd2HckP0Mr4BZRtUa2RjDNH1EfOP3xHESHRIXayOY= +github.com/irisnet/irismod v1.8.1-0.20240416092250-4018d9c74e78 h1:o2P1Ve1XO72zrGjFo8lGIaDvgWw4YJkUIQW7pEgNJ94= +github.com/irisnet/irismod v1.8.1-0.20240416092250-4018d9c74e78/go.mod h1:yR/g0kuqqdrUdoXJsRHyajGZxogAJZjRbj8OWEfK9cA= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= diff --git a/modules/token/wrapper.go b/modules/token/wrapper.go new file mode 100644 index 000000000..8d330c6f3 --- /dev/null +++ b/modules/token/wrapper.go @@ -0,0 +1,105 @@ +package token + +import ( + "context" + "math/big" + "strings" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/vm" + + "github.com/evmos/ethermint/crypto/ethsecp256k1" + evmkeeper "github.com/evmos/ethermint/x/evm/keeper" + evmtypes "github.com/evmos/ethermint/x/evm/types" + + ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + + tokentypes "github.com/irisnet/irismod/modules/token/types" + irismodtypes "github.com/irisnet/irismod/types" +) + +var ( + _ tokentypes.EVMKeeper = (*evmKeeper)(nil) + _ tokentypes.ICS20Keeper = (*ics20Keeper)(nil) +) + +// WrapEVMKeeper wraps the given evmkeeper.Keeper and returns a new evmKeeper. +// +// ek: The evmkeeper.Keeper to be wrapped. +// Returns a pointer to the wrapped evmKeeper. +func WrapEVMKeeper(ek *evmkeeper.Keeper) tokentypes.EVMKeeper { + return &evmKeeper{ek: ek} +} + +type evmKeeper struct { + ek *evmkeeper.Keeper +} + +// ApplyMessage implements types.EVMKeeper. +func (e *evmKeeper) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogger, commit bool) (*irismodtypes.Result, error) { + res, err := e.ek.ApplyMessage(ctx, msg, tracer, commit) + if err != nil { + return nil, err + } + return &irismodtypes.Result{ + Hash: res.Hash, + Logs: evmtypes.LogsToEthereum(res.Logs), + Ret: res.Ret, + VMError: res.VmError, + GasUsed: res.GasUsed, + }, nil +} + +// ChainID implements types.EVMKeeper. +func (e *evmKeeper) ChainID() *big.Int { + return e.ek.ChainID() +} + +// EstimateGas implements types.EVMKeeper. +func (e *evmKeeper) EstimateGas(ctx context.Context, req *irismodtypes.EthCallRequest) (uint64, error) { + res, err := e.ek.EstimateGas(ctx, &evmtypes.EthCallRequest{ + Args: req.Args, + GasCap: req.GasCap, + ProposerAddress: req.ProposerAddress, + ChainId: req.ChainID, + }) + if err != nil { + return 0, err + } + return res.Gas, nil +} + +// SupportedKey implements types.EVMKeeper. +func (e *evmKeeper) SupportedKey(pubKey cryptotypes.PubKey) bool { + _, ok := pubKey.(*ethsecp256k1.PubKey) + return ok +} + +// WrapICS20Keeper wraps the given ibctransferkeeper.Keeper into an ics20Keeper. +// +// Parameters: +// - ik: the ibctransferkeeper.Keeper to be wrapped. +// +// Return: +// - *ics20Keeper: the wrapped ics20Keeper. +func WrapICS20Keeper(ik ibctransferkeeper.Keeper) tokentypes.ICS20Keeper { + return &ics20Keeper{ik: ik} +} + +type ics20Keeper struct { + ik ibctransferkeeper.Keeper +} + +// HasTrace implements types.ICS20Keeper. +func (i *ics20Keeper) HasTrace(ctx sdk.Context, denom string) bool { + hash, err := ibctransfertypes.ParseHexHash(strings.TrimPrefix(denom, "ibc/")) + if err != nil { + return false + } + _, has := i.ik.GetDenomTrace(ctx, hash) + return has +} From c4ffb1f4a6a7b0c6d7c5f50609c9046bc7eb18ad Mon Sep 17 00:00:00 2001 From: dreamer Date: Thu, 18 Apr 2024 16:50:31 +0800 Subject: [PATCH 02/12] bump up irismod --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dec033d74..19f499206 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/cosmos/iavl v0.20.1 // indirect github.com/cosmos/ibc-go/v7 v7.3.0 github.com/evmos/ethermint v0.22.0 - github.com/irisnet/irismod v1.8.1-0.20240416092250-4018d9c74e78 //release/v1.8.0-lsm + github.com/irisnet/irismod v1.8.1-0.20240418084635-44011b7a2626 //release/v1.8.0-lsm ) require ( diff --git a/go.sum b/go.sum index cdd261627..e92711b4b 100644 --- a/go.sum +++ b/go.sum @@ -846,8 +846,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/irisnet/irismod v1.8.1-0.20240416092250-4018d9c74e78 h1:o2P1Ve1XO72zrGjFo8lGIaDvgWw4YJkUIQW7pEgNJ94= -github.com/irisnet/irismod v1.8.1-0.20240416092250-4018d9c74e78/go.mod h1:yR/g0kuqqdrUdoXJsRHyajGZxogAJZjRbj8OWEfK9cA= +github.com/irisnet/irismod v1.8.1-0.20240418084635-44011b7a2626 h1:MH+/S1tunWuoxZ3X4YsnG1LbUw1BHEJcDyFr3wimRGw= +github.com/irisnet/irismod v1.8.1-0.20240418084635-44011b7a2626/go.mod h1:yR/g0kuqqdrUdoXJsRHyajGZxogAJZjRbj8OWEfK9cA= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= From 0d5b9a3a2a6f69b7f27c1d507184602f1c740fc8 Mon Sep 17 00:00:00 2001 From: dreamer Date: Thu, 18 Apr 2024 17:58:02 +0800 Subject: [PATCH 03/12] refactor code --- app/keepers/keepers.go | 8 +-- go.mod | 2 +- go.sum | 4 +- modules/mint/simulation/genesis.go | 2 +- modules/mint/types/params.go | 3 +- types/runtime.go | 2 + wrapper/farm.go | 53 ++++++++++++++++++++ modules/token/wrapper.go => wrapper/token.go | 10 ++-- 8 files changed, 69 insertions(+), 15 deletions(-) create mode 100644 wrapper/farm.go rename modules/token/wrapper.go => wrapper/token.go (89%) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 0597f78b2..579d6ac3a 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -110,8 +110,8 @@ import ( "github.com/irisnet/irishub/v3/modules/internft" mintkeeper "github.com/irisnet/irishub/v3/modules/mint/keeper" minttypes "github.com/irisnet/irishub/v3/modules/mint/types" - iristoken "github.com/irisnet/irishub/v3/modules/token" iristypes "github.com/irisnet/irishub/v3/types" + "github.com/irisnet/irishub/v3/wrapper" ) // AppKeepers defines a structure used to consolidate all @@ -518,7 +518,7 @@ func New( AddRoute(farmtypes.RouterKey, farm.NewCommunityPoolCreateFarmProposalHandler(appKeepers.FarmKeeper)) appKeepers.GovKeeper.SetHooks(govtypes.NewMultiGovHooks( - farmkeeper.NewGovHook(appKeepers.FarmKeeper), + wrapper.NewFarmGovHook(farmkeeper.NewGovHook(appKeepers.FarmKeeper)), )) appKeepers.GovKeeper.SetLegacyRouter(govRouter) @@ -551,8 +551,8 @@ func New( appKeepers.keys[tokentypes.StoreKey], appKeepers.BankKeeper, appKeepers.AccountKeeper, - iristoken.WrapEVMKeeper(appKeepers.EvmKeeper), - iristoken.WrapICS20Keeper(appKeepers.IBCTransferKeeper), + wrapper.NewEVMKeeper(appKeepers.EvmKeeper), + wrapper.NewICS20Keeper(appKeepers.IBCTransferKeeper), authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ).WithSwapRegistry(tokenv1.SwapRegistry{ diff --git a/go.mod b/go.mod index 19f499206..694294842 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/cosmos/iavl v0.20.1 // indirect github.com/cosmos/ibc-go/v7 v7.3.0 github.com/evmos/ethermint v0.22.0 - github.com/irisnet/irismod v1.8.1-0.20240418084635-44011b7a2626 //release/v1.8.0-lsm + github.com/irisnet/irismod v1.8.1-0.20240418095024-5fb0418185bd //release/v1.8.0-lsm ) require ( diff --git a/go.sum b/go.sum index e92711b4b..fcb556c92 100644 --- a/go.sum +++ b/go.sum @@ -846,8 +846,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/irisnet/irismod v1.8.1-0.20240418084635-44011b7a2626 h1:MH+/S1tunWuoxZ3X4YsnG1LbUw1BHEJcDyFr3wimRGw= -github.com/irisnet/irismod v1.8.1-0.20240418084635-44011b7a2626/go.mod h1:yR/g0kuqqdrUdoXJsRHyajGZxogAJZjRbj8OWEfK9cA= +github.com/irisnet/irismod v1.8.1-0.20240418095024-5fb0418185bd h1:vU9Ui6o0BenMVVkpRmTYdbMkLgqHRmLk7HNDKjVy700= +github.com/irisnet/irismod v1.8.1-0.20240418095024-5fb0418185bd/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= diff --git a/modules/mint/simulation/genesis.go b/modules/mint/simulation/genesis.go index 9d18523f4..6bbd698c8 100644 --- a/modules/mint/simulation/genesis.go +++ b/modules/mint/simulation/genesis.go @@ -32,7 +32,7 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { inflation = GenInflation(r) }, ) - params := types.Params{Inflation: inflation, MintDenom: types.MintDenom} + params := types.Params{Inflation: inflation, MintDenom: sdk.DefaultBondDenom} mintGenesis := types.NewGenesisState(types.DefaultMinter(), params) bz, err := json.MarshalIndent(&mintGenesis, "", " ") diff --git a/modules/mint/types/params.go b/modules/mint/types/params.go index a7fb4505a..3882ccb70 100644 --- a/modules/mint/types/params.go +++ b/modules/mint/types/params.go @@ -22,7 +22,6 @@ var ( // params store for inflation params KeyInflation = []byte("Inflation") KeyMintDenom = []byte("MintDenom") - MintDenom = sdk.DefaultBondDenom ) // ParamTable for mint module @@ -41,7 +40,7 @@ func NewParams(mintDenom string, inflation sdk.Dec) Params { func DefaultParams() Params { return Params{ Inflation: sdk.NewDecWithPrec(4, 2), - MintDenom: MintDenom, + MintDenom: sdk.DefaultBondDenom, } } diff --git a/types/runtime.go b/types/runtime.go index fb04585c0..99a60c58c 100644 --- a/types/runtime.go +++ b/types/runtime.go @@ -62,6 +62,8 @@ func init() { Mintable: true, Owner: sdk.AccAddress(crypto.AddressHash([]byte(tokentypes.ModuleName))).String(), } + sdk.DefaultBondDenom = NativeToken.MinUnit + userHomeDir, err := os.UserHomeDir() if err != nil { diff --git a/wrapper/farm.go b/wrapper/farm.go new file mode 100644 index 000000000..624b29411 --- /dev/null +++ b/wrapper/farm.go @@ -0,0 +1,53 @@ +package wrapper + +import ( + "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + farmkeeper "github.com/irisnet/irismod/modules/farm/keeper" +) + +var _ govtypes.GovHooks = farmGovHook{} + +type farmGovHook struct { + gh farmkeeper.GovHook +} + +// NewFarmGovHook creates a new farmGovHook instance. +// +// It takes a parameter of type farmkeeper.GovHook and returns a farmGovHook. +func NewFarmGovHook(gh farmkeeper.GovHook) govtypes.GovHooks { + return farmGovHook{ + gh: gh, + } +} + +// AfterProposalDeposit implements types.GovHooks. +func (f farmGovHook) AfterProposalDeposit(ctx types.Context, proposalID uint64, depositorAddr types.AccAddress) error { + f.gh.AfterProposalDeposit(ctx, proposalID, depositorAddr) + return nil +} + +// AfterProposalFailedMinDeposit implements types.GovHooks. +func (f farmGovHook) AfterProposalFailedMinDeposit(ctx types.Context, proposalID uint64) error { + f.gh.AfterProposalFailedMinDeposit(ctx, proposalID) + return nil +} + +// AfterProposalSubmission implements types.GovHooks. +func (f farmGovHook) AfterProposalSubmission(ctx types.Context, proposalID uint64) error { + f.gh.AfterProposalSubmission(ctx, proposalID) + return nil +} + +// AfterProposalVote implements types.GovHooks. +func (f farmGovHook) AfterProposalVote(ctx types.Context, proposalID uint64, voterAddr types.AccAddress) error { + f.gh.AfterProposalVote(ctx, proposalID,voterAddr) + return nil +} + +// AfterProposalVotingPeriodEnded implements types.GovHooks. +func (f farmGovHook) AfterProposalVotingPeriodEnded(ctx types.Context, proposalID uint64) error { + f.gh.AfterProposalVotingPeriodEnded(ctx, proposalID) + return nil +} diff --git a/modules/token/wrapper.go b/wrapper/token.go similarity index 89% rename from modules/token/wrapper.go rename to wrapper/token.go index 8d330c6f3..e0d87a3f1 100644 --- a/modules/token/wrapper.go +++ b/wrapper/token.go @@ -1,4 +1,4 @@ -package token +package wrapper import ( "context" @@ -27,11 +27,11 @@ var ( _ tokentypes.ICS20Keeper = (*ics20Keeper)(nil) ) -// WrapEVMKeeper wraps the given evmkeeper.Keeper and returns a new evmKeeper. +// NewEVMKeeper wraps the given evmkeeper.Keeper and returns a new evmKeeper. // // ek: The evmkeeper.Keeper to be wrapped. // Returns a pointer to the wrapped evmKeeper. -func WrapEVMKeeper(ek *evmkeeper.Keeper) tokentypes.EVMKeeper { +func NewEVMKeeper(ek *evmkeeper.Keeper) tokentypes.EVMKeeper { return &evmKeeper{ek: ek} } @@ -79,14 +79,14 @@ func (e *evmKeeper) SupportedKey(pubKey cryptotypes.PubKey) bool { return ok } -// WrapICS20Keeper wraps the given ibctransferkeeper.Keeper into an ics20Keeper. +// NewICS20Keeper wraps the given ibctransferkeeper.Keeper into an ics20Keeper. // // Parameters: // - ik: the ibctransferkeeper.Keeper to be wrapped. // // Return: // - *ics20Keeper: the wrapped ics20Keeper. -func WrapICS20Keeper(ik ibctransferkeeper.Keeper) tokentypes.ICS20Keeper { +func NewICS20Keeper(ik ibctransferkeeper.Keeper) tokentypes.ICS20Keeper { return &ics20Keeper{ik: ik} } From dbeca912c5d4162655473fc78d8aface7caa838b Mon Sep 17 00:00:00 2001 From: dreamer Date: Thu, 18 Apr 2024 18:10:57 +0800 Subject: [PATCH 04/12] remove useless logic --- cmd/iris/cmd/testnet.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cmd/iris/cmd/testnet.go b/cmd/iris/cmd/testnet.go index 5884edd9b..4022862f8 100644 --- a/cmd/iris/cmd/testnet.go +++ b/cmd/iris/cmd/testnet.go @@ -249,17 +249,13 @@ func InitTestnet( return err } - accTokens := sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction) - accStakingTokens := sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction) - accEvmTokens := sdk.TokensFromConsensusPower(5000, PowerReduction) - accIrisTokens := sdk.TokensFromConsensusPower(5000, sdk.DefaultPowerReduction) + accStakingTokens := sdk.TokensFromConsensusPower(15e8, sdk.DefaultPowerReduction) + accEvmTokens := sdk.TokensFromConsensusPower(5e8, PowerReduction) - coins := sdk.Coins{ - sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), accTokens), + coins := sdk.NewCoins( sdk.NewCoin(sdk.DefaultBondDenom, accStakingTokens), sdk.NewCoin(iristypes.EvmToken.MinUnit, accEvmTokens), - sdk.NewCoin(nativeIrisMinUnit, accIrisTokens), - } + ) genBalances = append( genBalances, From 36b71045f1f7f42488815c5fac8ac14a5961a5c1 Mon Sep 17 00:00:00 2001 From: dreamer Date: Fri, 19 Apr 2024 11:24:27 +0800 Subject: [PATCH 05/12] fix error --- go.mod | 4 +++- go.sum | 6 ++---- modules/evm/state_transition.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 694294842..fd78b3188 100644 --- a/go.mod +++ b/go.mod @@ -232,6 +232,8 @@ require ( replace github.com/zondax/hid => github.com/zondax/hid v0.9.0 // use bianjieai fork of ethermint -replace github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240403080035-de4b07ecf255 //release/v0.2…20231207-lsm +replace github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240419023144-3cea3d782107 //release/v0.2…20231207-lsm replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 + +replace github.com/irisnet/irismod => /Users/dreamer/workspace/github/irisnet/irismod diff --git a/go.sum b/go.sum index fcb556c92..673a7ac89 100644 --- a/go.sum +++ b/go.sum @@ -295,8 +295,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240403080035-de4b07ecf255 h1:Rngrww/saMItIkpSozg5poBQiRHsE52iZnio5zII8EQ= -github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240403080035-de4b07ecf255/go.mod h1:x9BFez6AUL9Yksv4zZd3QLmSazwOkyNd3h2zFV2B4RU= +github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240419023144-3cea3d782107 h1:ssrDDPlhLILV0UaQD+D/mRqAvQ5FeQrWB3lltaP5YTc= +github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240419023144-3cea3d782107/go.mod h1:x9BFez6AUL9Yksv4zZd3QLmSazwOkyNd3h2zFV2B4RU= github.com/bianjieai/nft-transfer v1.1.3-ibc-v7.3.0 h1:399lErsTpI+faTerw5Q4OuVlXAmAQSuibVvxHR3C6OY= github.com/bianjieai/nft-transfer v1.1.3-ibc-v7.3.0/go.mod h1:u2PNH4v8CD4AWU4Rf7yt8/qqQtrrwwHiw03qQSKERhg= github.com/bianjieai/tibc-go v0.5.0 h1:/J1OQe4gwUUkS3Q6+nm0EsTY7MNAOPNzfnpvgIWlvKM= @@ -846,8 +846,6 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/irisnet/irismod v1.8.1-0.20240418095024-5fb0418185bd h1:vU9Ui6o0BenMVVkpRmTYdbMkLgqHRmLk7HNDKjVy700= -github.com/irisnet/irismod v1.8.1-0.20240418095024-5fb0418185bd/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= diff --git a/modules/evm/state_transition.go b/modules/evm/state_transition.go index 7c1156ae7..f710dc47d 100644 --- a/modules/evm/state_transition.go +++ b/modules/evm/state_transition.go @@ -59,7 +59,7 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction, fee // snapshot to contain the tx processing and post processing in same scope var commit func() tmpCtx := ctx - if k.hasHook { + if k.evmkeeper.Hooks() != nil { // Create a cache context to revert state when tx hooks fails, // the cache context is only committed when both tx and hooks executed successfully. // Didn't use `Snapshot` because the context stack has exponential complexity on certain operations, From 0f8ff8b02cc7b1b5d00da12dfcf7fd117f75baf7 Mon Sep 17 00:00:00 2001 From: dreamer Date: Fri, 19 Apr 2024 11:27:02 +0800 Subject: [PATCH 06/12] fix error --- go.mod | 4 ++-- go.sum | 2 ++ modules/evm/keeper.go | 14 ++++---------- modules/evm/moudle.go | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index fd78b3188..5193e6077 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/cosmos/iavl v0.20.1 // indirect github.com/cosmos/ibc-go/v7 v7.3.0 github.com/evmos/ethermint v0.22.0 - github.com/irisnet/irismod v1.8.1-0.20240418095024-5fb0418185bd //release/v1.8.0-lsm + github.com/irisnet/irismod v1.8.1-0.20240419032051-734da9df7b72 //release/v1.8.0-lsm ) require ( @@ -236,4 +236,4 @@ replace github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.22.0-iri replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 -replace github.com/irisnet/irismod => /Users/dreamer/workspace/github/irisnet/irismod +// replace github.com/irisnet/irismod => /Users/dreamer/workspace/github/irisnet/irismod diff --git a/go.sum b/go.sum index 673a7ac89..4dc2e321d 100644 --- a/go.sum +++ b/go.sum @@ -846,6 +846,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= +github.com/irisnet/irismod v1.8.1-0.20240419032051-734da9df7b72 h1:HuM62nKRibhRxYV8Ui1Z3/aLbwYqstpKyu2ixT+ufo0= +github.com/irisnet/irismod v1.8.1-0.20240419032051-734da9df7b72/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= diff --git a/modules/evm/keeper.go b/modules/evm/keeper.go index 6d5028e76..860f3402b 100644 --- a/modules/evm/keeper.go +++ b/modules/evm/keeper.go @@ -21,7 +21,6 @@ import ( type Keeper struct { evmkeeper *evmkeeper.Keeper bankKeeper types.BankKeeper - hasHook bool } var _ types.MsgServer = &Keeper{} @@ -139,15 +138,10 @@ func (k *Keeper) EthereumTx( return response, nil } -// SetHooks sets the hooks for the EVM module -// It should be called only once during initialization, it panic if called more than once. -func (k *Keeper) SetHooks(eh types.EvmHooks) *Keeper { - return &Keeper{ - evmkeeper: k.evmkeeper.SetHooks(eh), - hasHook: true, - } -} - +// UpdateParams updates the parameters for the EVM module. +// +// It takes a context.Context object and a *types.MsgUpdateParams object as parameters. +// The function returns a *types.MsgUpdateParamsResponse object and an error. func (k *Keeper) UpdateParams( goCtx context.Context, msg *types.MsgUpdateParams, diff --git a/modules/evm/moudle.go b/modules/evm/moudle.go index 5117f75ce..7bbeb3478 100644 --- a/modules/evm/moudle.go +++ b/modules/evm/moudle.go @@ -30,7 +30,7 @@ func NewAppModule( ) AppModule { return AppModule{ AppModule: ethermint.NewAppModule(k, ak, ss), - k: &Keeper{k, bankKeeper, false}, + k: &Keeper{k, bankKeeper}, ss: ss, } } From 62d041e4fbe91182c3ea34afa0f4413e99f05619 Mon Sep 17 00:00:00 2001 From: dreamer Date: Fri, 19 Apr 2024 13:48:59 +0800 Subject: [PATCH 07/12] update changelog & fix error --- CHANGELOG.md | 1 + go.mod | 6 ++---- go.sum | 4 ++-- modules/mint/client/cli/cli_test.go | 3 ++- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbf2c4407..714a232dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * (IRISHub) [\#2908](https://github.com/irisnet/irishub/pull/2908) Add ICA module. * (IRISHub) [\#2909](https://github.com/irisnet/irishub/pull/2909) Add cosmos LSM. +* (IRISHub) [\#2925](https://github.com/irisnet/irishub/pull/2925) Enhance token module. ### Improvements diff --git a/go.mod b/go.mod index 5193e6077..57e83b85a 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/cosmos/iavl v0.20.1 // indirect github.com/cosmos/ibc-go/v7 v7.3.0 github.com/evmos/ethermint v0.22.0 - github.com/irisnet/irismod v1.8.1-0.20240419032051-734da9df7b72 //release/v1.8.0-lsm + github.com/irisnet/irismod v1.8.1-0.20240419035157-94a7b8330bbb //release/v1.8.0-lsm ) require ( @@ -234,6 +234,4 @@ replace github.com/zondax/hid => github.com/zondax/hid v0.9.0 // use bianjieai fork of ethermint replace github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240419023144-3cea3d782107 //release/v0.2…20231207-lsm -replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - -// replace github.com/irisnet/irismod => /Users/dreamer/workspace/github/irisnet/irismod +replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 \ No newline at end of file diff --git a/go.sum b/go.sum index 4dc2e321d..e3a0ecf5d 100644 --- a/go.sum +++ b/go.sum @@ -846,8 +846,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/irisnet/irismod v1.8.1-0.20240419032051-734da9df7b72 h1:HuM62nKRibhRxYV8Ui1Z3/aLbwYqstpKyu2ixT+ufo0= -github.com/irisnet/irismod v1.8.1-0.20240419032051-734da9df7b72/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= +github.com/irisnet/irismod v1.8.1-0.20240419035157-94a7b8330bbb h1:IQcFgUehR82K0kRgdFTiwoAKRWqacr+ERNIgBW450ZA= +github.com/irisnet/irismod v1.8.1-0.20240419035157-94a7b8330bbb/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= diff --git a/modules/mint/client/cli/cli_test.go b/modules/mint/client/cli/cli_test.go index a49c19842..001efbe85 100644 --- a/modules/mint/client/cli/cli_test.go +++ b/modules/mint/client/cli/cli_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" @@ -52,6 +53,6 @@ func (s *IntegrationTestSuite) TestMint() { s.Require().NoError(err) s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) params := respType.(*minttypes.Params) - s.Require().Equal("stake", params.MintDenom) + s.Require().Equal(sdk.DefaultBondDenom, params.MintDenom) s.Require().Equal("0.040000000000000000", params.Inflation.String()) } From 35ffee3c61e4c6ada3f0eda07426dd527a858b43 Mon Sep 17 00:00:00 2001 From: dreamer Date: Fri, 19 Apr 2024 17:53:54 +0800 Subject: [PATCH 08/12] bump up irismod --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 57e83b85a..738f56d59 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/cosmos/iavl v0.20.1 // indirect github.com/cosmos/ibc-go/v7 v7.3.0 github.com/evmos/ethermint v0.22.0 - github.com/irisnet/irismod v1.8.1-0.20240419035157-94a7b8330bbb //release/v1.8.0-lsm + github.com/irisnet/irismod v1.8.1-0.20240419092732-1eefdb19bf41 //release/v1.8.0-lsm ) require ( @@ -234,4 +234,4 @@ replace github.com/zondax/hid => github.com/zondax/hid v0.9.0 // use bianjieai fork of ethermint replace github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.22.0-irishub-20231207.0.20240419023144-3cea3d782107 //release/v0.2…20231207-lsm -replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 \ No newline at end of file +replace github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/go.sum b/go.sum index e3a0ecf5d..c0df8e434 100644 --- a/go.sum +++ b/go.sum @@ -846,8 +846,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/irisnet/irismod v1.8.1-0.20240419035157-94a7b8330bbb h1:IQcFgUehR82K0kRgdFTiwoAKRWqacr+ERNIgBW450ZA= -github.com/irisnet/irismod v1.8.1-0.20240419035157-94a7b8330bbb/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= +github.com/irisnet/irismod v1.8.1-0.20240419092732-1eefdb19bf41 h1:WU15MSBJK66jhONVcc63DkCeM6LFhhWFPYoIi+mYyB0= +github.com/irisnet/irismod v1.8.1-0.20240419092732-1eefdb19bf41/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= From b0d32291e804152f66b10d41551ebbafa4c0f6f3 Mon Sep 17 00:00:00 2001 From: dreamer Date: Mon, 22 Apr 2024 16:59:21 +0800 Subject: [PATCH 09/12] update irismod --- go.mod | 2 +- go.sum | 4 ++-- wrapper/token.go | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 738f56d59..31b84c3dd 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/cosmos/iavl v0.20.1 // indirect github.com/cosmos/ibc-go/v7 v7.3.0 github.com/evmos/ethermint v0.22.0 - github.com/irisnet/irismod v1.8.1-0.20240419092732-1eefdb19bf41 //release/v1.8.0-lsm + github.com/irisnet/irismod v1.8.1-0.20240422082845-aafd2bd851f9 //release/v1.8.0-lsm ) require ( diff --git a/go.sum b/go.sum index c0df8e434..2b3feea83 100644 --- a/go.sum +++ b/go.sum @@ -846,8 +846,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/irisnet/irismod v1.8.1-0.20240419092732-1eefdb19bf41 h1:WU15MSBJK66jhONVcc63DkCeM6LFhhWFPYoIi+mYyB0= -github.com/irisnet/irismod v1.8.1-0.20240419092732-1eefdb19bf41/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= +github.com/irisnet/irismod v1.8.1-0.20240422082845-aafd2bd851f9 h1:5uvIKhg55Y82su5FX3A4KT64sc89u0kEhacUMdhVIQc= +github.com/irisnet/irismod v1.8.1-0.20240422082845-aafd2bd851f9/go.mod h1:TQDhEmxqCIzo7OjyNy//UI0xKDuMtONjoy5LzUeRhVo= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= diff --git a/wrapper/token.go b/wrapper/token.go index e0d87a3f1..0ced2b5f0 100644 --- a/wrapper/token.go +++ b/wrapper/token.go @@ -75,6 +75,11 @@ func (e *evmKeeper) EstimateGas(ctx context.Context, req *irismodtypes.EthCallRe // SupportedKey implements types.EVMKeeper. func (e *evmKeeper) SupportedKey(pubKey cryptotypes.PubKey) bool { + // NOTICE: when the account has not executed native transactions, the pubkey is empty. + if pubKey == nil { + return true + } + _, ok := pubKey.(*ethsecp256k1.PubKey) return ok } From 6fe72ef2eed50dfd5c3321238e44aef58683e04b Mon Sep 17 00:00:00 2001 From: dreamer Date: Mon, 22 Apr 2024 17:05:38 +0800 Subject: [PATCH 10/12] update token params when upgrading --- app/upgrades/v300/constants.go | 3 +++ app/upgrades/v300/upgrades.go | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/app/upgrades/v300/constants.go b/app/upgrades/v300/constants.go index afb13b632..a97a83207 100644 --- a/app/upgrades/v300/constants.go +++ b/app/upgrades/v300/constants.go @@ -16,5 +16,8 @@ var ( // the portion of a chain's total stake can be liquid GlobalLiquidStakingCap = sdk.MustNewDecFromStr("0.25") // 25% + // BeaconContractAddress is the address of the beacon contract + BeaconContractAddress = "" + allowMessages = []string{"*"} ) diff --git a/app/upgrades/v300/upgrades.go b/app/upgrades/v300/upgrades.go index 736542743..0cfe2faf8 100644 --- a/app/upgrades/v300/upgrades.go +++ b/app/upgrades/v300/upgrades.go @@ -71,3 +71,12 @@ func mergeEVM(ctx sdk.Context, box upgrades.Toolbox) error { params.AllowUnprotectedTxs = true return box.EvmKeeper.SetParams(ctx, params) } + +func mergeToken(ctx sdk.Context, box upgrades.Toolbox) error { + ctx.Logger().Info("start to run token module migrations...") + + params := box.TokenKeeper.GetParams(ctx) + params.EnableErc20 = true + params.Beacon = BeaconContractAddress + return box.TokenKeeper.SetParams(ctx, params) +} From 5fea68208c5ed23ffeb686fa096005fc5b7af17c Mon Sep 17 00:00:00 2001 From: dreamer Date: Mon, 22 Apr 2024 17:26:54 +0800 Subject: [PATCH 11/12] fix bugs --- app/upgrades/v300/upgrades.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/upgrades/v300/upgrades.go b/app/upgrades/v300/upgrades.go index 0cfe2faf8..b4d559ded 100644 --- a/app/upgrades/v300/upgrades.go +++ b/app/upgrades/v300/upgrades.go @@ -33,6 +33,10 @@ func upgradeHandlerConstructor( if err := mergeEVM(ctx, box); err != nil { return nil, err } + + if err := mergeToken(ctx, box); err != nil { + return nil, err + } // initialize ICS27 module initICAModule(ctx, m, fromVM) From ac3b20a9f691fc0ef5fe344f7eb124233abd11c4 Mon Sep 17 00:00:00 2001 From: dreamer Date: Tue, 23 Apr 2024 09:35:39 +0800 Subject: [PATCH 12/12] apply comments from github --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 714a232dd..5d1978fd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Features * (IRISHub) [\#2908](https://github.com/irisnet/irishub/pull/2908) Add ICA module. -* (IRISHub) [\#2909](https://github.com/irisnet/irishub/pull/2909) Add cosmos LSM. +* (IRISHub) [\#2909](https://github.com/irisnet/irishub/pull/2909) Add Cosmos LSM module. * (IRISHub) [\#2925](https://github.com/irisnet/irishub/pull/2925) Enhance token module. ### Improvements