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

Gas stability pool mechanism improvement #3279

Open
lumtis opened this issue Dec 11, 2024 · 0 comments
Open

Gas stability pool mechanism improvement #3279

lumtis opened this issue Dec 11, 2024 · 0 comments

Comments

@lumtis
Copy link
Member

lumtis commented Dec 11, 2024

Extension of #3221, this issue is for a bug while this one is for a general optimization of the stability pool mechanism (eventually both are completed in the same PR)

Current mechanism

  • For each connected chains, a "gas stability pool" exists that is funded manually and with remaining fees from previous transactions
  • We store in the blockchain "gas stability flags" that describes how gas price must be increased with gas stability pool
  • At each epoch (configurable number of blocks), the pending cctxs are iterated and depending for how long it has been pending, the gas price is increased by a percentage from the flags, there is a percentage limit for max gas price. The difference of gas limit is funded from gas stability pool (then unused fees are resent unto the pool)

Some issues with the current mechanism

  • The increase is a fix percentage in the flags, independent of the gas price hikes, for very big hike in the price, the flags might be ineffective, if the flags are set to high percentage then it is not optimized for smaller gas price hike
  • Multiple outbounds are increased at the same time, outbound+100 might be increased while outbound+1 is blocked, all the pending outbound are increased, the gas price might again fall once the blocked outbound get signed, this might end up in a big waste of funds with unnecessary high gas price for most outbounds
  • The current mechanism is not adapted for EIP1559 since the increase for gasFeeCap and priorityFee might not be the same

Proposed solution

  • Update with more accurate values: remove the gas increase percent flag, instead when iterating pending outbound, the increase is determined by the current voted gas price. The difference in the fee limit is used for the gas stability pool. For EIP1559 both gasFeeCap and priorityFee are updated with the voted values
  • Having less look ahead and bigger focus on currently blocked outbound. Instead of iterating n+x next outbound, only the n+1 pending outbound is parsed (we can maybe tolerate a few ore but idea is to have a very small look ahead), it is parsed more frequently (smaller epoch), the gas price is updated if any of two conditions are met (been pending for a x delay OR the current voted gas price is above a threshold of the gas price currently used). If the gas price is increased while the tx has been signed and is being confirmed, this is not an issue as the effective fee paid will be used to refund to the gas stability pool.

In short the gas stability mechanism is more concentrated to the currently blocked outbound. There will be slower time to update gas price of all outbound in gas of dramatic hike in the price and large number of outbound in a short time frame but use of the gas stability pool will be made more optimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants