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

doc: specs #116

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

doc: specs #116

wants to merge 13 commits into from

Conversation

gupadhyaya
Copy link
Contributor

@gupadhyaya gupadhyaya commented Oct 6, 2023

Overview

Rendered

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@gupadhyaya gupadhyaya changed the title initial specs doc: specs Oct 6, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (09c272d) 67.81% compared to head (9bd3962) 63.66%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #116      +/-   ##
==========================================
- Coverage   67.81%   63.66%   -4.15%     
==========================================
  Files          38       39       +1     
  Lines        3079     3366     +287     
==========================================
+ Hits         2088     2143      +55     
- Misses        843     1058     +215     
- Partials      148      165      +17     

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

p2p/p2p.md Show resolved Hide resolved
p2p/p2p.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated Show resolved Hide resolved
sync/sync.md Outdated Show resolved Hide resolved
Copy link
Member

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

lgtm, some small clean up comments.

@gupadhyaya gupadhyaya requested a review from MSevey October 20, 2023 15:36
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

High-Level Q: What kind of spec is this and who is it targeted for?

It looks pretty Golang implementation-specific, and AFAIK, specs are meta descriptions of protocols and behaviors decoupled from implementation details. Usually, their target is a client implementer who needs to understand how things work. From my understanding, this is excellent code documentation, but not the spec. I wonder if we should aim to extract all the protocol information into an independent doc separating docs from specs or at least make the protocol description part of the documentation.

Anyway, this is awesome, and I am very grateful for this ❤️

I will review this in batches, and the first one is P2P doc review

specs/src/README.md Outdated Show resolved Hide resolved
specs/src/README.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated

The new peers are tracked by subscribing to `event.EvtPeerConnectednessChanged{}`.

The peer tracker also runs garbage collector (gc) that removes the disconnected peers (determined as disconnected for more than `maxAwaitingTime` or connected peers whose scores are less than or equal to `defaultScore`) from the tracked peers list once every `gcPeriod`.
Copy link
Member

Choose a reason for hiding this comment

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

We should either link to those constants or mention their values here is some legend.

Copy link
Member

Choose a reason for hiding this comment

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

This comment applies to all other constants throughout the spec


## Metrics

Currently only following metrics are collected:
Copy link
Member

Choose a reason for hiding this comment

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

Note that the list is already extended for Subscriber, and more will be added soon.

Copy link
Member

Choose a reason for hiding this comment

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

I'll take care of updating the spec

p2p/p2p.md Outdated Show resolved Hide resolved
p2p/p2p.md Outdated
Comment on lines 73 to 78
// GetRangeByHeight returns the given range of Headers.
GetRangeByHeight(ctx context.Context, from, amount uint64) ([]H, error)

// GetVerifiedRange requests the header range from the provided Header and
// verifies that the returned headers are adjacent to each other.
GetVerifiedRange(ctx context.Context, from H, amount uint64) ([]H, error)
Copy link
Member

Choose a reason for hiding this comment

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

These methods were recently unified, and this needs to be updated.

Comment on lines +98 to +106
```
message HeaderRequest {
oneof data {
uint64 origin = 1;
bytes hash = 2;
}
uint64 amount = 3;
}
```
Copy link
Member

Choose a reason for hiding this comment

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

[blocking]
Let's separate the protocol from implementation. I suggest adding ### Protocol paragraph, which contains all the messages and explains the basic flow. The method description of components can then link to it.

@gupadhyaya
Copy link
Contributor Author

High-Level Q: What kind of spec is this and who is it targeted for?

It looks pretty Golang implementation-specific, and AFAIK, specs are meta descriptions of protocols and behaviors decoupled from implementation details. Usually, their target is a client implementer who needs to understand how things work. From my understanding, this is excellent code documentation, but not the spec. I wonder if we should aim to extract all the protocol information into an independent doc separating docs from specs or at least make the protocol description part of the documentation.

Anyway, this is awesome, and I am very grateful for this ❤️

I will review this in batches, and the first one is P2P doc review

thanks for your review @Wondertan
i am writing this specs from the perspective of the consumer (e.g. rollkit, in future other frameworks). i agree that it includes interface definitions in a specific language (golang), however i don't think it will prevent a non-golang adopter from understanding and consuming it. the whole idea here is to clearly specify the interfaces and implicit/explicit assumptions made. we have followed similar strategy in specifying rollkit.

i agree that we can add a protocol section which tries to summarize the components without getting into the details. but i don't think we should try to make two separate documents (specs and impl details) imho.

if we want, we can convert the golang interface definitions to language independent. let me know.

@gupadhyaya
Copy link
Contributor Author

@Wondertan let me revise this based on your comments and try to make certain parts golang independent. Will request review soon.

@gupadhyaya
Copy link
Contributor Author

@Wondertan tried to generalize as much as i can. as discussed, we can revisit regularly and keep improving. wdyt?

Exchange defines a client for requesting headers from the P2P network. An exchange client is initialized using self [host.Host][host], a list of peers in the form of slice [peer.IDSlice][peer], and a [connection gater][gater] for blocking and allowing nodes. Optional parameters like `ChainID` and `NetworkID` can also be passed. The exchange client also maintains a list of trusted peers via a peer tracker. The peer tracker will continue to discover peers until:

* the total peers (connected and disconnected) does not exceed [`maxPeerTrackerSize`][maxPeerTrackerSize] or
* connected peer count does not exceed disconnected peer count.
Copy link
Member

Choose a reason for hiding this comment

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

Really? Connected peer count should always be less than disconnected peer count?

Feels like this needs some explanation.

MSevey
MSevey previously approved these changes Oct 30, 2023
Copy link
Member

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

overall lgtm

@Wondertan
Copy link
Member

@gupadhyaya, getting back to this finally

@Wondertan Wondertan added documentation Improvements or additions to documentation kind:docs and removed documentation Improvements or additions to documentation labels Dec 1, 2023
@Wondertan
Copy link
Member

So, I added a rendered link to the PR description with rendered specs readme and realized that linking between symlinks defined in the specs folder and the actual specs markdown does not work. Do we really need this symlink redirection? I think we can directly point root specs README to the relevant md files.

cc @MSevey (as I see you set it up this way)

@MSevey
Copy link
Member

MSevey commented Dec 1, 2023

So, I added a rendered link to the PR description with rendered specs readme and realized that linking between symlinks defined in the specs folder and the actual specs markdown does not work. Do we really need this symlink redirection? I think we can directly point root specs README to the relevant md files.

cc @MSevey (as I see you set it up this way)

@Wondertan what is the actual issue? The rendered readme works fine for me, plus you can see the rendered version in the diff.

The symlinks were a way to keep the specs close to the code to encourage keeping them up to date.

@Wondertan
Copy link
Member

Wondertan commented Dec 1, 2023

@MSevey, try clicking links to Components on the rendered page and you will see

@MSevey
Copy link
Member

MSevey commented Dec 1, 2023

@MSevey, try clicking links to Components on the rendered page and you will see

oh right, yea we've talked about this internally. The Github UI doesn't support symlinks, but that is fine since we are optimizing for the rendered website and keeping the specs close to the code.

@Wondertan
Copy link
Member

@MSevey, which rendered website?

@Wondertan
Copy link
Member

I think we should make it work for both GH and the rendered website(or whatever it is) by removing symlinks and linking directly.

@MSevey
Copy link
Member

MSevey commented Dec 1, 2023

@Wondertan the specs site https://celestiaorg.github.io/go-header/

to make it work with both I would just not link to the specs folder. the specs folder is essentially a wrapper to enable a deployed specs website.

The original discussion the team had came down to whether or not we want the spec md files in the specs folder or close to the code. Since there was a preference for keeping the specs md files close to the code, we set up the specs folder with symlinks to make the website work.

So to make it work on the GH UI we just shouldn't reference the specs folder outside the specs folder.

@Wondertan
Copy link
Member

So to make it work on the GH UI we just shouldn't reference the specs folder outside the specs folder.

@MSevey, Do you mean pointing to the code directly like in here?

@MSevey
Copy link
Member

MSevey commented Dec 8, 2023

So to make it work on the GH UI we just shouldn't reference the specs folder outside the specs folder.

@MSevey, Do you mean pointing to the code directly like in here?

Yea, if a the spec in pkgA wants to reference the spec in pkgB, it should link directly to pkgB not the spec/src/spec/pkgB symlink location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants