Skip to content

Commit

Permalink
chore(evm): Set appropriate gas value for the required gas of the "IF…
Browse files Browse the repository at this point in the history
…unToken.sol" precompile. (#2013)

* chore(evm): Set appropriate gas value for the required gas of the "IFunToken.sol" precompile.

* typo
  • Loading branch information
Unique-Divine authored Aug 22, 2024
1 parent 0a68933 commit dea4cdc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 10 additions & 6 deletions x/evm/precompile/funtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down

0 comments on commit dea4cdc

Please sign in to comment.