Closed pmnoxx closed 2 years ago
@bowenwang1996 @mm-near @matklad
Great idea! I've just spend five minutes reading the doc in the wip PR, and I feel I've already learned more about near networking more than I knew before.
I have one high-level comment here: we might want to ensure strict separation between protocol specification and code-level documentation. Ideally, I'd love to see two documents: "NEAR P2P protocol" and "Implementation of networking in nearcore". The first documents abstract protocol without references to a particular implementation. It doesn't mention Rust, tokio, nearcore or actors, but it does mention TCP, borsh format, persistent nonces etc. So if you want to implement a nearcore node in Go, you can use that document as a spec. The second document describes how we implement protocol in nearcore (eg, "to maintain persistent nonces, we store removed edges into the database using this column").
Don't think that we should immediately create that, but it might make sense to keep the separation between proper protocol and specific implementation in mind while writing the docs.
The first documents abstract protocol without references to a particular implementation
I guess the right home for that doc is https://nomicon.io/ChainSpec/NetworkSpec.html (and network spec should probably be lifted one level up and become a sibling of ChanSpec
)
To make network code easier to understand we should write a reference level documentation. That will make it easier for new developers to understand different parts of the networking code.
Add in-code documentation
Graph
- https://github.com/near/nearcore/pull/5162utils.rs
(https://github.com/near/nearcore/pull/5216)test_utils.rs
(https://github.com/near/nearcore/pull/5217)rate_counter.rs
(https://github.com/near/nearcore/pull/5218)Dead code
Improve code quality:
Edge
- https://github.com/near/nearcore/pull/5223