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

Add txfees module and add anteHandler gas filter for liquidStake/redeemStake and IbcTransfer #464

Open
riley-stride opened this issue Dec 5, 2022 · 0 comments

Comments

@riley-stride
Copy link
Contributor

riley-stride commented Dec 5, 2022

Background

Some gas-free cosmos chains have been attacked by spam transactions that clutter blocks and crowd out legitimate users and app logic. Stride has no transactios fees today, so that the UX is seamless for liquid stakers, but this makes Stride potentially vulnerable to spam transactions.

We could achieve the same seamless UX by setting a small non-zero default tx price, but allowing exceptions: liquidStake and redeemStake txs are gas-free below some threshold value (e.g. less than 1000atom), and ibcTransfers of st assets are gas free. This is the only relevant user flow we need to keep gas-free for the sake of UX; we can charge gas for other types of transactions - that won't impact the UX since it's outside the typical user flow.

Credit to Osmosis for writing the x/txfees module and writing the first

Suggested Design

High level

  1. Add the x/txfees module (and greenlight st assets)
  2. Set default gas to small non-zero value
  3. Add detection logic to AnteHandler for charging custom gas based on message type and value (pioneered by Osmosis)

Detailed Design (full credit to Osmosis for pioneering this)

Transaction Fees
x/txfees is implemented in Osmosis' repo here

AnteHandler work

  • Using FeeDecoratorFilter architecture, we could implement it like this:
    • Write GetMinBaseGasPriceForTx() like this
    • Write IsZeroGasTx() like this (checking for msg type and num tokens)
    • Define gasPrice like this and initialize like this
    • In AnteHandle(), invoke GetMinBaseGasPriceForTx() like this

As a reference, see Dev’s AnteHandler work for arb-tx detection + custom gas prices:
- Written in osmosis-labs/osmosis#741
- Refactored in https://github.com/osmosis-labs/osmosis/pull/777

Acceptance Criteria

  • all existing and new tests should pass
  • add tests for x/txfees: can pay gas in st assets
  • add tests for antehandler: zero-gas works only for specified transactions
  • get a review from someone on the osmosis team
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

No branches or pull requests

1 participant