pull/4377/head
frozen 2 years ago committed by Casey Gardiner
parent 5874c3082c
commit 37d82f99ad
  1. 48
      api/service/explorer/service.go
  2. 3
      cmd/harmony/main.go
  3. 13
      consensus/consensus_v2.go
  4. 11
      consensus/validator.go
  5. 7
      consensus/view_change.go
  6. 1
      node/node_newblock.go
  7. 31
      test/configs/local-resharding.txt
  8. 5
      test/deploy.sh

@ -7,13 +7,11 @@ import (
"fmt"
"net"
"net/http"
"os"
"path"
"strconv"
"time"
"github.com/RoaringBitmap/roaring/roaring64"
"github.com/harmony-one/harmony/internal/common"
harmonyconfig "github.com/harmony-one/harmony/internal/configs/harmony"
ethCommon "github.com/ethereum/go-ethereum/common"
@ -121,9 +119,6 @@ func (s *Service) Run() *http.Server {
s.router.Path("/addresses").Queries("size", "{[0-9]*?}", "prefix", "{[a-zA-Z0-9]*?}").HandlerFunc(s.GetAddresses).Methods("GET")
s.router.Path("/addresses").HandlerFunc(s.GetAddresses)
s.router.Path("/height").HandlerFunc(s.GetHeight)
s.router.Path("/leader").HandlerFunc(s.GetLeader)
s.router.Path("/blocks").HandlerFunc(s.GetBlocks)
s.router.Path("/halt").HandlerFunc(s.halt)
// Set up router for supply info
s.router.Path("/burn-addresses").Queries().HandlerFunc(s.GetInaccessibleAddressInfo).Methods("GET")
@ -191,49 +186,6 @@ type HeightResponse struct {
S3 uint64 `json:"3,omitempty"`
}
func (s *Service) GetLeader(w http.ResponseWriter, r *http.Request) {
if s.backend.IsCurrentlyLeader() {
w.Write([]byte("true "))
} else {
w.Write([]byte("false"))
}
keys := ""
for _, p := range s.backend.GetPublicKeys() {
addr := common.Address{}
addrBytes := p.Object.GetAddress()
addr.SetBytes(addrBytes[:])
keys += fmt.Sprintf("%s ", addr.String())
break
}
//blsPubKeyBytes := leaderKey.Object.GetAddress()
//coinbase.SetBytes(blsPubKeyBytes[:])
w.Write([]byte(fmt.Sprintf(" %d", s.blockchain.ShardID())))
w.Write([]byte(fmt.Sprintf(" %s", s.Port)))
w.Write([]byte(fmt.Sprintf(" %s", keys)))
w.Write([]byte(fmt.Sprintf(" %s", s.backend.GetPublicKeys().SerializeToHexStr())))
}
func (s *Service) GetBlocks(w http.ResponseWriter, r *http.Request) {
cur := s.blockchain.CurrentHeader().Number().Uint64()
for i := cur; i > 0; i-- {
block := s.blockchain.GetBlockByNumber(i)
leaderPubKey, _ := chain.GetLeaderPubKeyFromCoinbase(s.backend.Blockchain(), block.Header())
w.Write([]byte(fmt.Sprintf("%s ", leaderPubKey.Bytes.Hex())))
w.Write([]byte(fmt.Sprintf("#%d ", i)))
w.Write([]byte(fmt.Sprintf("v%s ", block.Header().ViewID().String())))
w.Write([]byte(fmt.Sprintf("e%d ", block.Header().Epoch().Uint64())))
w.Write([]byte(fmt.Sprintf("%s\n", block.Header().Coinbase().Hex())))
}
}
func (s *Service) halt(w http.ResponseWriter, r *http.Request) {
os.Exit(0)
}
// GetHeight returns heights of current and beacon chains if needed.
func (s *Service) GetHeight(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")

@ -425,9 +425,8 @@ func setupNodeAndRun(hc harmonyconfig.HarmonyConfig) {
if currentNode.NodeConfig.Role() == nodeconfig.Validator {
currentNode.RegisterValidatorServices()
} else if currentNode.NodeConfig.Role() == nodeconfig.ExplorerNode {
currentNode.RegisterExplorerServices()
}
currentNode.RegisterExplorerServices()
currentNode.RegisterService(service.CrosslinkSending, crosslink_sending.New(currentNode, currentNode.Blockchain()))
if hc.Pprof.Enabled {
setupPprofService(currentNode, hc)

@ -678,8 +678,6 @@ func (consensus *Consensus) tryCatchup() error {
}
func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMessage) error {
// this function evaluates for all, leader and validators.
if consensus.Blockchain().CurrentBlock().NumberU64() < blk.NumberU64() {
if _, err := consensus.Blockchain().InsertChain([]*types.Block{blk}, !consensus.FBFTLog.IsBlockVerified(blk.Hash())); err != nil {
consensus.getLogger().Error().Err(err).Msg("[commitBlock] Failed to add block to chain")
@ -777,17 +775,6 @@ func (consensus *Consensus) setupForNewConsensus(blk *types.Block, committedMsg
consensus.resetState()
}
func (consensus *Consensus) getEpochFirstBlockViewID(epoch *big.Int) (uint64, error) {
if epoch.Uint64() == 0 {
return 0, nil
}
epochBlock := consensus.Blockchain.GetBlockByNumber(shard.Schedule.EpochLastBlock(epoch.Uint64() - 1))
if epochBlock == nil {
return 0, errors.Errorf("block not found for number %d", epoch.Uint64()-1)
}
return epochBlock.Header().ViewID().Uint64() + 1, nil
}
func (consensus *Consensus) postCatchup(initBN uint64) {
if initBN < consensus.BlockNum() {
consensus.getLogger().Info().

@ -18,7 +18,6 @@ import (
)
func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
recvMsg, err := consensus.parseFBFTMessage(msg)
if err != nil {
consensus.getLogger().Error().
@ -27,9 +26,6 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
Msg("[OnAnnounce] Unparseable leader message")
return
}
if consensus.ShardID == 0 {
//fmt.Println("onAnnounce called ", recvMsg.BlockNum)
}
// NOTE let it handle its own logs
if !consensus.onAnnounceSanityChecks(recvMsg) {
@ -398,13 +394,6 @@ func (consensus *Consensus) onCommitted(recvMsg *FBFTMessage) {
consensus.getLogger().Info().Msg("[OnCommitted] Start consensus timer (new block added)")
consensus.consensusTimeout[timeoutConsensus].Start()
}
//fmt.Println("onCommitted", utils.GetPort(), recvMsg.BlockNum)
if blk != nil {
//consensus.ReshardingNextLeader(blk)
} else {
//fmt.Println("onCommitted", utils.GetPort(), recvMsg.BlockNum, "blk is nil")
}
}
// Collect private keys that are part of the current committee.

@ -367,13 +367,6 @@ func (consensus *Consensus) onViewChange(recvMsg *FBFTMessage) {
return
}
consensus.getLogger().Debug().
Err(err).
Interface("SenderPubkeys", recvMsg.SenderPubkeys).
Str("NextLeader", recvMsg.LeaderPubkey.Bytes.Hex()).
Str("myBLSPubKey", consensus.priKey.GetPublicKeys().SerializeToHexStr()).
Msg("[onViewChange] I am the Leader")
if consensus.Decider.IsQuorumAchievedByMask(consensus.vc.GetViewIDBitmap(recvMsg.ViewID)) {
consensus.getLogger().Info().
Int64("have", consensus.Decider.SignersCount(quorum.ViewChange)).

@ -2,7 +2,6 @@ package node
import (
"errors"
"fmt"
"sort"
"strings"
"time"

@ -1,12 +1,25 @@
127.0.0.1 9000 validator .hmy/65f55eb3052f9e9f632b2923be594ba77c55543f5c58ee1454b9cfd658d25e06373b0f7d42a19c84768139ea294f6204.key
127.0.0.1 9002 validator .hmy/02c8ff0b88f313717bc3a627d2f8bb172ba3ad3bb9ba3ecb8eed4b7c878653d3d4faf769876c528b73f343967f74a917.key
127.0.0.1 9004 validator .hmy/e751ec995defe4931273aaebcb2cd14bf37e629c554a57d3f334c37881a34a6188a93e76113c55ef3481da23b7d7ab09.key
127.0.0.1 9006 validator .hmy/2d61379e44a772e5757e27ee2b3874254f56073e6bd226eb8b160371cc3c18b8c4977bd3dcb71fd57dc62bf0e143fd08.key
127.0.0.1 9008 validator .hmy/86dc2fdc2ceec18f6923b99fd86a68405c132e1005cf1df72dca75db0adfaeb53d201d66af37916d61f079f34f21fb96.key
127.0.0.1 9010 validator .hmy/95117937cd8c09acd2dfae847d74041a67834ea88662a7cbed1e170350bc329e53db151e5a0ef3e712e35287ae954818.key
127.0.0.1 9099 explorer null 0
127.0.0.1 9002 validator .hmy/40379eed79ed82bebfb4310894fd33b6a3f8413a78dc4d43b98d0adc9ef69f3285df05eaab9f2ce5f7227f8cb920e809.key
127.0.0.1 9004 validator .hmy/02c8ff0b88f313717bc3a627d2f8bb172ba3ad3bb9ba3ecb8eed4b7c878653d3d4faf769876c528b73f343967f74a917.key
127.0.0.1 9006 validator .hmy/ee2474f93cba9241562efc7475ac2721ab0899edf8f7f115a656c0c1f9ef8203add678064878d174bb478fa2e6630502.key
127.0.0.1 9008 validator .hmy/e751ec995defe4931273aaebcb2cd14bf37e629c554a57d3f334c37881a34a6188a93e76113c55ef3481da23b7d7ab09.key
127.0.0.1 9010 validator .hmy/776f3b8704f4e1092a302a60e84f81e476c212d6f458092b696df420ea19ff84a6179e8e23d090b9297dc041600bc100.key
127.0.0.1 9012 validator .hmy/2d61379e44a772e5757e27ee2b3874254f56073e6bd226eb8b160371cc3c18b8c4977bd3dcb71fd57dc62bf0e143fd08.key
127.0.0.1 9014 validator .hmy/c4e4708b6cf2a2ceeb59981677e9821eebafc5cf483fb5364a28fa604cc0ce69beeed40f3f03815c9e196fdaec5f1097.key
127.0.0.1 9016 validator .hmy/86dc2fdc2ceec18f6923b99fd86a68405c132e1005cf1df72dca75db0adfaeb53d201d66af37916d61f079f34f21fb96.key
127.0.0.1 9018 validator .hmy/49d15743b36334399f9985feb0753430a2b287b2d68b84495bbb15381854cbf01bca9d1d9f4c9c8f18509b2bfa6bd40f.key
127.0.0.1 9020 validator .hmy/95117937cd8c09acd2dfae847d74041a67834ea88662a7cbed1e170350bc329e53db151e5a0ef3e712e35287ae954818.key
127.0.0.1 9022 validator .hmy/68ae289d73332872ec8d04ac256ca0f5453c88ad392730c5741b6055bc3ec3d086ab03637713a29f459177aaa8340615.key
127.0.0.1 9200 explorer null 0
127.0.0.1 9100 validator .hmy/52ecce5f64db21cbe374c9268188f5d2cdd5bec1a3112276a350349860e35fb81f8cfe447a311e0550d961cf25cb988d.key
127.0.0.1 9102 validator .hmy/678ec9670899bf6af85b877058bea4fc1301a5a3a376987e826e3ca150b80e3eaadffedad0fedfa111576fa76ded980c.key
127.0.0.1 9104 validator .hmy/16513c487a6bb76f37219f3c2927a4f281f9dd3fd6ed2e3a64e500de6545cf391dd973cc228d24f9bd01efe94912e714.key
127.0.0.1 9106 validator .hmy/eca09c1808b729ca56f1b5a6a287c6e1c3ae09e29ccf7efa35453471fcab07d9f73cee249e2b91f5ee44eb9618be3904.key
127.0.0.1 9102 validator .hmy/a547a9bf6fdde4f4934cde21473748861a3cc0fe8bbb5e57225a29f483b05b72531f002f8187675743d819c955a86100.key
127.0.0.1 9104 validator .hmy/678ec9670899bf6af85b877058bea4fc1301a5a3a376987e826e3ca150b80e3eaadffedad0fedfa111576fa76ded980c.key
127.0.0.1 9106 validator .hmy/63f479f249c59f0486fda8caa2ffb247209489dae009dfde6144ff38c370230963d360dffd318cfb26c213320e89a512.key
127.0.0.1 9108 validator .hmy/16513c487a6bb76f37219f3c2927a4f281f9dd3fd6ed2e3a64e500de6545cf391dd973cc228d24f9bd01efe94912e714.key
127.0.0.1 9110 validator .hmy/576d3c48294e00d6be4a22b07b66a870ddee03052fe48a5abbd180222e5d5a1f8946a78d55b025de21635fd743bbad90.key
127.0.0.1 9112 validator .hmy/eca09c1808b729ca56f1b5a6a287c6e1c3ae09e29ccf7efa35453471fcab07d9f73cee249e2b91f5ee44eb9618be3904.key
127.0.0.1 9114 validator .hmy/f47238daef97d60deedbde5302d05dea5de67608f11f406576e363661f7dcbc4a1385948549b31a6c70f6fde8a391486.key
127.0.0.1 9116 validator .hmy/fc4b9c535ee91f015efff3f32fbb9d32cdd9bfc8a837bb3eee89b8fff653c7af2050a4e147ebe5c7233dc2d5df06ee0a.key
127.0.0.1 9118 validator .hmy/ca86e551ee42adaaa6477322d7db869d3e203c00d7b86c82ebee629ad79cb6d57b8f3db28336778ec2180e56a8e07296.key
127.0.0.1 9300 explorer null 1

@ -69,7 +69,7 @@ function launch_localnet() {
if ${VERBOSE}; then
verbosity=5
else
verbosity=5
verbosity=3
fi
base_args=(--log_folder "${log_folder}" --min_peers "${MIN}" --bootnodes "${BN_MA}" "--network_type=$NETWORK" --blspass file:"${ROOT}/.hmy/blspass.txt" "--dns=false" "--verbosity=${verbosity}" "--p2p.security.max-conn-per-ip=100")
@ -80,11 +80,8 @@ function launch_localnet() {
while IFS='' read -r line || [[ -n "$line" ]]; do
i=$((i + 1))
# Read config for i-th node form config file
IFS=' ' read -r ip port mode bls_key shard node_config <<<"${line}"
echo "LINE: ${line} ${shard}"
args=("${base_args[@]}" --ip "${ip}" --port "${port}" --key "/tmp/${ip}-${port}.key" --db_dir "${ROOT}/db-${ip}-${port}" "--broadcast_invalid_tx=false")
if [[ -z "$ip" || -z "$port" ]]; then
echo "skip empty node"

Loading…
Cancel
Save