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(txfees): added charge fees method #76

Merged
merged 9 commits into from
Nov 4, 2024

Conversation

keruch
Copy link

@keruch keruch commented Oct 31, 2024

Closes: dymensionxyz/dymension#1246

What is the purpose of the change

Add a description of the overall background and high level changes that this PR introduces

(E.g.: This pull request improves documation of area A by adding ....

Brief Changelog

(for example:)

  • The metadata is stored in the blob store on job creation time as a persistent artifact
  • Deployments RPC transmits only the blob storage reference
  • Daemons retrieve the RPC data from the blob cache

Testing and Verifying

(Please pick one of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added unit test that validates ...
  • Added integration tests for end-to-end deployment with ...
  • Extended integration test for ...
  • Manually verified the change by ...

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no)
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no)
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented)

@keruch keruch self-assigned this Oct 31, 2024
@keruch keruch requested a review from danwt November 1, 2024 17:06
@keruch keruch marked this pull request as ready for review November 1, 2024 17:06
Copy link
Collaborator

@omritoptix omritoptix left a comment

Choose a reason for hiding this comment

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

great work.
mostly product requirements which were unclear.

Comment on lines 44 to 45
// If the fee token is unknown, it is burned directly.
func (k Keeper) ChargeFees(
Copy link
Collaborator

Choose a reason for hiding this comment

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

2 things:

  1. should be swapped before sending to beneficiary (i.e send it DYM)
  2. shouldnt be burned

feetoken, err := k.GetFeeToken(ctx, takerFeeCoin.Denom)
if err != nil {
// This should never happen in practice
k.Logger(ctx).Error("Unknown fee token", "denom", takerFeeCoin.Denom, "error", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I blv this can happen. imagine the following:

  1. create rollapp without IRO
  2. no pool exists
  3. send ibc transfer an charge bridging fee

k.Logger(ctx).Error("Unknown fee token", "denom", takerFeeCoin.Denom, "error", err)

// Burn unknown fee tokens
err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(takerFeeCoin))
Copy link
Collaborator

Choose a reason for hiding this comment

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

we shouldn't burn unknown fee tokens but send them to the community pool.
expanded more about that on later comment.

k.Logger(ctx).Error("Failed to swap fee token to base token. Trying to burn the tokens", "denom", takerFeeCoin.Denom, "error", err)

// Burn unknown fee tokens
err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(takerFeeCoin))
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here. shouldn't burn them but send them to the community pool.

return nil
}
// Charge the fee from the payer to x/txfees
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, payer, types.ModuleName, sdk.NewCoins(takerFeeCoin))
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not clear on the PRD but the intent was to send tokens after swapping to DYM.
since currently we only give the owner fees on:

  1. IRO (he gets dym directly cause taker fee is only in DYM)
  2. SWAP (we assume at max 1 hop)

than we should always have a way to swap it for the beneficiary.

@@ -39,7 +38,7 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need still need the epochs?

Copy link
Author

Choose a reason for hiding this comment

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

yes we do! eg for non-DYM fees.

@mtsitrin
Copy link
Collaborator

mtsitrin commented Nov 3, 2024

what about feedecorator.go? needs to be changed as well to support immediate swaps for gas fees

return fmt.Errorf("swap fee to base denom: %w", err)
}
if baseDenomFee.IsNil() || baseDenomFee.IsZero() {
// Fee is unknown token, thus sent to the community pool
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be clearer to call FundCommunityPool here

return err
})
if err != nil {
k.Logger(ctx).Error("Failed to swap fee token to base token. Trying to burn the tokens", "denom", takerFeeCoin.Denom, "error", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

wrong logging

@mtsitrin
Copy link
Collaborator

mtsitrin commented Nov 4, 2024

@omritoptix maybe we can move the txfees module to dymension repo on this opportunity?

@keruch
Copy link
Author

keruch commented Nov 4, 2024

we discusses not to handle non-DYM gas fees for now
dymensionxyz/dymension#1387

@omritoptix
Copy link
Collaborator

@mtsitrin lets see if will have time for it. I'd rather not do it now. opened an issue: dymensionxyz/dymension#1388

x/txfees/keeper/fees.go Outdated Show resolved Hide resolved
x/txfees/keeper/fees.go Outdated Show resolved Hide resolved
@omritoptix omritoptix merged commit 91342c9 into main-dym Nov 4, 2024
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.

Creator Rev Share - Impl
3 participants