diff --git a/api/service/explorer/service.go b/api/service/explorer/service.go index b13f73db6..b5ffa1b8b 100644 --- a/api/service/explorer/service.go +++ b/api/service/explorer/service.go @@ -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") diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index 1dabf5c45..437a91dc5 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -420,9 +420,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) diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 3122a368b..e87ea2101 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -660,8 +660,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") @@ -760,17 +758,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(). diff --git a/consensus/validator.go b/consensus/validator.go index 013769395..a73ac92eb 100644 --- a/consensus/validator.go +++ b/consensus/validator.go @@ -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) { @@ -188,9 +184,6 @@ func (consensus *Consensus) sendCommitMessages(blockObj *types.Block) { // if onPrepared accepts the prepared message from the leader, then // it will send a COMMIT message for the leader to receive on the network. func (consensus *Consensus) onPrepared(recvMsg *FBFTMessage) { - if consensus.ShardID == 0 { - //fmt.Println("onPrepared", recvMsg.BlockNum) - } consensus.mutex.Lock() defer consensus.mutex.Unlock() @@ -406,13 +399,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. diff --git a/consensus/view_change.go b/consensus/view_change.go index 3bd0c181f..6631051dc 100644 --- a/consensus/view_change.go +++ b/consensus/view_change.go @@ -372,7 +372,6 @@ func (consensus *Consensus) startNewView(viewID uint64, newLeaderPriKey *bls.Pri // onViewChange is called when the view change message is received. func (consensus *Consensus) onViewChange(recvMsg *FBFTMessage) { - //fmt.Printf("[onViewChange] received view change message from %+v\n", recvMsg) consensus.mutex.Lock() defer consensus.mutex.Unlock() @@ -395,13 +394,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)). diff --git a/node/node_newblock.go b/node/node_newblock.go index 8738a9807..03fd69d9d 100644 --- a/node/node_newblock.go +++ b/node/node_newblock.go @@ -2,7 +2,6 @@ package node import ( "errors" - "fmt" "sort" "strings" "time" @@ -89,8 +88,6 @@ func (node *Node) WaitForConsensusReadyV2(readySignal chan consensus.ProposalTyp newBlock, err := node.ProposeNewBlock(newCommitSigsChan) if err == nil { - fmt.Printf("ProposeNewBlock: #%d :%d e:%d, sh:%d with leader %s\n", newBlock.NumberU64(), utils.GetPort(), node.Blockchain().CurrentHeader().Epoch().Uint64(), node.Blockchain().ShardID(), node.Consensus.GetLeaderPubKey().Bytes.Hex()) - if blk, ok := node.proposedBlock[newBlock.NumberU64()]; ok { utils.Logger().Info().Uint64("blockNum", newBlock.NumberU64()).Str("blockHash", blk.Hash().Hex()). Msg("Block with the same number was already proposed, abort.") diff --git a/test/configs/local-resharding.txt b/test/configs/local-resharding.txt index fc3d3e97b..4ce91ece1 100644 --- a/test/configs/local-resharding.txt +++ b/test/configs/local-resharding.txt @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/test/deploy.sh b/test/deploy.sh index 5a949637e..6bbb12eb9 100755 --- a/test/deploy.sh +++ b/test/deploy.sh @@ -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"