-
Notifications
You must be signed in to change notification settings - Fork 33
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
[P2P] Integrate background router #732
Conversation
7f58195
to
ab81389
Compare
ab81389
to
b01996d
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## refactor/unicast-router #732 +/- ##
===========================================================
+ Coverage 31.78% 32.23% +0.45%
===========================================================
Files 106 87 -19
Lines 8996 6099 -2897
===========================================================
- Hits 2859 1966 -893
+ Misses 5795 3861 -1934
+ Partials 342 272 -70
☔ View full report in Codecov by Sentry. |
b01996d
to
a8206ec
Compare
a8206ec
to
744cb2b
Compare
30e94a6
to
fe24824
Compare
744cb2b
to
d564ade
Compare
86d739c
to
53e81e5
Compare
ca0b962
to
f80e6e9
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
p2p/README.md
Outdated
|
||
| Sender | Receiver | Router | Example Usage | | ||
|----------------|----------------|-----------------|------------------------------------------------------| | ||
| Staked Actor | Staked Actor | Raintree only | Consensus (state sync) messages (to validators only) | |
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.
As noted in the P2P knowledge transfer (#438) ticket, for hotstuff consensus, we don't use RainTree for messages propagation between staked actors (e.g. state sync) but for consensus, it's a star pattern (i.e. direct)
p2p/README.md
Outdated
|
||
| Sender | Receiver | Router | Example Usage | | ||
|----------------|----------------|-----------------|------------------------------------------------------| | ||
| Staked Actor | Staked Actor | Raintree only | Consensus (state sync) messages (to validators only) | |
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.
How about this:
Sender | Receiver | Router | Example Usage |
|----------------|----------------|-----------------|------------------------------------------------------|
| Staked Actor | Staked Actor | No router | Consensus (hotstuff) messages (to validators only) |
| Staked Actor | Staked Actor | Raintree only | Consensus (state sync) messages (to validators only) |
| Unstaked Actor | Staked Actor | Background only | Consensus (state sync) messages (to validators only) |
| Unstaked Actor | Unstaked Actor | Background only | Consensus (state sync) & Debug (CLI) messages |
d2dc98a
to
b76efdf
Compare
* pokt/main: [Utility] Update E2E feature path template doc (#870) [IBC] Add nil check on proof for membership and non-membership proof creation (#877) Added git diff state to devlog10 Devlog 10 (#872) [Documentation] Add IBC Module introduction as an example (#853) [Persistence][Bug] Fix Actor Schema Assignment for ValidatorActor in GetActor (#857) QOL: add bash completion for p1 to localnet client (#865)
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.
Let's 🚢 this!!
{ | ||
name: "empty PocketEnvelope", | ||
msgBz: mustMarshal(t, &typesP2P.BackgroundMessage{ | ||
// NB: `Data` is normally a serialized `PocketEnvelope`. |
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.
Appreciate the comments 🙌
t, receiverPeer, | ||
receiverHost, | ||
func(data []byte) error { | ||
receivedChan <- data |
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.
Nice change
* pokt/main: [P2P] Integrate background router (#732) Update main README.md [Bug] Fix CI linter errors (#885) [Tooling] Block `IN_THIS_*` comments from passing CI (#889) [Utility] Update E2E feature path template doc (#870) [IBC] Add nil check on proof for membership and non-membership proof creation (#877) Added git diff state to devlog10 Devlog 10 (#872)
## Description Because `0` is the zero (default) value for `uint64`, if it is valid to be used as a nonce, it becomes difficult to distinguish the scenario where sender did not set a nonce from one where they explicitly set it to `0`. I'm not confident whether the ability to make this distinction matters now or has the potential to later but was following a feeling. <!-- reviewpad:summarize:start --> ### Summary generated by Reviewpad on 11 Jul 23 11:56 UTC This pull request includes the following changes: - In the `p2p/module.go` file, the `handlePocketEnvelope` function now checks if `poktEnvelope.Nonce` is zero and returns an error if it is. The error message includes the hex-encoded nonce value. - In the `p2p/module_test.go` file, new test cases have been added to test the handling of an invalid nonce. - In the `p2p/types/errors.go` file, a new error variable `ErrInvalidNonce` has been added to represent an invalid nonce value. - In the `shared/crypto/rand.go` file, a check has been added to ensure that the generated nonce value is not zero. If it is zero, the function recursively calls itself to generate a new nonce. <!-- reviewpad:summarize:end --> ## Issue N/A; observation made while working on #732. ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [x] Bug fix - [ ] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Adds `ErrInvalidNonce` P2P error type - Ensures the P2P message handler rejects the zero value `Nonce` (`uint64(0)`) is invalid - Ensures the `GetNonce` function never returns the zero value ## Testing - [ ] `make develop_test`; if any code changes were made - [ ] `make test_e2e` on [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any code changes were made - [ ] `e2e-devnet-test` passes tests on [DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd); if any code was changed - [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced - [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made ## Required Checklist - [ ] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment)) - [ ] I have tested my changes using the available tooling - [ ] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [x] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s)
@Reviewer
This PR may be more digestible / reviewable on a commit-by-commit basis. Commits are organized logically and any given line is only modified in a single commit, with few exceptions*.
*(In the interest of preserving the git-time-continuum 👮🚨, this applies in batches of commits between comments or reviews by humans, only once "in review")
Description
Before
While
backgroundRouter
exists and implements theRouter
interface, it had yet to be connected to anything. Additionally, it was not able to handle incoming unicast messages.After
backgroundRouter
embedsUnicastRouter
and is integrated intop2pModule
such that it is considered when callingP2PModule#Send()
andP2PModule#Broadcast()
.Issue
Dependencies
Type of change
Please mark the relevant option(s):
List of changes
Router#Close()
interface methodPocketEnvelope
nonce generation toPackMessage()
Handler
to router configsRouter
interface changesRouter
interface changesTesting
make develop_test
; if any code changes were madeRequired Checklist
godoc
format comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)