-
Notifications
You must be signed in to change notification settings - Fork 33
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
[P2P] [Tooling] Peer discovery peer connections
subcommand
#801
base: feat/peer-discovery-list
Are you sure you want to change the base?
[P2P] [Tooling] Peer discovery peer connections
subcommand
#801
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## re/refactor/cli #801 +/- ##
==================================================
Coverage ? 29.96%
==================================================
Files ? 108
Lines ? 8829
Branches ? 0
==================================================
Hits ? 2646
Misses ? 5873
Partials ? 310 ☔ View full report in Codecov by Sentry. |
3784b14
to
1c23be5
Compare
ce1b1bd
to
80aec49
Compare
9209358
to
968be5f
Compare
0cdc40d
to
c78193d
Compare
c6e8447
to
39a2f3e
Compare
592eee8
to
e56bc6e
Compare
6ba979e
to
4716bf7
Compare
5eea086
to
a18c047
Compare
f498196
to
10e00d0
Compare
8213d38
to
a4b12df
Compare
0d9d930
to
380e7d5
Compare
ed9ed31
to
1bbad38
Compare
b64c8f4
to
59449b0
Compare
ea50366
to
2bd789c
Compare
2bd789c
to
4df2da8
Compare
@@ -10,7 +10,8 @@ import ( | |||
|
|||
func (m *p2pModule) handleDebugMessage(msg *messaging.DebugMessage) error { | |||
switch msg.Action { | |||
case messaging.DebugMessageAction_DEBUG_P2P_PEER_LIST: | |||
case messaging.DebugMessageAction_DEBUG_P2P_PEER_LIST, | |||
messaging.DebugMessageAction_DEBUG_P2P_PEER_CONNECTIONS: | |||
if !m.cfg.EnablePeerDiscoveryDebugRpc { |
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.
I feel like we can skip the first switch statement and just return (with a debug log or error) if if !m.cfg.EnablePeerDiscoveryDebugRpc {
@@ -100,6 +100,7 @@ config: | |||
use_rain_tree: true | |||
is_empty_connection_type: false | |||
private_key: "" # @ignored This value is needed but ignored - use privateKeySecretKeyRef instead | |||
# TODO: I think this has been renamed to `max_nonces` |
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.
) | ||
|
||
var ( | ||
connectionsCmd = &cobra.Command{ |
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.
Everywhere else we have a function that returns a new instance of cobra.Command
.
I think we should either:
- Stay consisstent
- Stay consistent + add a TODO to change the others
- Change all of them
@@ -0,0 +1,149 @@ | |||
package debug |
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.
Should we add a debug build tag?
return nil | ||
} | ||
|
||
func PrintConnectionsTable(conns []libp2pNetwork.Conn) error { |
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.
does PrintConnectionsTable
need to be publically exposed given that we use PrintPeerConnections
in the cli?
func peerConnsRowConsumerFactory(conns []libp2pNetwork.Conn) utils.RowConsumer { | ||
return func(provideRow utils.RowProvider) error { | ||
for _, conn := range conns { | ||
if err := provideRow( |
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.
what happens if we don't return an error when provideRow
errors? Is a partial list not an option?
Use: "connections", | ||
Short: "Print open peer connections", |
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.
Use: "connections", | |
Short: "Print open peer connections", | |
Use: "Connections", | |
Short: "Print open peer connections", | |
Long: "Prints ..." // list out printConnectionsHeader | |
Aliases: []string{"conns"}, |
} | ||
|
||
switch { | ||
case stakedFlag: |
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.
OPTIONAL: The way I would've done this is by having a smaller private helper function like below that returns the router typ:
func foo() routerType {
switch
case stakedFlag && !unstakedFlag && !allFlag {
return debug.StakeRouterType
}
case unstakedFlag && !stakedFlag && !allFlag {
return debug.UnstakedRouterType
}
case stakedFlag || unstakedFlag {
return ErrRouterType
}
// even if `allFlag` is false, we still want to print all connections
default:
return debug.AllRouterTypes
}
}
Wdyt?
|
||
// TECHDEBT(#810, #811): will need to wait for DHT bootstrapping to complete before | ||
// p2p broadcast can be used with to reach unstaked actors. | ||
// CONSIDERATION: add the peer commands to the interactive CLI as the P2P module |
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.
So why don't we do this?
return fmt.Errorf("creating anypb from debug message: %w", err) | ||
} | ||
|
||
if localFlag { |
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.
So if this is false we don't print anything?
I don't fully understand its use. Is it like a "verbose" flag?
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.
This localFlag
determines whether we print locally ie to the terminal that ran the command or on the node itself AFAIK. With -l
we will see the output in our terminal, otherwise it will be logged by the node
@bryanchriswhite Can you pick this up when you're back? |
@Reviewer
This PR may be more digestible / reviewable on a commit-by-commit basis. Commits are organized logically and any given line is only modified in a single commit, with few exceptions*.
*(In the interest of preserving the git-time-continuum 👮🚨, this applies in batches of commits between comments or reviews by humans, only once "in review")
Description
Adds the following subcommands:
Issue
Related:
Dependencies:
Type of change
Please mark the relevant option(s):
List of changes
peer connections
subcommandP2PModule#GetConnections()
interface method & implementationTesting
make develop_test
; if any code changes were mademake test_e2e
on k8s LocalNet; if any code changes were madee2e-devnet-test
passes tests on DevNet; if any code was changedRequired Checklist
godoc
format comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)