More from Aptos Labs
Keep up with the latest from Aptos Labs
The Path to 10x Lower Gas Fees on Aptos with Community-Driven Feedback
As part of our mission to accelerate Aptos ecosystem growth, we often engage with community builders to aid their implementations and gather feedback on improving Aptos. A top request is for improvements to the gas schedule. This request correlates well with a core Aptos tenant, namely, that the demand of the network should largely dictate the costs associated with using Aptos.
To anchor our principles in reality, our team has spoken with many ecosystem builders over the past month about their applications, analyzed a plethora of on-chain data, and engaged in many internal brainstorms.
Our three-stage plan to delivering demand-driven gas costs on Aptos:
- Early January 2023: Improve operations on NFT data to drop prices by 10x for dynamic NFTs.
- Q1 2023: Build gas-efficient data structures with end-to-end support from guides to indexing.
- Late Q1, early Q2 2023: Devise advanced gas model that separates storage and execution costs, thereby providing demand-driven gas costs for execution.
Initially, the team set out with a goal of reducing gas rates by 10 to 100x, and we came back with a plan that might be even more substantial than that! To validate the possibility, we spoke directly with many ecosystem builders including: Aries, AUX, Econia, Ferum, Nutrios, Pyth, Souffl3, Switchboard, Topaz, Tsunami, and many more. These interviews and the exploration of much transaction data on-chain led to the following insights:
- A coin transfer on Aptos (aptos_account::transfer) can cost around .00055 APT.
- Many DeFi operations land in the range of .003 to .005 APT.
- Gas cost has largely been dominated by execution at 50%+ and item creation at more than 20%.
Despite seeking a short-term silver bullet, there was none. The team identified a conundrum created by our existing gas policy: Aptos bundles both execution and storage gas costs together despite them having different intentions. For execution, gas limits the maximum execution time of a transaction. For storage, gas dictates intelligent usage of scarce resources; after all, storage is permanent. Given this bundling, dropping costs for one has implications for the other. For example, a substantial reduction in execution gas would result in an equally substantial drop in the total amount of storage available for a single transaction. Our analysis suggests this would result in a very low gain.
Short term — dynamic NFT gas reduction
Despite the lack of an immediate elixir for reducing gas fees by 10 to 100x, we found one area to make an immediate impact: dynamic NFTs! When writing our initial SimpleMap, we took the path of premature optimization. The SimpleMap provided O(Log N) reads and O(N) additions and removals. However, the comparator used for evaluations had substantial impact on gas prices, which was unknown when it was implemented. It turns out that using a brute force implementation could actually be more than 50% cheaper! The Aptos team is currently readying this update for Mainnet and in the process of publishing our first Aptos Improvement Proposal (AIP) along the way.
Medium term — gas-efficient data structures
Many teams within the ecosystem have already recognized the nuances of storage gas and have implemented their own gas-efficient data structures. We are exploring these, as well. In this space, there are several trade-offs to explore: 1) the size of the data, and 2) application of the data.
The Aptos gas storage model offers free bytes when creating a slot, i.e., a table item or resource. Aggregating data past a certain point within an existing slot will eventually be more expensive than creating a new slot. A few clever builders have figured out this balance. In working with them, we have begun developing a SmartVector to help facilitate this.
Obviously, a vector has limitations due to look up times that will have a direct impact on costs and scale. To that end, the team is also exploring a SmartTree with efficient look up and delta operation times.
Finally, we anticipate resurrecting our support of BucketTable for more efficient large-scale map-like storage. Currently, Table is the preferred method for much of this work as demonstrated in the Aptos Token Standard’s TokenStore. Token could potentially be stored more effectively in a BucketTable, to make this work effectively BucketTable needs a little more love.
Each of these efforts requires a bit more hardening, AIPs, documentation, and indexing support.
Of course, the code is readily available for many of these improvements; so you need not wait for these solutions to be mainstream before benefiting!
Longer term — demand-driven gas costs
The current gas framework combines execution and storage fees, which in turn leads to an unbalanced gas price. In addition, the current storage pricing scheme lacks the ability to reflect data lifetime; as a result, storage interaction has to be expensive to prevent storage abuses. The current storage pricing scheme further offers no incentive to delete data.
Over the coming months, the Aptos team has committed to solving these issues with two initiatives: 1) separating storage and execution gas fees and reducing execution fees, and 2) providing a framework to support storage refunds.
While storage refunds are still in the early brainstorming phase, we have established the following core principles:
- A refund should be returned to the original account that paid for the data creation.
- Subsidization of data creation should be feasible from central accounts, e.g., a resource account creating NFTs or facilitating DeFi operations.
While it is still early, we look forward to sharing more details either in AIPs or in future Medium posts!
At the end of these significant endeavors, transactions such as moving around or modifying NFTs, updating an oracle, and even updating positions in DeFi operations will all benefit from substantial drops in gas prices.
Leading up to the launch of the Aptos blockchain, faucets were plenty! After mainnet, teams focused on scaling their operations. Our team engaged with the ecosystem to learn more about how you build and how we can make you build more effectively. We believe that our three-phase plan to improve gas prices will make it even better to build with Aptos. Let’s move!
The Path to 10x Lower Gas Fees on Aptos with Community-Driven Feedback was originally published in Aptos on Medium, where people are continuing the conversation by highlighting and responding to this story.