diff --git a/CHANGELOG.md b/CHANGELOG.md index f6f536f43..b4103476e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#2003](https://github.com/NibiruChain/nibiru/pull/2003) - fix(evm): fix FunToken conversions between Cosmos and EVM - [#2004](https://github.com/NibiruChain/nibiru/pull/2004) - refactor(evm)!: replace `HexAddr` with `EIP55Addr` - [#2008](https://github.com/NibiruChain/nibiru/pull/2008) - refactor(evm): clean up precompile setups +- [#2013](https://github.com/NibiruChain/nibiru/pull/2013) - chore(evm): Set appropriate gas value for the required gas of the "IFunToken.sol" precompile. #### Dapp modules: perp, spot, oracle, etc diff --git a/x/evm/precompile/funtoken.go b/x/evm/precompile/funtoken.go index 4e1f131cd..365cac8e1 100644 --- a/x/evm/precompile/funtoken.go +++ b/x/evm/precompile/funtoken.go @@ -12,6 +12,7 @@ import ( gethabi "github.com/ethereum/go-ethereum/accounts/abi" gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" + gethparams "github.com/ethereum/go-ethereum/params" "github.com/NibiruChain/nibiru/v2/app/keepers" "github.com/NibiruChain/nibiru/v2/x/evm" @@ -32,12 +33,15 @@ func (p precompileFunToken) Address() gethcommon.Address { } func (p precompileFunToken) RequiredGas(input []byte) (gasPrice uint64) { - // TODO: https://github.com/NibiruChain/nibiru/issues/1990 - // We need to determine an appropriate gas value for the transaction to - // configure this function and add a assertions around the gas usage to - // the precompile's test suite. UD-DEBUG: not implemented yet. Currently - // set to 0 gasPrice - return 22 + // Since [gethparams.TxGas] is the cost per (Ethereum) transaction that does not create + // a contract, it's value can be used to derive an appropriate value for the + // precompile call. The FunToken precompile performs 3 operations, labeld 1-3 + // below: + // 0 | Call the precompile (already counted in gas calculation) + // 1 | Send ERC20 to EVM. + // 2 | Convert ERC20 to coin + // 3 | Send coin to recipient. + return gethparams.TxGas * 3 } const (