-
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
Block broadcasts: inv vs ping and P2P noise #1844
Comments
👍 |
I think that we can remove |
@shargon why do you want to remove the Pong message? It was added for a good reason; to be able to get an up to date chain state of the remote client. AFAIK it is also used in the current syncing strategy, neo-cli + other implementations (at least Python) also make use of it for syncing. |
Well, we need to remember why these ping-pongs were added. And it happened in #899 to fix #841. A fully synchronized node of height And we have |
That's exactly the original reason why it got added in #673 |
Exactly, at the time it was added we had problems with a fixed variable called The way blocks are being broadcasting can be seen as a different issue in my opinion. Perhaps it still need adjustments. |
Miss-clicked. |
@roman-khimov, I was double checking your comment and suggestion. I think that ping/pong is not really a traffic, it is inside the communication channel of two peers, it should not be rebroadcasted. But perhaps we need to think about better timing strategies for making those updates. |
Currently we send ping twice, one in blockchain before persist, and other by tasks but also this tasks was raised neo/src/neo/Ledger/Blockchain.cs Lines 332 to 333 in 9322675
|
Close? |
Certainly not, from what I see in the code we're still misusing pings and sending one ping per persisted block. |
if (block.Index == Height + 1)
{
if (!block.Verify(currentSnapshot))
return VerifyResult.Invalid;
block_cache.TryAdd(block.Hash, block);
block_cache_unverified.Remove(block.Index);
Persist(block);
SaveHeaderHashList();
if (block_cache_unverified.TryGetValue(Height + 1, out var unverifiedBlocks))
{
foreach (var unverifiedBlock in unverifiedBlocks.Blocks)
Self.Tell(unverifiedBlock, ActorRefs.NoSender);
block_cache_unverified.Remove(Height + 1);
}
// We can store the new block in block_cache and tell the new height to other nodes after Persist().
system.LocalNode.Tell(Message.Create(MessageCommand.Ping, PingPayload.Create(Singleton.Height)));
}
return VerifyResult.Succeed;
} It happens here, @roman-khimov. Before we had a mechanism that just made |
It's not just that, it's also important to stop misusing pings for things that are to be done with invs. |
Summary or problem description
#1397 changed the way new blocks are being broadcasted through the network, before it there were
inv
messages with block hash, now the node sendsping
with its new height (speculatively, I should add). This has some consequences that I'd like to discuss.Tons of useless pings being sent
If you're to look at node's traffic for preview3 node during the initial sync, it constantly emits pings for new blocks added to the chain:
All these
00180c01000000...
,00180c02000000...
,00180c03000000...
messages happily tell our peers that we've got block number 1, 2, 3, etc. Each block is obviously an important event in node's life, but I don't think any peer with their current ~54K height really care. Before #1397 there was some logic preventing similar behavior.But as we're sending pings now, we also have another problem.
Ping-pong traffic
Each
ping
technically requires an answer from the other side, which ispong
. And sure enough, we can see a lot of these too:Even if we're to solve the first problem in some way, this one is an issue of its own, because we don't really care about pongs in this case, all we want is to tell everyone that there is a new block and to do that we have an
inv
message type, that is made specifically to advertise things we have on the network. So before #1397 block broadcasting worked likeinv - getdata - block
sequence, but now it's more likeping - pong, getblockbyindex - block
and what's the point of thispong
in the scheme? Also note that if the other side already has a block in question it could just ignore theinv
previously, but now it has to respond with apong
anyway.But there is another subtle thing if we're to look into the
ping
contents.Node's height and ping contents
It's a bit more opinionated and I've seen discussions around
PingPayload.Create(Singleton.Height + 1)
and I admit that it can be somewhat worthy optimization, but at the same time it looks like a blatant lie sent to the peer. IMO ping's payload should tell everyone our current height and the other side can assume that the node has a state corresponding to that height. But it doesn't at the moment, this height is being advertised speculatively, before fully persisting the block.Compare that to the innocent
inv
that is just an advertisement, it has no obligations associated with it. We're just telling everyone that we have this thing, that's it, whether we've persisted it or not is a completely separate question.Do you have any solution you want to propose?
p.LastBlockIndex() < b.Index
to determine which one will get a message).ping
messaging back toinv
for the latest block relaying, it's less traffic and it looks a bit more appropriate for the task.Neo Version
Where in the software does this update applies to?
The text was updated successfully, but these errors were encountered: