Original article: "How is the Aptos Gas model with separate storage and execution costs planned?"

On December 23, the Aptos team stated that through interviews and feedback from the Aptos community, it will work on improving gas fees in the coming months.

The first step is to reduce the gas price of dynamic NFTs by 10 times in January 2023 (should be 1/10 of the original), the second step is to build a gas-efficient data structure in the first quarter of next year, and the third step is to design a new gas model in early Q2 2023 to separate storage and execution costs, thereby providing demand-driven gas costs for execution.

Regarding the Aptos Gas plan, before the mainnet was launched, Aptos Labs had released its own principles and processes for formulating GAS, how to calculate GAS, and the subsequent GAS fee adjustment. For more information, please read "Understanding the first GAS design of MOVE language in one article: Stable and cheap GAS unit cost"

The following is an article from AptosLabs about plans to improve the gas model next year

As part of our mission to accelerate the growth of the Aptos ecosystem, we frequently work with community builders to help them implement and gather feedback on improving Aptos. The most important request was for an improved schedule for gas fees.

Our three-phase plan to deliver demand-driven gas costs on Aptos:

Early January 2023: Improve the operation of NFT data and reduce the Gas price of dynamic NFTs by 10 times (should be 1/10 of the original).

Q1 2023: Build efficient Gas data structures with end-to-end support from guidance to indexing.

Late Q1 2023, early Q2 2023: Design an advanced gas model that separates storage and execution costs, thereby providing demand-driven gas costs for execution.

background

Initially, the team aimed to reduce gas fees by 10 to 100 times, and to verify this possibility, we spoke directly to many ecosystem builders, including Aries, AUX, Econia, Ferum, Nutrios, Pyth, Souffl3, Switchboard, Topaz, Tsunami, etc. These interviews and analysis of a large amount of transaction data on the chain yielded the following insights:

Token transfer fees on Aptos ( aptos_account::transfer) are around 0.00055 APT. Many DeFi operations fall in the .003 to .005 APT range. Gas costs mainly account for 50%+ of execution and 20%+ of item creation.

While there is no silver bullet for the short-term solution, we identified a challenge caused by the existing gas policy: Aptos bundles execution and storage gas costs together, even though they have different roles.

For execution, gas limits the maximum execution time of a transaction. For storage, gas determines the intelligent use of scarce resources; after all, storage is permanent. Given this bundling, reducing costs on one side has an impact on the other.

For example, a large reduction in execution gas would result in an equally large decrease in the total amount of storage available for a single transaction. Our analysis shows that this would result in very low gains.

Short term - reduce dynamic NFT gas by 10x

While there is no silver bullet to reduce gas fees by 10x-100x, we found an area where we could have an immediate impact: dynamic NFTs! When writing our original SimpleMap, we chose the path of premature optimization.

SimpleMap provides O(Log N) reads and O(N) adds and removes. However, the comparator used for evaluation has a significant impact on gas prices, which was unknown at the time of implementation.

It turns out that brute force can achieve a price reduction of over 50%! The Aptos team is currently preparing this update for Mainnet and is publishing our first Aptos Improvement Proposal (AIP).

Medium term - gas-efficient data structures

Many teams in the ecosystem have recognized the nuances of storing gas and implemented their own gas efficient data structures. We are exploring these as well. In this space, there are several tradeoffs to explore: 1) the size of the data, 2) the application of the data.

The Aptos gas storage model provides free bytes when a slot (i.e., table item or resource) is created. Aggregating data beyond a certain point within an existing slot will eventually become more expensive than creating a new slot. Some smart builders have already found this balance. In working with them, we have begun developing SmartVector to help facilitate this.

Obviously, vectors have limitations as the lookup time will have a direct impact on cost and scale. To this end, the team is also exploring SmartTrees with efficient lookup and increment operation times.

Eventually, we anticipate restoring support for BucketTable for more efficient large-scale map-like storage. Currently, Table is the preferred approach for most of this work, as demonstrated by the TokenStore of the Aptos Token standard.

Tokens may be more efficiently stored in BucketTable, and BucketTable needs more love to make this work more efficiently. Each of these efforts requires more hardening, AIP, documentation, and index support.

Of course, the code for many of these improvements is readily available; so you don't have to wait for these solutions to become mainstream to benefit!

Long term - demand driven gas costs

The current gas framework combines execution fees and storage fees, which in turn leads to an imbalanced gas price. In addition, the current storage pricing scheme lacks the ability to reflect the life cycle of data; therefore, storage interactions must be expensive to prevent storage abuse. The current storage pricing scheme further provides no incentive to delete data.

Over the next few months, the Aptos team worked to address these issues through two initiatives:

1) Separate storage and execution gas fees and reduce execution fees

2) Provide a framework to support storage fee refunds

While storage refunds are still in the early brainstorming stages, we have established the following core principles: Storage fee refunds should be returned to the original account that paid for the data creation.

Subsidies for data creation should be available from a central account, e.g., a resource account that creates NFTs or facilitates DeFi operations. While it’s early days, we look forward to sharing more details in the AIP or future Medium posts!

At the end of these major efforts, transactions such as moving or modifying NFTs, updating oracles, and even updating positions in DeFi operations will benefit from a significant drop in gas fee prices.