Description
Currently, the proposal is gossiped using block parts. This, in theory, is highly advantageous because nodes can gossip the block in parallel and only partially to each of their peers. The overall throughput should be able to far exceed that of the per peer bandwidth allocation.
Block propagation could be further improved by making it compatible with other optimizations. Mainly
-
- Erasure encoded block propagation
-
- Compact Blocks EPIC: Compact Blocks celestiaorg/celestia-core#883
-
- Combining i. and ii.
i. Erasure Encoded Block Parts
erasure encoded block parts would make block propagation even faster and more efficient because instead of waiting on the network to distribute 100% of the block, we only have to wait on the network distributing any 50% (or even 33% in some schemes) of the block to each peer. The block is of course 2x bigger (or 3x in the 33% case) but we would still never actually download more than the original block data. This would require changing the way that block parts are committed to, as we would need to first erasure encode them.
ii. Compact Blocks
Compact blocks are amazing not only because we are only gossiping block data once while retaining the benefits of a mempool, but also because we can gossip block data outside of the proposal period. Compact blocks also fit in extremely well with schemes that break the proposer monopoly, because the probability of gossiping redundant data is high when we have many block producers contributing to each block.
Using the existing block part scheme with compact blocks would be limited in benefit. While we would have the capability to distribute blocks quickly, in any scenario where we have to rely on distributing the block during the proposal period, we essentially revert to the current protocol. If the block part scheme was changed so that each transaction is a block part, then we would not lose the benefits of gossiping block data outside the proposal period. In this scenario, we would start gossiping blocks identically to how we normally would, except peers would start off with partially filled blocks.
iii. Combined Approach
If we combine both erasure encoding block parts and using individual transactions as block parts, we can get the best of both schemes. At that point, [imo] we are quickly getting into "state of the art gossiping protocol" territory.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
evan-forbes commentedon Dec 8, 2023
to clarify, this issue is a proposal for a potential change
also probably need to point out that I think this would work best for chains that have large transactions
melekes commentedon Dec 11, 2023
Have you done any tests?
To clarify, here you're talking about
ii. Compact Blocks, right?ebuchman commentedon Jan 28, 2024
Linking to some old related issues:
I think there's really two things at play here:
I'll share some thoughts on each.
Removing PartSetHeader from Blocks
Having the PartSetHeader in the block is a pain because it pollutes the data structure throughout the code base (we have to use BlockID which isn't just a hash but contains this other PartSetHeader structure), it means the block data structure is tightly coupled to the block gossip mechanism (yuk), and it bloats the block size by ~80 bytes (each PartSetHeader is 32+4 + encoding, and theres two in each block, one for the LastBlockID and one in the Commit).
I believe the reason the PartSetHeader is in the block is to support peers syncing up through the consensus reactor. Of course you're not meant to do this for long, ideally you sync with blockchain reactor, but then there could still be a need to sync a few blocks using the consensus reactor, in case between block sync and switching to consensus the consensus has gotten ahead.
Why do you need the PartSetHeader in the block if you're syncing using consensus? Well, if you're part of real time consensus, there's no need to have the PartSetHeader in the block - the PartSetHeader can be signed in the Proposal so you know how many parts there are and how to verify them. However if you're catching up using the consensus reactor, you don't get to see the proposals (they're not persisted), all you get are votes. By including the PartSetHeader in the BlockID, its automatically included in the vote. If it were not in the votes, then a node catching up would have no way to verify block parts as it downloaded them. It wouldn't even know how many there are.
There's a few ways to solve this:
1 doesn't really work and wouldnt be viable long term, and 3 kind of just seems like a worse version of 2. So probably the best solution here is 2, which shouldn't be too complicated. It will require proposals be persisted for some time (should prob be unbonding period equivalent), and nodes will need to be able to verify who the proposer is at each height/round. This might take some care to work out, but seems doable. It does mean storing some extra data, but proposals are relatively small, so its not that much.
If we do this, I think we. can safely remove the PartSetHeader from the block 🎉
Decouple Block Gossip from Consensus
The block gossip is currently an integral part of the consensus reactor, but its really orthogonal to the core logic. In principle it could be separated out, even into its own reactor. This would clean up the consensus reactor and allow it to align even further with the core consensus specification, which would be nice.
However, there's a few complications to consider in the interface between the consensus reactor and such a new block gossip reactor.
First, as discussed, we need to ensure its still possible to sync up securely through the consensus reactor. This means the Proposal will need to contain some kind of commitment to the block gossip mechanism, whatever it might be (this was the motivation behind this issue in the first place!). Since removing the PartSetHeader from the Block already requires us to add it to the Proposal, we could go ahead and call it "BlockGossipHeader" for generality sake, and have the type be dependent on the actual block gossip mechanism used. I'm not sure it should literally be a generic type, it could just be
[]bytethat are interpreted as necessary by the block gossip (this would mean a bit of extra encoding, but probably a pretty minor thing).Second, we need to synchronize the round state and the peer states between the two reactors. Block gossiping logic depends heavily on our own consensus state (height, round, proposal) and on that of our peers. Since this information is communicated/stored in the consensus reactor, it would be ideal if it could be reused in the block gossip reactor (without having to be gossiped independenlty). But this will either require some way to share state, which could get messy, or to have regular communication between the two. Basically every time we update our own RoundState or a PeerState, we'd have to notify the BlockGossipReactor as well. This way it would know what to be downloading, and what to be sending to peers.
Third, we need to figure out how proposals will work. Currently the consensus calls CreateProposal from the state package, which calls into the mempool to fetch txs to assemble into a block and then calls PrepareProposal. This could stay in the consensus, but once the block is assembled, we'd need to send it to the BlockGossipReactor to start gossiping. Alternatively this could be done in the BlockGossipReactor, but then the block hash and BlockGossipHeader needs to be sent back to the consensus reactor so it can form the proposal. This would probably be the more natural separation of concerns. That way the consensus doesn't actually need to know anything about blocks, since it would just operate on the block hash and an opaque BlockGossipHeader. And the BlockGossipReactor can start putting together its proposals whenever it wants (eg. in advance of actually becoming the proposer).
Finally, we need a way for the BlockGossipReactor to communicate back to the consensus reactor that it received a complete block. This should be straight forward.
So there's quite a bit to work out, but it definetely seems doable and like it would be a huge unlock, simplifying the consensus package and allowing for much easier experimentation with new gossip mechanisms.
A separate issue was opened for decoupling the block gossip from consensus in #2127, so we could move that part of the convo there.
I suppose both of these sections should be turned into their own ADRs ...
ebuchman commentedon Jan 28, 2024
Ok copied the second part of the above comment to #2127 (comment)