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

spec: Shwap #3205

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

spec: Shwap #3205

wants to merge 17 commits into from

Conversation

Wondertan
Copy link
Member

@Wondertan Wondertan commented Feb 23, 2024

Introduces Shwap page that points to the CIP. This PR integrates it nicely with mdbook engine like it is a local document in the node. It integrates multiple mdbook preprocessors into rendering pipeline and GH CI.

Rendered on GH pages

Copy link

github-actions bot commented Feb 23, 2024

PR Preview Action v1.4.7
🚀 Deployed preview to https://celestiaorg.github.io/celestia-node/pr-preview/pr-3205/
on branch gh-pages at 2024-03-26 16:57 UTC

@Wondertan Wondertan added the kind:docs For solely documentation PRs label Feb 23, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.59%. Comparing base (1809680) to head (5a818be).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3205      +/-   ##
==========================================
- Coverage   51.92%   51.59%   -0.34%     
==========================================
  Files         178      178              
  Lines       11316    11316              
==========================================
- Hits         5876     5838      -38     
- Misses       4942     4971      +29     
- Partials      498      507       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Identifiers are embeddable to narrow down to the needed content. (TODO: Describe better)

Identifiers MUST have a fixed size for their fields. Subsequently, protobuf can't be used for CID serialization due to
varint usage. Instead, identifiers use simple binary big endian serialization.
Copy link
Contributor

@oblique oblique Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your current Shwap PR little endian is used. We also implemented it with little endian. Which one should we use?

Copy link
Member Author

@Wondertan Wondertan Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will use the big endian. I did a slight research on that and found out that its is used in IP and QUIC with rationale that its just faster on most architectures, so decided to follow that here.

@zvolin
Copy link

zvolin commented Feb 28, 2024

what would you say for enforcing the package fields in proto definitions in the spec?

@Wondertan
Copy link
Member Author

@zvolin, I find it unnecessary, but might missing some context from other languages.

@zvolin
Copy link

zvolin commented Feb 28, 2024

so it usually affects the namespace in which the generated types will be. In our case we are generating and exposing all protos in a single crate (package) and all the messages without a package will be in a root namespace (even if they are generated separately). It sounds like something that will not hurt but can be useful.
In celestia-app protos are organized using pattern celestia.module.version and that ends up in types like celestia::blob::v1::MsgPayForBlobs in rust.
In node they usually look similar to the go module they are in, so we have header::pb::ExtendedHeader or share::p2p::shrex::nd::GetSharesByNamespaceRequest.
It would look nice on our end if shwap would have package share.p2p.shwap or something like so to be consistent.

Comment on lines 252 to 257
### Bitswap CID integration

The naive question would be: "Why not to make content verification after Bitswap provided it back over its API?"
Intuitively, this would simplify a lot and wouldn't require "hacking" CID. However, this has an important downside -
the Bitswap in such case would consider the content as fetched and valid, sending DONT_WANT message to its peers, while
the message might be invalid according to the verification rules.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the verification is done in the Bitswap level, the only way knowing that data sampling failed and block should be rejected, is to have a timeout. So, how many seconds the timeout should be? Should we define it here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting thought. I think this timeout is out of Shwap's scope. The actual sampling logic - how, how many samples are selected, and what the timeout for sampling deserves as separate spec/cip that depends on Shwap protocol.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shwap is a transport for specialized DA messaging. The sampling logic/details are out of its scope

@Wondertan
Copy link
Member Author

Wondertan commented Feb 28, 2024

@zvolin, my hesitation with package share.p2p.shwap is that it enforces a certain package structure for the client implementations. I aim for the spec to be as language-agnostic as possible and broadly free from any non-protocol constraints.

Making all the proto follow the same package forces all the types to be generated in a single place, like what the core and lumina are doing. Node on the other hand is more modular and we keep proto-types together with the protocols, where each protocol is its own independent module/package. This is an example of an architecture decision that implementers are free to make and enforcing package structure through package directive breaks that.

It's nice to be consistent and I see why consistency is good to follow in general, but not in this case.

The current Data Availability Sampling (DAS) network protocol is inefficient. A _single_ sample operation takes log2(k) network
round-trips(where k is the square size). This is not practical and does not scale for the theoretically unlimited data
square that the Celestia network enables. The main motive here is a protocol with O(1) round-trip for _multiple_ samples, preserving
the assumption of having 1/n honest peers connected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does "1/n" means that there needs to be at least one peer out of N, or something else?
Also, clarification is needed on whether peers must be both honest and possess the requested data shares. For example, an honest light node might lack the relevant data shares, impacting sampling efficiency. Clarifying these points would strengthen the protocol's specifications.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does "1/n" means that there needs to be at least one peer out of N, or something else?

1 honest peer.

Also, clarification is needed on whether peers must be both honest and possess the requested data shares

1/n is a pretty common assumption in p2p networks. In this context honesty assumes possession. Nevertheless, clarifying it makes. Thanks for pointing this out.

### Multihashes and CID

Shwap takes inspiration from content addressability, but breaks-free from hash-based only model to optimize message sizes
and data request patterns. In some way, it hacks into multihash abstraction to make it contain data that isn't in fact a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and data request patterns. In some way, it hacks into multihash abstraction to make it contain data that isn't in fact a
and data request patterns. In some way, it hacks into multihash abstraction to make it contain arbitrary message fields that isn't in fact a

We might want to be more specific here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this change anything to message I tried to convery. Arbitrary message fields are also quite general and can mean anything.

Maybe something like "identification data" may improve it


Identifiers are embeddable to narrow down to the needed content. (TODO: Describe better)

Identifiers MUST have a fixed size for their fields. Subsequently, protobuf can't be used for CID serialization due to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it is worth to explain that the reason why Identifiers MUST have a fixed size is bitswap internal architecture.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I really would like not to have bitswap as a rationale for this, as this breaks Shwap protocol independence. Ideally, we would find a way to avoid this limitation until the CIP is finalized or find another rationale for why this is necessary.

Comment on lines 84 to 88
| Name | Multihash | Codec |
|----------|-----------|--------|
| RowID | 0x7811 | 0x7810 |
| SampleID | 0x7801 | 0x7800 |
| DataID | 0x7821 | 0x7820 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for nice aligment, why not those not ordered by desc multihash/codec?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I wanted to keep the order of IDs as defined in the spec and I didn't want to break what was already implemented, but as we break other things, it may not hurt to break this one.


Shwap takes inspiration from content addressability, but breaks-free from hash-based only model to optimize message sizes
and data request patterns. In some way, it hacks into multihash abstraction to make it contain data that isn't in fact a
hash. Furthermore, the protocol does not include hash digests in the multihashes. The authentication of the messages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hash. Furthermore, the protocol does not include hash digests in the multihashes. The authentication of the messages
hash. Furthermore, the protocol does not include hash digests in the multihashes. The verification of the messages

My understanding is that authentication is verifying who provided data, rather than content in response. What do you think to replace authentication -> verification

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both terms work in this case. I've seen data/message authentication used to describe data that is not being tampered with and is coming from the right source. In this case, we authenticate messages against DAH, which assures us the data is correct and is coming from/produced by consensus/validators

@Wondertan
Copy link
Member Author

Wondertan commented Mar 4, 2024

Noting that spec fully migrated to celestiaorg/CIPs#77, so all the comments and discussions should move there as well. Check the description for more on new changes here

@@ -1 +1,2 @@
book
theme
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rootulp, the theme dir can be similarly .gitignored in the app's repo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:docs For solely documentation PRs specs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants