-
Notifications
You must be signed in to change notification settings - Fork 1k
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 ping/pong for updating node height #673
Conversation
When you receive an
So we don't need |
I disagree on the need.
Yes and then you need to keep that block and all following blocks in memory until you're synced. That's a waste of memory as described above if you're far behind on syncing. This #620 (comment) and this #620 (comment) seem to discuss the same issue + solution by other people so apparently it's a common problem + idea how to solve it. If we remove the 1 request per session then I agree this is not needed, because then I can request the block, read the index and delete it until I'm actually close to being in sync. Then I can request it again and persist. |
I think not all the clients need to know the height of connected nodes. Maybe we can send |
I don't really understand the objection against the extra 4 bytes, but I updated the PR to reflect your idea. Now we have a "ping" command with no payload and that responds with a "pong" + PongPayload that contains the current height. I do really hope we can get this included in |
@ixje I modified it. Now both |
looks good. thanks |
When will be delivered this message? |
The client or plugin can broadcast the |
OnPingMessageReceived(msg.GetPayload<PingPayload>()); | ||
break; | ||
case "pong": | ||
OnPongMessageReceived(msg.GetPayload<PingPayload>()); |
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.
Is it correct @ixje @erikzhang msg.GetPayload<PingPayload>
for Pong?
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, there is only 1 payload for both.
@erikzhang I don't know what your intention of the added nonce
field was, but should that maybe have been included in the response as a way of confirming that the pong
is a response to our ping
?
e.g
-> ping
generate nonce
e.g. 123
<- pong
with nonce
set to the received PingPayload.nonce
e.g. 123
in this example
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.
but should that maybe have been included in the response as a way of confirming that the pong is a response to our ping?
Good idea!
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, there is only 1 payload for both.
Thanks for the clarification. So, perhaps rename to PingPongPayload, just for clarity? That really looked like a typo me :)
Already contains in PR #899 |
Currently there is no easy way to request the current height of the remote node. When connecting we get a snapshot of the height in the
VersionPayload
. This height is static.neo-cli
nodes broadcastinv
messages of typeBlock
which could be used to request the the full block (via agetdata
) and extract the height from theBlock.Index
. There are 2 downsidesTransportSession
apparently does not allow requesting data for the same hash twice on a single session. Note that because there is no timeout that cleans up previously requested hashes it could collect the full 3.x million MainNet hashes in memory if synced from 0 without disconnecting).Instead of forcing a reconnect of the peer to get an updated height via the
VersionPayload
, this PR introduces a minimal footprint backwards compatible ping/pong function. Old clients will ignore the "ping" command, new ones reply with "pong" + a height.The output of the
show state
command inneo-cli
can also use this information to stay up to date.