-
Notifications
You must be signed in to change notification settings - Fork 615
feat(p2p): optional P2P_BROADCAST_PORT #13525
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
eff9a73
chore: add to config
Maddiaa0 56c7f92
chore: announce on broadcast port, listen on existing p2p port
Maddiaa0 b3cbb4d
fix: reset aztec up script
Maddiaa0 6e0b2b6
chore: map p2p broadcast port to p2p port on the container
Maddiaa0 a733a59
fix
Maddiaa0 30eb50b
fix
Maddiaa0 f1e1faf
chore: add test
Maddiaa0 df3fd8e
fix: only forward a single port
Maddiaa0 9e1c349
Merge branch 'master' into md/optional-broadcast-port
Maddiaa0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,21 +51,30 @@ export class DiscV5Service extends EventEmitter implements PeerDiscoveryService | |
| configOverrides: Partial<IDiscv5CreateOptions> = {}, | ||
| ) { | ||
| super(); | ||
| const { p2pIp, p2pPort, bootstrapNodes } = config; | ||
| const { p2pIp, p2pPort, bootstrapNodes, p2pBroadcastPort } = config; | ||
|
|
||
| this.bootstrapNodeEnrs = bootstrapNodes.map(x => ENR.decodeTxt(x)); | ||
| // create ENR from PeerId | ||
| this.enr = SignableENR.createFromPeerId(peerId); | ||
| // Add aztec identification to ENR | ||
| this.versions = setAztecEnrKey(this.enr, config); | ||
|
|
||
| // If no overridden broadcast port is provided, use the p2p port as the broadcast port | ||
| if (!p2pBroadcastPort) { | ||
| config.p2pBroadcastPort = p2pPort; | ||
| } | ||
|
Comment on lines
+64
to
+67
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm getting more and more convinced that we need to split up our config types into "UserProvidedConfig" and "ResolvedConfig". Not for this PR, of course. |
||
|
|
||
| const bindAddrs: any = { | ||
| ip4: multiaddr(convertToMultiaddr(config.listenAddress, p2pPort, 'udp')), | ||
| }; | ||
|
|
||
| if (p2pIp) { | ||
| const multiAddrTcp = multiaddr(`${convertToMultiaddr(p2pIp!, p2pPort, 'tcp')}/p2p/${peerId.toString()}`); | ||
| // if no udp announce address is provided, use the tcp announce address | ||
| const multiAddrUdp = multiaddr(`${convertToMultiaddr(p2pIp!, p2pPort, 'udp')}/p2p/${peerId.toString()}`); | ||
| const multiAddrTcp = multiaddr( | ||
| `${convertToMultiaddr(p2pIp!, config.p2pBroadcastPort!, 'tcp')}/p2p/${peerId.toString()}`, | ||
| ); | ||
| const multiAddrUdp = multiaddr( | ||
| `${convertToMultiaddr(p2pIp!, config.p2pBroadcastPort!, 'udp')}/p2p/${peerId.toString()}`, | ||
| ); | ||
|
|
||
| // set location multiaddr in ENR record | ||
| this.enr.setLocationMultiaddr(multiAddrUdp); | ||
|
|
@@ -113,7 +122,8 @@ export class DiscV5Service extends EventEmitter implements PeerDiscoveryService | |
|
|
||
| private onMultiaddrUpdated(m: Multiaddr) { | ||
| // We want to update our tcp port to match the udp port | ||
| const multiAddrTcp = multiaddr(convertToMultiaddr(m.nodeAddress().address, this.config.p2pPort, 'tcp')); | ||
| // p2pBroadcastPort is optional on config, however it is set to default within the p2p client factory | ||
| const multiAddrTcp = multiaddr(convertToMultiaddr(m.nodeAddress().address, this.config.p2pBroadcastPort!, 'tcp')); | ||
| this.enr.setLocationMultiaddr(multiAddrTcp); | ||
| this.logger.info('Multiaddr updated', { multiaddr: multiAddrTcp.toString() }); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we remove these mappings if there is a
P2P_BROADCAST_PORTset? Feels like we should be doing either one or the other?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i was sheepish to touch this too much but i should remove it