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

Migrate x/sync to p2p #3106

Merged
merged 18 commits into from
Sep 25, 2024
Merged

Migrate x/sync to p2p #3106

merged 18 commits into from
Sep 25, 2024

Conversation

joshua-kim
Copy link
Contributor

Why this should be merged

Eliminates our last usage of the blocking clients

How this works

Replaces usage of blocking client with p2p async clients

How this was tested

Added unit tests

x/sync/client.go Outdated Show resolved Hide resolved
@joshua-kim joshua-kim changed the base branch from p2p-test to master June 14, 2024 07:25
x/sync/metrics.go Outdated Show resolved Hide resolved
func (m *Manager) doWork(ctx context.Context, work *workItem) {
// Backoff for failed requests accounting for time this job has already
// spent waiting in the unprocessed queue
backoff := calculateBackoff(work.attempt)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not optimal since this worker goroutine is going to be waiting until this timeout passes and ideally we would prioritize requests that are always executable, but felt like something more complex would make the diff hard to review since the scope of this PR is just trying to get rid of the blocking networking calls

return client.GetRangeProof(ctx, request)
}

func TestGetRangeProof(t *testing.T) {
Copy link
Contributor Author

@joshua-kim joshua-kim Jun 21, 2024

Choose a reason for hiding this comment

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

All client-side error handling cases were moved into Test_Sync_Result_Correct_Root and server-side cases were moved into network_server_test

@joshua-kim joshua-kim self-assigned this Jun 21, 2024
@joshua-kim joshua-kim added the cleanup Code quality improvement label Jun 21, 2024
@joshua-kim joshua-kim marked this pull request as ready for review June 21, 2024 17:00
network/p2p/p2ptest/client.go Outdated Show resolved Hide resolved
network/p2p/p2ptest/client_test.go Outdated Show resolved Hide resolved
Comment on lines -85 to -86
// tracking of peers & bandwidth usage
peers *p2p.PeerTracker
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to configure the p2p client to perform a similar type of peer sampling? It's a critical performance improvement to select peers based on historical bandwidth.

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'll need to merge in some form of #3007

x/sync/client.go Outdated Show resolved Hide resolved
x/sync/manager.go Outdated Show resolved Hide resolved
x/sync/manager.go Outdated Show resolved Hide resolved
x/sync/network_server.go Show resolved Hide resolved
Copy link

github-actions bot commented Sep 1, 2024

This PR has become stale because it has been open for 30 days with no activity. Adding the lifecycle/frozen label will cause this PR to ignore lifecycle events.

network/p2p/p2ptest/client.go Show resolved Hide resolved
network/p2p/p2ptest/client.go Outdated Show resolved Hide resolved
x/sync/network_server.go Outdated Show resolved Hide resolved
x/sync/network_server.go Show resolved Hide resolved
x/sync/network_server.go Show resolved Hide resolved
x/sync/sync_test.go Outdated Show resolved Hide resolved
x/sync/sync_test.go Show resolved Hide resolved
x/sync/manager.go Outdated Show resolved Hide resolved
x/sync/manager.go Show resolved Hide resolved
x/sync/manager.go Outdated Show resolved Hide resolved
joshua-kim and others added 4 commits September 24, 2024 10:33
Signed-off-by: Joshua Kim <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
@StephenButtolph StephenButtolph removed the request for review from dboehm-avalabs September 24, 2024 15:15
Signed-off-by: Joshua Kim <[email protected]>
x/sync/manager.go Outdated Show resolved Hide resolved
x/sync/network_server.go Show resolved Hide resolved
request: &pb.SyncGetRangeProofRequest{
RootHash: smallTrieRoot[:],
KeyLimit: 2 * defaultRequestKeyLimit,
BytesLimit: defaultRequestByteSizeLimit,
},
expectedResponseLen: defaultRequestKeyLimit,
},
"bytes limit too large": {
{
name: "response bounded by byte limit",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is meant to test the case where the specified byte limit in the request is larger than the server setting. (did we accidentally drop the "response bounded by byte limit" test?)

Copy link
Contributor Author

@joshua-kim joshua-kim Sep 25, 2024

Choose a reason for hiding this comment

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

We're not removing a test here, not sure what you're referring to? it's the same test (prev: "bytes limit too large") but we renamed it because the previous name makes it sound like it's supposed to error when the expected behavior is to truncate/cap the response from the server.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could have a case where the bytes limit requested by the client is valid (less than the limit enforced by the server) and is the limiting factor in the response size.

x/sync/network_server_test.go Show resolved Hide resolved
x/sync/sync_test.go Outdated Show resolved Hide resolved
x/sync/manager.go Show resolved Hide resolved
x/sync/manager.go Show resolved Hide resolved
x/sync/manager.go Show resolved Hide resolved
x/sync/manager.go Show resolved Hide resolved
x/sync/manager.go Outdated Show resolved Hide resolved
x/sync/manager.go Outdated Show resolved Hide resolved
joshua-kim and others added 9 commits September 25, 2024 00:41
Signed-off-by: Joshua Kim <[email protected]>
Co-authored-by: Darioush Jalali <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
Co-authored-by: Darioush Jalali <[email protected]>
Signed-off-by: Joshua Kim <[email protected]>
@StephenButtolph StephenButtolph added this to the v1.11.12 milestone Sep 25, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Sep 25, 2024
Merged via the queue into master with commit 0a46687 Sep 25, 2024
22 checks passed
@StephenButtolph StephenButtolph deleted the p2p-sync branch September 25, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants