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

p2p/enr: parse ENRs with enode #1011

Merged
merged 7 commits into from
Aug 23, 2022
Merged

p2p/enr: parse ENRs with enode #1011

merged 7 commits into from
Aug 23, 2022

Conversation

dB2510
Copy link
Contributor

@dB2510 dB2510 commented Aug 21, 2022

Corrects ENR encode/decode base64 format with the help of enode.

category: bug
ticket: #970

@dB2510 dB2510 linked an issue Aug 21, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Aug 21, 2022

Codecov Report

Merging #1011 (e505b01) into main (9b1b974) will decrease coverage by 0.60%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##             main    #1011      +/-   ##
==========================================
- Coverage   54.16%   53.56%   -0.61%     
==========================================
  Files         118      119       +1     
  Lines       13215    13282      +67     
==========================================
- Hits         7158     7114      -44     
- Misses       5030     5143     +113     
+ Partials     1027     1025       -2     
Impacted Files Coverage Δ
cluster/operator.go 68.08% <ø> (ø)
cmd/createcluster.go 48.36% <0.00%> (-0.19%) ⬇️
testutil/compose/define.go 40.00% <0.00%> (-0.25%) ⬇️
p2p/enr.go 81.25% <80.00%> (+18.75%) ⬆️
core/qbft/qbft.go 71.67% <0.00%> (-10.31%) ⬇️
core/types.go 32.81% <0.00%> (-3.71%) ⬇️
core/scheduler/scheduler.go 72.82% <0.00%> (-0.08%) ⬇️
core/interfaces.go 0.00% <0.00%> (ø)
core/bcast/recast.go 0.00% <0.00%> (ø)
app/app.go 59.33% <0.00%> (+1.07%) ⬆️
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

p2p/enr_test.go Outdated
require.Error(t, err)
require.Contains(t, err.Error(), "input contains more than one value")
}

func TestBackwardsENR(t *testing.T) {
oldVersionENR := "enr:-HW4QHwvU8usykhaKQ_cxyAaAck_TlS0zr9nLNXDODQll87ifLECDsnczJz7vC_aVTKq9Q8aC3UIKWwls1i4TmEXLAuAgmlkgnY0iXNlY3AyNTZrMaEDhry2ryLc-Y39laN92yfixHghkWIjLeQ4orBvDQy20jA="
Copy link
Contributor

@corverroos corverroos Aug 21, 2022

Choose a reason for hiding this comment

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

better do 100 random old ENRs (copy old EncodeENR to test file)

Copy link
Contributor

Choose a reason for hiding this comment

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

also see encoding/base64/base64_test.go:62

p2p/enr.go Outdated
Comment on lines 41 to 42
if strings.HasSuffix(enrStr, "=") {
enrStr = enrStr[:len(enrStr)-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it

@corverroos corverroos added the do not merge Indicate to bulldozer bot that this PR should not be merged label Aug 22, 2022
@corverroos
Copy link
Contributor

Just adding "do not merge" until we fully understand why things were not breaking sooner

Comment on lines 393 to 396
p2pConfig := p2p.Config{
TCPAddrs: []string{"127.0.0.1:3610"},
UDPAddr: "127.0.0.1:3630",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

don't understand why this is required

if !ok {
return enr.Record{}, errors.New("invalid ENR with no prefix (enr:)")
}
// Ensure backwards compatibility with older versions with encoded ENR strings.
Copy link
Contributor

Choose a reason for hiding this comment

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

add comment what that older actually did

}
}

func encodeOldVersion(t *testing.T, r enr.Record) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

add comment what this is

p2p/enr_test.go Outdated

func TestBackwardsENR(t *testing.T) {
random := rand.New(rand.NewSource(time.Now().Unix()))
for i := 0; i < 1000; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

100 is probably fine

Comment on lines 319 to 322
config := p2p.Config{
TCPAddrs: []string{"127.0.0.1:3610"},
UDPAddr: "127.0.0.1:3630",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't seem right

@corverroos corverroos removed the do not merge Indicate to bulldozer bot that this PR should not be merged label Aug 23, 2022
@dB2510 dB2510 added the merge when ready Indicates bulldozer bot may merge when all checks pass label Aug 23, 2022
@obol-bulldozer obol-bulldozer bot merged commit 0ffecff into main Aug 23, 2022
@obol-bulldozer obol-bulldozer bot deleted the dhruv/correctenr branch August 23, 2022 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect ENR base64 format
2 participants