How osmosis-labs/fee-abstraction works
Main Components to Highlight
• Application Layer (app, cmd): The “app” directory contains the core logic (e.g., AnteHandler modification, exchange rate updates, and processing of IBC packet data) and tests. The “cmd” folder defines the entry point (feeappd) to run the application.
• Fee Abstraction Module (“x/feeabs”): This directory holds the module-specific logic for fee abstraction. It includes subdirectories for Ante handlers, keeper logic, IBC integrations, proposals, and gRPC queries.
• Protocol Buffers (“proto”): Contains all the proto definitions for various types including fee proposals, queries, transactions, and other IBC messages. It also has its own Dockerfile and build configuration (buf files) for managing proto generation.
• IBC & External Interactions: The README outlines two major workflows:
• Pulling TWAP data via an Interchain Query: the module periodically makes IBC queries (handled via async-icq) to obtain TWAP data from Osmosis.
• Swapping IbC tokens using Osmosis Crosschain Swap (XCS): Once tokens are collected as fees, they are transferred, swapped, and returned.
• Scripts & Testing: Provided scripts for deploying contracts, starting nodes, configuring relayers, and integration tests validate interchain interactions.
Relationships and Interactions
• The Fee Abstraction Module (in “x/feeabs”) interacts with:
• The Cosmos SDK’s Mempool and AnteHandler (modified to check and convert IBC tokens to the native token equivalent).
• The IBC protocol components for sending and receiving query packets (e.g., sending an InterchainQueryPacketData and handling MsgAcknowledgement).
• External Osmosis services (the async-icq module for TWAP queries and the swap router for performing crosschain swaps).
• The “app” layer sets-up the BeginBlocker events to trigger the periodic exchange rate update by sending IBC packets.
• The “proto” folder defines the data models used by these modules across different services.
• Command-line utilities in “cmd/feeappd” provide the interface for running and administering the blockchain node, while scripts help in testing and deployment.
Architectural Patterns and Principles
• Modular Design: The architecture cleanly separates core application logic from the fee abstraction module (in “x/feeabs”), and isolates protocol definitions in the “proto” directory.
• Inter-module Communication: Using IBC, the fee abstraction leverages asynchronous queries and responses along with controlled relayer interactions.
• Testing & CI/CD: Multiple test directories and GitHub Actions workflows are present to support integration, interchain tests, linting, and container builds.
• Extensibility: The project structure (with versioned branches for different Cosmos SDK and IBC-go versions) emphasizes extensibility and support for multiple chain implementations.