-
Notifications
You must be signed in to change notification settings - Fork 1
Add gas recommender IIP #17
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||
| --- | ||||||
| iip: 3 | ||||||
| title: Gas Price Recommendation Tool | ||||||
| description: An AI-assisted mechanism for estimating transaction fees in IOTA | ||||||
| author: Salahledin Soliman (@salahledinsoliman) <salaheldin.soliman@iota.org> | ||||||
| discussions-to: https://github.com/iotaledger/IIPs/discussions/16 | ||||||
| status: Draft | ||||||
| type: Process | ||||||
| created: 2025-06-04 | ||||||
| --- | ||||||
|
|
||||||
| ## Abstract | ||||||
|
|
||||||
| This IIP introduces a gas price recommendation mechanism for IOTA Rebased that leverages historical transaction outcomes and real-time congestion indicators to improve the user experience by reducing unnecessary fee over-payment and transaction cancellation. The mechanism is implemented as an off-chain, adaptive prediction model trained using feedback from previously cancelled and accepted transactions. At its core, the model estimates the minimal tip required for a transaction to be included under current network conditions by learning from features such as object hotness, computation cost, and scheduling outcomes. The training process uses online stochastic gradient descent to continuously refine the model with fresh data, allowing it to adapt to dynamic workloads and validator behavior. The proposed mechanism requires no changes to protocol logic and can be integrated into wallets, SDKs, and developer tooling to provide actionable, data-driven fee guidance. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If I remember correctly, we tent not to use the term "Rebased" anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What do you mean by "validator behavior" here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is it correct? The gas price feedback mechanism is required (which is on the protocol level) and a congestion tracker in the full node to dry-run transactions and get estimates. |
||||||
|
|
||||||
| ## Motivation | ||||||
|
|
||||||
| In IOTA, transactions can involve either owned objects (which are guaranteed to finalize upon passing consensus, regardless of their gas price) or shared objects (which may conflict with other transactions and cause congestion). However, the protocol currently offers no mechanism to help users estimate the appropriate tip for shared-object transactions, which are more likely to be delayed or cancelled under contention. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| As a result, users often underbid and get rejected or delayed, or overbid and waste IOTAs, especially in high-traffic scenarios. This unpredictability harms user experience and undermines efficiency. | ||||||
|
|
||||||
| To solve this, we propose a feedback-driven gas price recommendation engine that analyzes historical transaction outcomes to predict the minimum tip that would likely have led to inclusion. This enables nearly accurate, real-time tip suggestions without requiring changes to the protocol, improving fairness, reliability, and developer experience. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not sure about this. Read similar comment above. |
||||||
|
|
||||||
| ## Specification | ||||||
|
|
||||||
| This proposal introduces a feedback and prediction mechanism for gas price estimation in transactions involving shared objects on the IOTA smart contract platform. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this proposal introduces a gas price feedback mechanism too, then it definitely requires changes in the core protocol. |
||||||
|
|
||||||
| ### Gas Price Feedback | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for computing the gas price feedback has slightly changed to limit codebase changes and still have an accurate estimation. @roman1e2f5p8s Can you please check this part? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No sure what this comment is referring too. Do we need to describe the logic for computing the gas price feedback here? |
||||||
| As part of the core node logic, each time a transaction is scheduled, the node records its gas price and execution duration per shared object it accesses. When a transaction is later cancelled due to repeated deferrals, the node provides a gas price suggestion—a value that would likely have resulted in successful inclusion under the observed congestion levels. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| This value is computed using percentile-based statistics over recorded gas prices per object, adjusted according to transaction duration and the severity of congestion. The feedback is embedded in the deferral response to the client and requires no protocol modification. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### Gas Price Prediction | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To improve readability of the document, I would add a block diagram highlighting where (i) gas price feedback and (ii) gas price prediction get computed. It would also be nice to visually show what information is needed for the calculations |
||||||
| A prediction engine uses the historical gas price feedback to estimate, before submission, the minimum tip a user should attach to ensure inclusion. This engine operates off-chain and is designed to be integrated into wallets, SDKs, or development tools. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| The predictor models shared-object contention using a per-object congestion weight vector, which is updated incrementally using online stochastic gradient descent. For a new transaction, the engine uses these weights to compute a harmonically weighted gas price suggestion. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### Syntax and Semantics | ||||||
| #### Gas Price Feedback API (Node): | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand what is written in this section. You need to glue these bullet points and short sentences. I think you need to write down where the feedback gas price is contained in a checkpointed transaction, and how that feedback gas price is going to be used by the recommender. |
||||||
|
|
||||||
| New field in cancellation response: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean here? You need to explain how the gas price feedback is given. Specifically, for canceled transactions we incapsulate the gas price feedback in the (invalid) sequence number. It would be useful to explain the logic used here. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||
|
|
||||||
| `suggested_gas_price: u64` | ||||||
|
|
||||||
| A recommended gas price for resubmission, computed from historical scheduling outcomes. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| #### Prediction Interface (External Tool): | ||||||
|
|
||||||
| Input: Transaction metadata (touched objects) | ||||||
|
|
||||||
| Output: Estimated recommended_gas_price: u64 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| An anticipatory recommendation before submission. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Solitary sentence again with no obvious connection to the rest of the text. |
||||||
|
|
||||||
| This specification introduces no changes to consensus, validity rules, or core transaction semantics. It adds observational logic and client-side estimation tools to enhance user experience without impacting protocol security or performance. | ||||||
|
|
||||||
|
|
||||||
| ## Rationale | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part is repeating what is already written above. I would like to see some more details on how the feedback and the prediction is computed, especially related to what information you need for the calculations |
||||||
|
|
||||||
| The motivation for this proposal stems from a fundamental user experience issue in IOTA’s transaction model: users interacting with shared objects have no guidance on how much gas price (tip) they should offer to ensure inclusion. This leads to inefficiencies—users may overpay, or worse, repeatedly underbid and have their transactions cancelled. The current mechanism lacks any feedback or proactive recommendation logic. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am lost again. Is this proposal introduces the feedback mechanism as well, or it assumes the feedback is already provided by the protocol? |
||||||
|
|
||||||
| ### Design Decisions | ||||||
| To address this, the design separates the solution into two components: | ||||||
|
|
||||||
| #### In-node Gas Price Feedback: | ||||||
| The gas price suggestion returned upon transaction cancellation is computed from real historical data observed by the node. It reflects object-level congestion at the time of deferral and uses percentile-based aggregation over recorded gas prices and execution durations. This provides immediate, data-grounded feedback to users without modifying protocol rules. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In-node gas price feedback does require modifications in the protocol. |
||||||
|
|
||||||
| #### External Prediction Engine: | ||||||
| A learning-based model predicts, prior to submission, the minimum gas price likely required for successful inclusion. This model is trained on historical feedback collected over time. We chose online stochastic gradient descent (SGD) for its simplicity, adaptability, and low overhead in a high-throughput setting. It continuously updates per-object congestion weights and requires minimal infrastructure. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| #### Alternative Approaches | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also mention Mamba (https://arxiv.org/abs/2312.00752) which is representing a breakthrough in ML prediction models |
||||||
| We considered more sophisticated models, including recurrent neural networks (RNNs), which are well-suited for learning temporal patterns and could offer higher prediction accuracy in complex congestion scenarios. However, RNNs have drawbacks: | ||||||
|
|
||||||
| - Higher computational cost and memory footprint | ||||||
|
|
||||||
| - Greater complexity in tuning and deployment | ||||||
|
|
||||||
| Given the early stage of the proposal and the requirement for integration with live, high-throughput transaction streams, we opted to first implement online gradient descent. This simpler model allows rapid prototyping, direct interpretability of object weights, and easier integration with tooling. | ||||||
|
|
||||||
| #### Roadmap for Comparison | ||||||
| There is a draft plan to implement and evaluate both models—online SGD and RNNs—on historical transaction datasets. This will allow for empirical comparison of accuracy, responsiveness, and usability. Depending on results, we may later recommend a more advanced architecture. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ## Credits | ||||||
|
|
||||||
| - This proposal is a part of Salaheldin's thesis research project, which is supervised and directed by @vekkiokonio . | ||||||
| - @roman1e2f5p8s is currently working on in-node gas price feedback. | ||||||
| - @bingyanglin and @cyberphysic4l suggested the usage of RNNs. | ||||||
| - @iotaledger/research have been continuously providing feedback and suggestions to improve the proposal. | ||||||
|
|
||||||
| ## Copyright | ||||||
|
|
||||||
| Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use "gas price" instead of "transaction fees" because it is what the recommender will be estimating.