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

Optimize Ping message #1903

Merged
merged 24 commits into from
Sep 23, 2020
Merged

Optimize Ping message #1903

merged 24 commits into from
Sep 23, 2020

Conversation

shargon
Copy link
Member

@shargon shargon commented Sep 3, 2020

Related to #1844 (comment)

@erikzhang
Copy link
Member

@Qiao-Jin What do you think?

@Qiao-Jin
Copy link
Contributor

Qiao-Jin commented Sep 7, 2020

I think this looks fine

@erikzhang
Copy link
Member

But I think we shouldn't relay the unverified blocks to other nodes.

@ShawnYun
Copy link
Contributor

ShawnYun commented Sep 7, 2020

I think Remove Ping message is ok.

But I think we shouldn't relay the unverified blocks to other nodes.

We don't seem to relay unverified blocks.

@erikzhang
Copy link
Member

In this PR, we send ping messages in TaskManager when we received blocks. And the blocks are from RemoteNode, which are unverified.

@ShawnYun
Copy link
Contributor

ShawnYun commented Sep 7, 2020

The Ping message tell the Blockchain.Singleton.Height to other nodes.

@shargon
Copy link
Member Author

shargon commented Sep 7, 2020

We can add the last sent height in session in order to avoid duplicates

@erikzhang
Copy link
Member

We can send ping messages after OnPersist().

@shargon
Copy link
Member Author

shargon commented Sep 12, 2020

Please, could you check it again?

@@ -359,6 +357,8 @@ private VerifyResult OnNewBlock(Block block)
Self.Tell(unverifiedBlock, ActorRefs.NoSender);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not parallel, right?
In this sense, we were telling heights that were cached?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously was before persists, now after it

@erikzhang
Copy link
Member

@Qiao-Jin Review.

@Qiao-Jin
Copy link
Contributor

Qiao-Jin commented Sep 16, 2020

I think this PR is OK. However, I think maybe we can remove the SendPingMessage logic when taskmanager receives blocks. Currently we send Ping messages in 4 occasions: OnBlock, OnRegister and RequestTasks in TaskManager, and OnNewBlock in Blockchain,where I think the first one is duplicate and can be removed directly.

@shargon shargon changed the title Remove Ping message before OnPersist Optimize Ping message Sep 18, 2020
@erikzhang
Copy link
Member

@Qiao-Jin

Qiao-Jin
Qiao-Jin previously approved these changes Sep 21, 2020
@vncoelho
Copy link
Member

@shargon, take a look at the last commit, since SendPingMessage is always called from RequestTasks it looked like that the check if (sessions.Count == 0) return; was duplicated.

@shargon
Copy link
Member Author

shargon commented Sep 21, 2020

@vncoelho yes, i think that it's a good change!

if (msg.Command == MessageCommand.Ping || msg.Command == MessageCommand.Pong)
{
PingPayload payload = (PingPayload)msg.Payload;
if (msg.Command == MessageCommand.Ping && LastHeightSent >= payload.LastBlockIndex) break;
Copy link
Member Author

@shargon shargon Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think @neo-project/core @Qiao-Jin:

  • Avoid duplicate pings and pong set LastHeightSent to avoid duplicate pings

Copy link
Member

@vncoelho vncoelho Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could be something like this:

                        PingPayload payload = (PingPayload)msg.Payload;
                        aux = LastHeightSent;
                        if (LastHeightSent < payload.LastBlockIndex)  LastHeightSent = payload.LastBlockIndex;
                        if (aux >= payload.LastBlockIndex) break;                       

@shargon
Copy link
Member Author

shargon commented Sep 22, 2020

ready to merge @vncoelho @Qiao-Jin ?

@vncoelho
Copy link
Member

I am not sure, @erikzhang reverted the pong, yes? Why not to use it to update the LastBlockIndex?

@shargon
Copy link
Member Author

shargon commented Sep 22, 2020

@vncoelho ping and pong use PingPayload, is not reverted, only optimized

@erikzhang erikzhang merged commit a7ea1fa into neo-project:master Sep 23, 2020
@shargon shargon deleted the optimize-ping-2 branch September 23, 2020 08:30
ShawnYun pushed a commit to ShawnYun/neo that referenced this pull request Jan 8, 2021
cloud8little pushed a commit to cloud8little/neo that referenced this pull request Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants