-
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
Fix Cross Compile Build/Ledger Build Tag #1674
Conversation
This should be non-breaking, correct? |
d937864
to
dd911de
Compare
@cwgoes ledger is disabled by default. We can have it enabled by default except when cross-compiling (aka, |
dd911de
to
53787f5
Compare
53787f5
to
f4ade7b
Compare
Yes, I think so. |
Makefile
Outdated
ifdef GCC | ||
BUILD_TAGS += ledger | ||
else | ||
$(error "gcc not installed for ledger support, please install") |
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.
Will clang
work too?
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.
(or does CGO require gcc
anyways?)
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 requires gcc
afaik.
crypto/ledger.go
Outdated
// If ledger support (build tag) has been enabled, automically attempt to load | ||
// and set the ledger device, ledgerDevice, if it has not already been set. | ||
func init() { | ||
if ledgerDevice == nil { |
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 do we need to check this - init()
will only be called once?
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, init
will only be called once. Alternatively, you could wrap it in a once.Do(...)
call.
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.
Nvm, I see you're point. The old code was this way -- I'll remove it 👍
crypto/ledger_test.go
Outdated
) | ||
|
||
func TestRealLedgerSecp256k1(t *testing.T) { | ||
var ledgerEnabledEnv = "LEDGER_ENABLED" |
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.
Hmm, do we want to use the same environment variable here? e.g. we want CI to build with Ledger support, but it can't run the tests that require having a Ledger plugged in
f4ade7b
to
dcd1994
Compare
Codecov Report
@@ Coverage Diff @@
## master #1674 +/- ##
==========================================
- Coverage 62.15% 62.07% -0.08%
==========================================
Files 117 116 -1
Lines 6938 6929 -9
==========================================
- Hits 4312 4301 -11
- Misses 2384 2385 +1
- Partials 242 243 +1 |
--- FAIL: TestRealLedgerSecp256k1 (0.00s)
Error Trace: ledger_test.go:23
Error: Expected nil, but got: &errors.errorString{s:"failed to create PrivKeyLedgerSecp256k1: missing ledger device"}
Test: TestRealLedgerSecp256k1
Messages: failed to create PrivKeyLedgerSecp256k1: missing ledger device
FAIL
FAIL github.com/cosmos/cosmos-sdk/crypto 0.026s Ledger app is running, and |
|
||
check-ledger: | ||
ifeq ($(LEDGER_ENABLED),true) | ||
ifndef GCC |
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.
Should we add a check here for the linux udev rules?
https://support.ledgerwallet.com/hc/en-us/articles/115005165269-Connection-issues-with-Windows-or-Linux
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.
Mhmmm, not sure? But feel free to update it if it makes sense :-)
@cwgoes ahh indeed. `init() isn't being called. Fixing... EDIT: Ahh, wait. That test needs to run with the |
crypto/ledger.go
Outdated
@@ -0,0 +1,18 @@ | |||
// +build ledger |
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.
Can this be cgo,ledger
just so that this doesn't work if ledger flag is set but cgo isn't installed.
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 👍
Any idea how to do that? |
Yeah, you just add
|
@ValarDragon you don't have to add it to the test file file. Doing the following should suffice:
|
0683844
to
c9da1f6
Compare
@ValarDragon and I made a few minor modifications to update the testsuite for the real Ledger. |
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.
LGTM
Has cross compilation been tested?
@ValarDragon cross compilation works (without ledger), but could use some actual testing. Maybe running a local test net? |
Good idea - also, we need to backport this to v0.21.0 - #1683. |
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.
Tested ACK
Merging so Voyager can build (we can definitely test on an internal testnet too).
Changelog
check-ledger
target used byinstall
andbuild-linux
build-linux
only)crypto/
to use an interface and built tag.To build with ledger support:
$ LEDGER_ENABLED=true|false make install
closes: #1581
docs/
)CHANGELOG.md
cmd/gaia
andexamples/
For Admin Use: