-
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 list
subcommand
#892
base: main
Are you sure you want to change the base?
Conversation
f888ea0
to
7bc433b
Compare
0a33ea9
to
58e29e7
Compare
7bc433b
to
2348968
Compare
58e29e7
to
2779b0c
Compare
2348968
to
309fabc
Compare
f86641b
to
087a995
Compare
309fabc
to
af3eee6
Compare
d85dd79
to
2c383df
Compare
af3eee6
to
00dc9bf
Compare
ff7f2dc
to
67b432f
Compare
00dc9bf
to
3e9adaa
Compare
588ff17
to
55ed0b2
Compare
e0f409f
to
def32d3
Compare
31b8f4c
to
e90fb2c
Compare
f811e95
to
b9770bb
Compare
|
||
switch routerType { | ||
case StakedRouterType: | ||
// TODO_IN_THIS_COMMIT: what about unstaked peers actors? |
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.
@Olshansk Am I missing something here but what does what about unstaked peers actors
mean?
When using the staked router type we are only looking for staked actors? If we want both we would use AllRouterTypes
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 TODO goes along with the commented code line below. It's referring to the current actor (this local P2P module instance ). My thinking at the time was something along the lines of: if the current actor is unstaked, it may not make sense to ask the peerstore provider for the staked actor set. Perhaps it should indeed work as written and it would be the responsibility of the P2P module to ensure the appropriate peerstore provider implementation is registered and then that of the node setup to ensure a compatible persistence module implementation is also registered (which may not yet exist), for example in the case of light client actors.
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.
@bryanchriswhite I appreciate your response during your time away so no rush on this reply. But AFAIK if we are checking whether the node is staked we need to retrieve the staked peerstore anyway? the p2pModule.isStakedActor()
function is as follows:
func (m *p2pModule) getStakedPeerstore() (typesP2P.Peerstore, error) {
pstoreProvider, err := peerstore_provider.GetPeerstoreProvider(m.GetBus())
if err != nil {
return nil, err
}
return pstoreProvider.GetStakedPeerstoreAtHeight(
m.GetBus().GetCurrentHeightProvider().CurrentHeight(),
)
}
// isStakedActor returns whether the current node is a staked actor at the current height.
// Return an error if a peerstore can't be provided.
func (m *p2pModule) isStakedActor() (bool, error) {
pstore, err := m.getStakedPeerstore()
if err != nil {
return false, fmt.Errorf("getting staked peerstore: %w", err)
}
// Ensure self address is present in current height's staked actor set.
if self := pstore.GetPeer(m.address); self != nil {
return true, nil
}
return false, nil
}
So if we check the addr from bus.GetP2PModule().GetAddress()
against this staked list and its not there we return the unstaked peerstore? I feel like this defeats the purpose of us passing in the router type in the first place if we are going to ignore it? Or am I misunderstanding?
case AllRouterTypes: | ||
routerPlurality = "s" | ||
|
||
// TODO_IN_THIS_COMMIT: what about unstaked peers actors? |
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.
Again here I am confused, are we not already getting both staked and unstaked?
To give an update on the changes I made:
There is 2 bugs that are being encountered in this branch currently:
{"level":"debug","time":"2023-07-27T10:29:40+01:00","message":"Creating P2P module"}
{"level":"debug","module":"p2p","time":"2023-07-27T10:29:40+01:00","message":"setupPeerstoreProvider"}
{"level":"debug","module":"p2p","time":"2023-07-27T10:29:40+01:00","message":"loaded peerstore provider..."}
{"level":"fatal","error":"parsing multiaddr from config: resolving peer IP for hostname: validator1: resolving peer IP for hostname: validator1, lookup validator1: no such host","time":"2023-07-27T10:29:40+01:00","message":"Failed to create p2p module"} When func setupAndStartP2PModule(rm runtime.Manager) {
bus := rm.GetBus()
mod, err := p2p.Create(bus)
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create p2p module")
}
var ok bool
P2PMod, ok := mod.(modules.P2PModule)
if !ok {
logger.Global.Fatal().Msgf("unexpected P2P module type: %T", mod)
}
if err := P2PMod.Start(); err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to start p2p module")
}
} in switch m.cfg.ConnectionType {
case types.ConnectionType_TCPConnection:
addr, err := m.getMultiaddr()
if err != nil {
return nil, fmt.Errorf("parsing multiaddr from config: %w", err)
}
m.listenAddrs = libp2p.ListenAddrs(addr)
case types.ConnectionType_EmptyConnection:
m.listenAddrs = libp2p.NoListenAddrs
default:
return nil, fmt.Errorf(
// TECHDEBT: rename to "transport protocol" instead.
"unsupported connection type: %s: %w",
m.cfg.ConnectionType,
err,
)
} Specifically in the |
@h5law Appreciate for all the work, improvements, hours spent debugging as well as a concise update summary. I think this is in a good place to pause things for now and have @bryanchriswhite pick it up when he's back. |
@Olshansk To give an update I pushed a commit to comment out some buggy lines in the charts yaml files. These were pointed out by @okdas as a sort of chicken-and-egg problem. This stops the bug which breaks bootstrapping in k8s localnet. This enabled me to check the |
@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 subcommand to the CLI:
Issue
Related:
Dependencies:
Type of change
Please mark the relevant option(s):
List of changes
enable_peer_discovery_debug_rpc
to P2P configp1 peer
subcommandp1 peer list
subcommandPeerstoreProvider#GetUnstakedPeerstore()
implementationsPeerstoreProvider#GetStakedPeerstoreAtCurrentHeight()
Testing
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)