-
Notifications
You must be signed in to change notification settings - Fork 710
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
Torrent-style fetching for PoVs: high-level #968
Comments
This might all be irrelevant if we just have backing groups of size 1 or 2. Groups of 3 or more are likely to benefit from this. |
UPDATE: After discussing with Rob, this currently falls short of the goal. I am going to double back and revisit later after reading further into the CandidateDescriptor logic. Suggestion: Instead of committing to the Merkle Root Hash of the PoV, it may be beneficial to some Elliptic Curve magic instead. Reason: If we commit to the Root Hash alone, then we have the problem that we either need to verify all the merkle proofs for every chunk we receive or we need to download the entire PoV in order to verify that it matches the commitment (without actually needing to validate the entire PoV). One way to circumvent this would be to commit to the hash of every chunk of the PoV, but this allows an attacker to learn the hash of the chunks of the PoV without needing access to the PoV at all. Goal: How can we transmit a single "Hash" to the validator such that they can verify that a certain chunk of the PoV is a "valid" part of the whole PoV, thereby ensuring that only people with access to the PoV can actually compute the Hash of a certain chunk. Not even the validator should really know the hash of a certain chunk until they actually download the chunks and verify that it is a member of the overarching set of commitments to the PoV. One way to achieve this would be as follows (let's assume for the sake of discussion that we use BLS signatures):
This ensures that (i). The chunk is a valid chunk of the PoV committed to by the original advertisement that got seconded That is, we don't need to verify the chunks right away and needn't wait before we know whether a chunk is invalid if we don't verify the chunk itself. If the collator were in addition able to prove that the commitments submitted in the advertisement that got seconded are commitments a PoV for which each Merkle proof is valid under some public root hash, we could "fix" the block at the seconding step without needing to have the PoV ready at that point in time. The PoV will only need to become available in the Approval Voting step (if I understand correctly). However, due to the depth of a Blake2 circuit, proof generation is completely untenable. Moving to Pedersen Hashing for the PoV Merkle tree will make proof generation more tenable, but depending on the number of Merkle proofs, there may be a better proof system for proving knowledge of all or some leaves of a Merkle tree under a public root hash. |
@burdges Would it be possible to ask for a review of the protocol? I'm not sure it works... Need to think about it more. It may be necessary to use random weights to compute the composite hash point. |
Alright first.. Our erasure coding is systemic, meaning chunks If you simply define the chunk to validator map by We already have a chunks Merkle tree so this yields roughly bittorrent but degrades smoothly into full reconstruction. We'd loose this clean layering if we ever discover some non-systemic codes with much better performance, but that's unlikely and several years away if ever. |
Second.. Your protocol is not secure because summing hashed-to-curve points does not act like an accumulator. Just fyi, BLS signatures are crazy slow and should never be used without really careful consideration. The DLEQ proof used by schnorrkel's VRF gives some similar properties, but not aggregation. I already expose vrfs_merge functions in schnorrkel that merge multiple VRF pre-outputs in one DLEQ proof, but this requires a scalar multiplication per point, which costs like 1/2 the CPU that a signature costs, so slow relative to a Merkle proof. We should already avoid senders doing signatures over they chunks they send because the chunk's Merkle proofs trace back to the candidate receipt on chain. Absolutely nothing you could do would be less CPU than this. We likely use our radix 16 storage Merkle tree for computing the availability root thing. About every 6 months for the last 2 years, I complain to someone that radix 16 hashing needlessly bloats Merkle proofs in dense Merkle trees, by maybe a factor of 4x in the worst case. I always tell them to switch storage to binary hashing with a "fast forwarding hash function" and radix 16 caching. Invariably, they always explore the issue and come back to me saying that our storage Merkle trees are usually not dense, and so state migration is too much of a pain. They are wrong because some parachains will definitely use dense storage, but by this time I'm always too busy doing something else to push the issue. This is one of those dense Merkle tree situations where radix 16 hashing bloats our proofs of course. In brief, my second suggestion is that Emeric or someone eventually fix our bloated Merkle proofs. |
Ladi and I also had a longer discussion about the protocol and decided that we don't need anything other than regular merklization as I described in the original post.
Yes, can confirm. re: paritytech/polkadot#3317 we will be able to update the semantic meaning of the erasure-root and migrate to cheaper trie. Although the 16-trie branch proofs are still probably not that bad for 1000 validators. They will also probably not be that bad for a trie mapping 64 indices to unique pov chunks of 32KB. (2MB PoV)
Yes. This is orthogonal, though. |
Yes, cool. We could exploit our erasure coding being systemic to streamline fetching PoVs. It gives a clean failover from direct fetching to reconstruction. |
For us to make use of the systemic code effectively we'd have to change the validator indices who hold the systemic chunks more often than we do now, which is once per session. Maybe compute them in some balanced way based on relay-parent number. |
Yes, something like |
The first two |
I miss-typed above I'd think At first blush I'd worry about doing
|
Initially, I'd everyone using their own VRF in the tit-for-tat, so that nobody knew from who honest people fetch, but..
Is a relay chain block producer going to not make a block because they've some bad distribution of chunks I therefore think this formula works..
with the fetching rules
You can just straight to 3 anytime you like of course. I prefer doing 1 before 2 but if you need 2 before 1 then I'll get over it. :) |
Cross posting from paritytech/substrate#11944 The Episub gossip protocol is a successor to the FloodSub protocol, which allows two types of peers to exist, In the context of distributing PoV's, it is possible for the backing set for the given parachain to be eager peers, and the other validators could be lazy peers, to facilitate gossiping. As an added functionality, the lazy peers who wish to validate the block can request the chunks as well. There is an existing implementation of the Episub protocol, in Rust. As per my understanding of this use-case, using Episub for PoV distribution, would result in -
|
We'd never widely "gossip" PoV blocks under any circumstances, as that'd be extremely inefficient. We do "gossip" parablocks among parachain nodes aka collators, but among the parachain nodes these parablocks need not be PoVs of course, which makes the blocks far smaller. A collator expands its parablock into being a PoV only when sending to its parachains five backing validators. Any backing validator receiving a parablock PoV B could then check B and expand B into its erasure coded chunks B_i to create the candidate receipt R for B. We then "gossip" Rs among only the five backing validators, which yes then results in those five backing validators "gossiping" the Rs for those Bs. There is no useful notion of eager & lazy here obviously. We also enforce several constraints which do not afaik fit a general pubsub protocol. In fact, we're currently rewriting gossip within backing groups ala paritytech/polkadot#5055 (comment) because the existing protocol used something resembling eager & lazy peers, but proved too wasteful for network bandwidth. After some candidate receipt R collects two backing votes and appears on the relay chain then we begin availability distribution, which means sending the erasure coded chunks B_i of R to validator i. Approval checkers later reconstruct the PoV B of R by fetching enough erasure coded chunks B_i of R, which is what this issue discusses. I should emphasize that both these last two steps do not constitute gossip, and in fact are asymptotically far more efficient than any possible gossip. At a high level, I'm dubious pub-sub protocols could ever really be a desirable abstraction. Afaik, one should gossip only when absolutely essential for security & redundancy, and think carefully about the gossip topology for that particular message type, while manually structuring heavier bandwidth flows around direct connection, perhaps using erasure coding to bridge critical gaps. Always think more like bittorrent and less like bitcoin. At a personal level we need fundamental tools like set reconciliation via BCH codes, as discussed in https://hackmd.io/@rgbPIkIdTwSICPuAq67Jbw/HJ5rpldsB or https://github.com/w3f/research-internal/issues/141 We do not need poorly considered and hard-to-optimize abstractions of the sort libp2p seemingly provides. Apologize for being gruff here, but you brought pub-sub to "how to be like bittorrent" thread. |
We're clearly happy to pay for someone to work on set reconciliation via BCH codes in Rust of course, maybe @drahnr |
Apologies again for being gruff there. We want good abstractions that makes building p2p networks easier, but afaik they do not appear to be as simple as things like eagerness & laziness. I'll tell a personal story: I wanted polkadot's availability system not just to be like bittorrent, but to actually become bittorrent, by which I mean I believed a common protocol exists through which we'd benefit from bittorret folks delicate network optimizations, and bittorrent would benefit from our reliability. I eventually & sadly concluded this protocol does not exist per se, because polkadot needs Reed-Solomn to ensure a undecodable ratio under 1/3, while file sharing likely benefits from rateless erasure codes, under their typical threat model of honest encoders. As these codes are nice for such different reasons, it's dubious that any nice common abstraction exists either above QUIC streams or whatever. We should do networking abstractions at whatever level looks viable, but we should first build more real applications, so our abstractions hunting works with real material. |
Thanks for the explanation! I should've looked a little more into how the distribution is being done. |
) Co-authored-by: ron <[email protected]> Co-authored-by: Clara van Staden <[email protected]>
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.59 to 0.1.61. - [Release notes](https://github.com/dtolnay/async-trait/releases) - [Commits](dtolnay/async-trait@0.1.59...0.1.61) --- updated-dependencies: - dependency-name: async-trait dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Our current Proof-of-Validity (PoV) distribution system for backing is quite simple: A validator fetches a full PoV from a collator, the the validator announces the PoV, and other validators in the group supply it in full.
PoV hashes and trie commitments
It is possible to change the semantics of the
pov_hash
in the candidate descriptor to refer to a merkle trie of the PoV data as opposed to the entire data. It needs to be done in a backwards compatible way, so we still support full PoVs. What we would allow is something like this:The trie is computed as a mapping from indices i to the chunk hash.
This is the root hash of the merkle trie as well as the number of chunks contained in the trie. The rightmost chunk may have size less than 32KiB, so the upper bound on the size is predicted by
n_chunks * CHUNK_SIZE
. Storing the number of chunks is important, so validators can tell immediately from the trie root commitment whether the PoV is oversized.For the
pov_hash
in the candidate descriptor, it is defined to either behash(PoV)
orhash(PoVTrieCommitment)
. This allows for backwards compatibility. Note that the erasure root in the candidate receipt is computed over an erasure-coding on the full PoV data, and will not change. However, it will become necessary for approval and dispute checkers to check that thepov_hash
in the descriptor matches the trie commitment computed from the full PoV data. Backing checkers, having recovered the PoV from the trie, do not need to do this check.As the old format of
pov_hash = hash(pov)
is still supported, validators checking the validity of a descriptor will have to check bothpov_hash == hash(pov) || pov_hash == trie_commitment(pov)
. However, computing the commitment can be done in a single pass over the PoV data without any allocations, just by hashing the stream and ending every 32KiB, so it should be relatively cheap - instead of taking 1 hash pass over the PoV, we take 2, and this is not a bottleneck for approval checkers.Pre-validation functions (PreVF)
Authenticating a collator's submitted block without downloading the entire PoV is impossible right now. To address this we use the notion of a Pre-validation function, or PreVF for short. PreVFs also have their own counterpart to the PoV - the Proof-of-Pre-Validity, or PrePoV for short. Definitionally, PoVs and PrePoVs are both just byte vectors, however they have different semantic meanings and can have different semantic length limits imposed. For example, while PoVs may be allowed to span multiple Megabytes, a PrePoV may be limited to just a few kilobytes.
This is a new function on the Parachain Validation code which has this approximate signature
We introduce the notion of reasonable uniqueness. For a PreVF to function effectively, its result must be reasonably unique. Signatures by a specific validator are reasonably unique so long as equivocations are punished ecnomically. Proofs of Work are reasonably unique if they are sufficiently difficult. And so on. It's allowed to occasionally have collisions in the PreVF, but the multiplicity should be low even if so.
With PreVFs, collators can send over
(CandidateReceipt, PrePoV)
pairs. The PrePoV can be used by validators to determine preliminary validity.Note that we don't rely on PreVFs for security of any kind. A Parachain exposing a PreVF which is not plausibly unique only detracts from the liveness of the parachain, as it can only be used to force validators to waste bandwidth and fail to back any candidate for the parachain.
Torrenting PoVs
We introduce a new request type:
We introduce a new gossip statement, to be used exclusively among backing validators:
Stage 1: Torrenting among validator groups
Stage 1 can be implemented before PreVFs. At this point, a seconding validator still needs to download the full PoV from a collator and check it before seconding. However, after issuing the
Seconded
message, the validator can issue anIntentToRecover(seconded, trie_commitment)
and the other validators in the group can also signal an intent to recover the data and will recover it from the seconding validator as well as each other.We have a few pieces of information that can be used to determine the chunk range that validators initially download, to maximize initial coverage:
Validators can choose the initial ranges of chunks they download based on this information, to achieve a desirable balance of redundancy and availability.
Stage 2: Torrenting before seconding
PreVFs will enable validators to recover and torrent a PoV among all validators in the group as well as potentially from the collator even before checking the candidate. There should be a limit of 2 or 3 recoveries at a time, and due to the condition of reasonable uniqueness we expect on PreVFs, this should not affect throughput.
A validator, having checked a PreVF, can distribute the PreVF to other validators in the group, and all begin torrenting chunks from each other as well as the initial collator. The same basic principles for choosing chunk ranges to fetch apply, with the addition of potential rules for collators to follow about which chunks to prioritize serving which validators.
The text was updated successfully, but these errors were encountered: