-
Notifications
You must be signed in to change notification settings - Fork 2
feat(rfc): sharded dag with virtual blocks RFC #66
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
base: ash/rfc/filepack
Are you sure you want to change the base?
Conversation
alanshaw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this sounds great ❤️
Something I realised is that we could remove the caching of these blocks that we do in freeway and any cost associated with that!
| type ShardedDagIndex_0_2 struct { | ||
| content Link | ||
| shards [Link] | ||
| blocks [Link] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array of multihash digests rather than links?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should model/phrase this as a "merkle proof" to prevent arbitrary blocks from being attached?
i.e. blocks MUST include content as the first block. Specify that other blocks MUST be linked from the root or one of it's children.
We should specify that blocks MUST NOT include DAG leaf blocks. i.e. no IPLD raw blocks (a reason to leave it as CID not hash).
Consider renaming blocks to proofs?
|
|
||
| The `blocks` attribute in a sharded DAG index v0.2 block is simply a collection of links to blocks that are included in this index file. Since a Sharded DAG Index is a CAR file, these blocks are simply inserted into the CAR file. | ||
|
|
||
| **IMPORTANT**: While small, this represents a breaking change for retrieval clients. Because the blocks included in the index are no longer in the underlying shard file, a retrieval client MUST be able to read the additional blocks out of the Sharded DAG Index CAR file in order to perform the retrieval. This is why we change the version of the Sharded DAG Index and list the included blocks in the Sharded DAG Index v0.2 root block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
|
|
||
| ## Benefits | ||
|
|
||
| Adding the ability to put blocks directly into the Sharded DAG Index would enable us to store files as blobs in their original format (up to the shard size), while maintaining full UnixFS compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also go the other way and store a small file in the index and only upload 1 blob... 🐢
|
|
||
| This would provide much faster RTT when using w3s.link -- the block could be returned directly from the location claim, and with no range request. Because the blob hash is sha256, it could be verified directly by the browser's various data integrity tools. | ||
|
|
||
| This approach could enable other optimizations as well. For many UnixFS directories, the entire directory structure could live in the sharded DAG Index. This would enable deep pathing in only two roundtrips -- one to fetch the sharded dag index, and one to fetch the underlying file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏 OMG fast directory listings for HAMT
| type ShardedDagIndex_0_2 struct { | ||
| content Link | ||
| shards [Link] | ||
| blocks [Link] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea: structure the block links:
e.g.
{
content: { "/": "bafyroot" },
proof: [
{ "/": "bafyroot" }
[
/** children of bafyroot */
[{ "/": "bafyblock0" }, [/** more intermediate children */]],
[{ "/": "bafyblock1" }, [/** more intermediate children */]]
]
]
}i.e. proof does the same thing as blocks by specifying the included blocks, but also encodes the DAG structure? I'm not sure if useful though and seems a little complicated...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I originally imagined various more complicated listings, then decided just listing the blocks and including them is probably the right move.
|
|
||
| ``` | ||
|
|
||
| The `blocks` attribute in a sharded DAG index v0.2 block is simply a collection of links to blocks that are included in this index file. Since a Sharded DAG Index is a CAR file, these blocks are simply inserted into the CAR file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth mentioning that these blocks MUST/SHOULD/MAY(?) NOT be included in any shard the index references?
Preview