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

♻️ 🧹 Removed Stop from GetBlockHashesMsg #3942

Merged
merged 4 commits into from
Sep 3, 2024

Conversation

greymistcube
Copy link
Contributor

@greymistcube greymistcube commented Sep 2, 2024

  • Removed Stop from GetBlockHashesMsg. I suspect this was implemented to imitate the Bitcoin's implementation. I don't really see a rationale for this to exist.
  • Cleaned up BlockLocator and GetBlockHashesMsg accordingly.

Addendum

  • Partially reverted GetBlockHashesMsg encoding to be backward compatible as a network protocol.

@greymistcube greymistcube self-assigned this Sep 2, 2024
@greymistcube greymistcube changed the title ♻️ 🧹 Refactor/remove stop ♻️ 🧹 Removed Stop from GetBlockHashesMsg; refactor overall encoding for GetBlockHashesMsg Sep 2, 2024
@greymistcube greymistcube marked this pull request as ready for review September 2, 2024 02:30
using Libplanet.Blockchain;
using Libplanet.Types.Blocks;

namespace Libplanet.Net.Messages
{
internal class GetBlockHashesMsg : MessageContent
{
public GetBlockHashesMsg(BlockLocator locator, BlockHash? stop)
Copy link
Member

Choose a reason for hiding this comment

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

Is it backward compatible?

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 backward compatibility has been broken since #3913, albeit on a different level. This further(?) breaks the compatibility since it has been already broken. 🙄

Copy link
Contributor Author

@greymistcube greymistcube Sep 2, 2024

Choose a reason for hiding this comment

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

The result is the same, that is, any node running with a different Libplanet version would not be able to sync to a node running the newest version.

Copy link
Member

Choose a reason for hiding this comment

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

So is there any way to test a new version of Libplanet on a network where the live version is running?

Copy link
Contributor Author

@greymistcube greymistcube Sep 2, 2024

Choose a reason for hiding this comment

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

It is possible to apply only the business logic and force partial compatibility as I have with #3913, but I don't think that is necessary (or worth the time). If you are still worried, we can further divide this PR into multiple releases where

  • We keep partial compatibility.
    • Message level compatibility is left intact.
    • Ignore BlockLocators with multiple BlockHashes and/or non-null Stop.
    • This results in a newer node being able to sync to an old node, but not the other way around.
    • This only breaks the business logic layer.
  • We break compatibility completely by cleaning up/updating the GetBlockHashesMsg encoding.
    • This would result in a newer node and an old node not being able to sync to each other.
    • This breaks the network layer as well.

As the newer node is about getting rid of "unnecessary" block sync logic and dependencies, the compatibility has to be broken at some point.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think backward compatibility is necessary on this. But, at least, we need to test this feature on our dev cluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arg, might as well separate the encoding part into a separate PR for easier testing. 😕

@greymistcube greymistcube changed the title ♻️ 🧹 Removed Stop from GetBlockHashesMsg; refactor overall encoding for GetBlockHashesMsg ♻️ 🧹 Removed Stop from GetBlockHashesMsg ~~refactor overall encoding for GetBlockHashesMsg~~ Sep 2, 2024
@greymistcube greymistcube changed the title ♻️ 🧹 Removed Stop from GetBlockHashesMsg ~~refactor overall encoding for GetBlockHashesMsg~~ ♻️ 🧹 Removed Stop from GetBlockHashesMsg Sep 2, 2024
@greymistcube
Copy link
Contributor Author

@riemannulus @limebell
Added ce6e275 for backwards compatibility.
Funnily enough, this is more compatible with old versions of Libplanet than after #3913.
A newer node would simply ignore irrelevant information given and interpret GetBlockHashesMsg differently
(and behave accordingly).
An outgoing GetBlockHashesMsg from a newer node can also be read normally by older nodes.

Copy link
Member

@limebell limebell left a comment

Choose a reason for hiding this comment

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

Overall logic looks good to me, are you plan to change MessageType in other PR?

@greymistcube
Copy link
Contributor Author

greymistcube commented Sep 3, 2024

@limebell

Overall logic looks good to me, are you plan to change MessageType in other PR?

If we leave as it is without changing the encoding/decoding process, this should be compatible with the old MessageType.

  • A newer version only sends out GetBlockHashesMsg with a single BlockHash in a compliant form which can be interpreted by an older version.
  • A newer version can parse a GetBlockHashesMsg (although this is interpreted differently) sent by an older version.

I will update it when we change the encoding.

@greymistcube greymistcube merged commit 3314da9 into planetarium:main Sep 3, 2024
22 checks passed
@greymistcube greymistcube deleted the refactor/remove-stop branch September 3, 2024 06:07
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