Skip to content
Open
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
6 changes: 3 additions & 3 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
switch typeURL := opts[0].GetTypeUrl(); typeURL {
case "/cosmos.evm.vm.v1.ExtensionOptionsEthereumTx":
// handle as *evmtypes.MsgEthereumTx
anteHandler = newMonoEVMAnteHandler(options)
anteHandler = newMonoEVMAnteHandler(ctx, options)
case "/cosmos.evm.types.v1.ExtensionOptionDynamicFeeTx":
// cosmos-sdk tx with dynamic fee extension
anteHandler = NewCosmosAnteHandler(options)
anteHandler = NewCosmosAnteHandler(ctx, options)
default:
return ctx, errorsmod.Wrapf(
errortypes.ErrUnknownExtensionOptions,
Expand All @@ -42,7 +42,7 @@ func NewAnteHandler(options HandlerOptions) sdk.AnteHandler {
// handle as totally normal Cosmos SDK tx
switch tx.(type) {
case sdk.Tx:
anteHandler = NewCosmosAnteHandler(options)
anteHandler = NewCosmosAnteHandler(ctx, options)
default:
return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid transaction type: %T", tx)
}
Expand Down
10 changes: 6 additions & 4 deletions app/ante/ante_cosmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (
cosmosante "github.com/pushchain/push-chain-node/app/cosmos"
)

// newCosmosAnteHandler creates the default ante handler for Cosmos transactions
func NewCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
// NewCosmosAnteHandler creates the default ante handler for Cosmos transactions
func NewCosmosAnteHandler(ctx sdk.Context, options HandlerOptions) sdk.AnteHandler {
feemarketParams := options.FeeMarketKeeper.GetParams(ctx)
txFeeChecker := evmante.NewDynamicFeeChecker(&feemarketParams)

return sdk.ChainAnteDecorators(
cosmosevmcosmosante.NewRejectMessagesDecorator(), // reject MsgEthereumTxs
Expand All @@ -35,9 +37,9 @@ func NewCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {
ante.NewValidateMemoDecorator(options.AccountKeeper),
cosmosante.NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, txFeeChecker),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
evmante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper, &feemarketParams),
// NewAccountInitDecorator must be called before all signature verification decorators and SetPubKeyDecorator
// - this
// 1. generates the account for the new accounts only for gasless transactions,
Expand Down
6 changes: 5 additions & 1 deletion app/ante/ante_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ func (w evmAccountKeeperWrapper) TryAddUnorderedNonce(_ sdk.Context, _ []byte, _
}

// newMonoEVMAnteHandler creates the sdk.AnteHandler implementation for the EVM transactions.
func newMonoEVMAnteHandler(options HandlerOptions) sdk.AnteHandler {
func newMonoEVMAnteHandler(ctx sdk.Context, options HandlerOptions) sdk.AnteHandler {
evmParams := options.EvmKeeper.GetParams(ctx)
feemarketParams := options.FeeMarketKeeper.GetParams(ctx)
return sdk.ChainAnteDecorators(
evmante.NewEVMMonoDecorator(
evmAccountKeeperWrapper{options.AccountKeeper},
options.FeeMarketKeeper,
options.EvmKeeper,
options.MaxTxGasWanted,
&evmParams,
&feemarketParams,
),
)
}
6 changes: 1 addition & 5 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ type HandlerOptions struct {
ExtensionOptionChecker ante.ExtensionOptionChecker
SignModeHandler *txsigning.HandlerMap
SigGasConsumer func(meter storetypes.GasMeter, sig signing.SignatureV2, params authtypes.Params) error
TxFeeChecker ante.TxFeeChecker // safe to be nil

WasmConfig *wasmtypes.NodeConfig
WasmKeeper *wasmkeeper.Keeper
TXCounterStoreService corestoretypes.KVStoreService
Expand All @@ -63,6 +61,7 @@ type HandlerOptions struct {
FeeMarketKeeper anteinterfaces.FeeMarketKeeper
EvmKeeper anteinterfaces.EVMKeeper


IBCKeeper *ibckeeper.Keeper
CircuitKeeper *circuitkeeper.Keeper
}
Expand Down Expand Up @@ -98,9 +97,6 @@ func (options HandlerOptions) Validate() error {
return errorsmod.Wrap(errortypes.ErrLogic, "wasm keeper is required for ante builder")
}

if options.TxFeeChecker == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "tx fee checker is required for AnteHandler")
}
if options.FeeMarketKeeper == nil {
return errorsmod.Wrap(errortypes.ErrLogic, "fee market keeper is required for AnteHandler")
}
Expand Down
44 changes: 31 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool"
"github.com/cosmos/cosmos-sdk/types/msgservice"
signingtype "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/version"
Expand Down Expand Up @@ -107,10 +108,9 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
cosmosevmante "github.com/cosmos/evm/ante"
cosmosevmevmante "github.com/cosmos/evm/ante/evm"
cosmosevmencoding "github.com/cosmos/evm/encoding"
srvflags "github.com/cosmos/evm/server/flags"
cosmosevmtypes "github.com/cosmos/evm/types"
antetypes "github.com/cosmos/evm/ante/types"
cosmosevmutils "github.com/cosmos/evm/utils"
"github.com/cosmos/evm/x/erc20"
erc20keeper "github.com/cosmos/evm/x/erc20/keeper"
Expand Down Expand Up @@ -155,6 +155,7 @@ import (
ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint"

// "github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/common"
cosmoscorevm "github.com/ethereum/go-ethereum/core/vm"
chainante "github.com/pushchain/push-chain-node/app/ante"

Expand Down Expand Up @@ -289,6 +290,8 @@ type ChainApp struct {
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry types.InterfaceRegistry
clientCtx client.Context
pendingTxListeners []func(common.Hash)

// keys to access the substores
keys map[string]*storetypes.KVStoreKey
Expand Down Expand Up @@ -708,8 +711,9 @@ func NewChainApp(
app.BankKeeper,
app.StakingKeeper,
app.FeeMarketKeeper,
app.ConsensusParamsKeeper,
&app.ConsensusParamsKeeper,
&app.Erc20Keeper,
EVMChainID,
tracer,
)

Expand Down Expand Up @@ -787,13 +791,11 @@ func NewChainApp(
*app.StakingKeeper,
app.DistrKeeper,
app.BankKeeper,
app.Erc20Keeper,
app.TransferKeeper,
&app.Erc20Keeper,
&app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.EVMKeeper,
app.GovKeeper,
app.SlashingKeeper,
app.EvidenceKeeper,
appCodec,
)

Expand Down Expand Up @@ -853,7 +855,6 @@ func NewChainApp(
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]),
app.GetSubspace(ibctransfertypes.ModuleName),
app.RatelimitKeeper, // ICS4Wrapper
//app.IBCFeeKeeper,
app.IBCKeeper.ChannelKeeper,
Expand Down Expand Up @@ -1046,7 +1047,7 @@ func NewChainApp(
packetforward.NewAppModule(app.PacketForwardKeeper, app.GetSubspace(packetforwardtypes.ModuleName)),
wasmlc.NewAppModule(app.WasmClientKeeper),
ratelimit.NewAppModule(appCodec, app.RatelimitKeeper),
vm.NewAppModule(app.EVMKeeper, authKeeperEVMWrapper{app.AccountKeeper}, app.AccountKeeper.AddressCodec()),
vm.NewAppModule(app.EVMKeeper, authKeeperEVMWrapper{app.AccountKeeper}, app.BankKeeper, app.AccountKeeper.AddressCodec()),
feemarket.NewAppModule(app.FeeMarketKeeper),
erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper),
uexecutor.NewAppModule(appCodec, app.UexecutorKeeper, app.EVMKeeper, app.FeeMarketKeeper, app.BankKeeper, app.AccountKeeper, app.UregistryKeeper, app.UvalidatorKeeper),
Expand All @@ -1070,7 +1071,8 @@ func NewChainApp(
// NOTE: upgrade module is required to be prioritized
app.ModuleManager.SetOrderPreBlockers(
upgradetypes.ModuleName,
authtypes.ModuleName, // NEW
authtypes.ModuleName,
evmtypes.ModuleName,
)
// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
Expand Down Expand Up @@ -1239,10 +1241,9 @@ func NewChainApp(
CircuitKeeper: &app.CircuitKeeper,

EvmKeeper: app.EVMKeeper,
ExtensionOptionChecker: cosmosevmtypes.HasDynamicFeeExtensionOption,
ExtensionOptionChecker: antetypes.HasDynamicFeeExtensionOption,
SigGasConsumer: cosmosevmante.SigVerificationGasConsumer,
MaxTxGasWanted: cast.ToUint64(appOpts.Get(srvflags.EVMMaxTxGasWanted)),
TxFeeChecker: cosmosevmevmante.NewDynamicFeeChecker(app.FeeMarketKeeper),
})

// must be before Loading version
Expand Down Expand Up @@ -1376,7 +1377,7 @@ func (a *ChainApp) Configurator() module.Configurator {
// InitChainer application update at chain initialization
func (app *ChainApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {

var genesisState cosmosevmtypes.GenesisState
var genesisState map[string]json.RawMessage
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
}
Expand Down Expand Up @@ -1450,6 +1451,7 @@ func (a *ChainApp) DefaultGenesis() map[string]json.RawMessage {

evmGenState := evmtypes.DefaultGenesisState()
evmGenState.Params.ActiveStaticPrecompiles = evmtypes.AvailableStaticPrecompiles
evmGenState.Params.EvmDenom = BaseDenom
genesis[evmtypes.ModuleName] = a.appCodec.MustMarshalJSON(evmGenState)

// NOTE: for the example chain implementation we are also adding a default token pair,
Expand Down Expand Up @@ -1550,6 +1552,22 @@ func (app *ChainApp) RegisterNodeService(clientCtx client.Context, cfg config.Co
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg)
}

// SetClientCtx sets the client context on the app (required by evmserver.Application).
func (app *ChainApp) SetClientCtx(clientCtx client.Context) {
app.clientCtx = clientCtx
}

// RegisterPendingTxListener registers a listener for pending EVM transactions (required by evmserver.Application).
func (app *ChainApp) RegisterPendingTxListener(listener func(common.Hash)) {
app.pendingTxListeners = append(app.pendingTxListeners, listener)
}

// GetMempool returns nil — push-chain does not use the EVM experimental mempool.
// This satisfies the evmserver.Application interface added in cosmos/evm v0.5.
func (app *ChainApp) GetMempool() sdkmempool.ExtMempool {
return nil
}

// GetMaccPerms returns a copy of the module account permissions
//
// NOTE: This is solely to be used for testing purposes.
Expand Down
13 changes: 1 addition & 12 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var ChainsCoinInfo = map[string]evmtypes.EvmCoinInfo{
Denom: BaseDenom,
ExtendedDenom: BaseDenom,
DisplayDenom: DisplayDenom,
Decimals: evmtypes.EighteenDecimals,
Decimals: evmtypes.EighteenDecimals.Uint32(),
},
}

Expand Down Expand Up @@ -59,17 +59,6 @@ func EVMAppOptions(chainID string) error {
return err
}

ethCfg := evmtypes.DefaultChainConfig(EVMChainID)

err := evmtypes.NewEVMConfigurator().
WithChainConfig(ethCfg).
// NOTE: we're using the 18 decimals
WithEVMCoinInfo(coinInfo).
Configure()
if err != nil {
return err
}

sealed = true
return nil
}
Expand Down
Loading
Loading