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

Start creating connections (edges) with large nonces #7966

Merged
merged 23 commits into from
Nov 25, 2022
Merged

Conversation

mm-near
Copy link
Contributor

@mm-near mm-near commented Oct 31, 2022

No description provided.

@mm-near mm-near marked this pull request as ready for review November 7, 2022 21:07
@mm-near mm-near requested a review from a team as a code owner November 7, 2022 21:07
@mm-near mm-near changed the title 1028 large nonces Start creating connections (edges) with large nonces Nov 7, 2022
@mm-near mm-near requested a review from pompon0 November 22, 2022 16:27
&self,
clock: &time::Clock,
peer1: &PeerId,
with_nonce: Option<u64>,
Copy link
Contributor

Choose a reason for hiding this comment

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

The approach you took to inject a nonce is totally valid and I agree with it, however on the other hand it has become quite intrusive, given that we need to pass around the nonce explicitly through a bunch of calls and it is used only for tests. Please consider using a lower level abstraction than PeerActor to force a custom nonce. I already planned to do that in my next PR: https://github.com/near/nearcore/pull/8076/files#diff-b691489bc9c0e1683942223dad298acaca321241108c799bf7376c641d75be1a . PTAL at chain/network/src/peer_manager/tests/nonce.rs there, to see whether it would also simplify your PR.

Copy link
Contributor Author

@mm-near mm-near Nov 23, 2022

Choose a reason for hiding this comment

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

the with_nonce was only to fix that one test (that I see that you also fixed in your PR)

Copy link
Contributor

@pompon0 pompon0 left a comment

Choose a reason for hiding this comment

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

You might be missing a call to conn.edge.store() in RequestUpdateNonce handler, because I can't find it anywhere.

@mm-near mm-near requested a review from pompon0 November 23, 2022 17:40
// Make sure that it gets updated too.
for new_edge in new_local_edges {
this.tier2.update_edge(&new_edge);
}
Copy link
Contributor

@pompon0 pompon0 Nov 24, 2022

Choose a reason for hiding this comment

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

local_edges are the edges of the graph adjacent to this node.
edge stored in connection is the edge that the ends of the connection have agreed upon during handshake.

Given that now the edge is supposed to change dynamically and that it is delivered to a node via SyncRoutingTable message it doesn't make sense to duplicate it I guess. We can either:

  • remove edge field from the connection entirely and just rely on local_edges (I think that would be preferred)
  • revert to using ResponseUpdateNonce message, so that each PeerActor can manage the connection.edge on their own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, we could remove the edge from the connection -- but I'd do that in a separate PR (as this one is becoming too large)

Copy link
Contributor

Choose a reason for hiding this comment

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

ack, please add a TODO

Copy link
Contributor

Choose a reason for hiding this comment

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

also you unnecesarily take a lock on the whole pool in Pool::update_edge. Instead just update the edge in-place.

Copy link
Contributor

Choose a reason for hiding this comment

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

and for that you might want ArcMutex/ArcSwap instead of AtomicCell.

Copy link
Contributor

@pompon0 pompon0 left a comment

Choose a reason for hiding this comment

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

PTAL at the comment

@mm-near mm-near requested a review from pompon0 November 24, 2022 14:07
use crate::tcp;
use crate::testonly::make_rng;
use crate::testonly::stream;
use crate::time;
use crate::types::Edge;
use ::time::Duration;
Copy link
Contributor

Choose a reason for hiding this comment

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

use crate::time;
don't import Duration directly, and use crate::time instead of ::time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

&self,
clock: &time::Clock,
peer1: &PeerId,
with_nonce: Option<u64>,
Copy link
Contributor

Choose a reason for hiding this comment

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

is this even used now once you merged with master?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it is - in last_edge.

@pompon0 pompon0 self-requested a review November 24, 2022 15:46
@mm-near mm-near merged commit 9e576fe into master Nov 25, 2022
@mm-near mm-near deleted the 1028_large_nonces branch November 25, 2022 14:05
nikurt pushed a commit that referenced this pull request Nov 26, 2022
* preparing for sending large nonces

* also show nonce on debug page.

* add time since nonce was created to html

* set proper nonces on re-initialzing of the connection

* fixed broken test

* added more tests

* reviews feedback part1

* comments

* logs fix

* comments and cleanup unnecessary clock advance

* added missing updates

* compile fixes

* test fixed

* fixed compilation issue

* review comment

* fixed after merge
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.

2 participants