Merge branch 'master' of github.com:harmony-one/harmony into goimports

pull/321/head
Eugene Kim 6 years ago
commit 57e934b08d
  1. 19
      README.md
  2. 1
      cmd/client/txgen/main.go
  3. 1
      cmd/harmony.go
  4. 11
      consensus/consensus_leader.go
  5. 6
      consensus/consensus_validator.go
  6. 4
      crypto/bls/bls.go
  7. 6
      crypto/pki/utils.go
  8. 4
      internal/utils/utils.go
  9. BIN
      test/crypto/bls/main
  10. 4
      test/crypto/bls/main.go

@ -4,16 +4,35 @@
<a href="https://discord.gg/kdf8a6T">![Discord](https://img.shields.io/discord/532383335348043777.svg)</a>
[![Coverage Status](https://coveralls.io/repos/github/harmony-one/harmony/badge.svg?branch=master)](https://coveralls.io/github/harmony-one/harmony?branch=master)
## Installation Requirements
GMP and OpenSSL
```bash
brew install gmp
brew install openssl
```
## Dev Environment Setup
```bash
export GOPATH=$HOME/<path_of_your_choice>
export CGO_CFLAGS="-I$GOPATH/src/github.com/harmony-one/bls/include -I$GOPATH/src/github.com/harmony-one/mcl/include -I/usr/local/opt/openssl/include"
export CGO_LDFLAGS="-L$GOPATH/src/github.com/harmony-one/bls/lib -L/usr/local/opt/openssl/lib"
export LD_LIBRARY_PATH=$GOPATH/src/github.com/harmony-one/bls/lib:$GOPATH/src/github.com/harmony-one/mcl/lib:/usr/local/opt/openssl/lib
export LIBRARY_PATH=$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
mkdir -p $HOME/<path_of_your_choice>/src/github.com/harmony-one
cd $HOME/<path_of_your_choice>/src/github.com/harmony-one
git clone git@github.com:harmony-one/mcl.git
cd mcl && make -j4 && cd ..
git clone git@github.com:harmony-one/bls.git
cd bls && make -j4 && cd ..
git clone git@github.com:harmony-one/harmony.git
cd harmony

@ -22,7 +22,6 @@ import (
"github.com/harmony-one/harmony/p2p/p2pimpl"
peerstore "github.com/libp2p/go-libp2p-peerstore"
multiaddr "github.com/multiformats/go-multiaddr"
)
var (

@ -20,7 +20,6 @@ import (
"github.com/harmony-one/harmony/p2p"
"github.com/harmony-one/harmony/p2p/p2pimpl"
peerstore "github.com/libp2p/go-libp2p-peerstore"
multiaddr "github.com/multiformats/go-multiaddr"
)
var (

@ -183,7 +183,7 @@ func (consensus *Consensus) processPrepareMessage(message consensus_proto.Messag
// Broadcast prepared message
host.BroadcastMessageFromLeader(consensus.host, consensus.GetValidatorPeers(), msgToSend, consensus.OfflinePeers)
// Set state to targetState (ChallengeDone or FinalChallengeDone)
// Set state to targetState
consensus.state = targetState
}
}
@ -264,9 +264,8 @@ func (consensus *Consensus) processCommitMessage(message consensus_proto.Message
return
}
threshold := 2
targetState := CommitDone
if len(*commitSigs) >= ((len(consensus.PublicKeys)*threshold)/3+1) && consensus.state != targetState {
targetState := CommittedDone
if len(*commitSigs) >= ((len(consensus.PublicKeys)*2)/3+1) && consensus.state != targetState {
utils.GetLogInstance().Info("Enough commits received!", "num", len(*commitSigs), "state", consensus.state)
// Construct committed message
@ -276,9 +275,6 @@ func (consensus *Consensus) processCommitMessage(message consensus_proto.Message
// Broadcast committed message
host.BroadcastMessageFromLeader(consensus.host, consensus.GetValidatorPeers(), msgToSend, consensus.OfflinePeers)
// Set state to CollectiveSigDone or Finished
consensus.state = targetState
var blockObj types.Block
err = rlp.DecodeBytes(consensus.block, &blockObj)
if err != nil {
@ -312,7 +308,6 @@ func (consensus *Consensus) processCommitMessage(message consensus_proto.Message
time.Sleep(500 * time.Millisecond)
// Send signal to Node so the new block can be added and new round of consensus can be triggered
consensus.ReadySignal <- struct{}{}
consensus.state = Finished
}
}

@ -105,7 +105,7 @@ func (consensus *Consensus) processAnnounceMessage(message consensus_proto.Messa
consensus.SendMessage(consensus.leader, msgToSend)
// utils.GetLogInstance().Warn("Sending Commit to leader", "state", targetState)
// Set state to CommitDone
// Set state to PrepareDone
consensus.state = PrepareDone
}
@ -255,7 +255,7 @@ func (consensus *Consensus) processCommittedMessage(message consensus_proto.Mess
consensus.SendMessage(consensus.leader, msgToSend)
consensus.state = PrepareDone
consensus.state = CommittedDone
// TODO: the block catch up logic is a temporary workaround for full failure node catchup. Implement the full node catchup logic
// The logic is to roll up to the latest blocks one by one to try catching up with the leader.
@ -283,6 +283,7 @@ func (consensus *Consensus) processCommittedMessage(message consensus_proto.Mess
}
utils.GetLogInstance().Info("Finished Response. Adding block to chain", "numTx", len(blockObj.Transactions()))
consensus.OnConsensusDone(&blockObj)
consensus.state = Finished
select {
case consensus.VerifiedNewBlock <- &blockObj:
@ -290,7 +291,6 @@ func (consensus *Consensus) processCommittedMessage(message consensus_proto.Mess
utils.GetLogInstance().Info("[SYNC] consensus verified block send to chan failed", "blockHash", blockObj.Hash())
continue
}
} else {
break
}

@ -7,6 +7,10 @@ import (
"github.com/harmony-one/bls/ffi/go/bls"
)
func init() {
bls.Init(bls.BLS12_381)
}
// AggregateSig aggregates all the BLS signature into a single multi-signature.
func AggregateSig(sigs []*bls.Sign) *bls.Sign {
var aggregatedSig bls.Sign

@ -4,13 +4,15 @@ import (
"crypto/sha256"
"encoding/binary"
"github.com/harmony-one/bls/ffi/go/bls"
"github.com/dedis/kyber"
"github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/crypto"
)
func init() {
bls.Init(bls.BLS12_381)
}
// GetAddressFromPublicKey returns address given a public key.
func GetAddressFromPublicKey(pubKey *bls.PublicKey) [20]byte {
bytes := pubKey.Serialize()

@ -24,6 +24,10 @@ import (
var lock sync.Mutex
func init() {
bls.Init(bls.BLS12_381)
}
// Unmarshal is a function that unmarshals the data from the
// reader into the specified value.
func Unmarshal(r io.Reader, v interface{}) error {

Binary file not shown.

@ -13,6 +13,10 @@ import (
"github.com/harmony-one/bls/ffi/go/bls"
)
func init() {
bls.Init(bls.BLS12_381)
}
func main() {
m := "message to sign"
var aggSig *bls.Sign

Loading…
Cancel
Save