Skip to content

Commit

Permalink
fix(erc20): better handling of gas consumption within erc20 contract …
Browse files Browse the repository at this point in the history
…execution (#2089)

* fix(erc20): better handling of gas consumption within erc20 contract execution

* chore: changelog update

* fix: refactored CallContractWithInput

* small PR feedback changes

oops

oops 2

---------

Co-authored-by: Unique-Divine <realuniquedivine@gmail.com>
  • Loading branch information
onikonychev and Unique-Divine authored Oct 24, 2024
1 parent 3199ae5 commit dd27f4b
Show file tree
Hide file tree
Showing 19 changed files with 913 additions and 167 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ reflected on all occurences of "base fee" in the codebase. This fixes [#2059](ht
and the [related comments from @Unique-Divine and @berndartmueller](https://github.com/NibiruChain/nibiru/issues/2059#issuecomment-2408625724).
- [#2084](https://github.com/NibiruChain/nibiru/pull/2084) - feat(evm-forge): foundry support and template for Nibiru EVM develoment
- [#2088](https://github.com/NibiruChain/nibiru/pull/2088) - refactor(evm): remove outdated comment and improper error message text
- [#2089](https://github.com/NibiruChain/nibiru/pull/2089) - better handling of gas consumption within erc20 contract execution


#### Dapp modules: perp, spot, oracle, etc
Expand Down
10 changes: 6 additions & 4 deletions eth/indexer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions proto/eth/evm/v1/evm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/NibiruChain/nibiru/v2/x/evm";

// FunToken is a fungible token mapping between a bank coin and a corresponding
// ERC-20 smart contract. Bank coins here refer to tokens like NIBI, IBC
// FunToken is a fungible token mapping between a Bank Coin and a corresponding
// ERC-20 smart contract. Bank Coins here refer to tokens like NIBI, IBC
// coins (ICS-20), and token factory coins, which are each represented by the
// "Coin" type in Golang.
message FunToken {
Expand All @@ -20,7 +20,7 @@ message FunToken {
// bank_denom: Coin denomination in the Bank Module.
string bank_denom = 2;

// True if the `FunToken` mapping was created from an existing bank coin and
// True if the `FunToken` mapping was created from an existing Bank Coin and
// the ERC-20 contract gets deployed by the module account. False if the
// mapping was created from an externally owned ERC-20 contract.
bool is_made_from_coin = 3;
Expand Down
2 changes: 1 addition & 1 deletion proto/eth/evm/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,6 @@ message QueryFunTokenMappingResponse {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// fun_token is a mapping between the Cosmos native coin and the ERC20 contract address
// fun_token is a mapping between the Bank Coin and the ERC20 contract address
eth.evm.v1.FunToken fun_token = 1;
}
16 changes: 8 additions & 8 deletions proto/eth/evm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ service Msg {
rpc EthereumTx(MsgEthereumTx) returns (MsgEthereumTxResponse) {
option (google.api.http).post = "/nibiru/evm/v1/ethereum_tx";
};
// UpdateParams defined a governance operation for updating the x/evm module parameters.
// The authority is hard-coded to the Cosmos SDK x/gov module account
// UpdateParams defined a governance operation for updating the x/evm module
// parameters. The authority is hard-coded to the x/gov module account
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);

// CreateFunToken: Create a "FunToken" mapping. Either the ERC20 contract
// address can be given to create the mapping to a bank coin, or the
// denomination for a bank coin can be given to create the mapping to an ERC20.
// address can be given to create the mapping to a Bank Coin, or the
// denomination for a Bank Coin can be given to create the mapping to an ERC20.
rpc CreateFunToken(MsgCreateFunToken) returns (MsgCreateFunTokenResponse);

// ConvertCoinToEvm: Sends a coin with a valid "FunToken" mapping to the
Expand Down Expand Up @@ -229,8 +229,8 @@ message MsgUpdateParams {
message MsgUpdateParamsResponse {}

// MsgCreateFunToken: Arguments to create a "FunToken" mapping. Either the ERC20
// contract address can be given to create the mapping to a bank coin, or the
// denomination for a bank coin can be given to create the mapping to an ERC20.
// contract address can be given to create the mapping to a Bank Coin, or the
// denomination for a Bank Coin can be given to create the mapping to an ERC20.
message MsgCreateFunToken {
// Hexadecimal address of the ERC20 token to which the `FunToken` maps
string from_erc20 = 1 [
Expand All @@ -250,7 +250,7 @@ message MsgCreateFunTokenResponse {
eth.evm.v1.FunToken funtoken_mapping = 1 [(gogoproto.nullable) = false];
}

// MsgConvertCoinToEvm: Arguments to send a bank coin to ERC-20 representation
// MsgConvertCoinToEvm: Arguments to send a Bank Coin to ERC-20 representation
message MsgConvertCoinToEvm {
// Hexadecimal address of the ERC20 token to which the `FunToken` maps
string to_eth_addr = 1 [
Expand All @@ -261,7 +261,7 @@ message MsgConvertCoinToEvm {
// Sender: Address for the signer of the transaction.
string sender = 2;

// Bank coin to get converted to ERC20
// Bank Coin to get converted to ERC20
cosmos.base.v1beta1.Coin bank_coin = 3 [
(gogoproto.moretags) = "yaml:\"bank_coin\"",
(gogoproto.nullable) = false
Expand Down
10 changes: 6 additions & 4 deletions proto/eth/types/v1/indexer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ message TxResult {

// height of the blockchain
int64 height = 1;
// tx_index of the cosmos transaction
// tx_index is the index of the block transaction. It is not the index of an
// "internal transaction"
uint32 tx_index = 2;
// msg_index in a batch transaction
uint32 msg_index = 3;

// eth_tx_index is the index in the list of valid eth tx in the block,
// aka. the transaction list returned by eth_getBlock api.
// eth_tx_index is the index in the list of valid eth tx in the block. Said
// another way, it is the index of the transaction list returned by
// eth_getBlock API.
int32 eth_tx_index = 4;
// failed is true if the eth transaction did not go succeed
// failed is true if the eth transaction did not succeed
bool failed = 5;
// gas_used by the transaction. If it exceeds the block gas limit,
// it's set to gas limit, which is what's actually deducted by ante handler.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "FunToken",
"contractName": "IFunToken",
"sourceName": "contracts/FunToken.sol",
"abi": [
{
Expand Down
Loading

0 comments on commit dd27f4b

Please sign in to comment.