Finschia / finschia-sdk

A framework for building blockchains based Finschia Mainnet that is forked from cosmos-sdk
Apache License 2.0
63 stars 29 forks source link

simapp does not support M1 #557

Closed ulbqb closed 2 years ago

ulbqb commented 2 years ago

Summary of Bug

I'm developing using M1 mac. I can't build simapp with docker.

Version

ac918acc77d77d934e4dff134dcc53b9f83e3370

Steps to Reproduce

❯ docker build --no-cache -t simapp .
[+] Building 30.3s (13/14)                                                                                                              
 => [internal] load build definition from Dockerfile                                                                               0.0s
 => => transferring dockerfile: 37B                                                                                                0.0s
 => [internal] load .dockerignore                                                                                                  0.0s
 => => transferring context: 34B                                                                                                   0.0s
 => [internal] load metadata for docker.io/library/alpine:edge                                                                     2.0s
 => [internal] load metadata for docker.io/library/golang:alpine                                                                   0.0s
 => CACHED [build-env 1/5] FROM docker.io/library/golang:alpine                                                                    0.0s
 => [internal] load build context                                                                                                  0.8s
 => => transferring context: 753.83kB                                                                                              0.8s
 => CACHED [stage-1 1/4] FROM docker.io/library/alpine:edge@sha256:c8420124adc6f31031a88c85f53e1e78f419b1ac46b827fd1d4d0fdae2c7e3  0.0s
 => [stage-1 2/4] RUN apk add --update ca-certificates                                                                             1.8s
 => [build-env 2/5] RUN apk add --no-cache curl make git libc-dev bash gcc g++ linux-headers eudev-dev python3                     4.9s
 => [stage-1 3/4] WORKDIR /root                                                                                                    0.0s
 => [build-env 3/5] WORKDIR /go/src/github.com/line/lbm-sdk                                                                        0.0s
 => [build-env 4/5] COPY . .                                                                                                       0.7s
 => ERROR [build-env 5/5] RUN make build-linux                                                                                    22.6s 
------                                                                                                                                  
 > [build-env 5/5] RUN make build-linux:                                                                                                
#13 0.203 GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false make build                                                                       
#13 0.204 make[1]: Entering directory '/go/src/github.com/line/lbm-sdk'                                                                 
#13 0.212 mkdir -p /go/src/github.com/line/lbm-sdk/build/                                                                               
#13 0.214 go build -mod=readonly -tags "netgo goleveldb" -ldflags '-X github.com/line/lbm-sdk/version.Name=sim -X github.com/line/lbm-sdk/version.AppName=simd -X github.com/line/lbm-sdk/version.Version=0.46.0-rc2 -X github.com/line/lbm-sdk/version.Commit=ac918acc77d77d934e4dff134dcc53b9f83e3370 -X github.com/line/lbm-sdk/types.DBBackend=goleveldb -X "github.com/line/lbm-sdk/version.BuildTags=netgo goleveldb," -w -s' -trimpath -o /go/src/github.com/line/lbm-sdk/build/ ./...
#13 3.774 go: downloading github.com/spf13/cobra v1.4.0
#13 3.775 go: downloading github.com/line/ostracon v1.0.5
#13 3.775 go: downloading github.com/spf13/viper v1.11.0
#13 3.777 go: downloading github.com/rakyll/statik v0.1.7
#13 3.819 go: downloading github.com/regen-network/protobuf v1.3.3-alpha.regen.1
#13 3.832 go: downloading github.com/golang/protobuf v1.5.2
#13 3.912 go: downloading github.com/grpc-ecosystem/grpc-gateway v1.16.0
#13 4.055 go: downloading google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac
#13 4.083 go: downloading google.golang.org/grpc v1.33.2
#13 4.249 go: downloading github.com/bgentry/speakeasy v0.1.0
#13 4.250 go: downloading github.com/mattn/go-isatty v0.0.14
#13 4.251 go: downloading github.com/gorilla/mux v1.8.0
#13 4.255 go: downloading github.com/spf13/pflag v1.0.5
#13 4.266 go: downloading github.com/pkg/errors v0.9.1
#13 4.266 go: downloading gopkg.in/yaml.v2 v2.4.0
#13 4.271 go: downloading google.golang.org/protobuf v1.28.0
#13 4.285 go: downloading github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
#13 4.290 go: downloading github.com/tendermint/go-amino v0.16.0
#13 4.290 go: downloading github.com/cosmos/go-bip39 v1.0.0
#13 4.358 go: downloading github.com/btcsuite/btcd v0.22.1
#13 4.371 go: downloading github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3
#13 4.409 go: downloading github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
#13 4.465 go: downloading golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
#13 4.487 go: downloading github.com/tendermint/btcd v0.1.1
#13 4.522 go: downloading github.com/gogo/gateway v1.1.0
#13 4.626 go: downloading github.com/gorilla/handlers v1.5.1
#13 4.674 go: downloading github.com/rs/zerolog v1.26.1
#13 4.709 go: downloading github.com/improbable-eng/grpc-web v0.15.0
#13 4.757 go: downloading github.com/confio/ics23/go v0.7.0
#13 4.773 go: downloading github.com/regen-network/cosmos-proto v0.3.1
#13 4.795 go: downloading github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486
#13 4.797 go: downloading github.com/spf13/cast v1.5.0
#13 4.820 go: downloading github.com/coinbase/rosetta-sdk-go v0.7.9
#13 4.875 go: downloading github.com/stretchr/testify v1.7.1
#13 4.908 go: downloading github.com/VictoriaMetrics/fastcache v1.10.0
#13 4.910 go: downloading github.com/go-kit/kit v0.12.0
#13 4.923 go: downloading github.com/prometheus/client_golang v1.12.1
#13 4.977 go: downloading github.com/coocood/freecache v1.2.1
#13 4.982 go: downloading github.com/dgraph-io/ristretto v0.1.0
#13 4.982 go: downloading github.com/line/iavl/v2 v2.0.0-init.1.0.20220215225951-cb11c91d8857
#13 4.992 go: downloading github.com/golang/mock v1.6.0
#13 5.004 go: downloading github.com/armon/go-metrics v0.3.11
#13 5.035 go: downloading github.com/prometheus/common v0.34.0
#13 5.045 go: downloading github.com/cosmos/btcutil v1.0.4
#13 5.047 go: downloading github.com/mailru/easyjson v0.7.7
#13 5.084 go: downloading github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
#13 5.086 go: downloading github.com/line/wasmvm v0.16.3-0.9.0
#13 5.133 go: downloading github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa
#13 5.158 go: downloading github.com/fsnotify/fsnotify v1.5.1
#13 5.188 go: downloading github.com/mitchellh/mapstructure v1.4.3
#13 5.340 go: downloading github.com/spf13/afero v1.8.2
#13 5.341 go: downloading github.com/spf13/jwalterweatherman v1.1.0
#13 5.597 go: downloading golang.org/x/net v0.0.0-20220412020605-290c469a71a5
#13 5.808 go: downloading golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
#13 5.986 go: downloading github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
#13 6.003 go: downloading github.com/davecgh/go-spew v1.1.1
#13 6.025 go: downloading filippo.io/edwards25519 v1.0.0-rc.1
#13 6.049 go: downloading github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b
#13 6.078 go: downloading github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2
#13 6.105 go: downloading github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c
#13 6.116 go: downloading github.com/mtibben/percent v0.2.1
#13 6.126 go: downloading github.com/go-kit/log v0.2.0
#13 6.145 go: downloading github.com/go-logfmt/logfmt v0.5.1
#13 6.155 go: downloading github.com/gorilla/websocket v1.5.0
#13 6.156 go: downloading github.com/felixge/httpsnoop v1.0.1
#13 6.157 go: downloading github.com/lib/pq v1.10.5
#13 6.160 go: downloading github.com/rs/cors v1.8.2
#13 6.162 go: downloading github.com/cenkalti/backoff/v4 v4.1.1
#13 6.173 go: downloading github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f
#13 6.179 go: downloading github.com/cenkalti/backoff v2.2.1+incompatible
#13 6.179 go: downloading nhooyr.io/websocket v1.8.6
#13 6.179 go: downloading github.com/google/btree v1.0.0
#13 6.186 go: downloading github.com/cespare/xxhash/v2 v2.1.2
#13 6.189 go: downloading github.com/golang/snappy v0.0.4
#13 6.193 go: downloading github.com/beorn7/perks v1.0.1
#13 6.193 go: downloading github.com/prometheus/client_model v0.2.0
#13 6.199 go: downloading github.com/cespare/xxhash v1.1.0
#13 6.203 go: downloading github.com/prometheus/procfs v0.7.3
#13 6.207 go: downloading github.com/hashicorp/go-immutable-radix v1.3.1
#13 6.208 go: downloading github.com/josharian/intern v1.0.0
#13 6.209 go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
#13 6.213 go: downloading github.com/subosito/gotenv v1.2.0
#13 6.223 go: downloading github.com/hashicorp/hcl v1.0.0
#13 6.230 go: downloading gopkg.in/ini.v1 v1.66.4
#13 6.232 go: downloading github.com/magiconair/properties v1.8.6
#13 6.252 go: downloading github.com/pelletier/go-toml v1.9.4
#13 6.257 go: downloading golang.org/x/text v0.3.7
#13 6.261 go: downloading github.com/herumi/bls-eth-go-binary v0.0.0-20200923072303-32b29e5d8cbf
#13 6.261 go: downloading github.com/gtank/merlin v0.1.1
#13 6.277 go: downloading github.com/libp2p/go-buffer-pool v0.0.2
#13 6.292 go: downloading github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
#13 6.365 go: downloading github.com/gtank/ristretto255 v0.1.2
#13 6.377 go: downloading golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
#13 6.463 go: downloading github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
#13 6.647 go: downloading github.com/Workiva/go-datastructures v1.0.52
#13 6.647 go: downloading github.com/minio/highwayhash v1.0.2
#13 6.718 go: downloading github.com/google/orderedcode v0.0.1
#13 6.735 go: downloading github.com/pmezard/go-difflib v1.0.0
#13 6.748 go: downloading gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
#13 6.750 go: downloading github.com/klauspost/compress v1.13.6
#13 6.771 go: downloading github.com/dustin/go-humanize v1.0.0
#13 6.786 go: downloading github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
#13 6.798 go: downloading github.com/r2ishiguro/vrf v0.0.0-20180716233122-192de52975eb
#13 6.863 go: downloading github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
#13 6.877 go: downloading github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643
#13 8.408 # github.com/herumi/bls-eth-go-binary/bls
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:9:28: undefined: SecretKey
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:9:40: undefined: Fr
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:13:26: undefined: Fr
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:13:31: undefined: SecretKey
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:19:28: undefined: PublicKey
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:19:40: undefined: G1
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:23:26: undefined: G1
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:23:31: undefined: PublicKey
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:29:23: undefined: Sign
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:29:30: undefined: G2
#13 8.408 /go/pkg/mod/github.com/herumi/bls-eth-go-binary@v0.0.0-20200923072303-32b29e5d8cbf/bls/cast.go:29:30: too many errors
#13 22.49 make[1]: *** [Makefile:120: build] Error 2
#13 22.49 make: *** [Makefile:117: build-linux] Error 2
#13 22.49 make[1]: Leaving directory '/go/src/github.com/line/lbm-sdk'
------
executor failed running [/bin/sh -c make build-linux]: exit code: 2

For Admin Use

ulbqb commented 2 years ago

Duplicate of #524 ?

ulbqb commented 2 years ago

Now I am running simapp with M1 with the following changes.

diff --git a/Dockerfile b/Dockerfile
index b35e290fb..6bc3a0c2c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,7 +30,7 @@ RUN make build-linux
 FROM alpine:edge

 # Install ca-certificates
-RUN apk add --update ca-certificates
+RUN apk add --update ca-certificates libstdc++ 
 WORKDIR /root

 # Copy over binaries from the build-env
diff --git a/Makefile b/Makefile
index fe874d60e..eaffb177d 100644
--- a/Makefile
+++ b/Makefile
@@ -114,7 +114,7 @@ BUILD_TARGETS := build install

 build: BUILD_ARGS=-o $(BUILDDIR)/
 build-linux:
-       GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
+       GOOS=linux GOARCH=arm64 LEDGER_ENABLED=false $(MAKE) build

 $(BUILD_TARGETS): go.sum $(BUILDDIR)/
        go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...
diff --git a/go.mod b/go.mod
index 796e5ecda..54c57edda 100644
--- a/go.mod
+++ b/go.mod
@@ -62,5 +62,6 @@ require (
 replace (
        github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
        github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
+       github.com/herumi/bls-eth-go-binary => github.com/herumi/bls-eth-go-binary v0.0.0-20220509081320-2d8ab06de53c
        google.golang.org/grpc => google.golang.org/grpc v1.33.2
 )
diff --git a/go.sum b/go.sum
index 16af642a2..652db8a7c 100644
--- a/go.sum
+++ b/go.sum
@@ -598,8 +598,8 @@ github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpT
 github.com/hdevalence/ed25519consensus v0.0.0-20200813231810-1694d75e712a/go.mod h1:V0zo781scjlo5OzNQb2GI8wMt6CD4vs7y1beXtxZEhM=
 github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU=
 github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE=
-github.com/herumi/bls-eth-go-binary v0.0.0-20200923072303-32b29e5d8cbf h1:Lw7EOMVxu3O+7Ro5bqn9M20a7GwuCqZQsmdXNzmcKE4=
-github.com/herumi/bls-eth-go-binary v0.0.0-20200923072303-32b29e5d8cbf/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U=
+github.com/herumi/bls-eth-go-binary v0.0.0-20220509081320-2d8ab06de53c h1:ppGSVyhAFh8VAGyDuNeLEGMYRJR5iDI92QgDNrMIqK0=
+github.com/herumi/bls-eth-go-binary v0.0.0-20220509081320-2d8ab06de53c/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U=
 github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
 github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
ulbqb commented 2 years ago

If you want to build lbm-sdk for amd64 on M1 mac, you need to fix and run as follows.

diff

diff --git a/Dockerfile b/Dockerfile
index b35e290fb..6bc3a0c2c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,7 +30,7 @@ RUN make build-linux
 FROM alpine:edge

 # Install ca-certificates
-RUN apk add --update ca-certificates
+RUN apk add --update ca-certificates libstdc++ 
 WORKDIR /root

 # Copy over binaries from the build-env
diff --git a/go.mod b/go.mod
index 796e5ecda..54c57edda 100644
--- a/go.mod
+++ b/go.mod
@@ -62,5 +62,6 @@ require (
 replace (
        github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
        github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
+       github.com/herumi/bls-eth-go-binary => github.com/herumi/bls-eth-go-binary v0.0.0-20220509081320-2d8ab06de53c
        google.golang.org/grpc => google.golang.org/grpc v1.33.2
 )
diff --git a/go.sum b/go.sum
index 16af642a2..652db8a7c 100644
--- a/go.sum
+++ b/go.sum
@@ -598,8 +598,8 @@ github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpT
 github.com/hdevalence/ed25519consensus v0.0.0-20200813231810-1694d75e712a/go.mod h1:V0zo781scjlo5OzNQb2GI8wMt6CD4vs7y1beXtxZEhM=
 github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU=
 github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE=
-github.com/herumi/bls-eth-go-binary v0.0.0-20200923072303-32b29e5d8cbf h1:Lw7EOMVxu3O+7Ro5bqn9M20a7GwuCqZQsmdXNzmcKE4=
-github.com/herumi/bls-eth-go-binary v0.0.0-20200923072303-32b29e5d8cbf/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U=
+github.com/herumi/bls-eth-go-binary v0.0.0-20220509081320-2d8ab06de53c h1:ppGSVyhAFh8VAGyDuNeLEGMYRJR5iDI92QgDNrMIqK0=
+github.com/herumi/bls-eth-go-binary v0.0.0-20220509081320-2d8ab06de53c/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U=
 github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
 github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=

build

$ docker build --platform="linux/amd64" --no-cache -t simapp .

run

$ docker run --platform="linux/amd64" -it simapp sh