@@ -113,6 +113,15 @@ import (
113113 pushchainmodule "pushchain/x/pushchain"
114114 pushchainmodulekeeper "pushchain/x/pushchain/keeper"
115115 pushchainmoduletypes "pushchain/x/pushchain/types"
116+
117+ evmante "github.com/zeta-chain/ethermint/app/ante"
118+ ethermint "github.com/zeta-chain/ethermint/types"
119+ "github.com/zeta-chain/ethermint/x/evm"
120+ evmkeeper "github.com/zeta-chain/ethermint/x/evm/keeper"
121+ evmtypes "github.com/zeta-chain/ethermint/x/evm/types"
122+ "github.com/zeta-chain/ethermint/x/feemarket"
123+ feemarketkeeper "github.com/zeta-chain/ethermint/x/feemarket/keeper"
124+ feemarkettypes "github.com/zeta-chain/ethermint/x/feemarket/types"
116125 // this line is used by starport scaffolding # stargate/app/moduleImport
117126
118127 appparams "pushchain/app/params"
@@ -187,6 +196,7 @@ var (
187196 stakingtypes .NotBondedPoolName : {authtypes .Burner , authtypes .Staking },
188197 govtypes .ModuleName : {authtypes .Burner },
189198 ibctransfertypes .ModuleName : {authtypes .Minter , authtypes .Burner },
199+ evmtypes .ModuleName : {authtypes .Minter , authtypes .Burner },
190200 // this line is used by starport scaffolding # stargate/app/maccPerms
191201 }
192202)
@@ -198,9 +208,10 @@ var (
198208
199209func init () {
200210 userHomeDir , err := os .UserHomeDir ()
201- if err != nil {
211+ if ( err != nil ) {
202212 panic (err )
203213 }
214+ sdk .DefaultPowerReduction = ethermint .PowerReduction
204215
205216 DefaultNodeHome = filepath .Join (userHomeDir , "." + Name )
206217}
@@ -244,6 +255,10 @@ type App struct {
244255 GroupKeeper groupkeeper.Keeper
245256 ConsensusParamsKeeper consensusparamkeeper.Keeper
246257
258+ //EVM
259+ EvmKeeper * evmkeeper.Keeper
260+ FeeMarketKeeper feemarketkeeper.Keeper
261+
247262 // make scoped keepers public for test purposes
248263 ScopedIBCKeeper capabilitykeeper.ScopedKeeper
249264 ScopedTransferKeeper capabilitykeeper.ScopedKeeper
@@ -269,7 +284,7 @@ func New(
269284 skipUpgradeHeights map [int64 ]bool ,
270285 homePath string ,
271286 invCheckPeriod uint ,
272- encodingConfig appparams .EncodingConfig ,
287+ encodingConfig ethermint .EncodingConfig ,
273288 appOpts servertypes.AppOptions ,
274289 baseAppOptions ... func (* baseapp.BaseApp ),
275290) * App {
@@ -296,10 +311,11 @@ func New(
296311 govtypes .StoreKey , paramstypes .StoreKey , ibcexported .StoreKey , upgradetypes .StoreKey ,
297312 feegrant .StoreKey , evidencetypes .StoreKey , ibctransfertypes .StoreKey , icahosttypes .StoreKey ,
298313 capabilitytypes .StoreKey , group .StoreKey , icacontrollertypes .StoreKey , consensusparamtypes .StoreKey ,
299- pushchainmoduletypes .StoreKey ,
314+ pushchainmoduletypes .StoreKey ,evmtypes .StoreKey ,feemarkettypes .StoreKey ,
315+
300316 // this line is used by starport scaffolding # stargate/app/storeKey
301317 )
302- tkeys := sdk .NewTransientStoreKeys (paramstypes .TStoreKey )
318+ tkeys := storetypes .NewTransientStoreKeys (paramstypes .TStoreKey , evmtypes . TransientKey , feemarkettypes . TransientKey )
303319 memKeys := sdk .NewMemoryStoreKeys (capabilitytypes .MemStoreKey )
304320
305321 app := & App {
@@ -343,7 +359,7 @@ func New(
343359 app .AccountKeeper = authkeeper .NewAccountKeeper (
344360 appCodec ,
345361 keys [authtypes .StoreKey ],
346- authtypes . ProtoBaseAccount ,
362+ ethermint . ProtoAccount ,
347363 maccPerms ,
348364 sdk .Bech32PrefixAccAddr ,
349365 authtypes .NewModuleAddress (govtypes .ModuleName ).String (),
@@ -415,6 +431,43 @@ func New(
415431 authtypes .NewModuleAddress (govtypes .ModuleName ).String (),
416432 )
417433
434+ // Create Ethermint keepers
435+ tracer := cast .ToString (appOpts .Get (srvflags .EVMTracer ))
436+ feeSs := app .GetSubspace (feemarkettypes .ModuleName )
437+ app .FeeMarketKeeper = feemarketkeeper .NewKeeper (
438+ appCodec ,
439+ authtypes .NewModuleAddress (govtypes .ModuleName ),
440+ keys [feemarkettypes .StoreKey ],
441+ tKeys [feemarkettypes .TransientKey ],
442+ feeSs ,
443+ app .ConsensusParamsKeeper ,
444+ )
445+
446+ evmSs := app .GetSubspace (evmtypes .ModuleName )
447+
448+ app .EvmKeeper = evmkeeper .NewKeeper (
449+ appCodec ,
450+ keys [evmtypes .StoreKey ],
451+ tKeys [evmtypes .TransientKey ],
452+ authtypes .NewModuleAddress (govtypes .ModuleName ),
453+ app .AccountKeeper ,
454+ app .BankKeeper ,
455+ app .StakingKeeper ,
456+ & app .FeeMarketKeeper ,
457+ tracer ,
458+ evmSs ,
459+ precompiles .StatefulContracts (
460+ & app .FungibleKeeper ,
461+ app .StakingKeeper ,
462+ app .BankKeeper ,
463+ app .DistrKeeper ,
464+ appCodec ,
465+ storetypes .TransientGasConfig (),
466+ ),
467+ app .ConsensusParamsKeeper ,
468+ aggregateAllKeys (keys , tKeys , memKeys ),
469+ )
470+
418471 groupConfig := group .DefaultConfig ()
419472 /*
420473 Example of setting group params:
@@ -504,11 +557,11 @@ func New(
504557 govConfig ,
505558 authtypes .NewModuleAddress (govtypes .ModuleName ).String (),
506559 )
507-
560+
508561 govRouter := govv1beta1 .NewRouter ()
509562 govRouter .
510- AddRoute (govtypes .RouterKey , govv1beta1 .ProposalHandler ).
511- AddRoute (paramproposal .RouterKey , params .NewParamChangeProposalHandler (app .ParamsKeeper )).
563+ AddRoute (govtypes .RouterKey , govv1beta1 .ProposalHandler ).
564+ AddRoute (paramproposal .RouterKey , params .NewParamChangeProposalHandler (app .ParamsKeeper )).
512565 AddRoute (upgradetypes .RouterKey , upgrade .NewSoftwareUpgradeProposalHandler (app .UpgradeKeeper )).
513566 AddRoute (ibcclienttypes .RouterKey , ibcclient .NewClientProposalHandler (app .IBCKeeper .ClientKeeper ))
514567 govKeeper .SetLegacyRouter (govRouter )
@@ -527,6 +580,10 @@ func New(
527580 )
528581 pushchainModule := pushchainmodule .NewAppModule (appCodec , app .PushchainKeeper , app .AccountKeeper , app .BankKeeper )
529582
583+ // app.EvmKeeper = app.EvmKeeper.SetHooks(evmkeeper.NewMultiEvmHooks(
584+ // app.CrosschainKeeper.Hooks(),
585+ // app.FungibleKeeper.EVMHooks(),
586+ // ))
530587 // this line is used by starport scaffolding # stargate/app/keeperDefinition
531588
532589 /**** IBC Routing ****/
@@ -569,13 +626,16 @@ func New(
569626 app .BaseApp .DeliverTx ,
570627 encodingConfig .TxConfig ,
571628 ),
629+ evm .NewAppModule (app .EvmKeeper , app .AccountKeeper , evmSs ),
630+
572631 auth .NewAppModule (appCodec , app .AccountKeeper , authsims .RandomGenesisAccounts , app .GetSubspace (authtypes .ModuleName )),
573632 authzmodule .NewAppModule (appCodec , app .AuthzKeeper , app .AccountKeeper , app .BankKeeper , app .interfaceRegistry ),
574633 vesting .NewAppModule (app .AccountKeeper , app .BankKeeper ),
575634 bank .NewAppModule (appCodec , app .BankKeeper , app .AccountKeeper , app .GetSubspace (banktypes .ModuleName )),
576635 capability .NewAppModule (appCodec , * app .CapabilityKeeper , false ),
577636 feegrantmodule .NewAppModule (appCodec , app .AccountKeeper , app .BankKeeper , app .FeeGrantKeeper , app .interfaceRegistry ),
578637 groupmodule .NewAppModule (appCodec , app .GroupKeeper , app .AccountKeeper , app .BankKeeper , app .interfaceRegistry ),
638+ feemarket .NewAppModule (app .FeeMarketKeeper , feeSs ),
579639 gov .NewAppModule (appCodec , & app .GovKeeper , app .AccountKeeper , app .BankKeeper , app .GetSubspace (govtypes .ModuleName )),
580640 mint .NewAppModule (appCodec , app .MintKeeper , app .AccountKeeper , nil , app .GetSubspace (minttypes .ModuleName )),
581641 slashing .NewAppModule (appCodec , app .SlashingKeeper , app .AccountKeeper , app .BankKeeper , app .StakingKeeper , app .GetSubspace (slashingtypes .ModuleName )),
@@ -622,11 +682,16 @@ func New(
622682 vestingtypes .ModuleName ,
623683 consensusparamtypes .ModuleName ,
624684 pushchainmoduletypes .ModuleName ,
685+ evmtypes .ModuleName ,
686+ feemarkettypes .ModuleName ,
687+
625688 // this line is used by starport scaffolding # stargate/app/beginBlockers
626689 )
627690
628691 app .mm .SetOrderEndBlockers (
629692 crisistypes .ModuleName ,
693+ evmtypes .ModuleName ,
694+ feemarkettypes .ModuleName ,
630695 govtypes .ModuleName ,
631696 stakingtypes .ModuleName ,
632697 ibctransfertypes .ModuleName ,
@@ -693,7 +758,7 @@ func New(
693758
694759 autocliv1 .RegisterQueryServer (app .GRPCQueryRouter (), runtimeservices .NewAutoCLIQueryService (app .mm .Modules ))
695760 reflectionSvc , err := runtimeservices .NewReflectionService ()
696- if err != nil {
761+ if ( err != nil ) {
697762 panic (err )
698763 }
699764 reflectionv1 .RegisterReflectionServiceServer (app .GRPCQueryRouter (), reflectionSvc )
@@ -711,26 +776,45 @@ func New(
711776 app .MountMemoryStores (memKeys )
712777
713778 // initialize BaseApp
714- anteHandler , err := ante .NewAnteHandler (
715- ante.HandlerOptions {
716- AccountKeeper : app .AccountKeeper ,
717- BankKeeper : app .BankKeeper ,
718- SignModeHandler : encodingConfig .TxConfig .SignModeHandler (),
719- FeegrantKeeper : app .FeeGrantKeeper ,
720- SigGasConsumer : ante .DefaultSigVerificationGasConsumer ,
779+ options := ante.HandlerOptions {
780+ AccountKeeper : app .AccountKeeper ,
781+ BankKeeper : app .BankKeeper ,
782+ EvmKeeper : app .EvmKeeper ,
783+ FeeMarketKeeper : app .FeeMarketKeeper ,
784+ SignModeHandler : encodingConfig .TxConfig .SignModeHandler (),
785+ SigGasConsumer : evmante .DefaultSigVerificationGasConsumer ,
786+ MaxTxGasWanted : TransactionGasLimit ,
787+ DisabledAuthzMsgs : []string {
788+ sdk .MsgTypeURL (
789+ & evmtypes.MsgEthereumTx {},
790+ ), // disable the Msg types that cannot be included on an authz.MsgExec msgs field
791+ sdk .MsgTypeURL (& vestingtypes.MsgCreateVestingAccount {}),
792+ sdk .MsgTypeURL (& vestingtypes.MsgCreatePermanentLockedAccount {}),
793+ sdk .MsgTypeURL (& vestingtypes.MsgCreatePeriodicVestingAccount {}),
721794 },
722- )
723- if err != nil {
724- panic (fmt .Errorf ("failed to create AnteHandler: %w" , err ))
795+ ObserverKeeper : app .ObserverKeeper ,
796+ }
797+
798+ anteHandler , err := ante .NewAnteHandler (options )
799+ if (err != nil ) {
800+ panic (err )
725801 }
726802
727803 app .SetAnteHandler (anteHandler )
804+ app .SetEndBlocker (app .EndBlocker )
805+ SetupHandlers (app )
806+ if (loadLatest ) {
807+ if (err := app .LoadLatestVersion (); err != nil ) {
808+ tmos .Exit (err .Error ())
809+ }
810+ }
811+
728812 app .SetInitChainer (app .InitChainer )
729813 app .SetBeginBlocker (app .BeginBlocker )
730814 app .SetEndBlocker (app .EndBlocker )
731815
732- if loadLatest {
733- if err := app .LoadLatestVersion (); err != nil {
816+ if ( loadLatest ) {
817+ if ( err := app .LoadLatestVersion (); err != nil ) {
734818 tmos .Exit (err .Error ())
735819 }
736820 }
@@ -758,7 +842,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
758842// InitChainer application update at chain initialization
759843func (app * App ) InitChainer (ctx sdk.Context , req abci.RequestInitChain ) abci.ResponseInitChain {
760844 var genesisState GenesisState
761- if err := json .Unmarshal (req .AppStateBytes , & genesisState ); err != nil {
845+ if ( err := json .Unmarshal (req .AppStateBytes , & genesisState ); err != nil ) {
762846 panic (err )
763847 }
764848 app .UpgradeKeeper .SetModuleVersionMap (ctx , app .mm .GetVersionMap ())
@@ -778,7 +862,7 @@ func (app *App) LoadHeight(height int64) error {
778862// ModuleAccountAddrs returns all the app's module account addresses.
779863func (app * App ) ModuleAccountAddrs () map [string ]bool {
780864 modAccAddrs := make (map [string ]bool )
781- for acc := range maccPerms {
865+ for ( acc := range maccPerms ) {
782866 modAccAddrs [authtypes .NewModuleAddress (acc ).String ()] = true
783867 }
784868
@@ -899,6 +983,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
899983 paramsKeeper .Subspace (slashingtypes .ModuleName )
900984 paramsKeeper .Subspace (govtypes .ModuleName ).WithKeyTable (govv1 .ParamKeyTable ()) //nolint:staticcheck
901985 paramsKeeper .Subspace (crisistypes .ModuleName )
986+ paramsKeeper .Subspace (evmtypes .ModuleName )
987+ paramsKeeper .Subspace (feemarkettypes .ModuleName )
902988 paramsKeeper .Subspace (ibctransfertypes .ModuleName )
903989 paramsKeeper .Subspace (ibcexported .ModuleName )
904990 paramsKeeper .Subspace (icacontrollertypes .SubModuleName )
0 commit comments