diff --git a/.github/workflows/ci-pr.yaml b/.github/workflows/ci-pr.yaml index 7e2069955f..c593851295 100644 --- a/.github/workflows/ci-pr.yaml +++ b/.github/workflows/ci-pr.yaml @@ -40,26 +40,6 @@ jobs: path: go/src/github.com/harmony-one/harmony persist-credentials: false - - &checkout-mcl - name: Checkout mcl - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0 - with: - repository: harmony-one/mcl - fetch-depth: 1 - ref: master - path: go/src/github.com/harmony-one/mcl - persist-credentials: false - - - &checkout-bls - name: Checkout bls - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0 - with: - repository: harmony-one/bls - fetch-depth: 1 - ref: master - path: go/src/github.com/harmony-one/bls - persist-credentials: false - - &setup-go name: Set up Go uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 #v6.5.0 @@ -90,15 +70,7 @@ jobs: strategy: *arch-matrix steps: - *checkout-harmony - - *checkout-mcl - - *checkout-bls - *setup-go - - name: Build mcl - run: make -j4 - working-directory: go/src/github.com/harmony-one/mcl - - name: Build bls - run: make BLS_SWAP_G=1 -j4 - working-directory: go/src/github.com/harmony-one/bls - name: Install tools run: | go install golang.org/x/tools/cmd/goimports@v0.30.0 @@ -163,7 +135,6 @@ jobs: strategy: *arch-matrix steps: - *checkout-harmony - - *checkout-bls - *download-harmony-binaries - *prepare-harmony-binaries - *checkout-harmony-test diff --git a/.github/workflows/ci-release.yaml b/.github/workflows/ci-release.yaml index 9dbaed2a0b..fad3a6e8ec 100644 --- a/.github/workflows/ci-release.yaml +++ b/.github/workflows/ci-release.yaml @@ -83,24 +83,6 @@ jobs: - ubuntu-24.04-arm steps: - - name: Checkout mcl - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0 - with: - repository: harmony-one/mcl - path: mcl - ref: master - fetch-depth: 1 - persist-credentials: false - - - name: Checkout bls - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0 - with: - repository: harmony-one/bls - path: bls - ref: master - fetch-depth: 1 - persist-credentials: false - - name: Checkout harmony core code uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 #v7.0.0 with: diff --git a/Dockerfile b/Dockerfile index 90ce25f97b..35a6b890d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,11 +9,6 @@ ENV GOPATH=/root/go ENV GO111MODULE=on ENV HMY_PATH=${GOPATH}/src/github.com/harmony-one ENV OPENSSL_DIR=/usr/lib/ssl -ENV MCL_DIR=${HMY_PATH}/mcl -ENV BLS_DIR=${HMY_PATH}/bls -ENV CGO_CFLAGS="-I${BLS_DIR}/include -I${MCL_DIR}/include" -ENV CGO_LDFLAGS="-L${BLS_DIR}/lib" -ENV LD_LIBRARY_PATH=${BLS_DIR}/lib:${MCL_DIR}/lib ENV GIMME_GO_VERSION=${GOLANG_VERSION} ENV PATH="/root/bin:${PATH}" @@ -31,14 +26,8 @@ RUN eval "$(~/bin/gimme ${GIMME_GO_VERSION})" RUN git clone https://github.com/harmony-one/harmony.git ${HMY_PATH}/harmony -RUN git clone https://github.com/harmony-one/bls.git ${HMY_PATH}/bls - -RUN git clone https://github.com/harmony-one/mcl.git ${HMY_PATH}/mcl - RUN git clone https://github.com/harmony-one/go-sdk.git ${HMY_PATH}/go-sdk -RUN cd ${HMY_PATH}/bls && make -j8 BLS_SWAP_G=1 - RUN touch /root/.bash_profile && \ gimme ${GIMME_GO_VERSION} >> /root/.bash_profile && \ echo "GIMME_GO_VERSION='${GIMME_GO_VERSION}'" >> /root/.bash_profile && \ diff --git a/Makefile b/Makefile index 844f6c5099..36d0f99625 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,3 @@ -TOP:=$(realpath ..) -export CGO_CFLAGS:=-I$(TOP)/bls/include -I$(TOP)/mcl/include -I/opt/homebrew/opt/openssl@1.1/include -export CGO_LDFLAGS:=-L$(TOP)/bls/lib -L/opt/homebrew/opt/openssl@1.1/lib -export LD_LIBRARY_PATH:=$(TOP)/bls/lib:$(TOP)/mcl/lib:/opt/homebrew/opt/openssl@1.1/lib:/opt/homebrew/opt/gmp/lib/:/opt/homebrew/opt/openssl@1.1/lib -export LIBRARY_PATH:=$(LD_LIBRARY_PATH) -export DYLD_FALLBACK_LIBRARY_PATH:=$(LD_LIBRARY_PATH) export GO111MODULE:=on PKGNAME=harmony VERSION?=$(shell git tag -l --sort=-v:refname | head -n 1 | tr -d v) @@ -70,8 +64,7 @@ help: @echo "protofiles - generate Go code from protobuf files" libs: - make -C $(TOP)/mcl -j8 - make -C $(TOP)/bls BLS_SWAP_G=1 -j8 + go mod download github.com/herumi/bls-eth-go-binary exe: bash ./scripts/go_executable_build.sh -S @@ -144,11 +137,8 @@ clean: rm -f coverage.txt distclean: clean - make -C $(TOP)/mcl clean - make -C $(TOP)/bls clean go-get: - source ./scripts/setup_bls_build_flags.sh go get -v ./... test: @@ -170,8 +160,6 @@ test-rosetta-attach: bash ./test/rosetta.sh attach linux_static: - make -C $(TOP)/mcl -j8 - make -C $(TOP)/bls minimised_static BLS_SWAP_G=1 -j8 bash ./scripts/go_executable_build.sh -s linux_static_quick: @@ -271,4 +259,4 @@ debug-delete-log: docker-go-test: - docker run --rm -it -v "$PWD":/go/src/github.com/harmony-one/harmony frozen621/harmony-test bash -c 'make go-test' \ No newline at end of file + docker run --rm -it -v "$PWD":/go/src/github.com/harmony-one/harmony frozen621/harmony-test bash -c 'make go-test' diff --git a/README.md b/README.md index ba69a146f5..df73df32ba 100644 --- a/README.md +++ b/README.md @@ -54,38 +54,15 @@ On macOS, make sure you have the **Xcode Command Line Tools** installed. This in xcode-select --install ``` -## Setting Up MCL & BLS Libraries on macOS +## BLS dependency -The Harmony project depends on the MCL (multi-curve library) and BLS (Boneh-Lynn-Shacham) cryptographic libraries. These need to be installed and configured before building the project. +Harmony uses Herumi's official Go package with prebuilt static BLS libraries. +No separate BLS or MCL checkout is required: -### Clone and Build MCL & BLS Repositories -First, clone the MCL and BLS repositories: ```bash -git clone https://github.com/harmony-one/mcl.git -git clone https://github.com/harmony-one/bls.git -``` - -### Update `.zshrc` for MCL and BLS Paths - -To ensure the libraries are correctly located when building the project, you need to add the MCL and BLS library paths to your `.zshrc` file. - -Add the following lines to your `.zshrc` (or `.bash_profile` for bash users): -```bash -# MCL & BLS paths for Harmony -export MCL_PATH=$GOPATH/src/github.com/harmony-one/mcl -export BLS_PATH=$GOPATH/src/github.com/harmony-one/bls - -# Add library paths for MCL and BLS -export CGO_CFLAGS="-I$MCL_PATH/include -I$BLS_PATH/include -I/opt/homebrew/opt/openssl@1.1/include" -export CGO_LDFLAGS="-L$MCL_PATH/lib -L$BLS_PATH/lib -L/opt/homebrew/opt/openssl@1.1/lib" -export LD_LIBRARY_PATH=$MCL_PATH/lib:$BLS_PATH/lib:/opt/homebrew/opt/openssl@1.1/lib -export LIBRARY_PATH=$LD_LIBRARY_PATH -export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH -``` - -Then, apply the changes by running: -```bash -source ~/.zshrc +git clone https://github.com/harmony-one/harmony.git +cd harmony +go mod download ``` ## Dev Environment @@ -102,10 +79,8 @@ cd $(go env GOPATH)/src/github.com/harmony-one ``` > If you get 'unknown command' or something along those lines, make sure to install [golang](https://golang.org/doc/install) first. -2. Clone this repo & dependent repos. +2. Clone this repo. ```bash -git clone https://github.com/harmony-one/mcl.git -git clone https://github.com/harmony-one/bls.git git clone https://github.com/harmony-one/harmony.git cd harmony ``` @@ -151,17 +126,7 @@ Learn more about docker [here](https://docker-curriculum.com/). The `make` command should automatically build the Harmony binary & all dependent libs. -However, if you wish to bypass the Makefile, first export the build flags: -```bash -export CGO_CFLAGS="-I$GOPATH/src/github.com/harmony-one/bls/include -I$GOPATH/src/github.com/harmony-one/mcl/include -I/opt/homebrew/opt/openssl@1.1/include" -export CGO_LDFLAGS="-L$GOPATH/src/github.com/harmony-one/bls/lib -L/opt/homebrew/opt/openssl@1.1/lib" -export LD_LIBRARY_PATH=$GOPATH/src/github.com/harmony-one/bls/lib:$GOPATH/src/github.com/harmony-one/mcl/lib:/opt/homebrew/opt/openssl@1.1/lib -export LIBRARY_PATH=$LD_LIBRARY_PATH -export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH -export GO111MODULE=on -``` - -Then you can build all executables with the following command: +You can build all executables directly with: ```bash bash ./scripts/go_executable_build.sh -S ``` @@ -276,4 +241,3 @@ See [`CONTRIBUTING`](CONTRIBUTING.md) for details. - Integration with WASM - Fast state synchronization - Auditable privacy asset using ZK proof - diff --git a/Test.Dockerfile b/Test.Dockerfile index ad0a974f3b..4a0863c510 100644 --- a/Test.Dockerfile +++ b/Test.Dockerfile @@ -8,15 +8,11 @@ RUN apt-get update && \ WORKDIR /go/src/github.com/harmony-one -RUN git clone https://github.com/harmony-one/mcl.git && \ - git clone https://github.com/harmony-one/bls.git - RUN echo "Cloning branch: ${ENV}" && \ git clone -b ${ENV} https://github.com/harmony-one/harmony.git && \ cd harmony && \ - go mod tidy && \ - make deps + go mod download WORKDIR /go/src/github.com/harmony-one/harmony -CMD ["make", "go-test"] \ No newline at end of file +CMD ["make", "go-test"] diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index 791bf21816..ff65c133e5 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -16,7 +16,6 @@ import ( ethCommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/log" - "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/api/service" "github.com/harmony-one/harmony/api/service/crosslink_sending" "github.com/harmony-one/harmony/api/service/pprof" @@ -28,6 +27,7 @@ import ( "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/core" + bls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/chain" "github.com/harmony-one/harmony/internal/cli" "github.com/harmony-one/harmony/internal/common" diff --git a/consensus/beacon_header_slash_test.go b/consensus/beacon_header_slash_test.go index 5399db5b5d..33e2063d6f 100644 --- a/consensus/beacon_header_slash_test.go +++ b/consensus/beacon_header_slash_test.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/common/denominations" @@ -18,6 +17,7 @@ import ( coretypes "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" hmybls "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" chain2 "github.com/harmony-one/harmony/internal/chain" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" diff --git a/consensus/checks.go b/consensus/checks.go index 739c19dd6c..d927653bf4 100644 --- a/consensus/checks.go +++ b/consensus/checks.go @@ -4,10 +4,10 @@ import ( "bytes" "encoding/binary" - libbls "github.com/harmony-one/bls/ffi/go/bls" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto/bls" + libbls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" "github.com/pkg/errors" protobuf "google.golang.org/protobuf/proto" diff --git a/consensus/consensus.go b/consensus/consensus.go index 311c01967e..251f5acdc1 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -7,13 +7,13 @@ import ( "time" "github.com/harmony-one/abool" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/consensus/engine" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto/bls" bls_cosi "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/registry" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/multibls" diff --git a/consensus/consensus_service.go b/consensus/consensus_service.go index 0cc54f8829..cb1ed1b16e 100644 --- a/consensus/consensus_service.go +++ b/consensus/consensus_service.go @@ -6,7 +6,6 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/api/proto" msg_pb "github.com/harmony-one/harmony/api/proto/message" consensus_engine "github.com/harmony-one/harmony/consensus/engine" @@ -16,6 +15,7 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto/bls" bls_cosi "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" "github.com/harmony-one/harmony/internal/chain" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 728a964687..7305bede5b 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -9,7 +9,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - bls2 "github.com/harmony-one/bls/ffi/go/bls" msg_pb "github.com/harmony-one/harmony/api/proto/message" proto_node "github.com/harmony-one/harmony/api/proto/node" "github.com/harmony-one/harmony/block" @@ -18,6 +17,7 @@ import ( "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/crypto/bls" + bls2 "github.com/harmony-one/harmony/crypto/bls/core" vrf_bls "github.com/harmony-one/harmony/crypto/vrf/bls" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/numeric" diff --git a/consensus/construct.go b/consensus/construct.go index dab4026918..f2a39f20a9 100644 --- a/consensus/construct.go +++ b/consensus/construct.go @@ -4,11 +4,11 @@ import ( "bytes" "errors" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/api/proto" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" protobuf "google.golang.org/protobuf/proto" ) diff --git a/consensus/construct_test.go b/consensus/construct_test.go index 96bb21390c..f012479d09 100644 --- a/consensus/construct_test.go +++ b/consensus/construct_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/registry" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/multibls" diff --git a/consensus/crosslink_cache_invalid_shard_reward_test.go b/consensus/crosslink_cache_invalid_shard_reward_test.go index ea38137f04..768c7a48aa 100644 --- a/consensus/crosslink_cache_invalid_shard_reward_test.go +++ b/consensus/crosslink_cache_invalid_shard_reward_test.go @@ -8,7 +8,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/consensus/quorum" @@ -19,6 +18,7 @@ import ( coretypes "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" hmybls "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" chain2 "github.com/harmony-one/harmony/internal/chain" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" diff --git a/consensus/double_sign.go b/consensus/double_sign.go index 6709d540a0..30cb0bd596 100644 --- a/consensus/double_sign.go +++ b/consensus/double_sign.go @@ -5,9 +5,9 @@ import ( "sort" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/staking/slash" ) diff --git a/consensus/fbft_log.go b/consensus/fbft_log.go index 60c4d248e1..da8c407a40 100644 --- a/consensus/fbft_log.go +++ b/consensus/fbft_log.go @@ -8,7 +8,7 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/pkg/errors" "github.com/rs/zerolog" diff --git a/consensus/leader.go b/consensus/leader.go index af7e39a0d7..9e901e70c6 100644 --- a/consensus/leader.go +++ b/consensus/leader.go @@ -9,10 +9,10 @@ import ( nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/ethereum/go-ethereum/rlp" - bls_core "github.com/harmony-one/bls/ffi/go/bls" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/core/types" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/p2p" ) diff --git a/consensus/quorum/one-node-one-vote.go b/consensus/quorum/one-node-one-vote.go index 4962dfc86e..2662b0360d 100644 --- a/consensus/quorum/one-node-one-vote.go +++ b/consensus/quorum/one-node-one-vote.go @@ -6,8 +6,8 @@ import ( "github.com/pkg/errors" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/ethereum/go-ethereum/common" "github.com/harmony-one/harmony/consensus/votepower" diff --git a/consensus/quorum/one-node-staked-vote.go b/consensus/quorum/one-node-staked-vote.go index 45f4289eab..b681bdbae1 100644 --- a/consensus/quorum/one-node-staked-vote.go +++ b/consensus/quorum/one-node-staked-vote.go @@ -9,7 +9,7 @@ import ( "github.com/harmony-one/harmony/internal/utils" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/pkg/errors" "github.com/harmony-one/harmony/consensus/votepower" diff --git a/consensus/quorum/one-node-staked-vote_test.go b/consensus/quorum/one-node-staked-vote_test.go index fcce3c61b0..c3e1451dfe 100644 --- a/consensus/quorum/one-node-staked-vote_test.go +++ b/consensus/quorum/one-node-staked-vote_test.go @@ -12,7 +12,7 @@ import ( shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/numeric" "github.com/harmony-one/harmony/shard" ) @@ -42,7 +42,9 @@ func generateRandomSlot() (shard.Slot, bls_core.SecretKey) { addr := common.Address{} addr.SetBytes(big.NewInt(int64(accountGen.Int63n(maxAccountGen))).Bytes()) secretKey := bls_core.SecretKey{} - secretKey.Deserialize(big.NewInt(int64(keyGen.Int63n(maxKeyGen))).Bytes()) + if err := secretKey.SetLittleEndian(big.NewInt(int64(keyGen.Int63n(maxKeyGen))).Bytes()); err != nil { + panic(err) + } key := bls.SerializedPublicKey{} key.FromLibBLSPublicKey(secretKey.GetPublicKey()) stake := numeric.NewDecFromBigInt(big.NewInt(int64(stakeGen.Int63n(maxStakeGen)))) diff --git a/consensus/quorum/quorom_test.go b/consensus/quorum/quorom_test.go index 6b0ae95968..59ea163b90 100644 --- a/consensus/quorum/quorom_test.go +++ b/consensus/quorum/quorom_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - bls_core "github.com/harmony-one/bls/ffi/go/bls" harmony_bls "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/harmony-one/harmony/shard" "github.com/stretchr/testify/assert" diff --git a/consensus/quorum/quorum.go b/consensus/quorum/quorum.go index c6954f0246..3f6fc99e96 100644 --- a/consensus/quorum/quorum.go +++ b/consensus/quorum/quorum.go @@ -8,9 +8,9 @@ import ( "github.com/harmony-one/harmony/crypto/bls" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/consensus/votepower" bls_cosi "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/multibls" diff --git a/consensus/quorum/thread_safe_decider.go b/consensus/quorum/thread_safe_decider.go index 5a74975f91..bfa6e7e3e2 100644 --- a/consensus/quorum/thread_safe_decider.go +++ b/consensus/quorum/thread_safe_decider.go @@ -5,9 +5,9 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/consensus/votepower" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/harmony-one/harmony/multibls" "github.com/harmony-one/harmony/numeric" diff --git a/consensus/slash_group_test.go b/consensus/slash_group_test.go index 409b428566..e8dde17f9b 100644 --- a/consensus/slash_group_test.go +++ b/consensus/slash_group_test.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/common/denominations" @@ -16,6 +15,7 @@ import ( coretypes "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" hmybls "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" chain2 "github.com/harmony-one/harmony/internal/chain" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" diff --git a/consensus/validator_wrapper_payout_test.go b/consensus/validator_wrapper_payout_test.go index 5301d947ed..c529bbb49e 100644 --- a/consensus/validator_wrapper_payout_test.go +++ b/consensus/validator_wrapper_payout_test.go @@ -10,7 +10,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/common/denominations" @@ -22,6 +21,7 @@ import ( coretypes "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" hmybls "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" chain2 "github.com/harmony-one/harmony/internal/chain" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" diff --git a/consensus/view_change_construct.go b/consensus/view_change_construct.go index 5d25531757..80b3f5ef9d 100644 --- a/consensus/view_change_construct.go +++ b/consensus/view_change_construct.go @@ -10,10 +10,10 @@ import ( "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/core/types" - bls_core "github.com/harmony-one/bls/ffi/go/bls" msg_pb "github.com/harmony-one/harmony/api/proto/message" "github.com/harmony-one/harmony/crypto/bls" bls_cosi "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/chain" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/multibls" diff --git a/consensus/view_change_msg.go b/consensus/view_change_msg.go index 1ba9c76063..fb939c20df 100644 --- a/consensus/view_change_msg.go +++ b/consensus/view_change_msg.go @@ -7,10 +7,10 @@ import ( "github.com/ethereum/go-ethereum/rlp" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/api/proto" msg_pb "github.com/harmony-one/harmony/api/proto/message" bls_cosi "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/multibls" "github.com/pkg/errors" diff --git a/consensus/view_change_test.go b/consensus/view_change_test.go index 9514981d55..eae7f35998 100644 --- a/consensus/view_change_test.go +++ b/consensus/view_change_test.go @@ -5,8 +5,8 @@ import ( "github.com/harmony-one/harmony/crypto/bls" - bls_core "github.com/harmony-one/bls/ffi/go/bls" harmony_bls "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/stretchr/testify/assert" ) diff --git a/consensus/votepower/roster.go b/consensus/votepower/roster.go index 96a3ac9c6b..b82ef97fe7 100644 --- a/consensus/votepower/roster.go +++ b/consensus/votepower/roster.go @@ -10,8 +10,8 @@ import ( "github.com/harmony-one/harmony/shard" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" common2 "github.com/harmony-one/harmony/internal/common" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/numeric" diff --git a/consensus/votepower/roster_test.go b/consensus/votepower/roster_test.go index 0e7148fa27..f70cda0893 100644 --- a/consensus/votepower/roster_test.go +++ b/consensus/votepower/roster_test.go @@ -10,7 +10,7 @@ import ( shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/numeric" "github.com/harmony-one/harmony/shard" ) @@ -48,7 +48,9 @@ func generateRandomSlot() shard.Slot { addr := common.Address{} addr.SetBytes(big.NewInt(int64(accountGen.Int63n(maxAccountGen))).Bytes()) secretKey := bls_core.SecretKey{} - secretKey.Deserialize(big.NewInt(int64(keyGen.Int63n(maxKeyGen))).Bytes()) + if err := secretKey.SetLittleEndian(big.NewInt(int64(keyGen.Int63n(maxKeyGen))).Bytes()); err != nil { + panic(err) + } key := bls.SerializedPublicKey{} key.FromLibBLSPublicKey(secretKey.GetPublicKey()) stake := numeric.NewDecFromBigInt(big.NewInt(int64(stakeGen.Int63n(maxStakeGen)))) diff --git a/core/blockchain_impl.go b/core/blockchain_impl.go index a696f554f9..f0e7e237ff 100644 --- a/core/blockchain_impl.go +++ b/core/blockchain_impl.go @@ -40,7 +40,6 @@ import ( "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" - bls2 "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" consensus_engine "github.com/harmony-one/harmony/consensus/engine" "github.com/harmony-one/harmony/consensus/reward" @@ -52,6 +51,7 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/crypto/bls" + bls2 "github.com/harmony-one/harmony/crypto/bls/core" harmonyconfig "github.com/harmony-one/harmony/internal/configs/harmony" "github.com/harmony-one/harmony/internal/params" "github.com/harmony-one/harmony/internal/tikv" diff --git a/core/evm_test.go b/core/evm_test.go index e095e5917b..ae63347f5f 100644 --- a/core/evm_test.go +++ b/core/evm_test.go @@ -11,7 +11,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/common/denominations" @@ -20,6 +19,7 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" chain2 "github.com/harmony-one/harmony/internal/chain" "github.com/harmony-one/harmony/internal/params" diff --git a/core/rawdb/accessors_indexes_test.go b/core/rawdb/accessors_indexes_test.go index 41f54ac98a..0ede88d8d2 100644 --- a/core/rawdb/accessors_indexes_test.go +++ b/core/rawdb/accessors_indexes_test.go @@ -25,9 +25,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - bls_core "github.com/harmony-one/bls/ffi/go/bls" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/core/types" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" "github.com/harmony-one/harmony/numeric" staking "github.com/harmony-one/harmony/staking/types" diff --git a/core/tx_pool_test.go b/core/tx_pool_test.go index f1e7ce5ce7..826c1d283d 100644 --- a/core/tx_pool_test.go +++ b/core/tx_pool_test.go @@ -33,12 +33,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" - bls_core "github.com/harmony-one/bls/ffi/go/bls" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/common/denominations" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" chain2 "github.com/harmony-one/harmony/internal/chain" "github.com/harmony-one/harmony/internal/params" diff --git a/crypto/bls/bls.go b/crypto/bls/bls.go index 4b6fe593bc..5f47eb4510 100644 --- a/crypto/bls/bls.go +++ b/crypto/bls/bls.go @@ -5,7 +5,7 @@ import ( "encoding/hex" "math/big" - "github.com/harmony-one/bls/ffi/go/bls" + bls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/pkg/errors" ) diff --git a/crypto/bls/core/core.go b/crypto/bls/core/core.go new file mode 100644 index 0000000000..330770e8a1 --- /dev/null +++ b/crypto/bls/core/core.go @@ -0,0 +1,190 @@ +// Package bls configures the Herumi BLS implementation for Harmony consensus. +package bls + +import ( + "crypto/sha256" + "encoding/hex" + "fmt" + "unsafe" + + herumi "github.com/herumi/bls-eth-go-binary/bls" +) + +type ( + ID = herumi.ID + + // SecretKey wraps Herumi's key with Harmony-safe cgo boundaries. + SecretKey struct{ herumi.SecretKey } + + // PublicKey wraps Herumi's public key with Harmony-specific operations. + PublicKey struct{ herumi.PublicKey } + + // Sign wraps a Herumi BLS signature. + Sign struct{ herumi.Sign } +) + +const BLS12_381 = herumi.BLS12_381 + +// This is the G1 generator produced by the historical Harmony BLS_SWAP_G +// implementation. Keeping it preserves all existing public keys. +const harmonyGenerator = "e500361ff315734cccd8f9b721ec159995e9e622be17afd41ac2f037a583e81b98c2320e0bf853a8f929e89e3d8ff504" + +func init() { + if err := Init(BLS12_381); err != nil { + panic(err) + } +} + +// Init initializes Herumi with Harmony's consensus-critical group layout, +// serialization, hash-to-curve mode and public-key generator. +func Init(curve int) error { + if err := herumi.Init(curve); err != nil { + return err + } + herumi.SetETHserialization(false) + if err := herumi.SetMapToMode(0); err != nil { + return fmt.Errorf("bls: failed to select Harmony map-to-curve mode: %w", err) + } + if err := herumi.SetETHmode(herumi.EthModeOld); err != nil { + return err + } + raw, err := hex.DecodeString(harmonyGenerator) + if err != nil { + return err + } + var generator PublicKey + if err := generator.Deserialize(raw); err != nil { + return fmt.Errorf("bls: decode Harmony generator: %w", err) + } + if err := herumi.SetGeneratorOfPublicKey(&generator.PublicKey); err != nil { + return fmt.Errorf("bls: install Harmony generator: %w", err) + } + return nil +} + +// GetAddress derives the Harmony address of a BLS public key. +func (pub *PublicKey) GetAddress() [20]byte { + var address [20]byte + if pub == nil { + return address + } + hash := sha256.Sum256(pub.Serialize()) + copy(address[:], hash[:len(address)]) + return address +} + +// GetPublicKey returns the public key corresponding to this secret key. +func (secret *SecretKey) GetPublicKey() *PublicKey { + if secret == nil { + return nil + } + public := secret.SecretKey.GetPublicKey() + if public == nil { + return nil + } + return &PublicKey{PublicKey: *public} +} + +// IsEqual reports whether two secret keys are equal. +func (secret *SecretKey) IsEqual(rhs *SecretKey) bool { + return secret != nil && rhs != nil && secret.SecretKey.IsEqual(&rhs.SecretKey) +} + +// Sign signs a string using Harmony's configured BLS mode. +func (secret *SecretKey) Sign(message string) *Sign { + if secret == nil { + return nil + } + signature := secret.SecretKey.Sign(message) + if signature == nil { + return nil + } + return &Sign{Sign: *signature} +} + +// SignHash copies the hash before crossing the cgo boundary. +func (secret *SecretKey) SignHash(hash []byte) *Sign { + if secret == nil { + return nil + } + signature := secret.SecretKey.SignHash(append([]byte(nil), hash...)) + if signature == nil { + return nil + } + return &Sign{Sign: *signature} +} + +// SignByte copies the message before crossing the cgo boundary. +func (secret *SecretKey) SignByte(message []byte) *Sign { + if secret == nil { + return nil + } + signature := secret.SecretKey.SignByte(append([]byte(nil), message...)) + if signature == nil { + return nil + } + return &Sign{Sign: *signature} +} + +// VerifyHash copies the hash before crossing the cgo boundary. +func (signature *Sign) VerifyHash(public *PublicKey, hash []byte) bool { + if signature == nil || public == nil { + return false + } + return signature.Sign.VerifyHash( + &public.PublicKey, + append([]byte(nil), hash...), + ) +} + +// VerifyByte copies the message before crossing the cgo boundary. +func (signature *Sign) VerifyByte(public *PublicKey, message []byte) bool { + if signature == nil || public == nil { + return false + } + return signature.Sign.VerifyByte( + &public.PublicKey, + append([]byte(nil), message...), + ) +} + +// Verify verifies a string signature. +func (signature *Sign) Verify(public *PublicKey, message string) bool { + if signature == nil || public == nil { + return false + } + return signature.Sign.Verify(&public.PublicKey, message) +} + +// Add adds another public key. +func (pub *PublicKey) Add(rhs *PublicKey) { + if pub != nil && rhs != nil { + pub.PublicKey.Add(&rhs.PublicKey) + } +} + +// IsEqual reports whether two public keys are equal. +func (pub *PublicKey) IsEqual(rhs *PublicKey) bool { + return pub != nil && rhs != nil && pub.PublicKey.IsEqual(&rhs.PublicKey) +} + +// Sub subtracts another BLS public key. +func (pub *PublicKey) Sub(rhs *PublicKey) { + if pub == nil || rhs == nil { + return + } + out := (*herumi.G1)(unsafe.Pointer(&pub.PublicKey)) + herumi.G1Sub(out, out, (*herumi.G1)(unsafe.Pointer(&rhs.PublicKey))) +} + +// Add adds another signature. +func (signature *Sign) Add(rhs *Sign) { + if signature != nil && rhs != nil { + signature.Sign.Add(&rhs.Sign) + } +} + +// IsEqual reports whether two signatures are equal. +func (signature *Sign) IsEqual(rhs *Sign) bool { + return signature != nil && rhs != nil && signature.Sign.IsEqual(&rhs.Sign) +} diff --git a/crypto/bls/core/core_test.go b/crypto/bls/core/core_test.go new file mode 100644 index 0000000000..5c18e6f593 --- /dev/null +++ b/crypto/bls/core/core_test.go @@ -0,0 +1,37 @@ +package bls + +import ( + "encoding/hex" + "testing" +) + +func TestHarmonyWireCompatibility(t *testing.T) { + var secret SecretKey + if err := secret.SetLittleEndian([]byte{1}); err != nil { + t.Fatal(err) + } + + const ( + wantSecret = "0100000000000000000000000000000000000000000000000000000000000000" + wantPublic = "e500361ff315734cccd8f9b721ec159995e9e622be17afd41ac2f037a583e81b98c2320e0bf853a8f929e89e3d8ff504" + wantSign = "c2aba747613499b2e086c3bd9714f6da7159b3cb256d246f1c41dcdd61b00fd608e7caadef2376ed77e68ffc0b486113617d21668e56f930bdee39af0af1fcb42dc7396c5de18af5f2560dc6a11f5e9dd04f9df5e1ac68773d85c8585dcf9c11" + wantHash = "1d730dd8da233d2fccc254b9b3fece52a6f15dd4522f3cd600f14551b5cd76c95ea6ebc7ec077ccc83dead3b2b5b8a12f05b8492119c773c81eb5fb56060f585e711e763f4a85221a5ba72894b87fab619fab4a4c0e478969125c75a9216d093" + ) + + assertHex := func(name string, got []byte, want string) { + t.Helper() + if hex.EncodeToString(got) != want { + t.Fatalf("%s changed:\n got %x\nwant %s", name, got, want) + } + } + + public := secret.GetPublicKey() + hash, err := hex.DecodeString("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f") + if err != nil { + t.Fatal(err) + } + assertHex("secret key", secret.Serialize(), wantSecret) + assertHex("public key", public.Serialize(), wantPublic) + assertHex("message signature", secret.Sign("harmony-bls-upgrade-compatibility").Serialize(), wantSign) + assertHex("hash signature", secret.SignHash(hash).Serialize(), wantHash) +} diff --git a/crypto/bls/mask.go b/crypto/bls/mask.go index 2bd908fd7c..cda255926a 100644 --- a/crypto/bls/mask.go +++ b/crypto/bls/mask.go @@ -1,7 +1,7 @@ package bls import ( - "github.com/harmony-one/bls/ffi/go/bls" + bls "github.com/harmony-one/harmony/crypto/bls/core" lru "github.com/hashicorp/golang-lru" "github.com/pkg/errors" ) @@ -44,7 +44,10 @@ func BytesToBLSPublicKey(bytes []byte) (*bls.PublicKey, error) { return nil, errPubKeyCast } pubKey := &bls.PublicKey{} - err := pubKey.Deserialize(bytes) + // The upstream wrapper passes this buffer to C. Copy it so callers may + // safely provide a slice backed by a Go struct containing pointer fields. + buf := append([]byte(nil), bytes...) + err := pubKey.Deserialize(buf) if err == nil { BLSPubKeyCache.Add(kkey, *pubKey) diff --git a/crypto/bls/mask_test.go b/crypto/bls/mask_test.go index 17770fd668..d920980216 100644 --- a/crypto/bls/mask_test.go +++ b/crypto/bls/mask_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/harmony-one/bls/ffi/go/bls" + bls "github.com/harmony-one/harmony/crypto/bls/core" ) // Test the basic functionality of a BLS multi-sig mask. diff --git a/crypto/vrf/bls/bls_vrf.go b/crypto/vrf/bls/bls_vrf.go index 54e1820c76..e7d273c974 100644 --- a/crypto/vrf/bls/bls_vrf.go +++ b/crypto/vrf/bls/bls_vrf.go @@ -5,7 +5,7 @@ import ( "crypto/sha256" "errors" - "github.com/harmony-one/bls/ffi/go/bls" + bls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/vrf" ) diff --git a/go.mod b/go.mod index c29c096e16..42658cd200 100644 --- a/go.mod +++ b/go.mod @@ -24,11 +24,11 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/websocket v1.5.3 github.com/harmony-one/abool v1.0.1 - github.com/harmony-one/bls v0.0.6 github.com/harmony-one/taggedrlp v0.1.4 github.com/harmony-one/vdf v0.0.0-20190924175951-620379da8849 github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d + github.com/herumi/bls-eth-go-binary v1.37.0 github.com/ipfs/go-ds-badger v0.3.0 github.com/json-iterator/go v1.1.12 github.com/libp2p/go-libp2p v0.36.2 diff --git a/go.sum b/go.sum index c50ab74642..cfb51d999a 100644 --- a/go.sum +++ b/go.sum @@ -645,8 +645,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqC github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/harmony-one/abool v1.0.1 h1:SjXLmrr3W8h6lY37gRuWtLiRknUOchnUnsXJWK6Gbm4= github.com/harmony-one/abool v1.0.1/go.mod h1:9sq0PJzb1SqRpKrpEV4Ttvm9WV5uud8sfrsPw3AIBJA= -github.com/harmony-one/bls v0.0.6 h1:KG4q4JwdkPf3DtFvJmAgMRWT6QdY1A/wqN/Qt+S4VaQ= -github.com/harmony-one/bls v0.0.6/go.mod h1:ML9osB/z3hR9WAYZVj7qH+IP6oaPRPmshDbxrQyia7g= github.com/harmony-one/taggedrlp v0.1.4 h1:RZ+qy0VCzT+d/mTfq23gH3an5tSvxOhg6AddLDO6tKw= github.com/harmony-one/taggedrlp v0.1.4/go.mod h1:osO5TRXLKdgCP+oj2J9qfqhywMOOA+4nP5q+o8nDSYA= github.com/harmony-one/vdf v0.0.0-20190924175951-620379da8849 h1:rMY4jLAen3pMTq9KO7kSXzuMaicnOHP5n1MgpA1T6G4= @@ -686,6 +684,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/herumi/bls-eth-go-binary v1.37.0 h1:EaLF+MWndrF3Vbd9VkbG0T9tad3wBbGwh+6kCYcY5QA= +github.com/herumi/bls-eth-go-binary v1.37.0/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gto8n9hAmRxKxoar0iE6BLucjw= github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e/go.mod h1:j9cQbcqHQujT0oKJ38PylVfqohClLr3CvDC+Qcg+lhU= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= diff --git a/internal/blsgen/helper.go b/internal/blsgen/helper.go index a1b178a78b..a9856743ed 100644 --- a/internal/blsgen/helper.go +++ b/internal/blsgen/helper.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/multibls" ) diff --git a/internal/blsgen/helper_test.go b/internal/blsgen/helper_test.go index bd5580f00e..03c0bc462a 100644 --- a/internal/blsgen/helper_test.go +++ b/internal/blsgen/helper_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" ) const ( diff --git a/internal/blsgen/kms.go b/internal/blsgen/kms.go index 0a197a54e0..4bc5bf8e5b 100644 --- a/internal/blsgen/kms.go +++ b/internal/blsgen/kms.go @@ -11,7 +11,7 @@ import ( "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/kms" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/pkg/errors" ) diff --git a/internal/blsgen/kms_test.go b/internal/blsgen/kms_test.go index 7fde9fdfcb..1e0f737902 100644 --- a/internal/blsgen/kms_test.go +++ b/internal/blsgen/kms_test.go @@ -13,8 +13,8 @@ import ( "github.com/aws/aws-sdk-go/service/kms" "github.com/ethereum/go-ethereum/common" - ffi_bls "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + ffi_bls "github.com/harmony-one/harmony/crypto/bls/core" ) var TestAwsConfig = AwsConfig{ diff --git a/internal/blsgen/lib.go b/internal/blsgen/lib.go index ec1edc0b4f..c46a3b21df 100644 --- a/internal/blsgen/lib.go +++ b/internal/blsgen/lib.go @@ -12,8 +12,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/kms" - ffi_bls "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + ffi_bls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/pkg/errors" ) diff --git a/internal/blsgen/loader.go b/internal/blsgen/loader.go index 4a3b1dc6aa..87982ca0bc 100644 --- a/internal/blsgen/loader.go +++ b/internal/blsgen/loader.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/multibls" ) diff --git a/internal/blsgen/passphrase.go b/internal/blsgen/passphrase.go index e26a0a1ebd..f01a368dbe 100644 --- a/internal/blsgen/passphrase.go +++ b/internal/blsgen/passphrase.go @@ -8,7 +8,7 @@ import ( "strings" "sync" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" ) // PassSrcType is the type of passphrase provider source. diff --git a/internal/blsgen/utils.go b/internal/blsgen/utils.go index 0ab96f4c96..a0118bbfbe 100644 --- a/internal/blsgen/utils.go +++ b/internal/blsgen/utils.go @@ -5,7 +5,7 @@ import ( "os" "strings" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" ) func loadBasicKeyWithProvider(blsKeyFile string, pp passProvider) (*bls_core.SecretKey, error) { diff --git a/internal/chain/engine.go b/internal/chain/engine.go index 8b701a3dce..8500361751 100644 --- a/internal/chain/engine.go +++ b/internal/chain/engine.go @@ -10,7 +10,7 @@ import ( "github.com/harmony-one/harmony/internal/params" "github.com/harmony-one/harmony/numeric" - bls2 "github.com/harmony-one/bls/ffi/go/bls" + bls2 "github.com/harmony-one/harmony/crypto/bls/core" blsvrf "github.com/harmony-one/harmony/crypto/vrf/bls" "github.com/ethereum/go-ethereum/common" diff --git a/internal/chain/engine_test.go b/internal/chain/engine_test.go index 677cb26a53..170cce75fd 100644 --- a/internal/chain/engine_test.go +++ b/internal/chain/engine_test.go @@ -7,12 +7,12 @@ import ( "time" "github.com/ethereum/go-ethereum/trie" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/consensus/engine" consensus_sig "github.com/harmony-one/harmony/consensus/signature" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/numeric" "github.com/harmony-one/harmony/shard" "github.com/harmony-one/harmony/staking/effective" diff --git a/internal/chain/sig.go b/internal/chain/sig.go index 23b51d5f1b..912c95cbd2 100644 --- a/internal/chain/sig.go +++ b/internal/chain/sig.go @@ -3,7 +3,7 @@ package chain import ( "errors" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/bls" "github.com/harmony-one/harmony/internal/utils" diff --git a/internal/configs/node/config.go b/internal/configs/node/config.go index 6f7caf3cf7..c694dcc4f4 100644 --- a/internal/configs/node/config.go +++ b/internal/configs/node/config.go @@ -10,8 +10,8 @@ import ( "sync" "time" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/harmony-one/harmony/internal/params" "github.com/harmony-one/harmony/multibls" diff --git a/internal/configs/node/config_test.go b/internal/configs/node/config_test.go index 9a6606c4f9..8a116afa34 100644 --- a/internal/configs/node/config_test.go +++ b/internal/configs/node/config_test.go @@ -3,8 +3,8 @@ package nodeconfig import ( "testing" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/blsgen" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" diff --git a/internal/genesis/genesis_test.go b/internal/genesis/genesis_test.go index 4ae5f8a423..59cf5425df 100644 --- a/internal/genesis/genesis_test.go +++ b/internal/genesis/genesis_test.go @@ -7,7 +7,7 @@ import ( "github.com/btcsuite/btcutil/bech32" ethCommon "github.com/ethereum/go-ethereum/common" - "github.com/harmony-one/bls/ffi/go/bls" + bls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/common" ) diff --git a/internal/registry/registry.go b/internal/registry/registry.go index 5152eb28e0..fe9f241a12 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -5,10 +5,10 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/consensus/engine" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/core" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/internal/shardchain" "github.com/harmony-one/harmony/multibls" diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 28af81aed8..b277e77d33 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -15,8 +15,8 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" p2p_crypto "github.com/libp2p/go-libp2p/core/crypto" "github.com/pkg/errors" ) diff --git a/multibls/multibls.go b/multibls/multibls.go index dc09d9a868..22bb84ba19 100644 --- a/multibls/multibls.go +++ b/multibls/multibls.go @@ -5,8 +5,8 @@ import ( "github.com/harmony-one/harmony/internal/utils" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" ) // PrivateKeys stores the bls secret keys that belongs to the node diff --git a/node/harmony/addresses.go b/node/harmony/addresses.go index 44279981c2..6ee8d6d657 100644 --- a/node/harmony/addresses.go +++ b/node/harmony/addresses.go @@ -5,8 +5,8 @@ import ( "sync" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" common2 "github.com/harmony-one/harmony/internal/common" "github.com/harmony-one/harmony/internal/registry" "github.com/harmony-one/harmony/internal/utils" diff --git a/node/harmony/node_cross_link.go b/node/harmony/node_cross_link.go index c772a9309d..271c842621 100644 --- a/node/harmony/node_cross_link.go +++ b/node/harmony/node_cross_link.go @@ -6,9 +6,9 @@ import ( common2 "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - ffi_bls "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/core" "github.com/harmony-one/harmony/core/types" + ffi_bls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/shard" "github.com/pkg/errors" diff --git a/node/harmony/node_test.go b/node/harmony/node_test.go index c7444d8d8f..48c5a504a8 100644 --- a/node/harmony/node_test.go +++ b/node/harmony/node_test.go @@ -9,10 +9,10 @@ import ( "testing" "time" - ffi_bls "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/consensus/quorum" "github.com/harmony-one/harmony/core" + ffi_bls "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/internal/chain" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/internal/registry" diff --git a/node/harmony/worker/slash_duplicate_reporter_test.go b/node/harmony/worker/slash_duplicate_reporter_test.go index ad3f6b6447..d5229b3a84 100644 --- a/node/harmony/worker/slash_duplicate_reporter_test.go +++ b/node/harmony/worker/slash_duplicate_reporter_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" blockfactory "github.com/harmony-one/harmony/block/factory" consensus_sig "github.com/harmony-one/harmony/consensus/signature" @@ -16,6 +15,7 @@ import ( "github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" chain2 "github.com/harmony-one/harmony/internal/chain" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" diff --git a/p2p/host.go b/p2p/host.go index c89fbc9189..23dbb33322 100644 --- a/p2p/host.go +++ b/p2p/host.go @@ -14,9 +14,9 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/harmony-one/abool" - "github.com/harmony-one/bls/ffi/go/bls" prom "github.com/harmony-one/harmony/api/service/prometheus" "github.com/harmony-one/harmony/common/clock" + bls "github.com/harmony-one/harmony/crypto/bls/core" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/internal/utils/blockedpeers" @@ -496,10 +496,14 @@ func NewHost(cfg HostConfig) (Host, error) { trustedPeersDnsResolvedCounter.Add(0) trustedPeersConnectFailuresCounter.Add(0) + consensusPubKey := "" + if self.ConsensusPubKey != nil { + consensusPubKey = self.ConsensusPubKey.SerializeToHexStr() + } utils.Logger().Info(). Str("self", net.JoinHostPort(self.IP, self.Port)). Interface("PeerID", self.PeerID). - Str("PubKey", self.ConsensusPubKey.SerializeToHexStr()). + Str("PubKey", consensusPubKey). Msg("libp2p host ready") return h, nil } diff --git a/rosetta/infra/Dockerfile b/rosetta/infra/Dockerfile index 28d11a885f..9b925b81fe 100644 --- a/rosetta/infra/Dockerfile +++ b/rosetta/infra/Dockerfile @@ -12,9 +12,7 @@ RUN mkdir -p $HMY_PATH WORKDIR $HMY_PATH -RUN git clone https://github.com/harmony-one/harmony.git && \ - git clone https://github.com/harmony-one/bls.git && \ - git clone https://github.com/harmony-one/mcl.git +RUN git clone https://github.com/harmony-one/harmony.git WORKDIR $HMY_PATH/harmony diff --git a/scripts/go_executable_build.sh b/scripts/go_executable_build.sh index 05c465cecf..5a43dc43da 100755 --- a/scripts/go_executable_build.sh +++ b/scripts/go_executable_build.sh @@ -34,22 +34,13 @@ case "${0}" in *) progdir=.;; esac -. "${progdir}/setup_bls_build_flags.sh" - declare -A LIB if [ "$(uname -s)" == "Darwin" ]; then MD5='md5 -r' GOOS=darwin - LIB[libbls384_256.dylib]=${BLS_DIR}/lib/libbls384_256.dylib - LIB[libmcl.dylib]=${MCL_DIR}/lib/libmcl.dylib - LIB[libgmp.10.dylib]=/opt/homebrew/opt/gmp/lib/libgmp.10.dylib - LIB[libgmpxx.4.dylib]=/opt/homebrew/opt/gmp/lib/libgmpxx.4.dylib - LIB[libcrypto.1.1.dylib]=/opt/homebrew/opt/openssl@1.1/lib/libcrypto.1.1.dylib else MD5=md5sum - LIB[libbls384_256.so]=${BLS_DIR}/lib/libbls384_256.so - LIB[libmcl.so]=${MCL_DIR}/lib/libmcl.so fi function usage @@ -155,11 +146,7 @@ function build_only fi done - $MD5 "${!SRC[@]}" "${!LIB[@]}" > md5sum.txt - # hardcode the prebuilt libcrypto to md5sum.txt - if [ "$(uname -s)" == "Linux" ]; then - echo '771150db04267126823190c873a96e48 libcrypto.so.10' >> md5sum.txt - fi + $MD5 "${!SRC[@]}" > md5sum.txt fi popd } diff --git a/scripts/macos_docker/Dockerfile b/scripts/macos_docker/Dockerfile index e8ad312bb6..bedc81bd99 100644 --- a/scripts/macos_docker/Dockerfile +++ b/scripts/macos_docker/Dockerfile @@ -9,11 +9,6 @@ ENV GOPATH=/root/go ENV GO111MODULE=on ENV HMY_PATH=${GOPATH}/src/github.com/harmony-one ENV OPENSSL_DIR=/usr/lib/ssl -ENV MCL_DIR=${HMY_PATH}/mcl -ENV BLS_DIR=${HMY_PATH}/bls -ENV CGO_CFLAGS="-I${BLS_DIR}/include -I${MCL_DIR}/include" -ENV CGO_LDFLAGS="-L${BLS_DIR}/lib" -ENV LD_LIBRARY_PATH=${BLS_DIR}/lib:${MCL_DIR}/lib ENV GIMME_GO_VERSION=${GOLANG_VERSION} ENV PATH="/root/bin:${PATH}" @@ -31,18 +26,8 @@ RUN eval "$(~/bin/gimme ${GIMME_GO_VERSION})" #RUN git clone https://github.com/harmony-one/harmony.git ${HMY_PATH}/harmony -RUN git clone https://github.com/harmony-one/mcl.git ${HMY_PATH}/mcl && \ - echo "mcl repository cloned" && \ - ls -la ${HMY_PATH}/mcl # List the contents of the mcl directory - -RUN git clone https://github.com/harmony-one/bls.git ${HMY_PATH}/bls && \ - echo "bls repository cloned" && \ - ls -la ${HMY_PATH}/bls # List the contents of the bls directory - RUN git clone https://github.com/harmony-one/go-sdk.git ${HMY_PATH}/go-sdk -RUN cd ${HMY_PATH}/bls && make -j8 BLS_SWAP_G=1 - RUN touch /root/.bash_profile && \ gimme ${GIMME_GO_VERSION} >> /root/.bash_profile && \ echo "GIMME_GO_VERSION='${GIMME_GO_VERSION}'" >> /root/.bash_profile && \ @@ -61,4 +46,3 @@ RUN . ~/.bash_profile; \ go install github.com/stamblerre/gocode; \ go install golang.org/x/tools/...; \ go install honnef.co/go/tools/cmd/staticcheck/... - diff --git a/scripts/setup_bls_build_flags.sh b/scripts/setup_bls_build_flags.sh deleted file mode 100644 index 92ee20579e..0000000000 --- a/scripts/setup_bls_build_flags.sh +++ /dev/null @@ -1,44 +0,0 @@ -# no shebang; to be sourced from other scripts - -unset -v progdir -case "${0}" in -*/*) progdir="${0%/*}";; -*) progdir=.;; -esac - -case "${HMY_PATH+set}" in -"") - unset -v gopath - gopath=$(go env GOPATH) - # HMY_PATH is the common root directory of all harmony repos - HMY_PATH="${gopath%%:*}/src/github.com/harmony-one" - if [ ! -d $HMY_PATH ]; then - # "env pwd" uses external pwd(1) implementation and not the Bash built-in, - # which does not fully dereference symlinks. - HMY_PATH=$(cd $progdir/../.. && env pwd) - fi - ;; -esac -: ${OPENSSL_DIR="/opt/homebrew/opt/openssl@1.1"} -: ${MCL_DIR="${HMY_PATH}/mcl"} -: ${BLS_DIR="${HMY_PATH}/bls"} -export CGO_CFLAGS="-I${BLS_DIR}/include -I${MCL_DIR}/include" -export CGO_LDFLAGS="-L${BLS_DIR}/lib" -export LD_LIBRARY_PATH=${BLS_DIR}/lib:${MCL_DIR}/lib - -OS=$(uname -s) -case $OS in - Darwin) - export CGO_CFLAGS="-I${BLS_DIR}/include -I${MCL_DIR}/include -I${OPENSSL_DIR}/include" - export CGO_LDFLAGS="-L${BLS_DIR}/lib -L${OPENSSL_DIR}/lib" - export LD_LIBRARY_PATH=${BLS_DIR}/lib:${MCL_DIR}/lib:${OPENSSL_DIR}/lib - export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH - ;; -esac - -if [ "$1" = "-v" ]; then - echo "{ \"CGO_CFLAGS\" : \"$CGO_CFLAGS\", - \"CGO_LDFLAGS\" : \"$CGO_LDFLAGS\", - \"LD_LIBRARY_PATH\" : \"$LD_LIBRARY_PATH\", - \"DYLD_FALLBACK_LIBRARY_PATH\" : \"$DYLD_FALLBACK_LIBRARY_PATH\"}" | jq "." -fi diff --git a/scripts/travis_go_checker.sh b/scripts/travis_go_checker.sh index c6c7640caf..d115ce50e5 100755 --- a/scripts/travis_go_checker.sh +++ b/scripts/travis_go_checker.sh @@ -14,8 +14,6 @@ tmpdir= trap 'case "${tmpdir}" in ?*) rm -rf "${tmpdir}";; esac' EXIT tmpdir=$(mktemp -d) -. "${progdir}/setup_bls_build_flags.sh" - echo "Checking go.mod..." gomod_diff_output="${tmpdir}/gomod.diff" if git diff --exit-code -- go.mod > "${gomod_diff_output}" diff --git a/shard/committee/assignment.go b/shard/committee/assignment.go index 5fba3e6200..57f8153d62 100644 --- a/shard/committee/assignment.go +++ b/shard/committee/assignment.go @@ -9,9 +9,9 @@ import ( "github.com/harmony-one/harmony/crypto/bls" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/block" "github.com/harmony-one/harmony/core/types" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" common2 "github.com/harmony-one/harmony/internal/common" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" diff --git a/staking/effective/calculate_test.go b/staking/effective/calculate_test.go index 7127192c3b..ebbde3e7be 100644 --- a/staking/effective/calculate_test.go +++ b/staking/effective/calculate_test.go @@ -9,8 +9,8 @@ import ( "sort" "testing" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/ethereum/go-ethereum/common" "github.com/harmony-one/harmony/numeric" diff --git a/staking/slash/double-sign.go b/staking/slash/double-sign.go index dbbeb6a66a..03e6dbf78a 100644 --- a/staking/slash/double-sign.go +++ b/staking/slash/double-sign.go @@ -9,9 +9,9 @@ import ( "github.com/harmony-one/harmony/shard" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" consensus_sig "github.com/harmony-one/harmony/consensus/signature" "github.com/harmony-one/harmony/core/state" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" common2 "github.com/harmony-one/harmony/internal/common" "github.com/harmony-one/harmony/internal/utils" diff --git a/staking/slash/double-sign_test.go b/staking/slash/double-sign_test.go index fcb0972c75..506ea949d2 100644 --- a/staking/slash/double-sign_test.go +++ b/staking/slash/double-sign_test.go @@ -13,11 +13,11 @@ import ( "github.com/harmony-one/harmony/crypto/bls" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" blockfactory "github.com/harmony-one/harmony/block/factory" consensus_sig "github.com/harmony-one/harmony/consensus/signature" "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/harmony-one/harmony/internal/params" "github.com/harmony-one/harmony/numeric" @@ -324,7 +324,7 @@ func TestVerify(t *testing.T) { sdb: defaultTestStateDB(), chain: defaultFakeBlockChain(), - expErr: errors.New("Empty buf"), + expErr: errors.New("err blsSignatureDeserialize"), }, { // false signature diff --git a/staking/types/transaction_test.go b/staking/types/transaction_test.go index 55f21053aa..2d251c54cf 100644 --- a/staking/types/transaction_test.go +++ b/staking/types/transaction_test.go @@ -9,7 +9,7 @@ import ( "github.com/harmony-one/harmony/crypto/bls" "github.com/ethereum/go-ethereum/common" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" common2 "github.com/harmony-one/harmony/internal/common" numeric "github.com/harmony-one/harmony/numeric" ) diff --git a/staking/types/validator.go b/staking/types/validator.go index 4f35a03e4f..395fdeec6b 100644 --- a/staking/types/validator.go +++ b/staking/types/validator.go @@ -9,9 +9,9 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - bls_core "github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/harmony/common/denominations" "github.com/harmony-one/harmony/consensus/votepower" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" common2 "github.com/harmony-one/harmony/internal/common" "github.com/harmony-one/harmony/internal/genesis" diff --git a/test/chain/reward/main.go b/test/chain/reward/main.go index aee4c4ed0e..4482cf27cc 100644 --- a/test/chain/reward/main.go +++ b/test/chain/reward/main.go @@ -8,7 +8,6 @@ import ( common2 "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - bls_core "github.com/harmony-one/bls/ffi/go/bls" msg_pb "github.com/harmony-one/harmony/api/proto/message" blockfactory "github.com/harmony-one/harmony/block/factory" "github.com/harmony-one/harmony/core" @@ -16,6 +15,7 @@ import ( "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/crypto/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" "github.com/harmony-one/harmony/internal/chain" "github.com/harmony-one/harmony/internal/common" diff --git a/test/chain/vrf/main.go b/test/chain/vrf/main.go index 1a44b9e416..81f503c605 100644 --- a/test/chain/vrf/main.go +++ b/test/chain/vrf/main.go @@ -7,7 +7,7 @@ import ( "github.com/harmony-one/harmony/crypto/bls" - bls_core "github.com/harmony-one/bls/ffi/go/bls" + bls_core "github.com/harmony-one/harmony/crypto/bls/core" "github.com/harmony-one/harmony/crypto/hash" vrf_bls "github.com/harmony-one/harmony/crypto/vrf/bls" ) diff --git a/test/deploy.sh b/test/deploy.sh index b06e35cf01..69a86ca5bc 100755 --- a/test/deploy.sh +++ b/test/deploy.sh @@ -11,8 +11,6 @@ ROOT="${progdir}/.." USER=$(whoami) OS=$(uname -s) -. "${ROOT}/scripts/setup_bls_build_flags.sh" - function cleanup() { if [[ "${CLEAN_START}" == "true" ]]; then "${progdir}/kill_node.sh" diff --git a/test/deploy_newnode.sh b/test/deploy_newnode.sh index a678a5314a..29a1bdf83c 100755 --- a/test/deploy_newnode.sh +++ b/test/deploy_newnode.sh @@ -3,8 +3,6 @@ ROOT=$(dirname $0)/.. USER=$(whoami) -. "${ROOT}/scripts/setup_bls_build_flags.sh" - set -x set -eo pipefail diff --git a/test/helpers/p2p.go b/test/helpers/p2p.go index aaf087452c..6bb9af06a7 100644 --- a/test/helpers/p2p.go +++ b/test/helpers/p2p.go @@ -1,8 +1,8 @@ package helpers import ( - "github.com/harmony-one/bls/ffi/go/bls" harmony_bls "github.com/harmony-one/harmony/crypto/bls" + bls "github.com/harmony-one/harmony/crypto/bls/core" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/p2p" libp2p_crypto "github.com/libp2p/go-libp2p/core/crypto"