-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: main
Are you sure you want to change the base?
doc: specs #116
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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.
lgtm, some small clean up comments.
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.
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
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`. |
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.
We should either link to those constants or mention their values here is some legend.
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.
This comment applies to all other constants throughout the spec
|
||
## Metrics | ||
|
||
Currently only following metrics are collected: |
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.
Note that the list is already extended for Subscriber, and more will be added soon.
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'll take care of updating the spec
p2p/p2p.md
Outdated
// 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) |
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.
These methods were recently unified, and this needs to be updated.
``` | ||
message HeaderRequest { | ||
oneof data { | ||
uint64 origin = 1; | ||
bytes hash = 2; | ||
} | ||
uint64 amount = 3; | ||
} | ||
``` |
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.
[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.
thanks for your review @Wondertan 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. |
@Wondertan let me revise this based on your comments and try to make certain parts golang independent. Will request review soon. |
Co-authored-by: Hlib Kanunnikov <[email protected]>
@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. |
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.
Really? Connected peer count should always be less than disconnected peer count?
Feels like this needs some explanation.
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.
overall lgtm
@gupadhyaya, getting back to this finally |
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. |
@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. |
@MSevey, which rendered website? |
I think we should make it work for both GH and the rendered website(or whatever it is) by removing symlinks and linking directly. |
@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. |
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. |
Overview
Rendered
Checklist