-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Outputs ENR text representation in admin.nodeInfo RPC #5701
Conversation
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.
Looks good, just several minor stylistic changes needed.
Also, could you please in a separate commit (can be this same PR) convert all tabs to spaces in the file Base64.cpp?
And yes, a unit test would be appreciated.
libdevcore/Base64.cpp
Outdated
@@ -46,13 +46,8 @@ static inline byte find_base64_char_index(byte c) | |||
else return 1 + find_base64_char_index('/'); | |||
} | |||
|
|||
string dev::toBase64(bytesConstRef _in) | |||
string toBase64Encoding(bytesConstRef _in, char const* base64_chars, bool _pad) |
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.
string toBase64Encoding(bytesConstRef _in, char const* base64_chars, bool _pad) | |
string toBase64Encoding(bytesConstRef _in, char const* _base64_chars, bool _pad) |
libdevcore/Base64.cpp
Outdated
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
"abcdefghijklmnopqrstuvwxyz" | ||
"0123456789+/"; | ||
bool _pad = true; |
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.
bool _pad = true; | |
bool const pad = true; |
libdevcore/Base64.cpp
Outdated
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
"abcdefghijklmnopqrstuvwxyz" | ||
"0123456789-_"; | ||
bool _pad = false; |
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.
bool _pad = false; | |
bool const pad = false; |
libdevcore/Base64.cpp
Outdated
ret += '='; | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
string dev::toBase64(bytesConstRef _in) | ||
{ | ||
static const char base64_chars[] = |
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.
static const char base64_chars[] = | |
static char const base64_chars[] = |
libdevcore/Base64.cpp
Outdated
|
||
string dev::toBase64URLSafe(bytesConstRef _in) | ||
{ | ||
static const char base64_chars[] = |
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.
static const char base64_chars[] = | |
static char const base64_chars[] = |
libp2p/ENR.cpp
Outdated
std::string ENR::textEncoding() const | ||
{ | ||
RLPStream s; | ||
this->streamRLP(s); |
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.
this->streamRLP(s); | |
streamRLP(s); |
libp2p/ENR.cpp
Outdated
{ | ||
RLPStream s; | ||
this->streamRLP(s); | ||
return toBase64URLSafe(std::string(s.out().begin(), s.out().end())); |
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.
I think something like
return toBase64URLSafe(std::string(s.out().begin(), s.out().end())); | |
return toBase64URLSafe(ref(s.out())); |
should work
libp2p/Host.h
Outdated
p2p::NodeInfo nodeInfo() const { return NodeInfo(id(), (networkConfig().publicIPAddress.empty() ? m_tcpPublic.address().to_string() : networkConfig().publicIPAddress), m_tcpPublic.port(), m_clientVersion); } | ||
p2p::NodeInfo nodeInfo() const | ||
{ | ||
auto e = enr(); |
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.
auto e = enr(); | |
auto const e = enr(); |
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.
Ah, one more thing: you need to add a prefix enr:
in function ENR::textEncoding()
See the spec https://github.com/ethereum/EIPs/blob/master/EIPS/eip-778.md#text-encoding
For unit test add a check that aleth/test/unittests/libp2p/ENRTest.cpp Line 24 in b212789
(this is a test vector from EIP spec) |
Codecov Report
@@ Coverage Diff @@
## master #5701 +/- ##
==========================================
- Coverage 63.05% 63.05% -0.01%
==========================================
Files 353 351 -2
Lines 30110 30015 -95
Branches 3378 3362 -16
==========================================
- Hits 18987 18926 -61
+ Misses 9894 9880 -14
+ Partials 1229 1209 -20 |
@gumb0 |
@gumb0 |
Yes, just return
Let's add just this one check
to the end of the test I linked, I think that would be enough for this PR. |
Also please add an item to CHANGELOG.md |
b40faf5
to
9e54363
Compare
@gumb0 |
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.
Looks good, please fix just one last minor naming issue and changelog, then it's ready
libdevcore/Base64.cpp
Outdated
} | ||
|
||
return ret; | ||
static char const _base64_chars[] = |
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.
static char const _base64_chars[] = | |
static char const c_base64_chars[] = |
libdevcore/Base64.cpp
Outdated
|
||
string dev::toBase64URLSafe(bytesConstRef _in) | ||
{ | ||
static char const _base64_chars[] = |
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.
static char const _base64_chars[] = | |
static char const c_base64_chars[] = |
CHANGELOG.md
Outdated
@@ -15,6 +15,7 @@ | |||
- Added: [#5634](https://github.com/ethereum/aleth/pull/5634) Bootnodes for Rinkeby and Goerli. | |||
- Added: [#5640](https://github.com/ethereum/aleth/pull/5640) Istanbul support: EIP-1702 Generalized Account Versioning Scheme. | |||
- Added: [#5690](https://github.com/ethereum/aleth/issues/5690) Istanbul support: EIP-2028 transaction data gas cost reduction. | |||
- Added: [#5622](https://github.com/ethereum/aleth/issues/5622) Outputs ENR text representation in admin.nodeInfo RPC. |
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.
Please link this to this PR instead of an issue
9e54363
to
542646b
Compare
Merge? |
Fixes #5622
Old PR #5697