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

feat(networking): only consider close records in price setting #1514

Merged
merged 8 commits into from
Apr 2, 2024

Conversation

joshuef
Copy link
Contributor

@joshuef joshuef commented Mar 27, 2024

Description

reviewpad:summary

@joshuef
Copy link
Contributor Author

joshuef commented Mar 27, 2024

I understand now @maqi why you were so hesitant to have the relevant check.. As we actually filter for relevance on inbound replicated data now (or at payment time).

Hmmm... Need to chew on cache + backup implications of this approach some.

@joshuef
Copy link
Contributor Author

joshuef commented Mar 27, 2024

Removing do not merge, as I think we need this either way.

As churn happens, our area of responsibility shrinks, so the price needs to reflect that, not be based upon what we're holding.

I know we only replicate in relevant data now, but as churn happens, some of that will become "out of scope". So we need to discard based upon that.

We can memoise the fn for every X checks or so perhaps if perf is an issue.


// set's the local distance range to be further if the new record is further
// This assumes the verified record is to be held by _us_...
self.distance_range = self.distance_range.map(|range| range.max(new_distance));
Copy link
Member

Choose a reason for hiding this comment

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

As the network grows, would we not be getting records that are closer to us? So this would mean that we'll be hanging on to the older value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aye, cleaned that out and moved farthest record check into an interval setter. Should be enough and prevent too much overzealous "close" checking on store etc.

sn_networking/src/record_store.rs Outdated Show resolved Hide resolved
NanoTokens::zero()
} else if let Some(distance_range) = self.distance_range {
let record_keys_as_hashset: HashSet<&Key> = self.records.keys().collect();
let relevant_records =
Copy link
Member

Choose a reason for hiding this comment

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

note that there is pruning to be carried out when hit max_records, which is regarding ALL.
i.e. this means relevant_records may way below max_records, and will never reach that bar.

It may be good, may be bad,

Also, I'd suggest just rename QuotingMetrics::records_stored to QuotingMetrics::relevant_records to avoid any potential confusion.

} else if let Some(distance_range) = self.distance_range {
let record_keys_as_hashset: HashSet<&Key> = self.records.keys().collect();
let relevant_records =
self.get_records_within_distance_range(record_keys_as_hashset, distance_range);
Copy link
Member

Choose a reason for hiding this comment

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

looks like the correspondent addr_distribution_sim test not got updated to reflect this change?
this will result in an un-sync between the sim and real code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, im not sure what needs to be changed here.

I've updated some naming, and made things a bit clearer, but the crux of the test is entirely the same. We were already only calculating for close_records as there's no churn here.

@JasonPaulGithub JasonPaulGithub added Small Pull request is small Merge When Ready PR is in "Merge When Ready" labels Mar 28, 2024
@joshuef joshuef added this pull request to the merge queue Apr 1, 2024
@maqi maqi removed this pull request from the merge queue due to a manual request Apr 1, 2024
sn_networking/src/driver.rs Outdated Show resolved Hide resolved
@joshuef joshuef enabled auto-merge April 1, 2024 12:10
@joshuef joshuef added this pull request to the merge queue Apr 1, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 1, 2024
@joshuef joshuef enabled auto-merge April 1, 2024 22:45
uses CLOSE_GROUP_SIZE + 1 peers' distance as a proxy. This gives some margin for error
and should err on the side of caution
@joshuef joshuef added this pull request to the merge queue Apr 2, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 2, 2024
@maqi maqi force-pushed the StoreCostTweaks branch from cbbeecb to f1e20eb Compare April 2, 2024 06:23
@maqi maqi enabled auto-merge April 2, 2024 06:24
// // As now using the `close_records_stored`, with the changing range,
// // there is chance that a newer close_records_stored will be smaller than old ones
// //
// // TODO: rethink about the detection policy on this part

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
@maqi maqi added this pull request to the merge queue Apr 2, 2024
Merged via the queue into maidsafe:main with commit 170bcb5 Apr 2, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merge When Ready PR is in "Merge When Ready" Small Pull request is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants