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

Display the identity hash of PeerIds when relevant #1576

Merged
merged 4 commits into from
May 18, 2020

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented May 14, 2020

The Debug and Display implementations call to_base58().
This PR transitions to_base58() to the "proper" string representation of the PeerId.

In other words, identity PeerIds will now start with 1... rather than Qm...

@tomaka tomaka requested a review from romanb May 14, 2020 17:06
@romanb
Copy link
Contributor

romanb commented May 14, 2020

Can we not end the transition period and remove the temporary canonical field and the rest of the migration code? The reason I'm asking is that using borrow() in to_base58 is strictly what we want: Equal peer IDs should have an equal Display. If we remove canonical and the rest of the temporary workarounds, borrow() and as_ref() will again be the same, as it was before this identity hashing migration, and thus the Display will be what you expect and the same peer IDs will have the same Display output. By just changing borrow() to as_ref() in Display now, without removing all the other compatibility workarounds, in particular the custom PartialEq, we introduce another intermediate state where peer IDs can be equal according to PartialEq but give different output for Display.

@tomaka
Copy link
Member Author

tomaka commented May 15, 2020

we introduce another intermediate state where peer IDs can be equal according to PartialEq but give different output for Display.

That was actually my intention when opening this.

The problem we're facing right now is that PeerIds are displayed to users in their SHA256 form. Users then copy these PeerIds around between machines, thereby losing the non-canonical version. The most obvious example is the bootstrap node addresses.

If we straight-up remove the migration code, then all these existing keys will become invalid.

The only way to fix that is to first have a step where we show the correct version printed out.

@romanb
Copy link
Contributor

romanb commented May 16, 2020

If we straight-up remove the migration code, then all these existing keys will become invalid.

So if I understand correctly, you would want to tell users explicitly to re-copy these new peer IDs to wherever they are used? Since without such explicit instruction, I don't see how it could make a difference. And since such explicit upgrade instruction(s) are needed, you need to tell users something of the form "Please (re)start your node or execute command foo to get your new peer ID output. Replace your old peer ID with this new one everywhere, e.g. in your list of bootstrap nodes.", right? Why is it important then that "everywhere" in substrate that a peer ID is printed, the new version is shown for that purpose? What I'm trying to get at is, wouldn't a simple one-time upgrade hint in substrate where the new ID is displayed suffice as preparation for removing the migration code here, so there doesn't need to be another intermediate transition state in libp2p itself?

@romanb
Copy link
Contributor

romanb commented May 16, 2020

If we straight-up remove the migration code, then all these existing keys will become invalid.

So if I understand correctly, you would want to tell users explicitly to re-copy these new peer IDs to wherever they are used? Since without such explicit instruction, I don't see how it could make a difference. And since such explicit upgrade instruction(s) are needed, you need to tell users something of the form "Please (re)start your node or execute command foo to get your new peer ID output. Replace your old peer ID with this new one everywhere, e.g. in your list of bootstrap nodes.", right? Why is it important then that "everywhere" in substrate that a peer ID is printed, the new version is shown for that purpose? What I'm trying to get at is, wouldn't a simple one-time upgrade hint in substrate where the new ID is displayed suffice as preparation for removing the migration code here, so there doesn't need to be another intermediate transition state in libp2p itself?

I guess you would say that, although this could be done, it would be quite confusing for users to be told "This is your new peer ID, use it everywhere" but then not actually see it in any output (e.g. logs), which is fair enough.

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.

2 participants