FuelLabs / fuel-core

Rust full node implementation of the Fuel v2 protocol.
Other
57.96k stars 2.78k forks source link

Create a stop in the case that DA gas price should go up but there are no txs to pay for it. #2347

Open MitchTurner opened 1 month ago

MitchTurner commented 1 month ago

The way the gas price algorithm is designed, we increase the DA gas price when the cost of posting L2 blocks to DA exceeds the reward received from charging L2 users the DA gas price.

In conjunction with this, as the DA gas price increases, there is a negative incentive for new txs to be submitted on L2, and this will lower the reward received, thus increasing the DA gas price further. This forms a negative feedback loop. If no txs are submitted, then the DA gas price could increase indefinitely, essentially bricking the network.

We need to introduce some kind of stop into the algorithm to prevent this negative feedback loop. Perhaps taking into account somehow the fullness of each L2 block before increasing the DA gas price.

This alone will only solve the symptom of the problem: DA gas price is high; and neglect the cause of the problem: a low profit (reward - cost). We need to also accommodate gradually working paying off the cost if there isn't an appetite from the market to pay the extra fee.

MitchTurner commented 1 month ago

One possible solution: We already have the max_da_gas_price_change_percent as part of the updater. What if we also include an activity parameter and a activity_fullness_threshold_percent parameter. Let's say the activity parameter is a value between 1 and 100 as is the activity_fullness_threshold_percent. Each time an L2 block fullness exceeds the activity_fullness_threshold_percent, the updater increases the activity by 1.

The activity parameter is then used in conjunction with the max_da_gas_price_change_percent when increasing the gas price (not when decreasing). It would be an additional fraction of the max_da_gas_price_change_percent, so if activity is 0, the max_da_gas_price_change_percent would be multiplied by 0 and the DA gas price wouldn't change.

This would have the effect of, as the network gets less and less used, the price will get increased less and less, even if the profit is negative and decreasing. hopefully this will prevent the network from ever getting into a state where the prices prevent activity from lowering the prices.

I don't think this enough though. I think there needs to be some threshold where it starts decreasing the price, despite the profit being really low. That's the only real way of preventing some kind of bricking of the network.