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

cmd: output all info in charon enr --verbose #1250

Merged
merged 3 commits into from
Oct 11, 2022

Conversation

xenowits
Copy link
Contributor

Output all information pertaining to a decoded ENR for charon enr --verbose.

category: feature
ticket: #998

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Base: 53.55% // Head: 53.57% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (a250f9e) compared to base (aadb722).
Patch coverage: 81.08% of modified lines in pull request are covered.

Additional details and impacted files
@@                           Coverage Diff                            @@
##           xenowits/remove-p2p-address-defaults    #1250      +/-   ##
========================================================================
+ Coverage                                 53.55%   53.57%   +0.01%     
========================================================================
  Files                                       139      139              
  Lines                                     16304    16260      -44     
========================================================================
- Hits                                       8732     8711      -21     
+ Misses                                     6306     6288      -18     
+ Partials                                   1266     1261       -5     
Impacted Files Coverage Δ
cmd/enr.go 36.95% <81.08%> (+23.62%) ⬆️
app/app.go 58.40% <0.00%> (-1.34%) ⬇️
core/priority/prioritiser.go 60.52% <0.00%> (-1.32%) ⬇️
core/qbft/qbft.go 80.68% <0.00%> (-1.29%) ⬇️
core/validatorapi/router.go 62.92% <0.00%> (-0.05%) ⬇️
app/eth2wrap/eth2wrap_gen.go 4.83% <0.00%> (+0.13%) ⬆️
testutil/beaconmock/options.go 33.33% <0.00%> (+0.27%) ⬆️
testutil/beaconmock/beaconmock.go 52.33% <0.00%> (+0.96%) ⬆️
core/fetcher/fetcher.go 67.44% <0.00%> (+2.03%) ⬆️

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

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@xenowits
Copy link
Contributor Author

Screenshot 2022-10-11 at 12 51 59 PM

Screenshot 2022-10-11 at 12 59 24 PM

@@ -109,3 +113,42 @@ func pubkeyHex(pubkey ecdsa.PublicKey) string {
func bindEnrFlags(flags *pflag.FlagSet, verbose *bool) {
flags.BoolVar(verbose, "verbose", false, "Prints the expanded form of ENR.")
}

// enrNetworkingKeys returns a string containing the non-empty networking keys (ips and ports) present in the ENR record.
func enrNetworkingKeys(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.

does this work?

entries :=  []enr.Entry{
		new(enr.IPv4),
		new(enr.IPv6),
		new(enr.TCP),
		new(enr.TCP6),
		new(enr.UDP),
		new(enr.UDP6),
	}
		
	var sb strings.Builder
	for _, entry := range entries {
		if err := r.Load(entry); err == nil {
			_, _ = sb.WriteString(fmt.Sprintf("%s: %v\n", entry.ENRKey(), entry))
		}
	}
	
	return sb.String()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would produce an output like this:

***************** Decoded ENR (see https://enr-viewer.com/ for additional fields) **********************
secp256k1 pubkey: 0x3078303333636239396363306238363662323863343838303662343534633130343461303965353432626232306536623966333164346639653235353335613363353963
signature: 0xfefd8e3cb48b0a76c7134eac7fd4b7549f02f923c6c9490c0e4ff02074ab6a0208352ee2e7156955dd7147444c9f61bd805fa92fec16c55d5a35bb33c14bc336
seq: 0
id: v4
ip: &[127 0 0 1]
tcp: 0x140000161b8
udp: 0x140000161bc
********************************************************************************************************

since, some needs to be converted to strings while others are ints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unfortunately it doesn't work. your approach seems quite concise though

cmd/enr.go Show resolved Hide resolved
@xenowits xenowits self-assigned this Oct 11, 2022
@xenowits xenowits added the merge when ready Indicates bulldozer bot may merge when all checks pass label Oct 11, 2022
@xenowits xenowits merged commit cc5280c into xenowits/remove-p2p-address-defaults Oct 11, 2022
@xenowits xenowits deleted the xenowits/enr-verbose branch October 11, 2022 16:10
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.

2 participants