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

Add info logs for adding and removing a neighbor #5459

Merged
merged 5 commits into from
Nov 21, 2024

Conversation

ASuciuX
Copy link
Contributor

@ASuciuX ASuciuX commented Nov 14, 2024

I got the display from adding a new neighbor. How could I reproduce the removal of a neighbor in order to check it is displayed as intended?

New neighbor added

INFO [1731602152.246766] [stackslib/src/net/neighbors/walk.rs:1089] [p2p-(0.0.0.0:20444,0.0.0.0:20443)] New neighbor added: public key: 233691638c08a3f8450f304c5ae7e487alda48 address: 00000000000000000000fff8e6a0db

@ASuciuX ASuciuX self-assigned this Nov 14, 2024
@ASuciuX ASuciuX requested a review from a team as a code owner November 14, 2024 19:15
@jcnelson
Copy link
Member

Hi @ASuciuX, the best place to do this is actually in PeerNetwork::register_peer() and PeerNetwork::deregister_peer(). The neighbor walk state machine is only one of several state machines that can add or remove neighbors.

@ASuciuX
Copy link
Contributor Author

ASuciuX commented Nov 14, 2024

Thank you! I will update it. How can I test a removal of a neighbor? I was running a mainnet instance but I could set up anything else if needed.

@jcnelson
Copy link
Member

@ASuciuX Check out struct P2PSession in stackslib/src/main.rs. It sets up a p2p session with a running node (getting you to register_peer()). Simply dropping the PeerSession instance will trigger a call to deregister_peer() since the socket will close.

@ASuciuX
Copy link
Contributor Author

ASuciuX commented Nov 18, 2024

@jcnelson I've moved them to p2p session, the output is the following:

For new neighbor accepted. The public key is an optional, which was always none in what I've run. Can this be Some(public_key) if the node is a miner or in what context would that be not none when adding a neighbor?

INFO [1731696282.438126] [stackslib/src/net/p2p.rs:1811] [p2p-(0.0.0.0:20444,0.0.0.0:20443)] Neighbor accepted! public key: None address: 00000000000000000000ffff8fc63cb8

For neighbor removed.

INFO [1731696340.243120] [stackslib/src/net/p2p.rs:1906] [p2p-(0.0.0.0:20444,0.0.0.0:20443)] Dropping neighbor! event id: 7 public address: b8db004e2928a10bf85d84071c0c9d398cee7dcf public key: 00000000000000000000ffff225662f3

stackslib/src/net/p2p.rs Outdated Show resolved Hide resolved
@ASuciuX ASuciuX added this pull request to the merge queue Nov 21, 2024
Merged via the queue into develop with commit 6a0d048 Nov 21, 2024
1 check passed
@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants