From e0ea579922081ea85f0fb11f9741847515b87519 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Fri, 29 Nov 2019 20:25:12 -0800 Subject: [PATCH] Fix comment --- cmd/harmony/main.go | 32 ++++++++++++++++---------------- internal/chain/reward.go | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index 4151dbde1..2415ef9b7 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -130,8 +130,8 @@ var ( pushgatewayPort = flag.String("pushgateway_port", "9091", "Metrics view port") publicRPC = flag.Bool("public_rpc", false, "Enable Public RPC Access (default: false)") // Bad block revert - doRevertBefore = flag.Int("do_revert_before", 1150, "If the current block is less than do_revert_before, revert all blocks until (including) revert_to block") - revertTo = flag.Int("revert_to", 1130, "The revert will rollback all blocks until and including block number revert_to") + doRevertBefore = flag.Int("do_revert_before", 0, "If the current block is less than do_revert_before, revert all blocks until (including) revert_to block") + revertTo = flag.Int("revert_to", 0, "The revert will rollback all blocks until and including block number revert_to") ) func initSetup() { @@ -291,13 +291,13 @@ func setupConsensusAndNode(nodeConfig *nodeconfig.ConfigType) *node.Node { // TODO: consensus object shouldn't start here // TODO(minhdoan): During refactoring, found out that the peers list is actually empty. Need to clean up the logic of consensus later. decider := quorum.NewDecider(quorum.SuperMajorityVote) + currentConsensus, err := consensus.New( myHost, nodeConfig.ShardID, p2p.Peer{}, nodeConfig.ConsensusPriKey, decider, ) currentConsensus.Decider.SetShardIDProvider(func() (uint32, error) { return currentConsensus.ShardID, nil }) - currentConsensus.Decider.SetMyPublicKeyProvider(func() (*bls.PublicKey, error) { return currentConsensus.PubKey, nil }) @@ -486,21 +486,21 @@ func main() { go currentNode.SupportBeaconSyncing() } - ////// Temporary fix for 8-6 incident ///////// - chain := currentNode.Blockchain() - curNum := chain.CurrentBlock().NumberU64() - if curNum < uint64(*doRevertBefore) && curNum >= uint64(*revertTo) { - // Remove invalid blocks - for chain.CurrentBlock().NumberU64() >= uint64(*revertTo) { - curBlock := chain.CurrentBlock() - rollbacks := []ethCommon.Hash{curBlock.Hash()} - chain.Rollback(rollbacks) - lastSig := curBlock.Header().LastCommitSignature() - sigAndBitMap := append(lastSig[:], curBlock.Header().LastCommitBitmap()...) - chain.WriteLastCommits(sigAndBitMap) + if uint64(*doRevertBefore) != 0 && uint64(*revertTo) != 0 { + chain := currentNode.Blockchain() + curNum := chain.CurrentBlock().NumberU64() + if curNum < uint64(*doRevertBefore) && curNum >= uint64(*revertTo) { + // Remove invalid blocks + for chain.CurrentBlock().NumberU64() >= uint64(*revertTo) { + curBlock := chain.CurrentBlock() + rollbacks := []ethCommon.Hash{curBlock.Hash()} + chain.Rollback(rollbacks) + lastSig := curBlock.Header().LastCommitSignature() + sigAndBitMap := append(lastSig[:], curBlock.Header().LastCommitBitmap()...) + chain.WriteLastCommits(sigAndBitMap) + } } } - /////////////////////////////////////////////// startMsg := "==== New Harmony Node ====" if *nodeType == "explorer" { diff --git a/internal/chain/reward.go b/internal/chain/reward.go index 1e7b7a80f..e3685dc13 100644 --- a/internal/chain/reward.go +++ b/internal/chain/reward.go @@ -135,7 +135,7 @@ func whatPercentStakedNow( beaconchain engine.ChainReader, ) (*numeric.Dec, error) { stakedNow := numeric.ZeroDec() - // Only active validators' stake is counted in stake ratio because their + // Only active validators' stake is counted in stake ratio because only their stake is under slashing risk active, err := beaconchain.ReadActiveValidatorList() if err != nil { return nil, err