-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add compare_content
function to Enr
to allow comparisons modulo signature
#53
Conversation
@AgeManning @divagant-martian please review |
Thanks, I'll get to this monday night. Could you please add a test that creates the differing Enrs and then compares them? |
5dd4cea
to
edb120e
Compare
Sounds good I wrote the tests for both The edge I posted about above looks like it only exists on |
Hey, I have a few thoughts on this. I think its a good idea to add a function that is like I'm hesitent to change the PartialEq and Hash traits however, because these ENRs are actually different. If we change the PartialEq and Hash traits, then they become indistinguishable. In hashmaps, if we have these two different ENRs they can replace each other undetected and if there's multiple versions floating in a DHT they could oscillate around in people's hashmaps as indistinguishable entities. I'm not sure its possible, but maybe there is some security risk in not checking signatures when over-writing other ENRs in our hashmaps, like maybe invalid sigs can get in there (I can't think of how atm). I would prefer that we still maintain the ability to distinguish between these ENRs. One of the reasons is that I would consider it a small bug or issue if someone is signing the same content over and over again without increasing the sequence number. Or just signing the same content using sequence 0 if there's a chance that ENR is already out in the wild. I'm not sure about your particular use-case, but I'd think it shouldn't be common practice to sign ENR contents if they have already be signed in the past. In most of the code i've used with ENRs we just check the seq-no and node-id then use the largest seq-no (regardless of anything else). Its up to the node doing the signing that the most up-to-date information is contained in the highest sequence number it has signed. If we keep them indistinguishable, then the differences can be detected in the network and we can find the source of the issue and correct it. If they are identical (via the Would adding a compare_content function or equivalent resolve your issues? |
Yeah that would be fine, I will change my PR to what you suggested when I get a chance. |
edb120e
to
4c6ac6f
Compare
@AgeManning ok I implemented your suggestion! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @KolbyML. I asked @AgeManning to give this one a look because the changes while reasonable also didn't feel quite right to me. This middle ground is perfect
Only missing getting CI green and we can merge
compare_content
function to Enr to allow comparisons modulo signature
compare_content
function to Enr to allow comparisons modulo signaturecompare_content
function to Enr
to allow comparisons modulo signature
@KolbyML why draft? anything else you plan to add? |
@divagant-martian I was just double checking something, It looks good. |
I want an easy way to check if 2 Enr's are equal to each other.
Doing enr1 == enr2 doesn't work because you can have the same Enr with different signatures because of the random nouce I believe.
Here is an example all 3 of these Enr's are the same except for the signatures, but all of the signatures are valid you could swap them and it wouldn't make a difference.
Currently there is no way to quickly check if 2 Enr's are the same because of this, without manually checking all the content. I don't want to manually do it ideally I could just do.
or if we fix PartialEq will work like this for the edge case posted above
I think PartialEq should work like this as well as comparing the signatures isn't a valid way to tell if the Enr's are the same or not.
I want to be able to do if enr1 == enr2 and it actually be a valid if case. Without the edge case I pointed to above, because right now doing
enr1 == enr2
just gives false information.I think PartialEq should be instead like
As this would solve the edge case ^
Here ^ we should not use the signature in the hash and instead just hash the RLP_CONTENT from that function. Since signatures are not deterministic as stated above.