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

chore: change bool to enum for is_key_within_radius_and_unavailable for better errors #974

Merged
merged 2 commits into from
Oct 10, 2023

Conversation

KolbyML
Copy link
Member

@KolbyML KolbyML commented Oct 10, 2023

What was wrong?

I was debugging gossip and then getting

2023-10-10T00:02:24.255068Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x00389863ef224a3d170b0d396387c31a39eb0cda2b59aee881cd8aaa3a2e73c5e4
2023-10-10T00:02:33.252706Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x029031e54f5b379e53a959fb3ac11b52c7943c1f06d4f5bb061da60a8573f2301f
2023-10-10T00:02:56.485819Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x035688720000000000
2023-10-10T00:02:56.569614Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x035b88720000000000
2023-10-10T00:02:56.690561Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02b7ae9353c706ba6ed2af6695db4c5366b9cdc433254ff3d35041377804403046
2023-10-10T00:02:59.370235Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x035688720000000000
2023-10-10T00:03:02.502284Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0081aa845bdb2b8175efe9cd5a2eb84e10c1bfcaf507b3784584931e732d244543
2023-10-10T00:03:02.702406Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0081aa845bdb2b8175efe9cd5a2eb84e10c1bfcaf507b3784584931e732d244543
2023-10-10T00:03:03.501519Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0070de357519e6c13dc8bd802ebec2dbb90026e73e4e3fd2cc9d466081c3953aa8
2023-10-10T00:03:06.577001Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x025d88720000000000
2023-10-10T00:03:06.862692Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x035d88720000000000
2023-10-10T00:03:06.870258Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x025d88720000000000
2023-10-10T00:03:25.392371Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0281aa845bdb2b8175efe9cd5a2eb84e10c1bfcaf507b3784584931e732d244543
2023-10-10T00:03:25.395235Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0170de357519e6c13dc8bd802ebec2dbb90026e73e4e3fd2cc9d466081c3953aa8
2023-10-10T00:03:25.766420Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0170de357519e6c13dc8bd802ebec2dbb90026e73e4e3fd2cc9d466081c3953aa8
2023-10-10T00:03:25.777803Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0170de357519e6c13dc8bd802ebec2dbb90026e73e4e3fd2cc9d466081c3953aa8
2023-10-10T00:03:25.819712Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0170de357519e6c13dc8bd802ebec2dbb90026e73e4e3fd2cc9d466081c3953aa8
2023-10-10T00:03:30.665624Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x025f88720000000000
2023-10-10T00:03:31.829169Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x025e88720000000000
2023-10-10T00:03:47.621830Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x01817f216a7d52ce926aaf66b212a4df54c18e6562729437e909140db770fd9a46
2023-10-10T00:03:47.692627Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02c9bdf87bc15a4e5fbc33a99554b7568c66c73ed1ffc3eecd1c7208d10a68aaac
2023-10-10T00:03:48.385482Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02c9bdf87bc15a4e5fbc33a99554b7568c66c73ed1ffc3eecd1c7208d10a68aaac
2023-10-10T00:03:48.797153Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02c9bdf87bc15a4e5fbc33a99554b7568c66c73ed1ffc3eecd1c7208d10a68aaac
2023-10-10T00:03:56.635546Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02c9bdf87bc15a4e5fbc33a99554b7568c66c73ed1ffc3eecd1c7208d10a68aaac
2023-10-10T00:03:56.973116Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x01817f216a7d52ce926aaf66b212a4df54c18e6562729437e909140db770fd9a46
2023-10-10T00:03:58.088142Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:03:58.330381Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:03:58.982694Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:00.031900Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:00.413834Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:00.838684Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:00.893539Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:00.988972Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:01.135871Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:01.168392Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:01.215831Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:01.279974Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:01.508719Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:01.765883Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:02.403408Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:02.865727Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:02.872610Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x02bcaec14408355e96c2ee4d93ebcb219c7a8cf04e6046a487b55c94c989fe1e58
2023-10-10T00:04:04.124284Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0065e7244c44d522780627c6e17a9ad945a35363e89829c889383eae7bad617848
2023-10-10T00:04:06.588619Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x01817f216a7d52ce926aaf66b212a4df54c18e6562729437e909140db770fd9a46
2023-10-10T00:04:09.554527Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x018bbcb94aedf20f334de50df3b17623c9b9e72bfacc1882623351755cb178b04f
2023-10-10T00:04:11.407619Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x018bbcb94aedf20f334de50df3b17623c9b9e72bfacc1882623351755cb178b04f
2023-10-10T00:04:19.752912Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0085d7117de9df645a7e0396528a8a1dc63f817274a0730acf8e05528b38f33932
2023-10-10T00:05:04.750450Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0285d7117de9df645a7e0396528a8a1dc63f817274a0730acf8e05528b38f33932
2023-10-10T00:05:09.076492Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x026788720000000000
2023-10-10T00:05:13.355423Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x023ea03eb2778b2bbd9decb351a7d2261271a5a70c03ae5d91f1052332b55b8794
2023-10-10T00:05:13.375733Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x01d86387af1c4038e9a7581acf48989a890da607e922f3a9faef5d976db923ffc9
2023-10-10T00:05:33.532006Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x01a30169098a44f02845764727f9873b64ddad7ba9813dbf41c05741fec499d31d
2023-10-10T00:05:53.337305Z  WARN portalnet::overlay_service: Accepted content outside radius or already stored content.key=0x0050400fcad1e0da329bd402b5fb0cb86c9ecf69c7e4734618d4b01f1ba2776867

Which is very unhelpful because then I need to manually check both the content in relation to the radius and if it is already stored.

How was it fixed?

By changing the bool to a enum, this allows us to better define warnings decreasing the guessing games when debugging. Checking if the content is outside of the radius requires quite a bit of setup to calculate if you aren't already prepared for it.

Checking if the content is stored is also work.

So I just made it so the error can be clear and direct in what the problem is. This decreases the work understanding the logs a lot which is a life saver when you are stairing at logs all day.

@KolbyML KolbyML marked this pull request as ready for review October 10, 2023 01:23
@KolbyML KolbyML self-assigned this Oct 10, 2023
@@ -67,6 +67,13 @@ pub enum ContentStoreError {
ContentKey(#[from] ContentKeyError),
}

#[derive(Debug, PartialEq)]
pub enum ShouldWeStoreContent {
Copy link
Member

Choose a reason for hiding this comment

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

A docstring would be valuable for this struct. I'm also not in love with the name but I can't come up with better alternatives.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The thing that stands out to me about the name is that it is conflating two things:

  1. current status of the content
  2. the proposed action as a result of that content status

There might be a variety of reasons that callers want to know the current status of the content, besides just "should we store it". Notice the function that returns it isn't called should_store(), because there might be other reasons you want to know this info. I opened a PR with a recommended name change: #983


All that said, this PR clearly is a great improvement from the status quo.

@@ -1633,7 +1635,7 @@ where
// Check if data should be stored, and store if true.
Copy link
Member

Choose a reason for hiding this comment

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

This comment needs to be updated.

@KolbyML KolbyML merged commit c443ee8 into ethereum:master Oct 10, 2023
6 checks passed
@njgheorghita
Copy link
Collaborator

For these kinds of log improvement prs, it would be useful to see an example of the new logs after the improvements

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.

4 participants