Onboarding rate and gas optimizations #1092
Replies: 11 comments 17 replies
-
Possible ways to save gas right now:
|
Beta Was this translation helpful? Give feedback.
-
So it's been suggested that we re-purpose nv25 to incorporate the short-term FIP-based improvements. Currently, it sounds like these FIPs will be relatively straightforward to describe, being mostly changes to network parameters. The plan is to discuss a potential schedule for this on the Filecoin Implementers' sync on 2024-12-17 (tomorrow). I'm running an every-little-thing update channel for those interested in keeping an eye on the broader workplan of lowering gas costs, but let's keep the discussion centered here. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately it doesn't quite work that way. The block gas limit mostly exists as to limit the amount of time a tipset can take to execute on average. However, gas is also charged for operations that don't take time (e.g., state storage gas). At the moment over 66% of the prove commit gas is state-storage gas. When considering the block gas limit, we have to consider the amount of time it would take to execute a tipset in the worst-case scenario: that is, the case where the block is full of messages that do nothing but use compute gas (little to no storage gas). The problem with simply "donating" the gas available in cron twofold:
The underlying problem is that we're spending a part of our time budget on limiting the rate at which state increases. Ideally those would be two independent variables, but that's tricky. |
Beta Was this translation helpful? Give feedback.
-
Balancing State Storage GasProblemFilecoin charges gas whenever an actor (whether it be a built-in miner actor, the market actor, or an EVM smart contract) stores state. It does so to try to:
Unfortunately:
In other words, we're both charging too little and charging too much for state storage. We charge so much because our state-storage model has to assume the worst-case:
We don't charge as much as we should because state gas is already really high. ProposalFixing this in the general case is difficult as it involves things like state "rent" but we we may be able to fix this for specific builtin actors by charging for state at a different layer. That is, we may be able to:
For example, right now whenever a sector is committed we have to charge state storage fees for the on-chain sector information assuming it sticks around forever. In practice, it generally does stick around forever because there's no incentive to clean it up. Instead, we could charge a per-sector onboarding fee (as has been proposed in the past) and either (a) add a mechanism force the cleanup of expired/terminated sectors and/or add a mechanism that charges a periodic fee as long as the state remains on-chain (i.e., state rent). Importantly, these fees can be unrelated to gas and therefore won't affect the base fee or use up any chain bandwidth. If we do this correctly, I'd expect both increased chain bandwidth as we'd be able to spend more of our block limit on compute and reduced chain state as SPs would be directly incentivized to cleanup old sectors. I can't actually promise lower gas fees because gas fees a product of supply and demand: these changes would increase gas supply but there's no guarantee they wouldn't also increase demand (see Braess's paradox). |
Beta Was this translation helpful? Give feedback.
-
Optimising thingsNot mentioned much in the solution space above is making things more efficient, using less state storage in particular. To my knowledge, very little profiling or optimisation work has been done on this. It may be that there are relatively low hanging fruit. For example, some time ago @ZenGround0 measured that the inputs to the complex retro-active termination fee occupied 20% of all chain state. FIP-0098 may resolve this (at least as far as replacing each input with a null/zero byte) and there's probably more room to squeeze there. I'm not sure this will translate directly into I don't have a big list of things to optimise – some profiling work needs to be done first. Just a call for someone to look into it because I have a sense there's decent room for improvement. Optimising things to give more effective throughput is a short-term strategy, that will only increase the onboarding limit so far. But so are most of the other things here, and pulling a few of them together might easily give us a 50-100% boost. |
Beta Was this translation helpful? Give feedback.
-
Why not consider increasing TPS |
Beta Was this translation helpful? Give feedback.
-
Is 1EiB the general consensus of the network (as in, part of Filecoin mission / Spec) or author's perspective of how much the network should achieve? |
Beta Was this translation helpful? Give feedback.
-
Can we roll back the mainnet to the previous version first, and then upgrade it when there is a good solution? |
Beta Was this translation helpful? Give feedback.
-
#1094 is one proposal arising from this discussion, to reduce the batch balancer and remove the aggregate fee from precommit. |
Beta Was this translation helpful? Give feedback.
-
Let me add a bit more data and a quick recap of ongoing efforts before the holiday break.
|
Beta Was this translation helpful? Give feedback.
-
I'm proposing in #1098 a minor expansion of scope of this proposal to include some related actors cleanup—the removal of some gas-limited legacy constraints:
This is work that is mostly done and ready to land, but is on a borderline of "does it need a FIP?". It's a protocol change and should go through a process of public consultation. In practice, these constraints are largely unnecessary and are mostly not even used due to the current gas model. Rather than propose a new trivial FIP for this, I'm proposing to bundle the change within this related FIP as a protocol simplification. |
Beta Was this translation helpful? Give feedback.
-
The facts:
Since August (nv23) gas used for onboarding methods has been higher than in the past year (link) - though total gas usage now is in-line with avg gas usage in 2021-2023.
Because of this, sector onboarding today is more expensive because of:
This causes the Filecoin network to have a self-imposed limit to the onboarding rate to avoid increasing basefee.
Currently only ~3-4PiB1 of data onboarding per day can fit within 5B gas units (block gas target), which is below the demand. 2-3X this value can be acceptable for a short-medium term.
Causes:
Why is the onboarding gas higher than before? We have identified 3 main causes:
Cause 1 (high gas unit usage): In nv23, FIP0084 was shipped. This FIP removed the cron subsidy for provecommit, making that method 2.7x instantly more expensive in terms of gas units, from ~71M to ~196M (previously this cost was subsidized by the network by virtue of cron).
Cause 2 (irrational aggregation): The batch gas charge (aka batchBalancer) parameters were introduced in FIP0013 and were set based on gas usage of onboarding methods at the time of the design. Protocol changes that happened after that (in particular FIP32/FIP57 and FIP84) caused a significant change in the average value of gas used for the onboarding method. Because of this, now the batchBalancer parameters are outdated and ProveCommitAggregate is always more expensive to use with respect to non-aggregated provecommit (the original design this method was intended to be cheaper when base fee is higher than batchBalancer *batchDiscount). In short, currently aggregation can not be used as a mechanism to alleviate congestion.
Cause 3 (high on-chain state storage gas): For a ProveCommit3 of a single sector, 66% of the gas for provecommit methods is related to state storage gas (unrelated to block time). This cost was increased during the FEVM launch (tripled) to try to bring our storage costs closer to Ethereum due to concerns of state growth.
Next Steps :
In the following we list possible next steps that we can take in order to remove or mitigate the causes identified above. Some of these solutions are protocol changes (labeled with “FIP”) others involve shipping new tooling.
Short Term (Jan/Feb)
publishStorageDeals
). However, not all SPs have switched their onboarding pipeline to DDO due to lack of the ecosystem tooling support, i.e: from FIL+ tooling & Spark, these teams shall prioritize working with the SP implementation teams to add the support. Spark team is planning DDO support for Q1, CC @patrickwoodhead.FilOz team is looking in these two:
Note that both these proposals have some security and usability concerns, we are collecting more data to evaluate the pros and cons.
Medium Term (Q3’2025)
Long Term (2026+)
The Filecoin network needs to scale above 3PiB per day, we want to reach 1EiB per day! To achieve that goal, we have few directions to research. In particular, in order to bring down the gas cost for onboarding method we could:
Footnotes
The 3PiB value assuming 32GiB sectors with a deal per sector, and it is obtained taking the recent average of gas units used for
the methods PreCommitSectorBatch2, ProveCommitSectors3 (no batching/aggregation), and PublishStogareDeals. ↩
Beta Was this translation helpful? Give feedback.
All reactions