Skip to content

Commit

Permalink
fix(evm): Fix unit inconsistency related to AuthInfo.Fee and txData.F…
Browse files Browse the repository at this point in the history
…ee (#2157)

* fix(evm): Fix unit inconsistency related to AuthInfo.Fee and txData.Fee using effective fee

* chore: change log
  • Loading branch information
Unique-Divine authored Jan 10, 2025
1 parent da4c2c7 commit f7a7007
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion app/evmante/evmante_validate_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
)
}
Expand Down
11 changes: 7 additions & 4 deletions x/evm/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit f7a7007

Please sign in to comment.