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

Add a batched PreCommitSectors method #25

Closed
anorth opened this issue Nov 2, 2020 · 16 comments
Closed

Add a batched PreCommitSectors method #25

anorth opened this issue Nov 2, 2020 · 16 comments
Labels
FIP0008 Links an existing discussion item to an existing FIP.

Comments

@anorth
Copy link
Member

anorth commented Nov 2, 2020

The miner PreCommitSector method only supports committing a single sector at a time. It's one of the two highest frequency methods observed on the chain at present (the other being ProveCommitSector). High-growth miners commit sectors at rates exceeding 1 per epoch. It's also a relatively expensive method, with multiple internal sends and loading and storing state including:

  • the Storage Power actor's power total (read)
  • the Storage Market actor's deal proposal AMT (read)
  • the Reward actor's totals (read)
  • the AllocatedSectors bitfield (read and modify)
  • the PrecommittedSectors HAMT (read and modify)
  • the Sectors AMT (read)
  • the PreCommittedSectorsExpiry AMT (read and modify)
  • the Storage Power actor's pledge total (read and modify)

A PreCommitSectorsBatch method has potential to amortize some of these costs across multiple sectors. If miner operators implemented a relatively short batch aggregation period (a few epochs), the number of invocations could be reduced significantly, and some of the state manipulations above reduced in proportion.

@anorth
Copy link
Member Author

anorth commented Nov 2, 2020

ProveCommitSector could also be batched, but that's a separate discussion. There is already a complex set-up around batching the proof verifications until the end of each epoch, and that discussion should start there.

@nicola
Copy link
Contributor

nicola commented Nov 4, 2020

I approve the spirit of this change.

One thing to note is that in the future (may not belong to this FIP), a PreCommitBatched could contain PreCommits from other miners and the batched method would be verifying the signature on those PreCommits (similarly to what we do for deals).

In this way, smaller miners could get together to jointly submit PreCommits.

@zixuanzh
Copy link
Contributor

zixuanzh commented Nov 5, 2020

I mentioned during all dev that batched precommits may give miners with high sealing throughput an advantage over miners who are smaller in scale. It is unclear if the cost saving is worth the tradeoff. On second thought, the number of sectors that we are batching is probably small enough that it wouldn't make much of a difference. Can we quantify the difference? Of course allowing different miners' PreCommits to batch will be great but that's also extra work and hurdle that presents challenges to smaller miners.

@nicola
Copy link
Contributor

nicola commented Nov 6, 2020

This FIP ensures that a miner can organize their PreCommits so that they can amortize their gas costs. The gas saving is pretty substantial. For example if you submit 32 sectors instead of 1, you may end up paying ~32x less gas (likely less than that).

This is a good concern, but since this is a "one-off" cost, I dont think this will have major impact in the total cost of mining of a small miner vs larger miner.

Extending this FIP in the future to support PreCommit from multiple miners will only benefit the miners.

@zixuanzh
Copy link
Contributor

zixuanzh commented Nov 6, 2020

It's a "one-off" cost that can be incurred repeatedly and the cost savings can add up, e.g. a miner who can submit 32 sectors at a time has a cost advantage over miners who can't. This is a structural force that can advantage larger miners more than smaller ones. However, I can be convinced if most miners can comfortably submit 32 sectors at a time.

@nicola
Copy link
Contributor

nicola commented Nov 12, 2020

Let me put it differently, the goal here is to reduce gas spent and not cost.

  1. We can make the batched operation to cost the same amount of $, but to consume less gas
  2. We can show that this fee does benefit large miners, but really little. For example, if this is a 1% cost reduction is that too much to favor large miners?

@zixuanzh
Copy link
Contributor

Thinking about this more, I think introducing this FIP at this moment will do more harm to the network than the potential cost savings it brings. The network is onboarding more than 15 PiB per day but most of that storage is not useful and it takes time to build applications on the network. In addition, FIP5 is already making PreCommit cheaper so committing storage is not too expensive or too slow per se. We can revisit this FIP in a few months once demand for storage on Filecoin has picked up (Filecoin Plus is operating successfully) and more applications are built on Filecoin. If teams want to push for this FIP, we should push harder on the other fronts first. We should however make it cheaper to do SubmitWindowPoSt and PublishStorageDeals.

@nicola
Copy link
Contributor

nicola commented Nov 16, 2020

The fact that the network is on-boarding 15PiB per day (of which most of it is not useful) won't change with this fix; this FIPs makes sure that even if the network onboards 15PiB, ~1/3 (IIRC) of the block is freer than currently. If we don't do this, fees could increase for everyone.

What would be the list of questions that we should answer to gain confidence on this?

As I said before, having a node that aggregates PreCommit from multiple miners could also be done - although more complex.

@anorth
Copy link
Member Author

anorth commented Nov 17, 2020

Economies of scale are real. We can't pretend they don't exist just because that's "unfair" to parties that don't have the scale to enjoy them. This is a very minor one in the big picture of Filecoin mining. Economies of scale is the very premise behind Filecoin's vision of abundant cheap storage. We should lean into them and get as much as possible!

As @nicola says, this will make no difference to the high growth rate of the network. High-growth miners are much more likely to be limited by cost of sealing hardware than the gas cost of pre-commits, so reducing that gas cost won't change anything except making the whole network's consensus more efficient and freeing up bandwidth for other messages.

@nicola
Copy link
Contributor

nicola commented Nov 24, 2020

We should land this at the same time or after we land ProveCommitBatched. The reason is that the decreased cost in PreCommitBatched could lead miners to think that they could submit many times more PreCommits, and this will lead to a more congested chain.

@anorth
Copy link
Member Author

anorth commented Dec 10, 2020

The FIP draft for this has landed (#27), but the team is generally agreed that we should postpone implementation until after first addressing Window PoSt affordability.

@nicola
Copy link
Contributor

nicola commented Mar 23, 2021

We finally have a more affordable WindowPoSt.

PreCommit is currently 23% of the gas used. This FIP would be great in combination with FIP0013!

@stuberman
Copy link

It is not clear to me whether the pre commit batch affects sealing. While precommit commit messages are waiting for release (expiration of "PreCommitBatchWait") are those sectors held from further processing/sealing? As an example is PreCommitBatchWait = 8 hours will PC2 sectors queue up on sealing disks until the timer expires? If so, miners will need to be advised to set the wait timer low enough to not run out of disk capacity and cause worker to idle waiting for timer to expire.

@ZenGround0
Copy link
Contributor

@stuberman this is an implementation concern so your question will be best addressed by filing an issue with the implementation you are using (sounds like https://github.com/filecoin-project/lotus is the right place)

@jennijuju
Copy link
Member

It is not clear to me whether the pre commit batch affects sealing. While precommit commit messages are waiting for release (expiration of "PreCommitBatchWait") are those sectors held from further processing/sealing? As an example is PreCommitBatchWait = 8 hours will PC2 sectors queue up on sealing disks until the timer expires? If so, miners will need to be advised to set the wait timer low enough to not run out of disk capacity and cause worker to idle waiting for timer to expire.

Also can be a great question for next weeks deep dive AMA!

@kaitlin-beegle
Copy link
Contributor

Tagged inactive due to the passage of FIP0008.

@kaitlin-beegle kaitlin-beegle added Technical - Proofs FIP0008 Links an existing discussion item to an existing FIP. labels Aug 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIP0008 Links an existing discussion item to an existing FIP.
Projects
None yet
Development

No branches or pull requests

8 participants
@anorth @nicola @ZenGround0 @zixuanzh @jennijuju @kaitlin-beegle @stuberman and others