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

Torpush gossip- creating separate tor based gossip sub instance for broadcasting over tor #3

Merged
merged 9 commits into from
Sep 27, 2023

Conversation

ujscale
Copy link

@ujscale ujscale commented Sep 6, 2023

This pull requests provides the first tor based gossipsub instance usage with in nimbus to broadcast attestations over tor.
The validator was successfully run based on this and stats were collected

Stats collected
Validator

@@ -2616,7 +2686,8 @@ proc broadcastAttestation*(
let
forkPrefix = node.forkDigestAtEpoch(node.getWallEpoch)
topic = getAttestationTopic(forkPrefix, subnet_id)
node.broadcast(topic, attestation)
echo "about to send attestion"
node.broadcastTor(topic, attestation)
Copy link

Choose a reason for hiding this comment

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

The main concern I'd have with relaying on a non-just-broadcast codepath is that it's too easy to accidentally leak (meta)data by leaving in place some node.broadcast() somewhere. So probably even for an experimental approach, it would be better to by any of various means ensure either

  • none of these node.broadcast()s ever get called, or
  • it automatically does the Tor broadcast, not non-Tor broadcast.

Tor and non-Tor broadcast co-existing seems risky.

Copy link

Choose a reason for hiding this comment

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

How about moving procs like broadcastAttestation and the ones that need broadcastTor to another file and keeping broadcastTor private? This file might benefit from some reorganization for readability and maintainability.

Copy link
Author

Choose a reason for hiding this comment

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

The coexistence of these tor based calls and normal calls in the code would be refactored to avoid leakage risk you mentioned. The concern is that for Blocks/attestatations/proofs/slashing/discovery etc.. should we move all over Tor if one of them is being transmitted over Tor? This needs to be examined further. As for code refactoring improvements, we can make tor methods private or in a separate file.

Copy link

Choose a reason for hiding this comment

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

Probably, moving most of them is required if any of them are moved. Ideally, yes, it's either all Tor or not at all, but it might be reasonable to avoid Tor for the largest and least frequent messages, such as blocks.

But attestations, discovery, et cetera all happen so regularly that it'd be easy to construct a correlation attack along the lines of #3 (comment), yes.

@@ -1290,7 +1297,7 @@ proc checkPeer(node: Eth2Node, peerAddr: PeerAddr): bool =
else:
true

proc dialPeer(node: Eth2Node, peerAddr: PeerAddr, index = 0) {.async.} =
proc dialPeer(node: Eth2Node, peerAddr: PeerAddr, index = 0, isnotTor = true ) {.async.} =
Copy link

Choose a reason for hiding this comment

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

Basically same comment as the broadcastTor and broadcast coexisting: this seems like an auditing challenge, to make sure that a function with a security-important optional parameter is always called correctly.

Choose a reason for hiding this comment

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

Maybe we can do something like that:

proc dialPeer(node: Eth2Node, peerAddr: PeerAddr, index = 0) {.async.} =
  await internalDialPeer(node, peerAddr, node.switch)

proc dialPeerThroughTor(node: Eth2Node, peerAddr: PeerAddr, index = 0) {.async.} =
  await internalDialPeer(node, peerAddr, node.torSwitch)

Copy link
Author

Choose a reason for hiding this comment

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

Okay that can be separately called. That would be part of other refactoring suggested.

@ujscale ujscale mentioned this pull request Sep 11, 2023
@ujscale
Copy link
Author

ujscale commented Sep 26, 2023

Stats collected
Validator

Ready for integration in main experimental branch

@ujscale ujscale marked this pull request as ready for review September 26, 2023 04:01
@ujscale ujscale merged commit 568da80 into stable Sep 27, 2023
@ujscale
Copy link
Author

ujscale commented Sep 27, 2023

Merging pull request

@kaiserd kaiserd deleted the torpush-gossip branch October 2, 2023 09:28
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

4 participants