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 outbound mesh quota #91

Merged
merged 2 commits into from
Jun 19, 2020
Merged

Conversation

wemeetagain
Copy link
Member

Implements
https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#outbound-mesh-quotas
https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#heartbeat-maintenance
https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#spam-protection-measures GRAFT spam protection

Most of these edits made directly in line with the go-libp2p-pubsub impl. https://github.com/libp2p/go-libp2p-pubsub/blob/master/gossipsub.go
I tried to avoid rewriting / adding all features, so there are some conditionals/blocks that aren't yet included (eg: direct peers, graft/prune backoff tracking, px, etc)

Big updates:
_addPeer, _removePeer

  • add/remove outbound cache for peer

_handleGraft

  • update to ignore negative score peer grafts
  • only accept outbound grafts if over Dhi

heartbeat

  • cache score
  • graftPeer, prunePeer inline functions
  • heartbeat maintenance and outbound mesh quota additions

test/gossip.js

  • tweak second test to be... better

@wemeetagain wemeetagain force-pushed the cayman/gs1.1-outbound-mesh-quota branch from d71c258 to 5c6df19 Compare June 18, 2020 22:48
@codecov-commenter
Copy link

codecov-commenter commented Jun 18, 2020

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           gsv1.1      #91   +/-   ##
=======================================
  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 a30801b...5c6df19. Read the comment docs.

let outbound = false
for (const c of this._connectionManager.getAll(peerId)) {
if (c.stat.direction === 'outbound') {
if (Array.from(c.registry.values()).some(rvalue => protocols.includes(rvalue.protocol))) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't great, not sure what the best way to do this is.
Trying to ensure that gossipsub is one of the protocols of one of the streams on the connection (considering that there may be multiple connections for a peer, not all containing a gossipsub stream)

Copy link
Collaborator

Choose a reason for hiding this comment

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

humm, yeah!
Maybe the connection could provide an utility API to check if it has open streams using a given protocol.
I will add to my TODO list to consider and implement it. Meanwhile, we can go this way

}

export interface ConnectionManager {
getAll(id: string): Connection[]
getAll(peerId: PeerId): Connection[]
Copy link
Member Author

Choose a reason for hiding this comment

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

this was a mistake that got through, fixed here and below

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.

This looks good!

@wemeetagain wemeetagain merged commit b25f9d0 into gsv1.1 Jun 19, 2020
@wemeetagain wemeetagain deleted the cayman/gs1.1-outbound-mesh-quota branch June 19, 2020 14:43
fryorcraken pushed a commit to fryorcraken/js-libp2p-gossipsub that referenced this pull request Aug 2, 2022
fryorcraken pushed a commit to fryorcraken/js-libp2p-gossipsub that referenced this pull request Aug 2, 2022
## [3.0.4](libp2p/js-libp2p-pubsub@v3.0.3...v3.0.4) (2022-08-01)

### Trivial Changes

* update project config ([ChainSafe#86](libp2p/js-libp2p-pubsub#86)) ([3251829](libp2p/js-libp2p-pubsub@3251829))

### Dependencies

* update it-length-prefixed and uint8arraylists deps ([ChainSafe#91](libp2p/js-libp2p-pubsub#91)) ([f295fce](libp2p/js-libp2p-pubsub@f295fce))
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