Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze committed Nov 21, 2022
1 parent abcc52f commit 4024fa6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/ante/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ func (mfd EthMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat
}

return next(ctx, tx, simulate)
}
}
32 changes: 16 additions & 16 deletions app/ante/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
return ctx, sdkerrors.Wrap(err, "tx basic validation failed")
}

// For eth type cosmos tx, some fields should be veified as zero values,
// For eth type cosmos tx, some fields should be verified as zero values,
// since we will only verify the signature against the hash of the MsgEthereumTx.Data
wrapperTx, ok := tx.(protoTxProvider)
if !ok {
Expand All @@ -119,6 +119,20 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx length of ExtensionOptions should be 1")
}

authInfo := protoTx.AuthInfo
if len(authInfo.SignerInfos) > 0 {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx AuthInfo SignerInfos should be empty")
}

if authInfo.Fee.Payer != "" || authInfo.Fee.Granter != "" {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx AuthInfo Fee payer and granter should be empty")
}

sigs := protoTx.Signatures
if len(sigs) > 0 {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx Signatures should be empty")
}

txFee := sdk.Coins{}
txGasLimit := uint64(0)

Expand Down Expand Up @@ -159,16 +173,7 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
return ctx, sdkerrors.Wrap(ethtypes.ErrTxTypeNotSupported, "dynamic fee tx not supported")
}

txFee = txFee.Add(sdk.NewCoin(evmDenom, sdkmath.NewIntFromBigInt(txData.Fee())))
}

authInfo := protoTx.AuthInfo
if len(authInfo.SignerInfos) > 0 {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx AuthInfo SignerInfos should be empty")
}

if authInfo.Fee.Payer != "" || authInfo.Fee.Granter != "" {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx AuthInfo Fee payer and granter should be empty")
txFee = txFee.Add(sdk.Coin{Denom: evmDenom, Amount: sdkmath.NewIntFromBigInt(txData.Fee())})
}

if !authInfo.Fee.Amount.IsEqual(txFee) {
Expand All @@ -179,10 +184,5 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid AuthInfo Fee GasLimit (%d != %d)", authInfo.Fee.GasLimit, txGasLimit)
}

sigs := protoTx.Signatures
if len(sigs) > 0 {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx Signatures should be empty")
}

return next(ctx, tx, simulate)
}
7 changes: 6 additions & 1 deletion x/evm/keeper/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,16 @@ func (suite *KeeperTestSuite) TestDeductTxCostsFromUserBalance() {

txData, _ := evmtypes.UnpackTxData(tx.Data)

fees, priority, err := suite.app.EvmKeeper.DeductTxCostsFromUserBalance(
ethCfg := suite.app.EvmKeeper.GetChainConfig(suite.ctx).EthereumConfig(nil)
baseFee := suite.app.EvmKeeper.GetBaseFee(suite.ctx, ethCfg)
priority := evmtypes.GetTxPriority(txData, baseFee)

fees, err := suite.app.EvmKeeper.DeductTxCostsFromUserBalance(
suite.ctx,
*tx,
txData,
evmtypes.DefaultEVMDenom,
baseFee,
false,
false,
suite.enableFeemarket, // london
Expand Down

0 comments on commit 4024fa6

Please sign in to comment.