-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Use embedded lib key type in sdk pub keys instead of bytes. #7672
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7672 +/- ##
=======================================
Coverage 54.10% 54.11%
=======================================
Files 611 611
Lines 38571 38571
=======================================
+ Hits 20869 20871 +2
+ Misses 15574 15573 -1
+ Partials 2128 2127 -1 |
crypto/keys/ed25519/ed25519_test.go
Outdated
@@ -1,6 +1,7 @@ | |||
package ed25519_test | |||
package ed25519 |
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.
why?
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.
to avoid weird package renames. It simplifies reading the code.
Also, we only have unit tests here. Using ed25519_test
is good for integration tests.
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 is a weird package rename. It actually helps the reader to have _test packages marked consistently.
is good for integration tests.
Why? How? In which cases?
Please revert this unnecesary change.
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.
BTW there are plenty of good reasons to hide internals when testing Go packages, that's why _test
packages are idiomatic in Go. We've made efforts in the past to make tests live within their respective _test
packages. This is a step backwards.
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.
Testing in same package is the Go idiomatic way. The go test roughly mentions about _test
package. The testing godoc doesn't mention it at all, same go wiki - learn testing. Go code review guidelines mention _test
packages only in one place - to use it to avoid circular dependencies - they suggest to use dot import
for that.
In all projects I was working (many) there was a preference to test in the package (not _test
). Personally I'm advocating to use use _test
packages for integration tests to have better feeling of a black box testing. This also gives a better separation between unit tests and other tests.
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.
It's not about which projects use and don't use _test
. We should strive to use when possible for better isolation. If the change isn't necessary, then we shouldn't change it.
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.
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 wanted to point out that it's a usual Go way for unit tests.
And I would like to point out that:
Test files that declare a package with the suffix "_test" will be compiled as a separate package, and then linked and run with the main test binary.
Per this piece of documentation here, that incidentally is hosted at tip.golang.org
.
how about using the dot import
No, it adds no value, plus it would make the imported symbols unpredictable.
How about reverting this change?
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.
Per this piece of documentation here, that incidentally is hosted at tip.golang.org.
I already linked go test
docs (using the source file) in one of my comments above. I don't see any relevant change in tip. If there is any, would you mind to pointing it out?
NOTE: I compared, there is no change in tip
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.
How about reverting this change?
OK, my motivation was to use the more adopted way for Go unit tests. If this is not an SDK way, no problem, reverting.
@@ -1,14 +1,14 @@ | |||
package ed25519 | |||
|
|||
import ( | |||
"crypto/ed25519" |
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 is good BTW
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.
yes, I made a note in the commit. Here are the details: https://golang.org/doc/go1.13#crypto/ed25519
We shouldn't use golang.org/x/crypto/ed25519 package.
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.
Few changes are requested.
50d4f7a
to
c7ccf0f
Compare
I've rolled back the package rename from |
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.
The changes look ok to me but could you resolve merge conflicts?
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.
the code lgtm, though I would prefer to approve once the tests pass.
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
In Go 1.13 the new crypto/ed25519 package implements the Ed25519 signature scheme. This functionality was previously provided by the golang.org/x/crypto/ed25519 package, which becomes a wrapper for crypto/ed25519 when used with Go 1.13+.
c7ccf0f
to
86b8250
Compare
Tests were passing, but there were conflicts after the nights merge. Now solved. |
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.
utACK, thanks!
Description
When doing the conversion of validators public key from
string
toAny
I noticed that we are doing unnecessary memory allocation for ed25519 keys and we can simplify by using theed25519.PrivateKey
directly in protobuf (ed25519.PrivateKey = []byte
).This changeset:
In Go 1.13 the new crypto/ed25519 package implements the Ed25519 signature scheme.
This functionality was previously provided by the golang.org/x/crypto/ed25519 package,
which becomes a wrapper for crypto/ed25519 when used with Go 1.13+.
ed25519.PrivateKey
direactly as "our" private key reducing the code (by delegating directly to the stdlib code!) an unnecessary memory allocations.closes: #7643
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes