diff --git a/app/app.go b/app/app.go index b20a0e0..7afb381 100644 --- a/app/app.go +++ b/app/app.go @@ -11,7 +11,7 @@ import ( appante "github.com/bianjieai/irita/app/ante" "github.com/bianjieai/irita/crypto/hd" "github.com/bianjieai/irita/lite" - appkeeper "github.com/bianjieai/irita/modules/evm" + appevm "github.com/bianjieai/irita/modules/evm" tibc "github.com/bianjieai/irita/modules/tibc" tibckeeper "github.com/bianjieai/irita/modules/tibc/keeper" "github.com/bianjieai/irita/wrapper" @@ -353,7 +353,7 @@ func NewIritaApp( ) app.nodeKeeper = node.NewKeeper(appCodec, keys[nodetypes.StoreKey], app.GetSubspace(node.ModuleName)) - stakingKeeper := wrapper.NewStakingKeeper(app.nodeKeeper) + stakingKeeper := wrapper.NewStakingKeeper(&app.nodeKeeper) app.slashingKeeper = slashingkeeper.NewKeeper( appCodec, cdc, @@ -456,7 +456,7 @@ func NewIritaApp( authorityAddr, app.accountKeeper, app.bankKeeper, - appkeeper.WNodeKeeper{Keeper: app.nodeKeeper}, + appevm.NewStakingKeeper(app.nodeKeeper), app.FeeMarketKeeper, nil, geth.NewEVM, diff --git a/app/app_config.go b/app/app_config.go index aad0203..9a5e76b 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -24,8 +24,6 @@ import ( evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/cosmos/cosmos-sdk/x/feegrant" "github.com/cosmos/cosmos-sdk/x/group" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" evmmodulev1 "github.com/evmos/ethermint/api/ethermint/evm/module/v1" feemarketmodulev1 "github.com/evmos/ethermint/api/ethermint/feemarket/module/v1" evmtypes "github.com/evmos/ethermint/x/evm/types" @@ -46,6 +44,7 @@ import ( tokentypes "mods.irisnet.org/modules/token/types" genutilmodulev1 "iritamod.bianjie.ai/api/iritamod/genutil/module/v1" + identitymodulev1 "iritamod.bianjie.ai/api/iritamod/identity/module/v1" nodemodulev1 "iritamod.bianjie.ai/api/iritamod/node/module/v1" paramsmodulev1 "iritamod.bianjie.ai/api/iritamod/params/module/v1" slashingmodulev1 "iritamod.bianjie.ai/api/iritamod/slashing/module/v1" @@ -53,12 +52,16 @@ import ( genutiltypes "iritamod.bianjie.ai/modules/genutil" identitytypes "iritamod.bianjie.ai/modules/identity/types" nodetypes "iritamod.bianjie.ai/modules/node/types" + paramstypes "iritamod.bianjie.ai/modules/params/types" + slashingtypes "iritamod.bianjie.ai/modules/slashing/types" upgradetypes "iritamod.bianjie.ai/modules/upgrade/types" _ "github.com/bianjieai/tibc-go/modules/tibc/apps/mt_transfer" // import for side-effects _ "iritamod.bianjie.ai/modules/genutil" // import for side-effects _ "iritamod.bianjie.ai/modules/identity" // import for side-effects _ "iritamod.bianjie.ai/modules/node" // import for side-effects + _ "iritamod.bianjie.ai/modules/params" // import for side-effects + _ "iritamod.bianjie.ai/modules/slashing" // import for side-effects _ "iritamod.bianjie.ai/modules/upgrade" // import for side-effects _ "mods.irisnet.org/modules/mt" // import for side-effects _ "mods.irisnet.org/modules/oracle" // import for side-effects @@ -78,20 +81,20 @@ var ( // can do so safely. genesisModuleOrder = []string{ capabilitytypes.ModuleName, - authtypes.ModuleName, + authtypes.ModuleName, banktypes.ModuleName, - nodetypes.ModuleName, + nodetypes.ModuleName, slashingtypes.ModuleName, - crisistypes.ModuleName, - genutiltypes.ModuleName, + crisistypes.ModuleName, + genutiltypes.ModuleName, evidencetypes.ModuleName, - feegrant.ModuleName, - paramstypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, upgradetypes.ModuleName, consensustypes.ModuleName, mttypes.ModuleName, nfttypes.ModuleName, - servicetypes.ModuleName, + servicetypes.ModuleName, oracletypes.ModuleName, randomtypes.ModuleName, recordtypes.ModuleName, @@ -99,8 +102,8 @@ var ( tokentypes.ModuleName, tibchost.ModuleName, tibcnfttypes.ModuleName, - tibcmttypes.ModuleName, - evmtypes.ModuleName, + tibcmttypes.ModuleName, + evmtypes.ModuleName, feemarkettypes.ModuleName, } @@ -113,6 +116,7 @@ var ( {Account: servicetypes.RequestAccName}, {Account: servicetypes.FeeCollectorName, Permissions: []string{authtypes.Burner}}, {Account: tokentypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}}, + {Account: evmtypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}}, // used for secure addition and subtraction of balance using module account } // blocked account addresses @@ -122,7 +126,7 @@ var ( servicetypes.RequestAccName, servicetypes.FeeCollectorName, tokentypes.ModuleName, - evmtypes.ModuleName, + evmtypes.ModuleName, feemarkettypes.ModuleName, // We allow the following module accounts to receive funds: // govtypes.ModuleName @@ -152,6 +156,7 @@ var ( genutiltypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, + identitytypes.ModuleName, mttypes.ModuleName, nfttypes.ModuleName, servicetypes.ModuleName, @@ -160,7 +165,7 @@ var ( recordtypes.ModuleName, tokentypes.ModuleName, consensustypes.ModuleName, - evmtypes.ModuleName, + evmtypes.ModuleName, feemarkettypes.ModuleName, }, EndBlockers: []string{ @@ -178,6 +183,7 @@ var ( paramstypes.ModuleName, upgradetypes.ModuleName, consensustypes.ModuleName, + identitytypes.ModuleName, mttypes.ModuleName, nfttypes.ModuleName, servicetypes.ModuleName, @@ -185,7 +191,7 @@ var ( randomtypes.ModuleName, recordtypes.ModuleName, tokentypes.ModuleName, - evmtypes.ModuleName, + evmtypes.ModuleName, feemarkettypes.ModuleName, }, OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{ @@ -264,6 +270,10 @@ var ( Name: consensustypes.ModuleName, Config: appconfig.WrapAny(&consensusmodulev1.Module{}), }, + { + Name: identitytypes.ModuleName, + Config: appconfig.WrapAny(&identitymodulev1.Module{}), + }, { Name: nfttypes.ModuleName, Config: appconfig.WrapAny(&nftmodule.Module{}), @@ -303,9 +313,8 @@ var ( }), }, { - Name: feemarkettypes.ModuleName, - Config: appconfig.WrapAny(&feemarketmodulev1.Module{ - }), + Name: feemarkettypes.ModuleName, + Config: appconfig.WrapAny(&feemarketmodulev1.Module{}), }, }, }) @@ -317,4 +326,4 @@ func DefaultDepinjectOptions() DepinjectOptions { Providers: []interface{}{}, Consumers: []interface{}{}, } -} \ No newline at end of file +} diff --git a/app/app_v2.go b/app/app_v2.go index 2d04388..a76bda1 100644 --- a/app/app_v2.go +++ b/app/app_v2.go @@ -5,10 +5,7 @@ import ( "os" "cosmossdk.io/depinject" - "github.com/bianjieai/irita/crypto/hd" - appkeeper "github.com/bianjieai/irita/modules/evm" - "github.com/bianjieai/irita/wrapper" - tibchost "github.com/bianjieai/tibc-go/modules/tibc/core/24-host" + dbm "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/baseapp" @@ -25,35 +22,32 @@ import ( authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + cosmosparamstypes "github.com/cosmos/cosmos-sdk/x/params/types" + evmkeeper "github.com/evmos/ethermint/x/evm/keeper" - evmtypes "github.com/evmos/ethermint/x/evm/types" feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper" - feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + + identitykeeper "iritamod.bianjie.ai/modules/identity/keeper" + nodekeeper "iritamod.bianjie.ai/modules/node/keeper" + paramskeeper "iritamod.bianjie.ai/modules/params/keeper" + slashingkeeper "iritamod.bianjie.ai/modules/slashing/keeper" + upgradekeeper "iritamod.bianjie.ai/modules/upgrade/keeper" + mtkeeper "mods.irisnet.org/modules/mt/keeper" nftkeeper "mods.irisnet.org/modules/nft/keeper" oraclekeeper "mods.irisnet.org/modules/oracle/keeper" randomkeeper "mods.irisnet.org/modules/random/keeper" recordkeeper "mods.irisnet.org/modules/record/keeper" - recordtypes "mods.irisnet.org/modules/record/types" servicekeeper "mods.irisnet.org/modules/service/keeper" - servicetypes "mods.irisnet.org/modules/service/types" tokenkeeper "mods.irisnet.org/modules/token/keeper" - tokentypes "mods.irisnet.org/modules/token/types" - identitykeeper "iritamod.bianjie.ai/modules/identity/keeper" - nodekeeper "iritamod.bianjie.ai/modules/node/keeper" - nodetypes "iritamod.bianjie.ai/modules/node/types" - slashingkeeper "iritamod.bianjie.ai/modules/slashing/keeper" - upgradekeeper "iritamod.bianjie.ai/modules/upgrade/keeper" + + "github.com/bianjieai/irita/crypto/hd" + "github.com/bianjieai/irita/wrapper" ) var _ servertypes.Application = (*IritaAppV2)(nil) @@ -84,7 +78,7 @@ type IritaAppV2 struct { OracleKeeper oraclekeeper.Keeper RandomKeeper randomkeeper.Keeper IdentityKeeper identitykeeper.Keeper - NodeKeeper nodekeeper.Keeper + NodeKeeper *nodekeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper CapabilityKeeper *capabilitykeeper.Keeper ConsensusParamsKeeper consensuskeeper.Keeper @@ -123,21 +117,18 @@ func NewIritaAppV2( providers = append(depInjectOptions.Providers, appOpts, - func(nodeKeeper nodekeeper.Keeper) *wrapper.StakingKeeper { - return wrapper.NewStakingKeeper(nodeKeeper) - }, - - func(evmKeeper *evmkeeper.Keeper) tokentypes.EVMKeeper { - return wrapper.NewEVMKeeper(evmKeeper) - }, - - func(nodeKeeper nodekeeper.Keeper) evmtypes.StakingKeeper { - return appkeeper.WNodeKeeper{Keeper: nodeKeeper} - }, ) // merge the AppConfig and other configuration in one config appConfig = depinject.Configs( depInjectOptions.Config, + depinject.Provide( + wrapper.ProvideSlashingStakingKeeper, + wrapper.ProvideEvidenceStakingKeeper, + wrapper.ProvideEvmStakingKeeper, + wrapper.ProvideEVMKeeper, + wrapper.ProvideICS20Keeper, + wrapper.ProvideEvmConstructor, + ), depinject.Supply( providers..., @@ -237,7 +228,7 @@ func NewIritaAppV2( os.Exit(1) } - app.initParamsKeeper() + // app.initParamsKeeper() /**** Module Options ****/ @@ -295,22 +286,7 @@ func (app *IritaAppV2) kvStoreKeys() map[string]*storetypes.KVStoreKey { // getSubspace returns a param subspace for a given module name. // // NOTE: This is solely to be used for testing purposes. -func (app *IritaAppV2) getSubspace(moduleName string) paramstypes.Subspace { +func (app *IritaAppV2) getSubspace(moduleName string) cosmosparamstypes.Subspace { subspace, _ := app.ParamsKeeper.GetSubspace(moduleName) return subspace -} - -// initParamsKeeper init params keeper and its subspaces -func (app *IritaAppV2) initParamsKeeper() { - app.ParamsKeeper.Subspace(authtypes.ModuleName) - app.ParamsKeeper.Subspace(banktypes.ModuleName) - app.ParamsKeeper.Subspace(nodetypes.ModuleName) - app.ParamsKeeper.Subspace(slashingtypes.ModuleName) - app.ParamsKeeper.Subspace(crisistypes.ModuleName) - app.ParamsKeeper.Subspace(tokentypes.ModuleName) - app.ParamsKeeper.Subspace(recordtypes.ModuleName) - app.ParamsKeeper.Subspace(servicetypes.ModuleName) - app.ParamsKeeper.Subspace(tibchost.ModuleName) - app.ParamsKeeper.Subspace(evmtypes.ModuleName) - app.ParamsKeeper.Subspace(feemarkettypes.ModuleName) -} +} \ No newline at end of file diff --git a/cmd/irita/main.go b/cmd/irita/main.go index 75c5770..e096490 100644 --- a/cmd/irita/main.go +++ b/cmd/irita/main.go @@ -3,6 +3,7 @@ package main import ( "os" + "github.com/cometbft/cometbft/crypto/algo" "github.com/cosmos/cosmos-sdk/server" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" @@ -11,6 +12,7 @@ import ( ) func main() { + algo.Algo = algo.SM2 rootCmd, _ := cmd.NewRootCmd() if err := svrcmd.Execute(rootCmd,"", app.DefaultNodeHome); err != nil { switch e := err.(type) { diff --git a/go.mod b/go.mod index 1496acc..2d79246 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,8 @@ go 1.19 replace ( github.com/cometbft/cometbft => github.com/bianjieai/cometbft v0.37.5-irita-240628 github.com/cosmos/cosmos-sdk => github.com/bianjieai/cosmos-sdk v0.47.12-irita-20240701 - github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.22.0-irishub-20240512.0.20240722070835-b3635f161021 + github.com/evmos/ethermint => /Users/dreamer/workspace/github/bianjieai/ethermint + // github.com/evmos/ethermint => github.com/bianjieai/ethermint v0.22.0-irishub-20240512.0.20240723082239-bd28be056dc7 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 golang.org/x/exp => golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb ) @@ -15,13 +16,13 @@ require ( cosmossdk.io/tools/rosetta v0.2.1 github.com/bianjieai/tibc-go v0.5.1-0.20240710015305-5ebf9ca08920 github.com/cosmos/cosmos-sdk v0.47.12 - iritamod.bianjie.ai/api v0.0.0-20240722082141-08d88a40c224 - iritamod.bianjie.ai/modules/genutil v0.0.0-20240722082141-08d88a40c224 - iritamod.bianjie.ai/modules/identity v0.0.0-20240722082141-08d88a40c224 - iritamod.bianjie.ai/modules/node v0.0.0-20240722082141-08d88a40c224 - iritamod.bianjie.ai/modules/params v0.0.0-20240722082141-08d88a40c224 - iritamod.bianjie.ai/modules/slashing v0.0.0-20240722082141-08d88a40c224 - iritamod.bianjie.ai/modules/upgrade v0.0.0-20240722082141-08d88a40c224 + iritamod.bianjie.ai/api v0.0.0-20240723085042-0822c26e608e + iritamod.bianjie.ai/modules/genutil v0.0.0-20240723085042-0822c26e608e + iritamod.bianjie.ai/modules/identity v0.0.0-20240723085042-0822c26e608e + iritamod.bianjie.ai/modules/node v0.0.0-20240723085042-0822c26e608e + iritamod.bianjie.ai/modules/params v0.0.0-20240723085042-0822c26e608e + iritamod.bianjie.ai/modules/slashing v0.0.0-20240723085042-0822c26e608e + iritamod.bianjie.ai/modules/upgrade v0.0.0-20240723085042-0822c26e608e mods.irisnet.org/modules/mt v0.0.0-20240705013837-55f906fb239e mods.irisnet.org/modules/nft v0.0.0-20240705013837-55f906fb239e mods.irisnet.org/modules/oracle v0.0.0-20240705013837-55f906fb239e diff --git a/go.sum b/go.sum index 3f17e6f..ec8eb0c 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,6 @@ github.com/bianjieai/cometbft v0.37.5-irita-240628 h1:ztIGnCj1zQ+H4zbEwmjzaEnXcP github.com/bianjieai/cometbft v0.37.5-irita-240628/go.mod h1:IBMt2O+RVs6kVJQ4/2QYdAmHQtMSX5ynfRrTu9ghCeA= github.com/bianjieai/cosmos-sdk v0.47.12-irita-20240701 h1:P01Cf16brUHKfRCkTlyn1ufM8Fr0a8YCYtoPNKHBQ2E= github.com/bianjieai/cosmos-sdk v0.47.12-irita-20240701/go.mod h1:Gd3PnQWerNtAZEJT6FbdOfxILK68AT8L9zZSRb9WMok= -github.com/bianjieai/ethermint v0.22.0-irishub-20240512.0.20240722070835-b3635f161021 h1:x9b8TlB2P2PyhonA4G9sa5Njie6WCHTs8vCjqxJ8ods= -github.com/bianjieai/ethermint v0.22.0-irishub-20240512.0.20240722070835-b3635f161021/go.mod h1:04OAz7IUzWNLtDLJWiGQMPLwmdQ1XjlWJUb/993+QHo= github.com/bianjieai/tibc-go v0.5.1-0.20240710015305-5ebf9ca08920 h1:HGL+3poZobbtkjwAP0JwtlUxD4QUtyQlzXqZ/zbDLKE= github.com/bianjieai/tibc-go v0.5.1-0.20240710015305-5ebf9ca08920/go.mod h1:pAl6C6Fu4Rq4eWLkkMELMvPE8gJplv2ksvbYr6mPmt4= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= @@ -1959,20 +1957,20 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= -iritamod.bianjie.ai/api v0.0.0-20240722082141-08d88a40c224 h1:R9uAWWaG+qdFrbSPyqzOcjaT4qrkeZqZSGHAacQjKmM= -iritamod.bianjie.ai/api v0.0.0-20240722082141-08d88a40c224/go.mod h1:YXOXuOvqR18EUOVUxe8GCw7toJomPdGmc44pmud/spU= -iritamod.bianjie.ai/modules/genutil v0.0.0-20240722082141-08d88a40c224 h1:RZsUM8K+cMlj4EqKjo5emIcLPCN25Bs373XLN3s3SwI= -iritamod.bianjie.ai/modules/genutil v0.0.0-20240722082141-08d88a40c224/go.mod h1:ybc3W8i7yqzvJBcWZ7FchKPfCqrz9IPX3R5VAnsu4ZA= -iritamod.bianjie.ai/modules/identity v0.0.0-20240722082141-08d88a40c224 h1:ZPFQM2p8ZxYMeomsIS+frouqeN6v9GLpLXRC5SHc1XA= -iritamod.bianjie.ai/modules/identity v0.0.0-20240722082141-08d88a40c224/go.mod h1:mbQHytjd/re1E/TyHb8Tl6ILhDBdPQtrxpey0g6gmto= -iritamod.bianjie.ai/modules/node v0.0.0-20240722082141-08d88a40c224 h1:kScAvTCa5XfH1+XJiPZ0vBxMVhxH/OKpP0RO4YmqR98= -iritamod.bianjie.ai/modules/node v0.0.0-20240722082141-08d88a40c224/go.mod h1:TtNdcDwQjuTujovq3jpJNZ2WGxFtTx4GtC+YJL1iOxQ= -iritamod.bianjie.ai/modules/params v0.0.0-20240722082141-08d88a40c224 h1:yeooQQXIIb4Kgz+cOXvwzBEl2N3k1nhztrat7hWYpSE= -iritamod.bianjie.ai/modules/params v0.0.0-20240722082141-08d88a40c224/go.mod h1:RaDtlzfFZ31tPm/Tc90zH5hJb3uNWI3LRMLpSTk5o5k= -iritamod.bianjie.ai/modules/slashing v0.0.0-20240722082141-08d88a40c224 h1:Q6gAxy6trX7bdRMqaU3z/paf3bCYx9P937/mVGfDWiM= -iritamod.bianjie.ai/modules/slashing v0.0.0-20240722082141-08d88a40c224/go.mod h1:OHndMemQbMIZZqpT92X03WAJ3De/zlHKSYGas6Yw6nI= -iritamod.bianjie.ai/modules/upgrade v0.0.0-20240722082141-08d88a40c224 h1:yZfir6D8s/HXBULkk7Edgwpwb4VvO96SmyN3Xc0XSKA= -iritamod.bianjie.ai/modules/upgrade v0.0.0-20240722082141-08d88a40c224/go.mod h1:qSTvq4DthUf6rvtBGjC4/ui9KyiQN2bdfEd0cLywx8g= +iritamod.bianjie.ai/api v0.0.0-20240723085042-0822c26e608e h1:umxzu+p36/Eo+OaPFMIp8+u07n+2+/tU2o/+aEN23GQ= +iritamod.bianjie.ai/api v0.0.0-20240723085042-0822c26e608e/go.mod h1:YXOXuOvqR18EUOVUxe8GCw7toJomPdGmc44pmud/spU= +iritamod.bianjie.ai/modules/genutil v0.0.0-20240723085042-0822c26e608e h1:4P1a4sMpke80bjwvLir0PXvwxmTno9vH0UQRrsWYvXc= +iritamod.bianjie.ai/modules/genutil v0.0.0-20240723085042-0822c26e608e/go.mod h1:ybc3W8i7yqzvJBcWZ7FchKPfCqrz9IPX3R5VAnsu4ZA= +iritamod.bianjie.ai/modules/identity v0.0.0-20240723085042-0822c26e608e h1:fMnyN7ntBDbpYwqHpMBjocnZkmaUNPBLQBCt1L2tv8g= +iritamod.bianjie.ai/modules/identity v0.0.0-20240723085042-0822c26e608e/go.mod h1:mbQHytjd/re1E/TyHb8Tl6ILhDBdPQtrxpey0g6gmto= +iritamod.bianjie.ai/modules/node v0.0.0-20240723085042-0822c26e608e h1:MjwNsn7FsCeVnasfpoy4142fBp3W5FHTRV/E7qrIqT8= +iritamod.bianjie.ai/modules/node v0.0.0-20240723085042-0822c26e608e/go.mod h1:kYET+nPDZqcAaABGwWbJopV1+eckv3itaYIchTw4cCk= +iritamod.bianjie.ai/modules/params v0.0.0-20240723085042-0822c26e608e h1:siBIrKT5UzXjoRf+qosyZjwXIAlsZxf5zfTidUI3RLY= +iritamod.bianjie.ai/modules/params v0.0.0-20240723085042-0822c26e608e/go.mod h1:RaDtlzfFZ31tPm/Tc90zH5hJb3uNWI3LRMLpSTk5o5k= +iritamod.bianjie.ai/modules/slashing v0.0.0-20240723085042-0822c26e608e h1:uRw/kPaIVt1KnY87Je+j7yFH7Ls120STbllS6iaZiic= +iritamod.bianjie.ai/modules/slashing v0.0.0-20240723085042-0822c26e608e/go.mod h1:oqndcjNU0R2NDi/AWbSZyqY+wFrHGFtsl2HCYYZoTdE= +iritamod.bianjie.ai/modules/upgrade v0.0.0-20240723085042-0822c26e608e h1:IrAOKm0bO2zkiLAeQPOE49m3vRQqjoqCJT0vyVI8JAw= +iritamod.bianjie.ai/modules/upgrade v0.0.0-20240723085042-0822c26e608e/go.mod h1:qSTvq4DthUf6rvtBGjC4/ui9KyiQN2bdfEd0cLywx8g= iritamod.bianjie.ai/simapp v0.0.0-20240715024259-c9745cbb9d78 h1:IgLToAIqLiWHOvpVuV4JSRWWLKVs6P+fvVnB73sdglg= mods.irisnet.org/api v0.0.0-20240628054110-4cb043e0238a h1:/MLyi/CV2TrCVtGREoSpeLpXZvCgIUfbe3vqy8Lo/k4= mods.irisnet.org/api v0.0.0-20240628054110-4cb043e0238a/go.mod h1:TpMaRRYSpqsXdeX4gDVFRj9ggedQ60Zcjs4iE2DIhsc= diff --git a/modules/evm/wnode.go b/modules/evm/wnode.go index 38a5a76..01db3cf 100644 --- a/modules/evm/wnode.go +++ b/modules/evm/wnode.go @@ -4,19 +4,27 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/bech32" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" "iritamod.bianjie.ai/modules/node" ) -type WNodeKeeper struct { +type stakingKeeper struct { node.Keeper } -func (node WNodeKeeper) GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool) { +// NewStakingKeeper creates a new instance of the stakingKeeper struct. +// +// It takes a `node.Keeper` as a parameter and returns a `evmtypes.StakingKeeper`. +func NewStakingKeeper(k node.Keeper) evmtypes.StakingKeeper { + return stakingKeeper{k} +} + +func (node stakingKeeper) GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool) { return node.Keeper.GetHistoricalInfo(ctx, height) } -func (node WNodeKeeper) GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool) { +func (node stakingKeeper) GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool) { addr, found := node.Keeper.GetValidatorByConsAddr(ctx, consAddr) if !found { return stakingtypes.Validator{}, false diff --git a/wrapper/evm.go b/wrapper/evm.go index 71e1014..91515cc 100644 --- a/wrapper/evm.go +++ b/wrapper/evm.go @@ -13,6 +13,8 @@ import ( "github.com/evmos/ethermint/crypto/ethsecp256k1" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" evmtypes "github.com/evmos/ethermint/x/evm/types" + evm "github.com/evmos/ethermint/x/evm/vm" + "github.com/evmos/ethermint/x/evm/vm/geth" tokentypes "mods.irisnet.org/modules/token/types" ) @@ -21,6 +23,14 @@ var ( _ tokentypes.EVMKeeper = (*evmKeeper)(nil) ) +func ProvideEvmConstructor() evm.Constructor { + return geth.NewEVM +} + +func ProvideEVMKeeper(evmKeeper *evmkeeper.Keeper) tokentypes.EVMKeeper { + return NewEVMKeeper(evmKeeper) +} + // NewEVMKeeper wraps the given evmkeeper.Keeper and returns a new evmKeeper. // // ek: The evmkeeper.Keeper to be wrapped. diff --git a/wrapper/ics20.go b/wrapper/ics20.go new file mode 100644 index 0000000..f7192f3 --- /dev/null +++ b/wrapper/ics20.go @@ -0,0 +1,16 @@ +package wrapper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + tokentypes "mods.irisnet.org/modules/token/types" +) +type MockICS20 struct{} + +// HasTrace implements types.ICS20Keeper. +func (t *MockICS20) HasTrace(ctx sdk.Context, denom string) bool { + return false +} + +func ProvideICS20Keeper() tokentypes.ICS20Keeper { + return &MockICS20{} +} \ No newline at end of file diff --git a/wrapper/staking.go b/wrapper/staking.go index 1e47e35..1c4fe6c 100644 --- a/wrapper/staking.go +++ b/wrapper/staking.go @@ -4,27 +4,48 @@ import ( "cosmossdk.io/math" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/bech32" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking/types" - nodekeeper "iritamod.bianjie.ai/modules/node/keeper" + + evmtypes "github.com/evmos/ethermint/x/evm/types" ) var ( _ slashingtypes.StakingKeeper = (*StakingKeeper)(nil) _ evidencetypes.StakingKeeper = (*StakingKeeper)(nil) + _ evmtypes.StakingKeeper = (*StakingKeeper)(nil) ) +type StakingKeeperI interface { + slashingtypes.StakingKeeper + evidencetypes.StakingKeeper + evmtypes.StakingKeeper +} + +func ProvideSlashingStakingKeeper(nodeKeeper *nodekeeper.Keeper) slashingtypes.StakingKeeper { + return NewStakingKeeper(nodeKeeper) +} + +func ProvideEvidenceStakingKeeper(nodeKeeper *nodekeeper.Keeper) evidencetypes.StakingKeeper { + return NewStakingKeeper(nodeKeeper) +} + +func ProvideEvmStakingKeeper(nodeKeeper *nodekeeper.Keeper) evmtypes.StakingKeeper { + return NewStakingKeeper(nodeKeeper) +} + // StakingKeeper implements the staking keeper interface. type StakingKeeper struct { - nk nodekeeper.Keeper + nk *nodekeeper.Keeper } // NewStakingKeeper creates a new instance of the stakingKeeper struct. // // It takes a nodekeeper.Keeper as a parameter and returns a pointer to the stakingKeeper struct. -func NewStakingKeeper(nk nodekeeper.Keeper) *StakingKeeper { +func NewStakingKeeper(nk *nodekeeper.Keeper) StakingKeeperI { return &StakingKeeper{ nk: nk, } @@ -127,3 +148,25 @@ func (s *StakingKeeper) GetParams(ctx sdk.Context) types.Params { MinCommissionRate: math.LegacyZeroDec(), } } + +// GetHistoricalInfo implements types.StakingKeeper. +func (s *StakingKeeper) GetHistoricalInfo(ctx sdk.Context, height int64) (types.HistoricalInfo, bool) { + return s.nk.GetHistoricalInfo(ctx, height) +} + +// GetValidatorByConsAddr implements types.StakingKeeper. +func (s *StakingKeeper) GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator types.Validator, found bool) { + addr, found := s.nk.GetValidatorByConsAddr(ctx, consAddr) + if !found { + return types.Validator{}, false + } + validator.Jailed = addr.Jailed + + _, i, err := bech32.DecodeAndConvert(addr.Operator) + if err != nil { + return types.Validator{}, false + } + validator.OperatorAddress = sdk.ValAddress(i).String() + + return validator, found +}