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

gs1.1 peer score #83

Merged
merged 15 commits into from
Jun 17, 2020
Merged

gs1.1 peer score #83

merged 15 commits into from
Jun 17, 2020

Conversation

wemeetagain
Copy link
Member

@wemeetagain wemeetagain commented Jun 4, 2020

  • add PeerScore class
    • manages scores of peers, including per-peer stats, message delivery stats, and peer IPs
    • API
      • addPeer, removePeer, addPenalty, score
      • graft, prune
      • validateMessage, deliverMessage, rejectMessage, ignoreMessage, duplicateMessage
    • lifted directly from go-libp2p-pubsub, including tests (imitation is the most sincere form of flattery <3)
    • lifted default score thresholds and params from rust-libp2p
    • relies on AddressBook from js-libp2p to fetch IP addresses / listen to IP address changes

@wemeetagain wemeetagain requested review from vasco-santos and a team June 4, 2020 19:05
@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2020

Codecov Report

Merging #83 into gsv1.1 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           gsv1.1      #83   +/-   ##
=======================================
  Coverage   80.00%   80.00%           
=======================================
  Files           1        1           
  Lines          10       10           
=======================================
  Hits            8        8           
  Misses          2        2           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1401e85...7206a9d. Read the comment docs.

@wemeetagain wemeetagain force-pushed the cayman/gs1.1-score branch from 56ab3ef to 2303125 Compare June 5, 2020 00:31
@wemeetagain wemeetagain force-pushed the cayman/gs1.1-score branch from 2303125 to 37d7020 Compare June 6, 2020 21:26
Copy link
Collaborator

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

Awesome work in this first iteration @wemeetagain
I think it was a good call go lift this from go-libp2p-pubsub, it helped a lot for the review and I think it will help us on future iterations :)

I mostly commented minor details, except for the usage of the AddressBook, which does not seem what you want here (details in the review comments).

For things like the throttled, white list ips, etc, I am ok on doing that in follow up PRs, but we need to leave it documented somewhere

ts/score/computeScore.ts Outdated Show resolved Hide resolved
ts/score/computeScore.ts Show resolved Hide resolved
ts/score/messageDeliveries.ts Show resolved Hide resolved
ts/score/peerScoreParams.ts Outdated Show resolved Hide resolved
try {
validateTopicScoreParams(params)
} catch (e) {
throw new Error(`invalid score parameters for topic ${topic}: ${e.message}`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use the err-code module for all these errors?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have access to the err-code repo? I see that some of the contributors there are part of @moxystudio
would be nice to have typescript type definitions in IndigoUnited/js-err-code#21

Copy link
Collaborator

Choose a reason for hiding this comment

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

I bumped it and talked directly with them, but that will not be merged unfortunately. Declare it in types will be the solution for now

Copy link
Member Author

Choose a reason for hiding this comment

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

will import @types/err-code once this PR is merged: DefinitelyTyped/DefinitelyTyped#45504

ts/score/peerScore.ts Outdated Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
ts/score/peerScore.ts Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
Copy link
Member Author

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

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

thanks for the thorough review

ts/score/computeScore.ts Show resolved Hide resolved
ts/score/computeScore.ts Show resolved Hide resolved
ts/score/messageDeliveries.ts Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
ts/score/peerScore.ts Show resolved Hide resolved
ts/score/peerScore.ts Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
ts/score/peerScore.ts Outdated Show resolved Hide resolved
* Update all peer IPs to currently open connections
* @returns {void}
*/
_updateIPs (): void {
Copy link
Member Author

Choose a reason for hiding this comment

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

here is the naive/simple synchronous IP updating

Copy link
Collaborator

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

LGTM

@wemeetagain wemeetagain merged commit 938e5b1 into gsv1.1 Jun 17, 2020
@wemeetagain wemeetagain deleted the cayman/gs1.1-score branch June 17, 2020 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants