From 7f31054085848cdd0e73223b6c3ff4acc85980ac Mon Sep 17 00:00:00 2001 From: Yongwoo Lee Date: Wed, 12 May 2021 17:36:04 +0900 Subject: [PATCH 1/2] fix: build properly when using libsecp256k1 --- Makefile | 8 ++++++-- crypto/keys/secp256k1/secp256k1_cgo.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 70390a49de..e8da213dd3 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,8 @@ ifeq ($(LEDGER_ENABLED),true) endif endif -# DB backend selection -ifeq (,$(filter $(LBM_BUILD_OPTIONS), cleveldb rocksdb boltdb badgerdb)) +# DB backend and secp256k1 implementation selection +ifeq (,$(filter $(LBM_BUILD_OPTIONS), cleveldb rocksdb boltdb badgerdb libsecp256k1)) BUILD_TAGS += goleveldb DB_BACKEND = goleveldb else @@ -64,6 +64,10 @@ else BUILD_TAGS += boltdb DB_BACKEND = boltdb endif + ifeq (libsecp256k1,$(findstring libsecp256k1,$(LBM_BUILD_OPTIONS))) + CGO_ENABLED=1 + BUILD_TAGS += libsecp256k1 + endif endif build_tags += $(BUILD_TAGS) diff --git a/crypto/keys/secp256k1/secp256k1_cgo.go b/crypto/keys/secp256k1/secp256k1_cgo.go index d0df532f34..de2c9a20f8 100644 --- a/crypto/keys/secp256k1/secp256k1_cgo.go +++ b/crypto/keys/secp256k1/secp256k1_cgo.go @@ -21,6 +21,6 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { // VerifySignature validates the signature. // The msg will be hashed prior to signature verification. -func (pubKey *PrivKey) VerifySignature(msg []byte, sig []byte) bool { +func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool { return secp256k1.VerifySignature(pubKey.Key, crypto.Sha256(msg), sig) } diff --git a/go.mod b/go.mod index 2b3ef9ad3a..bf8853e994 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/line/iavl/v2 v2.0.0-init.1.0.20210507092458-8331d3daef36 - github.com/line/ostracon v0.34.9-0.20210429084710-ef4fe0a40c7d + github.com/line/ostracon v0.34.9-0.20210512045543-6c7ab0535e10 github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524 github.com/magiconair/properties v1.8.4 github.com/mattn/go-isatty v0.0.12 diff --git a/go.sum b/go.sum index 8b022e0b5e..d45e125388 100644 --- a/go.sum +++ b/go.sum @@ -201,7 +201,6 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -332,8 +331,9 @@ github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55 h1:cXVtMiJkvQ4kn0px github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55/go.mod h1:DHRJroSL7NaRkpvocRx3OtRsleXVsYSxBI9SfHFlTQ0= github.com/line/iavl/v2 v2.0.0-init.1.0.20210507092458-8331d3daef36 h1:811bq0lFSv91AsR9mikOs+ArELnxVeNuYWh8QYUkL6k= github.com/line/iavl/v2 v2.0.0-init.1.0.20210507092458-8331d3daef36/go.mod h1:0Xz+0i1nlB9lrjUDEwpDRhcmjfEAkOjd20dRb40FBso= -github.com/line/ostracon v0.34.9-0.20210429084710-ef4fe0a40c7d h1:/6vnjrk3SpCUUiIDBv8UzbYexabZBYXxkwyc3Bp9hPo= github.com/line/ostracon v0.34.9-0.20210429084710-ef4fe0a40c7d/go.mod h1:ttnbq+yQJMQ9a2MT5SEisOoa/+pOgh2KenTiK/rVdiw= +github.com/line/ostracon v0.34.9-0.20210512045543-6c7ab0535e10 h1:Ab+t7zJRhoHYZlQTtdwOSNUyl+FKGXBj0zKf3658baI= +github.com/line/ostracon v0.34.9-0.20210512045543-6c7ab0535e10/go.mod h1:ttnbq+yQJMQ9a2MT5SEisOoa/+pOgh2KenTiK/rVdiw= github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524 h1:eKXXnUm1SblC0AIXAMNDaSyvIbQ50yXqFbh9+Q8Kjvg= github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524/go.mod h1:wmkyPabXjtVZ1dvRofmurjaceghywtCSYGqFuFS+TbI= github.com/line/wasmvm v0.14.0-0.4.0 h1:XvJZ0HO7xNtQ/+IEjF2WtK93PC1e+dT0McomCwRTZnQ= From 8a27f51b768a4220b812a1cefaddc08f9e7549ff Mon Sep 17 00:00:00 2001 From: Yongwoo Lee Date: Thu, 13 May 2021 11:52:35 +0900 Subject: [PATCH 2/2] fix: select goleveldb when options libsecp256k1 only When LBM_BUILD_OPTIONS has no DB options and only has libsecp256k1, goleveldb will be selected by default. The previous commit has a bug for that. --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e8da213dd3..3db2c17af7 100644 --- a/Makefile +++ b/Makefile @@ -41,8 +41,8 @@ ifeq ($(LEDGER_ENABLED),true) endif endif -# DB backend and secp256k1 implementation selection -ifeq (,$(filter $(LBM_BUILD_OPTIONS), cleveldb rocksdb boltdb badgerdb libsecp256k1)) +# DB backend selection +ifeq (,$(filter $(LBM_BUILD_OPTIONS), cleveldb rocksdb boltdb badgerdb)) BUILD_TAGS += goleveldb DB_BACKEND = goleveldb else @@ -64,10 +64,12 @@ else BUILD_TAGS += boltdb DB_BACKEND = boltdb endif - ifeq (libsecp256k1,$(findstring libsecp256k1,$(LBM_BUILD_OPTIONS))) - CGO_ENABLED=1 - BUILD_TAGS += libsecp256k1 - endif +endif + +# secp256k1 implementation selection +ifeq (libsecp256k1,$(findstring libsecp256k1,$(LBM_BUILD_OPTIONS))) + CGO_ENABLED=1 + BUILD_TAGS += libsecp256k1 endif build_tags += $(BUILD_TAGS)