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

chore(gossipsub): cleanups #1096

Merged
merged 2 commits into from
May 15, 2024
Merged

chore(gossipsub): cleanups #1096

merged 2 commits into from
May 15, 2024

Conversation

kaiserd
Copy link
Collaborator

@kaiserd kaiserd commented May 8, 2024

factored out from: #1092

  • add some docs
  • add missing penalty for invalid messages
  • simplify code
  • remove unused gossipsub fields

@diegomrsantos
Copy link
Collaborator

Should we use the conventional commits style for the PR's names?

@kaiserd
Copy link
Collaborator Author

kaiserd commented May 8, 2024

Yes. Good point. I'll edit.

(Main application for conventional commits though are the commit messages themselves, since they are used for compiling the version summary.
I'm editing the git commit messages for the squash commit to fit conventional commits.)

@kaiserd kaiserd changed the title gossipsub cleanups chore(gossipsub): cleanups May 8, 2024
* add some docs
* add missing penalty for invalid messages
* simplify code
* remove unused gossipsub fields
@diegomrsantos
Copy link
Collaborator

diegomrsantos commented May 8, 2024

I believe the PR title is used as the commit message that will end up in the master branch when we squash and merge the PR.

@kaiserd
Copy link
Collaborator Author

kaiserd commented May 8, 2024

Oh, yes, true. I sometimes add more sub-points to it.

Comment on lines +60 to +63
proc handleSubscribe(f: FloodSub,
peer: PubSubPeer,
topic: string,
subscribe: bool) =
Copy link
Collaborator

Choose a reason for hiding this comment

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

it might be better to follow this pattern https://github.com/vacp2p/nim-libp2p/pull/1095/files#diff-94a6536a89bc744b23b27b6d4577eee57ed6e4ed0b1f13f077b9db22c16ae8b8R280-R284. @arnetheduck how are you formatting it? Let's add it to the readme so we all share the same formatting rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

var rpcMsg = decodeRpcMsg(data).valueOr:
debug "failed to decode msg from peer", peer, err = error
raise newException(CatchableError, "")
raise newException(CatchableError, "Peer msg couldn't be decoded")
Copy link
Collaborator

@diegomrsantos diegomrsantos May 8, 2024

Choose a reason for hiding this comment

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

I believe we should either log and discard the exception or create a sequence Parent/Child that gets logged only once. Unfortunately, this seems not possible in Nim. I created this issue some time ago, but it was closed without a solution nim-lang/Nim#20677. @arnetheduck thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

you can: (ref CatchableError)(mgs: "test", parent: otherException) - when catching, you can use the parent field to print all parents as well - this latter thing does not exist but the core support in nim is there.


g.replenishFanout(topic) # Make sure fanout is populated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why has the replenishFanout condition been modified?

Copy link
Contributor

Choose a reason for hiding this comment

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

the same condition is checked inside of replenishFanout already

fanoutPeers = g.fanout.getOrDefault(topic).toSeq()
elif peers.len < g.parameters.dLow:
# not subscribed or bad mesh, send to fanout peers
# when flood-publishing, fanout won't help since all potential peers have
Copy link
Collaborator

@diegomrsantos diegomrsantos May 9, 2024

Choose a reason for hiding this comment

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

not sure this is true, I guess only if we assume that peers.len < g.parameters.dLow is always false when flood publishing is enabled even with the limit of peers to flood

Copy link
Contributor

Choose a reason for hiding this comment

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

when flood publishing is turned on, all possible peers will already have been added to the possible peers to send to - ie everyone that is subscribed gets a message, so there's no point to try again with fanout peers (which are a subset)

@kaiserd
Copy link
Collaborator Author

kaiserd commented May 15, 2024

LGTM.
@diegomrsantos can we merge this?

@kaiserd kaiserd merged commit 0911cb2 into master May 15, 2024
9 checks passed
@kaiserd kaiserd deleted the chore/gossipsub-cleanups branch May 15, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

3 participants