diff --git a/CHANGELOG.md b/CHANGELOG.md index 55b6d236b..eccf51dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ the `@nibiruchain/solidity` package. JSON encoding for the `EIP55Addr` struct was not following the Go conventions and needed to include double quotes around the hexadecimal string. - [#2156](https://github.com/NibiruChain/nibiru/pull/2156) - test(evm-e2e): add E2E test using the Nibiru Oracle's ChainLink impl +- [#2157](https://github.com/NibiruChain/nibiru/pull/2157) - fix(evm): Fix unit inconsistency related to AuthInfo.Fee and txData.Fee using effective fee #### Nibiru EVM | Before Audit 2 - 2024-12-06 diff --git a/app/evmante/evmante_validate_basic.go b/app/evmante/evmante_validate_basic.go index b72270a88..a9fcc8586 100644 --- a/app/evmante/evmante_validate_basic.go +++ b/app/evmante/evmante_validate_basic.go @@ -122,10 +122,12 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu ) } + // Compute fees using effective fee to enforce 1unibi minimum gas price + effectiveFeeMicronibi := evm.WeiToNative(txData.EffectiveFeeWei(evm.BASE_FEE_WEI)) txFee = txFee.Add( sdk.Coin{ Denom: evm.EVMBankDenom, - Amount: sdkmath.NewIntFromBigInt(txData.Fee()), + Amount: sdkmath.NewIntFromBigInt(effectiveFeeMicronibi), }, ) } diff --git a/x/evm/msg.go b/x/evm/msg.go index 53b607106..b11e59a0a 100644 --- a/x/evm/msg.go +++ b/x/evm/msg.go @@ -345,7 +345,7 @@ func (msg *MsgEthereumTx) UnmarshalBinary(b []byte) error { return msg.FromEthereumTx(tx) } -// BuildTx builds the canonical cosmos tx from ethereum msg +// BuildTx builds the Cosmos-SDK [signing.Tx] from ethereum tx ([MsgEthereumTx]) func (msg *MsgEthereumTx) BuildTx(b client.TxBuilder, evmDenom string) (signing.Tx, error) { builder, ok := b.(authtx.ExtensionOptionsTxBuilder) if !ok { @@ -361,10 +361,13 @@ func (msg *MsgEthereumTx) BuildTx(b client.TxBuilder, evmDenom string) (signing. if err != nil { return nil, err } + + // Compute fees using effective fee to enforce 1unibi minimum gas price fees := make(sdk.Coins, 0) - feeAmt := sdkmath.NewIntFromBigInt(txData.Fee()) - if feeAmt.Sign() > 0 { - fees = append(fees, sdk.NewCoin(evmDenom, feeAmt)) + effectiveFeeMicronibi := WeiToNative(txData.EffectiveFeeWei(BASE_FEE_WEI)) + feeAmtMicronibi := sdkmath.NewIntFromBigInt(effectiveFeeMicronibi) + if feeAmtMicronibi.Sign() > 0 { + fees = append(fees, sdk.NewCoin(evmDenom, feeAmtMicronibi)) } builder.SetExtensionOptions(option)