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

fix(Makefile)!: add ledger build flag to build with ledger support by default #2014

Merged
merged 4 commits into from
Jul 18, 2023

Conversation

liamsi
Copy link
Member

@liamsi liamsi commented Jul 2, 2023

Overview

Mainly add ledger flag to add ledger support by default.

fixes #1658

@MSevey MSevey requested a review from a team July 2, 2023 09:19
@@ -14,7 +47,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
Copy link
Member Author

@liamsi liamsi Jul 2, 2023

Choose a reason for hiding this comment

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

[note for reviewers] this var (build_tags_comma_sep) was never set but was still used here.

Makefile Outdated
Comment on lines 8 to 39
LEDGER_ENABLED ?= true


# process build tags
build_tags =
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif

whitespace :=
whitespace := $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
Copy link
Member Author

@liamsi liamsi Jul 2, 2023

Choose a reason for hiding this comment

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

[note for reviewers] Basically copy/pasted from cosmos-sdk/osmosis' Makefile. Linking here for comparison:
https://github.com/osmosis-labs/osmosis/blob/6ad2827c67cee185f2b7652ed7ae4cdea955f979/Makefile#L21-L43

Only diff:
Drop the netgo flag. I assume it was mainly there to ensure a statically linked net lib (compare: https://go.dev/src/net/netgo.go). it's orthogonal to ledger support and I am not sure we need it at all.

@liamsi
Copy link
Member Author

liamsi commented Jul 2, 2023

Ideally, we had a test to ensure that the build flag works as intended. I think there is a mock-ledger (at least when coding the KMS that was what we used; albeit in Rust).

@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2023

Codecov Report

Merging #2014 (c80fe5d) into main (c66ab98) will increase coverage by 3.51%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #2014      +/-   ##
==========================================
+ Coverage   21.54%   25.05%   +3.51%     
==========================================
  Files         126      121       -5     
  Lines       14285    13811     -474     
==========================================
+ Hits         3077     3460     +383     
+ Misses      10915     9995     -920     
- Partials      293      356      +63     

see 29 files with indirect coverage changes

@rootulp rootulp added bug Something isn't working and removed external labels Jul 3, 2023
Comment on lines +14 to +20
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

[not blocking][question] does anyone have a Windows machine to test this?

@@ -5,6 +5,39 @@ DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bu
IMAGE := ghcr.io/tendermint/docker-build-proto:latest
DOCKER_PROTO_BUILDER := docker run -v $(shell pwd):/workspace --workdir /workspace $(IMAGE)
PROJECTNAME=$(shell basename "$(PWD)")
LEDGER_ENABLED ?= true
Copy link
Collaborator

Choose a reason for hiding this comment

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

[note for reviewers] ?= is the optional variable assignment operator. It sets the LEDGER_ENABLED variable if it has not previously been set

Source: https://www.gnu.org/software/make/manual/html_node/Setting.html

Makefile Show resolved Hide resolved
@rootulp
Copy link
Collaborator

rootulp commented Jul 3, 2023

@liamsi has this PR been tested? In the absence of a test, can you please document in the PR description how it was manually verified?

@liamsi
Copy link
Member Author

liamsi commented Jul 3, 2023

has this PR been tested? In the absence of a test, can you please document in the PR description how it was manually verified?

I did only test if I can import a key from a ledger:
celestia-appd keys add my-key-name --ledger --index 2
which succeeded. Without the changes in this PR it previously failed. (note the index is optional; I just wanted to test with a different derivation path).

strip var

Co-authored-by: Rootul P <[email protected]>
@MSevey MSevey requested a review from a team July 3, 2023 15:00
rootulp
rootulp previously approved these changes Jul 3, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Code changes LGTM! Thanks for this

@evan-forbes
Copy link
Member

this LGTM! should we be worried about the docker build failing? should we set the default to false to avoid this for now until we fix docker?

#12 66.97 In file included from /go/pkg/mod/github.com/zondax/[email protected]/libusb/libusb/os/linux_usbfs.c:43,
#12 66.97                  from /go/pkg/mod/github.com/zondax/[email protected]/hid_enabled.go:26:
#12 66.97 /go/pkg/mod/github.com/zondax/[email protected]/libusb/libusb/os/linux_usbfs.h:24:10: fatal error: linux/types.h: No such file or directory
#12 66.97    24 | #include <linux/types.h>
#12 66.97       |          ^~~~~~~~~~~~~~~
#12 66.97 compilation terminated.
#12 106.6 make: *** [Makefile:62: build] Error 1
#12 ERROR: executor failed running [/bin/sh -c make build]: exit code: 2

#6 [stage-1 1/4] FROM docker.io/library/alpine:3.18.2@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1
------
 > [builder 5/5] RUN make build:
26.57 go: downloading github.com/go-playground/locales v0.13.0
26.57 go: downloading github.com/jmespath/go-jmespath/internal/testify v1.5.1
66.97 # github.com/zondax/hid
66.97 In file included from /go/pkg/mod/github.com/zondax/[email protected]/libusb/libusb/os/linux_usbfs.c:43,
66.97                  from /go/pkg/mod/github.com/zondax/[email protected]/hid_enabled.go:26:
66.97 /go/pkg/mod/github.com/zondax/[email protected]/libusb/libusb/os/linux_usbfs.h:24:10: fatal error: linux/types.h: No such file or directory
66.97    24 | #include <linux/types.h>
66.97       |          ^~~~~~~~~~~~~~~
66.97 compilation terminated.
106.6 make: *** [Makefile:62: build] Error 1
------
ERROR: failed to solve: executor failed running [/bin/sh -c make build]: exit code: 2

@liamsi
Copy link
Member Author

liamsi commented Jul 11, 2023

I tho I we can simply disable it for docker. Can look into that tmrw

@rootulp rootulp self-assigned this Jul 14, 2023
@MSevey MSevey requested a review from a team July 14, 2023 20:25
Comment on lines +7 to +8
# linux-headers are needed for Ledger support
linux-headers \
Copy link
Collaborator

Choose a reason for hiding this comment

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

[note to reviewers] this fixes the Docker workflow. Tested in rootulp#9

rootulp
rootulp previously approved these changes Jul 14, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

I ordered a Ledger for testing purposes but haven't received it yet so I'll test manually after I receive.

@rootulp rootulp requested review from staheri14 and removed request for evan-forbes July 14, 2023 20:35
@rootulp rootulp requested a review from rach-id July 14, 2023 20:35
rach-id
rach-id previously approved these changes Jul 14, 2023
Copy link
Member

@rach-id rach-id left a comment

Choose a reason for hiding this comment

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

utAck

Makefile Outdated Show resolved Hide resolved
@rootulp rootulp dismissed stale reviews from rach-id and themself via c80fe5d July 17, 2023 18:27
@MSevey MSevey requested a review from a team July 17, 2023 18:27
@rootulp rootulp requested review from cmwaters and rach-id July 17, 2023 18:28
Copy link
Member

@rach-id rach-id left a comment

Choose a reason for hiding this comment

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

utAck

Copy link
Member Author

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

Changes made to fix the docker builds make sense to me. Thanks @rootulp! I can't approve the PR though as I've opened it.

@rootulp rootulp merged commit 6b2ad5e into main Jul 18, 2023
20 checks passed
@rootulp rootulp deleted the liamsi/ledger_build branch July 18, 2023 14:02
@rootulp
Copy link
Collaborator

rootulp commented Jul 22, 2023

Circling back on this. I verified that I can add a key from Ledger

$ celestia-appd keys add ledger-1 --ledger

- address: celestia1xdc39xr027r78w4eeq6e7e35glgza9ka9rsds2
  name: ledger-1
  pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A+u46124WB1YIjLA+Ufriy5aQzcvdM4bily/Y32INEGV"}'
  type: ledger

evan-forbes pushed a commit that referenced this pull request Sep 4, 2023
… default (#2014)

## Overview

Mainly add ledger flag to add ledger support by default.

fixes #1658

---------

Co-authored-by: Rootul P <[email protected]>
evan-forbes pushed a commit that referenced this pull request Sep 4, 2023
#2415)

… default (#2014)

## Overview

Mainly add ledger flag to add ledger support by default.

fixes #1658

---------

<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [ ] New and updated code has appropriate documentation
- [ ] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords

Co-authored-by: Rootul P <[email protected]>
@rootulp rootulp mentioned this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support build for ledger
6 participants