Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom denom for gas fees #42

Merged
merged 7 commits into from
Dec 12, 2024

Conversation

keruch
Copy link

@keruch keruch commented Dec 10, 2024

Description

Implements the following: https://www.notion.so/dymension/Tx-gas-payment-using-optional-denom-in-EVM-106a4a51f86a803a81fdf43be998c93c?pvs=4#106a4a51f86a808c9ae7e989a1f211cd

We cannot use ERC-20 token as a tx fee since currently everything fee-related is tied to SDK coins (eg in CLI you specify fees using SDK coins). Specifically, FeeTx interface. The solution is to always use an SDK representation of token and convert from ERC-20 to SDK if necessary.

This PR modifies AnteHandlers.

Cosmos Ante

  • DeductFeeDecorator
  • DynamicFeeChecker

Evm Ante

  • EthMempoolFeeDecorator
  • EthGasConsumeDecorator
  • EthValidateBasicDecorator

Important changes:

  • app/ante/cosmos/fees.go
  • app/ante/evm/eth.go
  • app/ante/utils/claim_rewards.go
  • x/erc20/keeper/conversions.go

Closes dymensionxyz/rollapp-evm#383

@keruch keruch self-assigned this Dec 10, 2024
x/evm/keeper/address_test.go Show resolved Hide resolved
@@ -237,7 +237,7 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
}

// refund gas in order to match the Ethereum gas consumption instead of the default SDK one.
if err = k.RefundGas(ctx, msg, msg.Gas()-res.GasUsed, cfg.Params.EvmDenom); err != nil {
if err = k.RefundGas(ctx, msg, msg.Gas()-res.GasUsed, cfg.Params.GasDenom); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So GasDenom is forced to not empty? Imo should have a ticket to note the migration require this setting.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You wrote in the docs: On genesis, this parameter is empty (optionally, it equals to evm_denom)

Copy link
Author

@keruch keruch Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's true, I chose the latter. thought it's more seamless.

Copy link
Collaborator

@VictorTrustyDev VictorTrustyDev Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omritoptix FYI please make sure we don't forget to add value for this param on upgrade.

x/evm/types/params_legacy.go Show resolved Hide resolved
app/ante/cosmos/min_price.go Show resolved Hide resolved
rpc/backend/node_info.go Show resolved Hide resolved
x/erc20/keeper/conversions.go Show resolved Hide resolved
x/erc20/keeper/conversions.go Show resolved Hide resolved
x/erc20/keeper/conversions.go Show resolved Hide resolved
return errortypes.ErrInsufficientFee.Wrapf(
"wrong fee denomination; got: %s; required: %s", amount, stakingDenom,
)
// amount is not in staking denom, do not try to claim staking rewards
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch!!

@omritoptix omritoptix merged commit f9d9c20 into kirill/proto Dec 12, 2024
@omritoptix omritoptix deleted the kirill/383-custom-gas-denom branch December 12, 2024 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants