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 extended validators #93

Merged
merged 2 commits into from
Jun 23, 2020
Merged

Conversation

wemeetagain
Copy link
Member

Implements https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#extended-validators

Add extended topic validators and minimal refactoring to properly support it
Integrate scoring for validation (validation begin/reject/ignore), and successful message delivery

src/pubsub.js required some refactoring to support this feature. The main reason is that messages should first be checked for seenCache entries before running topic validation. Since the seenCache is currently on the gossipsub layer, and validation on the pubsub layer, there was some reworking to allow seenCache to checked before validation -- namely, moving validation from _processRpc, as a pre-step to _processRpcMessage, to instead run validation within _processRpcMessage. (See libp2p/js-libp2p-pubsub#50 and #92 for wrinkles still lingering)

This required some refactoring of the pubsub tests within this repo.

src/pubsub.js also got some slight refactoring around emitting messages.
_emitMessage now takes a single parameter (a InMessage), and is reused in both self publishing and publishing from received messages.
_processRpcMessage was extended with an additional method _publishFrom, which is meant to act as the "success case" for messages received from peers (step 7 in #92). This method is now extended on the gossipsub layer to broadcast messages to floodsub/mesh peers and support "message delivered" peer scoring.

@codecov-commenter
Copy link

codecov-commenter commented Jun 19, 2020

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           gsv1.1      #93   +/-   ##
=======================================
  Coverage   81.81%   81.81%           
=======================================
  Files           1        1           
  Lines          11       11           
=======================================
  Hits            9        9           
  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 12b4fa3...15befbd. Read the comment docs.

test/pubsub.spec.js Outdated Show resolved Hide resolved
ts/pubsub.js Show resolved Hide resolved
ts/index.ts Show resolved Hide resolved
ts/pubsub.js Show resolved Hide resolved
@wemeetagain wemeetagain force-pushed the cayman/gs1.1-extended-validators branch from 6103472 to 15befbd Compare June 22, 2020 20:28
@wemeetagain wemeetagain mentioned this pull request Jun 23, 2020
@wemeetagain wemeetagain merged commit 3542a6b into gsv1.1 Jun 23, 2020
@wemeetagain wemeetagain deleted the cayman/gs1.1-extended-validators branch June 23, 2020 16:17
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.

None yet

3 participants