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

Fix typos and inaccuracies in comments of the ChainSync client #233

Merged
merged 7 commits into from
Jul 21, 2023

Conversation

facundominguez
Copy link
Contributor

@facundominguez facundominguez commented Jul 14, 2023

This PR only modifies comments.

@facundominguez facundominguez requested a review from a team as a code owner July 14, 2023 15:56
Copy link
Member

@amesgen amesgen left a comment

Choose a reason for hiding this comment

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

Thanks, only a minor comment below ❤️

@@ -171,7 +171,7 @@ bracketChainSyncClient tracer ChainDbView { getIsInvalidBlock } varCandidates
-- We must keep the candidate chain synchronised with the corresponding
-- upstream chain. The upstream node's chain might roll forward or
-- backwards, and they will inform us about this. When we get these
-- messages, we will replicate these actions on our candidate chain.
-- messages, we will replicate these actions on our current chain.
Copy link
Member

Choose a reason for hiding this comment

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

I think this is already an improvement; but maybe using "our fragment" is even slightly better as it is called ourFrag in the code and "current chain" often refers to our selection in other places (i.e. the method of the ChainDB to get the current selection is called getCurrentChain).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adopted in a38ce67.

Comment on lines 525 to 526
-- The @intersection@ is not on our current chain, even though
-- we sent only points from our current chain to find an
Copy link
Member

Choose a reason for hiding this comment

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

Same point about "our current chain" -> "our fragment" as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adopted in a38ce67.

Copy link
Contributor

@nfrisby nfrisby left a comment

Choose a reason for hiding this comment

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

Thank you for opening this!

I'm Requesting Changes because I think "our fragment" is correct in one of the places you wrote it but incorrect in the other.

@@ -171,7 +171,7 @@ bracketChainSyncClient tracer ChainDbView { getIsInvalidBlock } varCandidates
-- We must keep the candidate chain synchronised with the corresponding
-- upstream chain. The upstream node's chain might roll forward or
-- backwards, and they will inform us about this. When we get these
-- messages, we will replicate these actions on our candidate chain.
-- messages, we will replicate these actions on our fragment.
Copy link
Contributor

Choose a reason for hiding this comment

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

The phrase "candidate chain" features prominently in the preceding paragraphs of this comment (starting with "Our task:"), so it is somewhat discontinuous to change only this occurrence.

Would you rather change every occurrence of "candidate chain" to "candidate fragment"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adopted in 93395a3.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry this didn't occur to me earlier, but: there are plenty of other occurrences of "candidate chain" in the rest of the comments in this source file.

Ultimately this is because engineers on this project eventually realize that "fragment" and "chain" are essentially interchangeable. It seems that whoever originally wrote this module was favoring "chain" at the time. Some other comments do already say "candidate fragment". I would guess that---if anything---it's most correlated to how broad the context of the comment is: "chains" in the broad cases, "fragment" in the very specific cases.

Usually, I wouldn't object to your PR as-is now: you've ensured the wording is at least coherent within its local context.

However, in this case, that local context happens to effectively be the binding site of "candidate chain" as it occurs throughout the rest of the module.

However however, the module was already using both "candidate chains" and "candidate fragment"... and it doesn't really matter which is used where. The only possible downside to your PR is that it inverts my hypothesized correlation between scope and chain-versus-fragment word choice 🤷.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for paying attention @nfrisby; in my initial review, I somehow thought that the context was the same for both changes in 982fc1c. I agree that the choice of "candidate chain" vs "candidate fragment" doesn't matter that much.

I am both fine with reverting the change in this block comment, or keeping it, in that case probably adding "candidate" again

Suggested change
-- messages, we will replicate these actions on our fragment.
-- messages, we will replicate these actions on the candidate fragment.

to make it clear that this is in fact not referring to the ourFrag variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

@facundominguez wrote:

I'm finding useful to talk about "candidate fragment" when referring to the local anchored fragment, and "candidate chain" to refer to the "upstream chain". My last commit 26c999a makes this story consistent in Client.hs.

To make this even more obvious, we could rename "candidate chain" to "upstream chain" if you want.

Update: I think considering "candidate fragment" and "candidate chain" interchangeable would really hide whether the text is referring to the upstream chain or to "their fragment" which is locally kept.

I haven't fully processed this. But my first knee-jerk reaction is that it seems while to point out: from a practical perspective, the upstream chain is almost always irrelevant to the code, simply because we have no way of observing it. The only thing we can observe is the candidate fragment, ie the prefix of the upstream chain that they have sent so far. The only knowledge we have about the upstream chain is that it is some (perhaps non-proper) extension of the candidate fragment. (Exception: they also send the tip point annotation and MsgAwaitReply, but those merely determine whether it's a proper or non-proper extension.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the upstream chain is almost always irrelevant to the code, simply because we have no way of observing it.

In that case, I invite you to check the remaining references to "candidate chain". I think they all refer to the upstream chain despite of lacking a way to observe it.

Copy link
Contributor

@nfrisby nfrisby left a comment

Choose a reason for hiding this comment

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

As I explain verbosely below: I think this is unblocked, now that the changes are coherent in their local context.

HOWEVER, if you're interested, there are other occurrences of "candidate chain" in this module. Feel free to hunt them down as well. But please do read my longer comment first, so that you know what swamp you're wading into.

I'm not going to Approve, because I want someone else's opinion first. (Perhaps even just yours.)

@@ -171,7 +171,7 @@ bracketChainSyncClient tracer ChainDbView { getIsInvalidBlock } varCandidates
-- We must keep the candidate chain synchronised with the corresponding
-- upstream chain. The upstream node's chain might roll forward or
-- backwards, and they will inform us about this. When we get these
-- messages, we will replicate these actions on our candidate chain.
-- messages, we will replicate these actions on our fragment.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sorry this didn't occur to me earlier, but: there are plenty of other occurrences of "candidate chain" in the rest of the comments in this source file.

Ultimately this is because engineers on this project eventually realize that "fragment" and "chain" are essentially interchangeable. It seems that whoever originally wrote this module was favoring "chain" at the time. Some other comments do already say "candidate fragment". I would guess that---if anything---it's most correlated to how broad the context of the comment is: "chains" in the broad cases, "fragment" in the very specific cases.

Usually, I wouldn't object to your PR as-is now: you've ensured the wording is at least coherent within its local context.

However, in this case, that local context happens to effectively be the binding site of "candidate chain" as it occurs throughout the rest of the module.

However however, the module was already using both "candidate chains" and "candidate fragment"... and it doesn't really matter which is used where. The only possible downside to your PR is that it inverts my hypothesized correlation between scope and chain-versus-fragment word choice 🤷.

@nfrisby nfrisby dismissed their stale review July 17, 2023 22:50

98% addressed

@facundominguez
Copy link
Contributor Author

facundominguez commented Jul 19, 2023

I'm finding useful to talk about "candidate fragment" when referring to the local anchored fragment, and "candidate chain" to refer to the "upstream chain". My last commit 26c999a makes this story consistent in Client.hs.

To make this even more obvious, we could rename "candidate chain" to "upstream chain" if you want.

Update: I think considering "candidate fragment" and "candidate chain" interchangeable would really hide whether the text is referring to the upstream chain or to "their fragment" which is locally kept.

@facundominguez facundominguez enabled auto-merge July 20, 2023 19:24
@facundominguez facundominguez force-pushed the fd/comment-fixes-chain-sync branch from ff8ea73 to 3f45b95 Compare July 20, 2023 19:24
@facundominguez
Copy link
Contributor Author

I'm merging given that the approvals stood for a while and we all seem to agree that the changes are better resting in main than here. But @nfrisby, let's continue the conversation on the need to refer to the upstream chain in comments.

@facundominguez facundominguez added this pull request to the merge queue Jul 21, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jul 21, 2023
@facundominguez facundominguez added this pull request to the merge queue Jul 21, 2023
Merged via the queue into main with commit 08b37e1 Jul 21, 2023
@facundominguez facundominguez deleted the fd/comment-fixes-chain-sync branch July 21, 2023 22:56
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.

3 participants