Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Jul 17, 2024
1 parent fa95bd2 commit bf3252f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 129 deletions.
11 changes: 6 additions & 5 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
evmtypes "github.com/evmos/ethermint/x/evm/types"
tokenkeeper "github.com/irisnet/irismod/modules/token/keeper"

ethante "github.com/evmos/ethermint/app/ante"
Expand All @@ -24,9 +23,9 @@ type HandlerOptions struct {
SignModeHandler signing.SignModeHandler

// evm config
EvmKeeper ethante.EVMKeeper
EvmFeeMarketKeeper evmtypes.FeeMarketKeeper
MaxTxGasWanted uint64
EvmKeeper ethante.EVMKeeper
FeeMarketKeeper ethante.FeeMarketKeeper
MaxTxGasWanted uint64
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
Expand All @@ -51,6 +50,9 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
case "/ethermint.types.v1.ExtensionOptionsWeb3Tx":
// handle as normal Cosmos SDK tx, except signature is checked for EIP712 representation
anteHandler = newCosmosAnteHandlerEip712(options)
case "/ethermint.types.v1.ExtensionOptionDynamicFeeTx":
// cosmos-sdk tx with dynamic fee extension
anteHandler = newCosmosAnteHandler(options)
default:
return ctx, errorsmod.Wrapf(
sdkerrors.ErrUnknownExtensionOptions,
Expand All @@ -70,6 +72,5 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
}

return anteHandler(ctx, tx, sim)

}
}
3 changes: 2 additions & 1 deletion app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ func newCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.RejectMessagesDecorator{}, // reject MsgEthereumTxs
ante.NewSetUpContextDecorator(),
ethante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),

// perm check
evmmoduleante.NewEthSigVerificationDecorator(options.EvmKeeper, options.AccountKeeper, options.SignModeHandler),
// evmmoduleante.NewEthSigVerificationDecorator(options.EvmKeeper, options.AccountKeeper, options.SignModeHandler),

// NOTE: extensions option decorator removed
// ante.NewRejectExtensionOptionsDecorator(),
Expand Down
32 changes: 19 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ import (
upgradetypes "iritamod.bianjie.ai/modules/upgrade/types"
)

const appName = "IritaApp"
const (
appName = "IritaApp"
)

var storeKeys = []string{
authtypes.StoreKey,
Expand Down Expand Up @@ -321,11 +323,14 @@ func NewIritaApp(
memKeys: memKeys,
}

authority := cast.ToString(appOpts.Get(flagAuthority))
authorityAddr := sdk.MustAccAddressFromBech32(authority)

app.paramsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
app.ConsensusParamsKeeper = consensuskeeper.NewKeeper(
appCodec,
app.keys[consensustypes.StoreKey],
authtypes.NewModuleAddress("gov").String(),
authority,
)

// set the BaseApp's parameter store
Expand All @@ -338,14 +343,14 @@ func NewIritaApp(
authtypes.ProtoBaseAccount,
maccPerms,
address.Bech32PrefixAccAddr,
authtypes.NewModuleAddress("gov").String(),
authority,
)
app.bankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
app.accountKeeper,
app.ModuleAccountAddrs(),
authtypes.NewModuleAddress("gov").String(),
authority,
)
app.nodeKeeper = node.NewKeeper(appCodec, keys[nodetypes.StoreKey], app.GetSubspace(node.ModuleName))

Expand All @@ -355,15 +360,15 @@ func NewIritaApp(
cdc,
keys[slashingtypes.StoreKey],
stakingKeeper,
authtypes.NewModuleAddress("gov").String(),
authority,
)
app.crisisKeeper = crisiskeeper.NewKeeper(
appCodec,
keys[crisistypes.StoreKey],
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
app.bankKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress("gov").String(),
authority,
)
app.feeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.accountKeeper)

Expand All @@ -378,7 +383,7 @@ func NewIritaApp(
appCodec,
cast.ToString(appOpts.Get(flags.FlagHome)),
app.BaseApp,
authtypes.NewModuleAddress("gov").String(),
authority,
)
app.upgradeKeeper = upgradekeeper.NewKeeper(sdkUpgradeKeeper)

Expand All @@ -400,7 +405,7 @@ func NewIritaApp(
wrapper.NewEVMKeeper(app.EvmKeeper),
nil,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress("gov").String(),
authority,
)

app.recordKeeper = recordkeeper.NewKeeper(appCodec, keys[recordtypes.StoreKey])
Expand All @@ -418,7 +423,7 @@ func NewIritaApp(
app.accountKeeper,
app.bankKeeper,
servicetypes.FeeCollectorName,
authtypes.NewModuleAddress("gov").String(),
authority,
)

app.oracleKeeper = oraclekeeper.NewKeeper(
Expand All @@ -441,7 +446,7 @@ func NewIritaApp(
// Create Ethermint keepers
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
appCodec,
authtypes.NewModuleAddress("gov"),
authorityAddr,
keys[feemarkettypes.StoreKey],
tkeys[feemarkettypes.TransientKey],
app.GetSubspace(feemarkettypes.ModuleName),
Expand All @@ -450,7 +455,7 @@ func NewIritaApp(
appCodec,
keys[evmtypes.StoreKey],
tkeys[evmtypes.TransientKey],
authtypes.NewModuleAddress("gov"),
authorityAddr,
app.accountKeeper,
app.bankKeeper,
appkeeper.WNodeKeeper{Keeper: app.nodeKeeper},
Expand All @@ -466,7 +471,7 @@ func NewIritaApp(
appCodec,
keys[tibchost.StoreKey],
app.nodeKeeper,
authtypes.NewModuleAddress("gov").String(),
authority,
)
app.tibcKeeper = tibckeeper.NewKeeper(tibccorekeeper)
app.nftTransferKeeper = tibcnfttransferkeeper.NewKeeper(
Expand Down Expand Up @@ -749,6 +754,7 @@ func (app *IritaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abc
serviceGenState.Definitions = append(serviceGenState.Definitions, randomtypes.GetSvcDefinition())
genesisState[servicetypes.ModuleName] = app.appCodec.MustMarshalJSON(&serviceGenState)

app.upgradeKeeper.UpgradeKeeper().SetModuleVersionMap(ctx, app.mm.GetVersionMap())
return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand Down Expand Up @@ -890,7 +896,7 @@ func (app *IritaApp) BuildAnteHandler(encodingConfig simappparams.EncodingConfig
SigGasConsumer: ethermintante.DefaultSigVerificationGasConsumer,

// evm
EvmFeeMarketKeeper: app.FeeMarketKeeper,
FeeMarketKeeper: app.FeeMarketKeeper,
EvmKeeper: app.EvmKeeper,
}

Expand Down
108 changes: 0 additions & 108 deletions app/app_test.go

This file was deleted.

16 changes: 16 additions & 0 deletions app/params.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package app

import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/spf13/cobra"
)

// Simulation parameter constants
const (
StakePerAccount = "stake_per_account"
Expand All @@ -22,3 +27,14 @@ const (
OpWeightMsgBeginRedelegate = "op_weight_msg_begin_redelegate"
OpWeightMsgUnjail = "op_weight_msg_unjail"
)

const (
flagAuthority = "authority"
defaultAuthority = "gov"
)

// AddStartFlags defines flags for the start of the application
func AddStartFlags(startCmd *cobra.Command) {
authority := authtypes.NewModuleAddress(defaultAuthority).String()
startCmd.Flags().String(flagAuthority, authority, "authority of the module")
}
5 changes: 3 additions & 2 deletions cmd/irita/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

"github.com/bianjieai/irita/app"

evmclient "github.com/bianjieai/irita/modules/evm/client"
genutilcli "iritamod.bianjie.ai/modules/genutil/client/cli"
"iritamod.bianjie.ai/modules/node"
)
Expand Down Expand Up @@ -122,13 +123,13 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
rpc.StatusCommand(),
queryCommand(),
txCommand(),
ethermintclient.KeyCommands(app.DefaultNodeHome),
evmclient.KeyCommands(app.DefaultNodeHome),
)

}

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
app.AddStartFlags(startCmd)
}

func queryCommand() *cobra.Command {
Expand Down

0 comments on commit bf3252f

Please sign in to comment.