{"action":"created","comment":{"url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/comments/217952201","pull_request_review_id":155785112,"id":217952201,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNzk1MjIwMQ==","diff_hunk":"@@ -302,894 +560,1935 @@ bool Messenger::GetNodeDSBlock(const vector<unsigned char>& src,\n         }\n     }\n \n+    // Get the part of the announcement that should be co-signed during the first round of consensus\n+\n+    messageToCosign.clear();\n+    if (dsBlock.GetHeader().Serialize(messageToCosign, 0)\n+        != DSBlockHeader::SIZE)\n+    {\n+        LOG_GENERAL(WARNING, \"DSBlockHeader serialization failed.\");\n+        return false;\n+    }\n+\n     return true;\n }\n \n-bool Messenger::SetNodeFinalBlock(vector<unsigned char>& dst,\n-                                  const unsigned int offset,\n-                                  const uint32_t shardID,\n-                                  const uint64_t dsBlockNumber,\n-                                  const uint32_t consensusID,\n-                                  const TxBlock& txBlock,\n-                                  const vector<unsigned char>& stateDelta)\n+bool Messenger::SetDSFinalBlockAnnouncement(\n+    vector<unsigned char>& dst, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, const pair<PrivKey, PubKey>& leaderKey,\n+    const TxBlock& txBlock, vector<unsigned char>& messageToCosign)\n {\n     LOG_MARKER();\n \n-    NodeFinalBlock result;\n+    ConsensusAnnouncement announcement;\n \n-    result.set_shardid(shardID);\n-    result.set_dsblocknumber(dsBlockNumber);\n-    result.set_consensusid(consensusID);\n-    SerializableToProtobufByteArray(txBlock, *result.mutable_txblock());\n-    result.set_statedelta(stateDelta.data(), stateDelta.size());\n+    // Set the FinalBlock announcement parameters\n \n-    if (!result.IsInitialized())\n+    DSFinalBlockAnnouncement* finalblock = announcement.mutable_finalblock();\n+    SerializableToProtobufByteArray(txBlock, *finalblock->mutable_txblock());\n+\n+    if (!finalblock->IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"NodeFinalBlock initialization failed.\");\n+        LOG_GENERAL(WARNING, \"DSFinalBlockAnnouncement initialization failed.\");\n         return false;\n     }\n \n-    return SerializeToArray(result, dst, offset);\n-}\n-\n-bool Messenger::GetNodeFinalBlock(const vector<unsigned char>& src,\n-                                  const unsigned int offset, uint32_t& shardID,\n-                                  uint64_t& dsBlockNumber,\n-                                  uint32_t& consensusID, TxBlock& txBlock,\n-                                  vector<unsigned char>& stateDelta)\n-{\n-    LOG_MARKER();\n+    // Set the common consensus announcement parameters\n \n-    NodeFinalBlock result;\n+    if (!SetConsensusAnnouncementCore(announcement, consensusID, blockHash,\n+                                      leaderID, leaderKey))\n+    {\n+        LOG_GENERAL(WARNING, \"SetConsensusAnnouncementCore failed.\");\n+        return false;\n+    }\n \n-    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+    // Serialize the part of the announcement that should be co-signed during the first round of consensus\n \n-    if (!result.IsInitialized())\n+    messageToCosign.clear();\n+    if (txBlock.GetHeader().Serialize(messageToCosign, 0)\n+        != TxBlockHeader::SIZE)\n     {\n-        LOG_GENERAL(WARNING, \"NodeFinalBlock initialization failed.\");\n+        LOG_GENERAL(WARNING, \"DSBlockHeader serialization failed.\");\n         return false;\n     }\n \n-    shardID = result.shardid();\n-    dsBlockNumber = result.dsblocknumber();\n-    consensusID = result.consensusid();\n-    ProtobufByteArrayToSerializable(result.txblock(), txBlock);\n-    stateDelta.resize(result.statedelta().size());\n-    copy(result.statedelta().begin(), result.statedelta().end(),\n-         stateDelta.begin());\n+    // Serialize the announcement\n \n-    return true;\n+    return SerializeToArray(announcement, dst, offset);\n }\n \n-bool Messenger::SetLookupGetSeedPeers(vector<unsigned char>& dst,\n-                                      const unsigned int offset,\n-                                      const uint32_t listenPort)\n+bool Messenger::GetDSFinalBlockAnnouncement(\n+    const vector<unsigned char>& src, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, const PubKey& leaderKey, TxBlock& txBlock,\n+    vector<unsigned char>& messageToCosign)\n {\n     LOG_MARKER();\n \n-    LookupGetSeedPeers result;\n+    ConsensusAnnouncement announcement;\n \n-    result.set_listenport(listenPort);\n+    announcement.ParseFromArray(src.data() + offset, src.size() - offset);\n \n-    if (!result.IsInitialized())\n+    if (!announcement.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetSeedPeers initialization failed.\");\n+        LOG_GENERAL(WARNING, \"ConsensusAnnouncement initialization failed.\");\n         return false;\n     }\n \n-    return SerializeToArray(result, dst, offset);\n-}\n+    if (!announcement.has_finalblock())\n+    {\n+        LOG_GENERAL(WARNING, \"DSFinalBlockAnnouncement initialization failed.\");\n+        return false;\n+    }\n \n-bool Messenger::GetLookupGetSeedPeers(const vector<unsigned char>& src,\n-                                      const unsigned int offset,\n-                                      uint32_t& listenPort)\n-{\n-    LOG_MARKER();\n+    // Check the common consensus announcement parameters\n \n-    LookupGetSeedPeers result;\n+    if (!GetConsensusAnnouncementCore(announcement, consensusID, blockHash,\n+                                      leaderID, leaderKey))\n+    {\n+        LOG_GENERAL(WARNING, \"GetConsensusAnnouncementCore failed.\");\n+        return false;\n+    }\n \n-    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+    // Get the FinalBlock announcement parameters\n \n-    if (!result.IsInitialized())\n+    const DSFinalBlockAnnouncement& finalblock = announcement.finalblock();\n+    ProtobufByteArrayToSerializable(finalblock.txblock(), txBlock);\n+\n+    // Get the part of the announcement that should be co-signed during the first round of consensus\n+\n+    messageToCosign.clear();\n+    if (txBlock.GetHeader().Serialize(messageToCosign, 0)\n+        != TxBlockHeader::SIZE)\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetSeedPeers initialization failed.\");\n+        LOG_GENERAL(WARNING, \"TxBlockHeader serialization failed.\");\n         return false;\n     }\n \n-    listenPort = result.listenport();\n-\n     return true;\n }\n \n-bool Messenger::SetLookupSetSeedPeers(vector<unsigned char>& dst,\n-                                      const unsigned int offset,\n-                                      const vector<Peer>& candidateSeeds)\n+bool Messenger::SetDSVCBlockAnnouncement(\n+    vector<unsigned char>& dst, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, const pair<PrivKey, PubKey>& leaderKey,\n+    const VCBlock& vcBlock, vector<unsigned char>& messageToCosign)\n {\n     LOG_MARKER();\n \n-    LookupSetSeedPeers result;\n+    ConsensusAnnouncement announcement;\n \n-    unordered_set<uint32_t> indicesAlreadyAdded;\n+    // Set the VCBlock announcement parameters\n \n-    random_device rd;\n-    mt19937 gen(rd());\n-    uniform_int_distribution<> dis(0, candidateSeeds.size() - 1);\n+    DSVCBlockAnnouncement* vcblock = announcement.mutable_vcblock();\n+    SerializableToProtobufByteArray(vcBlock, *vcblock->mutable_vcblock());\n \n-    for (unsigned int i = 0; i < candidateSeeds.size(); i++)\n+    if (!vcblock->IsInitialized())\n     {\n-        uint32_t index = dis(gen);\n-        while (indicesAlreadyAdded.find(index) != indicesAlreadyAdded.end())\n-        {\n-            index = dis(gen);\n-        }\n-        indicesAlreadyAdded.insert(index);\n+        LOG_GENERAL(WARNING, \"DSVCBlockAnnouncement initialization failed.\");\n+        return false;\n+    }\n \n-        SerializableToProtobufByteArray(candidateSeeds.at(index),\n-                                        *result.add_candidateseeds());\n+    // Set the common consensus announcement parameters\n+\n+    if (!SetConsensusAnnouncementCore(announcement, consensusID, blockHash,\n+                                      leaderID, leaderKey))\n+    {\n+        LOG_GENERAL(WARNING, \"SetConsensusAnnouncementCore failed.\");\n+        return false;\n     }\n \n-    if (!result.IsInitialized())\n+    // Serialize the part of the announcement that should be co-signed during the first round of consensus\n+\n+    messageToCosign.clear();\n+    if (vcBlock.GetHeader().Serialize(messageToCosign, 0)\n+        != VCBlockHeader::SIZE)\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetSeedPeers initialization failed.\");\n+        LOG_GENERAL(WARNING, \"VCBlockHeader serialization failed.\");\n         return false;\n     }\n \n-    return SerializeToArray(result, dst, offset);\n+    // Serialize the announcement\n+\n+    return SerializeToArray(announcement, dst, offset);\n }\n \n-bool Messenger::GetLookupSetSeedPeers(const vector<unsigned char>& src,\n-                                      const unsigned int offset,\n-                                      vector<Peer>& candidateSeeds)\n+bool Messenger::GetDSVCBlockAnnouncement(\n+    const vector<unsigned char>& src, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, const PubKey& leaderKey, VCBlock& vcBlock,\n+    vector<unsigned char>& messageToCosign)\n {\n     LOG_MARKER();\n \n-    LookupSetSeedPeers result;\n+    ConsensusAnnouncement announcement;\n \n-    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+    announcement.ParseFromArray(src.data() + offset, src.size() - offset);\n \n-    if (!result.IsInitialized())\n+    if (!announcement.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetSeedPeers initialization failed.\");\n+        LOG_GENERAL(WARNING, \"ConsensusAnnouncement initialization failed.\");\n         return false;\n     }\n \n-    for (int i = 0; i < result.candidateseeds_size(); i++)\n+    if (!announcement.has_vcblock())\n     {\n-        Peer seedPeer;\n-        ProtobufByteArrayToSerializable(result.candidateseeds(i), seedPeer);\n-        candidateSeeds.emplace_back(seedPeer);\n+        LOG_GENERAL(WARNING, \"DSVCBlockAnnouncement initialization failed.\");\n+        return false;\n     }\n \n-    return true;\n-}\n+    // Check the common consensus announcement parameters\n \n-bool Messenger::SetLookupGetDSInfoFromSeed(vector<unsigned char>& dst,\n-                                           const unsigned int offset,\n-                                           const uint32_t listenPort)\n-{\n-    LOG_MARKER();\n+    if (!GetConsensusAnnouncementCore(announcement, consensusID, blockHash,\n+                                      leaderID, leaderKey))\n+    {\n+        LOG_GENERAL(WARNING, \"GetConsensusAnnouncementCore failed.\");\n+        return false;\n+    }\n \n-    LookupGetDSInfoFromSeed result;\n+    // Get the VCBlock announcement parameters\n \n-    result.set_listenport(listenPort);\n+    const DSVCBlockAnnouncement& vcblock = announcement.vcblock();\n+    ProtobufByteArrayToSerializable(vcblock.vcblock(), vcBlock);\n \n-    if (!result.IsInitialized())\n+    // Get the part of the announcement that should be co-signed during the first round of consensus\n+\n+    messageToCosign.clear();\n+    if (vcBlock.GetHeader().Serialize(messageToCosign, 0)\n+        != VCBlockHeader::SIZE)\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetDSInfoFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"VCBlockHeader serialization failed.\");\n         return false;\n     }\n \n-    return SerializeToArray(result, dst, offset);\n+    return true;\n }\n \n-bool Messenger::GetLookupGetDSInfoFromSeed(const vector<unsigned char>& src,\n-                                           const unsigned int offset,\n-                                           uint32_t& listenPort)\n-{\n-    LOG_MARKER();\n+// ============================================================================\n+// Node messages\n+// ============================================================================\n+\n+bool Messenger::SetNodeDSBlock(vector<unsigned char>& dst,\n+                               const unsigned int offset,\n+                               const uint32_t shardID, const DSBlock& dsBlock,\n+                               const Peer& powWinnerPeer,\n+                               const VectorOfShard& shards,\n+                               const vector<Peer>& dsReceivers,\n+                               const vector<vector<Peer>>& shardReceivers,\n+                               const vector<vector<Peer>>& shardSenders)\n+{\n+    LOG_MARKER();\n+\n+    NodeDSBlock result;\n+\n+    result.set_shardid(shardID);\n+    SerializableToProtobufByteArray(dsBlock, *result.mutable_dsblock());\n+    SerializableToProtobufByteArray(powWinnerPeer,\n+                                    *result.mutable_powwinnerpeer());\n+\n+    for (const auto& shard : shards)\n+    {\n+        ShardingStructure::Shard* proto_shard\n+            = result.mutable_sharding()->add_shards();\n+\n+        for (const auto& node : shard)\n+        {\n+            ShardingStructure::Member* proto_member\n+                = proto_shard->add_members();\n+\n+            SerializableToProtobufByteArray(node.first,\n+                                            *proto_member->mutable_pubkey());\n+            SerializableToProtobufByteArray(node.second,\n+                                            *proto_member->mutable_peerinfo());\n+        }\n+    }\n+\n+    TxSharingAssignments* proto_assignments = result.mutable_assignments();\n+\n+    for (const auto& dsnode : dsReceivers)\n+    {\n+        SerializableToProtobufByteArray(dsnode,\n+                                        *proto_assignments->add_dsnodes());\n+    }\n+\n+    for (unsigned int i = 0; i < shardReceivers.size(); i++)\n+    {\n+        TxSharingAssignments::AssignedNodes* proto_shard\n+            = proto_assignments->add_shardnodes();\n+\n+        for (const auto& receiver : shardReceivers.at(i))\n+        {\n+            SerializableToProtobufByteArray(receiver,\n+                                            *proto_shard->add_receivers());\n+        }\n+        for (const auto& sender : shardSenders.at(i))\n+        {\n+            SerializableToProtobufByteArray(sender,\n+                                            *proto_shard->add_senders());\n+        }\n+    }\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"NodeDSBlock initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetNodeDSBlock(const vector<unsigned char>& src,\n+                               const unsigned int offset, uint32_t& shardID,\n+                               DSBlock& dsBlock, Peer& powWinnerPeer,\n+                               VectorOfShard& shards, vector<Peer>& dsReceivers,\n+                               vector<vector<Peer>>& shardReceivers,\n+                               vector<vector<Peer>>& shardSenders)\n+{\n+    LOG_MARKER();\n+\n+    NodeDSBlock result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"NodeDSBlock initialization failed.\");\n+        return false;\n+    }\n+\n+    shardID = result.shardid();\n+    ProtobufByteArrayToSerializable(result.dsblock(), dsBlock);\n+    ProtobufByteArrayToSerializable(result.powwinnerpeer(), powWinnerPeer);\n+\n+    for (int i = 0; i < result.sharding().shards_size(); i++)\n+    {\n+        shards.emplace_back();\n+\n+        const ShardingStructure::Shard& proto_shard\n+            = result.sharding().shards(i);\n+\n+        for (int j = 0; j < proto_shard.members_size(); j++)\n+        {\n+            const ShardingStructure::Member& proto_member\n+                = proto_shard.members(j);\n+\n+            PubKey key;\n+            Peer peer;\n+\n+            ProtobufByteArrayToSerializable(proto_member.pubkey(), key);\n+            ProtobufByteArrayToSerializable(proto_member.peerinfo(), peer);\n+\n+            shards.back().emplace_back(key, peer);\n+        }\n+    }\n+\n+    const TxSharingAssignments& proto_assignments = result.assignments();\n+\n+    for (int i = 0; i < proto_assignments.dsnodes_size(); i++)\n+    {\n+        Peer peer;\n+        ProtobufByteArrayToSerializable(proto_assignments.dsnodes(i), peer);\n+        dsReceivers.emplace_back(peer);\n+    }\n+\n+    for (int i = 0; i < proto_assignments.shardnodes_size(); i++)\n+    {\n+        const TxSharingAssignments::AssignedNodes& proto_shard\n+            = result.assignments().shardnodes(i);\n+\n+        shardReceivers.emplace_back();\n+\n+        for (int j = 0; j < proto_shard.receivers_size(); j++)\n+        {\n+            Peer peer;\n+            ProtobufByteArrayToSerializable(proto_shard.receivers(j), peer);\n+            shardReceivers.back().emplace_back(peer);\n+        }\n+\n+        shardSenders.emplace_back();\n+\n+        for (int j = 0; j < proto_shard.senders_size(); j++)\n+        {\n+            Peer peer;\n+            ProtobufByteArrayToSerializable(proto_shard.senders(j), peer);\n+            shardSenders.back().emplace_back(peer);\n+        }\n+    }\n+\n+    return true;\n+}\n+\n+bool Messenger::SetNodeFinalBlock(vector<unsigned char>& dst,\n+                                  const unsigned int offset,\n+                                  const uint32_t shardID,\n+                                  const uint64_t dsBlockNumber,\n+                                  const uint32_t consensusID,\n+                                  const TxBlock& txBlock,\n+                                  const vector<unsigned char>& stateDelta)\n+{\n+    LOG_MARKER();\n+\n+    NodeFinalBlock result;\n+\n+    result.set_shardid(shardID);\n+    result.set_dsblocknumber(dsBlockNumber);\n+    result.set_consensusid(consensusID);\n+    SerializableToProtobufByteArray(txBlock, *result.mutable_txblock());\n+    result.set_statedelta(stateDelta.data(), stateDelta.size());\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"NodeFinalBlock initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetNodeFinalBlock(const vector<unsigned char>& src,\n+                                  const unsigned int offset, uint32_t& shardID,\n+                                  uint64_t& dsBlockNumber,\n+                                  uint32_t& consensusID, TxBlock& txBlock,\n+                                  vector<unsigned char>& stateDelta)\n+{\n+    LOG_MARKER();\n+\n+    NodeFinalBlock result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"NodeFinalBlock initialization failed.\");\n+        return false;\n+    }\n+\n+    shardID = result.shardid();\n+    dsBlockNumber = result.dsblocknumber();\n+    consensusID = result.consensusid();\n+    ProtobufByteArrayToSerializable(result.txblock(), txBlock);\n+    stateDelta.resize(result.statedelta().size());\n+    copy(result.statedelta().begin(), result.statedelta().end(),\n+         stateDelta.begin());\n+\n+    return true;\n+}\n+\n+bool Messenger::SetNodeMicroBlockAnnouncement(\n+    vector<unsigned char>& dst, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, const pair<PrivKey, PubKey>& leaderKey,\n+    const MicroBlock& microBlock, vector<unsigned char>& messageToCosign)\n+{\n+    LOG_MARKER();\n+\n+    ConsensusAnnouncement announcement;\n+\n+    // Set the MicroBlock announcement parameters\n+\n+    NodeMicroBlockAnnouncement* microblock = announcement.mutable_microblock();\n+    SerializableToProtobufByteArray(microBlock,\n+                                    *microblock->mutable_microblock());\n+\n+    if (!microblock->IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING,\n+                    \"NodeMicroBlockAnnouncement initialization failed.\");\n+        return false;\n+    }\n+\n+    // Set the common consensus announcement parameters\n+\n+    if (!SetConsensusAnnouncementCore(announcement, consensusID, blockHash,\n+                                      leaderID, leaderKey))\n+    {\n+        LOG_GENERAL(WARNING, \"SetConsensusAnnouncementCore failed.\");\n+        return false;\n+    }\n+\n+    // Serialize the part of the announcement that should be co-signed during the first round of consensus\n+\n+    messageToCosign.clear();\n+    if (microBlock.GetHeader().Serialize(messageToCosign, 0)\n+        != MicroBlockHeader::SIZE)\n+    {\n+        LOG_GENERAL(WARNING, \"MicroBlockHeader serialization failed.\");\n+        return false;\n+    }\n+\n+    // Serialize the announcement\n+\n+    return SerializeToArray(announcement, dst, offset);\n+}\n+\n+bool Messenger::GetNodeMicroBlockAnnouncement(\n+    const vector<unsigned char>& src, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, const PubKey& leaderKey, MicroBlock& microBlock,\n+    vector<unsigned char>& messageToCosign)\n+{\n+    LOG_MARKER();\n+\n+    ConsensusAnnouncement announcement;\n+\n+    announcement.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!announcement.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"ConsensusAnnouncement initialization failed.\");\n+        return false;\n+    }\n+\n+    if (!announcement.has_microblock())\n+    {\n+        LOG_GENERAL(WARNING,\n+                    \"NodeMicroBlockAnnouncement initialization failed.\");\n+        return false;\n+    }\n+\n+    // Check the common consensus announcement parameters\n+\n+    if (!GetConsensusAnnouncementCore(announcement, consensusID, blockHash,\n+                                      leaderID, leaderKey))\n+    {\n+        LOG_GENERAL(WARNING, \"GetConsensusAnnouncementCore failed.\");\n+        return false;\n+    }\n+\n+    // Get the MicroBlock announcement parameters\n+\n+    const NodeMicroBlockAnnouncement& microblock = announcement.microblock();\n+    ProtobufByteArrayToSerializable(microblock.microblock(), microBlock);\n+\n+    // Get the part of the announcement that should be co-signed during the first round of consensus\n+\n+    messageToCosign.clear();\n+    if (microBlock.GetHeader().Serialize(messageToCosign, 0)\n+        != MicroBlockHeader::SIZE)\n+    {\n+        LOG_GENERAL(WARNING, \"MicroBlockHeader serialization failed.\");\n+        return false;\n+    }\n+\n+    return true;\n+}\n+\n+// ============================================================================\n+// Lookup messages\n+// ============================================================================\n+\n+bool Messenger::SetLookupGetSeedPeers(vector<unsigned char>& dst,\n+                                      const unsigned int offset,\n+                                      const uint32_t listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetSeedPeers result;\n+\n+    result.set_listenport(listenPort);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetSeedPeers initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupGetSeedPeers(const vector<unsigned char>& src,\n+                                      const unsigned int offset,\n+                                      uint32_t& listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetSeedPeers result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetSeedPeers initialization failed.\");\n+        return false;\n+    }\n+\n+    listenPort = result.listenport();\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupSetSeedPeers(vector<unsigned char>& dst,\n+                                      const unsigned int offset,\n+                                      const vector<Peer>& candidateSeeds)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetSeedPeers result;\n+\n+    unordered_set<uint32_t> indicesAlreadyAdded;\n+\n+    random_device rd;\n+    mt19937 gen(rd());\n+    uniform_int_distribution<> dis(0, candidateSeeds.size() - 1);\n+\n+    for (unsigned int i = 0; i < candidateSeeds.size(); i++)\n+    {\n+        uint32_t index = dis(gen);\n+        while (indicesAlreadyAdded.find(index) != indicesAlreadyAdded.end())\n+        {\n+            index = dis(gen);\n+        }\n+        indicesAlreadyAdded.insert(index);\n+\n+        SerializableToProtobufByteArray(candidateSeeds.at(index),\n+                                        *result.add_candidateseeds());\n+    }\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetSeedPeers initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupSetSeedPeers(const vector<unsigned char>& src,\n+                                      const unsigned int offset,\n+                                      vector<Peer>& candidateSeeds)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetSeedPeers result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetSeedPeers initialization failed.\");\n+        return false;\n+    }\n+\n+    for (int i = 0; i < result.candidateseeds_size(); i++)\n+    {\n+        Peer seedPeer;\n+        ProtobufByteArrayToSerializable(result.candidateseeds(i), seedPeer);\n+        candidateSeeds.emplace_back(seedPeer);\n+    }\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupGetDSInfoFromSeed(vector<unsigned char>& dst,\n+                                           const unsigned int offset,\n+                                           const uint32_t listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetDSInfoFromSeed result;\n+\n+    result.set_listenport(listenPort);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetDSInfoFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupGetDSInfoFromSeed(const vector<unsigned char>& src,\n+                                           const unsigned int offset,\n+                                           uint32_t& listenPort)\n+{\n+    LOG_MARKER();\n \n     LookupGetDSInfoFromSeed result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetDSInfoFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupGetDSInfoFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    listenPort = result.listenport();\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupSetDSInfoFromSeed(\n+    vector<unsigned char>& dst, const unsigned int offset,\n+    const vector<pair<PubKey, Peer>>& dsNodes)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetDSInfoFromSeed result;\n+\n+    for (const auto& node : dsNodes)\n+    {\n+        LookupSetDSInfoFromSeed::DSNode* protodsnode = result.add_dsnodes();\n+        SerializableToProtobufByteArray(node.first,\n+                                        *protodsnode->mutable_pubkey());\n+        SerializableToProtobufByteArray(node.second,\n+                                        *protodsnode->mutable_peer());\n+    }\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetDSInfoFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupSetDSInfoFromSeed(const vector<unsigned char>& src,\n+                                           const unsigned int offset,\n+                                           vector<pair<PubKey, Peer>>& dsNodes)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetDSInfoFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetDSInfoFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    for (int i = 0; i < result.dsnodes_size(); i++)\n+    {\n+        PubKey pubkey;\n+        Peer peer;\n+\n+        ProtobufByteArrayToSerializable(result.dsnodes(i).pubkey(), pubkey);\n+        ProtobufByteArrayToSerializable(result.dsnodes(i).peer(), peer);\n+        dsNodes.emplace_back(pubkey, peer);\n+    }\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupGetDSBlockFromSeed(vector<unsigned char>& dst,\n+                                            const unsigned int offset,\n+                                            const uint64_t lowBlockNum,\n+                                            const uint64_t highBlockNum,\n+                                            const uint32_t listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetDSBlockFromSeed result;\n+\n+    result.set_lowblocknum(lowBlockNum);\n+    result.set_highblocknum(highBlockNum);\n+    result.set_listenport(listenPort);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetDSBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupGetDSBlockFromSeed(const vector<unsigned char>& src,\n+                                            const unsigned int offset,\n+                                            uint64_t& lowBlockNum,\n+                                            uint64_t& highBlockNum,\n+                                            uint32_t& listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetDSBlockFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetDSBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    lowBlockNum = result.lowblocknum();\n+    highBlockNum = result.highblocknum();\n+    listenPort = result.listenport();\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupSetDSBlockFromSeed(vector<unsigned char>& dst,\n+                                            const unsigned int offset,\n+                                            const uint64_t lowBlockNum,\n+                                            const uint64_t highBlockNum,\n+                                            const vector<DSBlock>& dsBlocks)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetDSBlockFromSeed result;\n+\n+    result.set_lowblocknum(lowBlockNum);\n+    result.set_highblocknum(highBlockNum);\n+\n+    for (const auto& dsblock : dsBlocks)\n+    {\n+        SerializableToProtobufByteArray(\n+            dsblock, *result.add_dsblocks()->mutable_dsblock());\n+    }\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetDSBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupSetDSBlockFromSeed(const vector<unsigned char>& src,\n+                                            const unsigned int offset,\n+                                            uint64_t& lowBlockNum,\n+                                            uint64_t& highBlockNum,\n+                                            vector<DSBlock>& dsBlocks)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetDSBlockFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetDSBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    lowBlockNum = result.lowblocknum();\n+    highBlockNum = result.highblocknum();\n+\n+    for (int i = 0; i < result.dsblocks_size(); i++)\n+    {\n+        DSBlock dsblock;\n+        ProtobufByteArrayToSerializable(result.dsblocks(i).dsblock(), dsblock);\n+        dsBlocks.emplace_back(dsblock);\n+    }\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupGetTxBlockFromSeed(vector<unsigned char>& dst,\n+                                            const unsigned int offset,\n+                                            const uint64_t lowBlockNum,\n+                                            const uint64_t highBlockNum,\n+                                            const uint32_t listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetTxBlockFromSeed result;\n+\n+    result.set_lowblocknum(lowBlockNum);\n+    result.set_highblocknum(highBlockNum);\n+    result.set_listenport(listenPort);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetTxBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupGetTxBlockFromSeed(const vector<unsigned char>& src,\n+                                            const unsigned int offset,\n+                                            uint64_t& lowBlockNum,\n+                                            uint64_t& highBlockNum,\n+                                            uint32_t& listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetTxBlockFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetTxBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    lowBlockNum = result.lowblocknum();\n+    highBlockNum = result.highblocknum();\n+    listenPort = result.listenport();\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupSetTxBlockFromSeed(vector<unsigned char>& dst,\n+                                            const unsigned int offset,\n+                                            const uint64_t lowBlockNum,\n+                                            const uint64_t highBlockNum,\n+                                            const vector<TxBlock>& txBlocks)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetTxBlockFromSeed result;\n+\n+    result.set_lowblocknum(lowBlockNum);\n+    result.set_highblocknum(highBlockNum);\n+\n+    for (const auto& txblock : txBlocks)\n+    {\n+        SerializableToProtobufByteArray(\n+            txblock, *result.add_txblocks()->mutable_txblock());\n+    }\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetTxBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupSetTxBlockFromSeed(const vector<unsigned char>& src,\n+                                            const unsigned int offset,\n+                                            uint64_t& lowBlockNum,\n+                                            uint64_t& highBlockNum,\n+                                            vector<TxBlock>& txBlocks)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetTxBlockFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetTxBlockFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    lowBlockNum = result.lowblocknum();\n+    highBlockNum = result.highblocknum();\n+\n+    for (int i = 0; i < result.txblocks_size(); i++)\n+    {\n+        TxBlock txblock;\n+        ProtobufByteArrayToSerializable(result.txblocks(i).txblock(), txblock);\n+        txBlocks.emplace_back(txblock);\n+    }\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupGetTxBodyFromSeed(vector<unsigned char>& dst,\n+                                           const unsigned int offset,\n+                                           const vector<unsigned char>& txHash,\n+                                           const uint32_t listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetTxBodyFromSeed result;\n+\n+    result.set_txhash(txHash.data(), txHash.size());\n+    result.set_listenport(listenPort);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetTxBodyFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupGetTxBodyFromSeed(const vector<unsigned char>& src,\n+                                           const unsigned int offset,\n+                                           vector<unsigned char>& txHash,\n+                                           uint32_t& listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetTxBodyFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetTxBodyFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    txHash.resize(result.txhash().size());\n+    copy(result.txhash().begin(), result.txhash().end(), txHash.begin());\n+    listenPort = result.listenport();\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupSetTxBodyFromSeed(vector<unsigned char>& dst,\n+                                           const unsigned int offset,\n+                                           const vector<unsigned char>& txHash,\n+                                           const Transaction& txBody)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetTxBodyFromSeed result;\n+\n+    result.set_txhash(txHash.data(), txHash.size());\n+    SerializableToProtobufByteArray(txBody, *result.mutable_txbody());\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetTxBodyFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupSetTxBodyFromSeed(const vector<unsigned char>& src,\n+                                           const unsigned int offset,\n+                                           vector<unsigned char>& txHash,\n+                                           Transaction& txBody)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetTxBodyFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetTxBodyFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    txHash.resize(result.txhash().size());\n+    copy(result.txhash().begin(), result.txhash().end(), txHash.begin());\n+    ProtobufByteArrayToSerializable(result.txbody(), txBody);\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupSetNetworkIDFromSeed(vector<unsigned char>& dst,\n+                                              const unsigned int offset,\n+                                              const string& networkID)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetNetworkIDFromSeed result;\n+\n+    result.set_networkid(networkID);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING,\n+                    \"LookupSetNetworkIDFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupSetNetworkIDFromSeed(const vector<unsigned char>& src,\n+                                              const unsigned int offset,\n+                                              string& networkID)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetNetworkIDFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING,\n+                    \"LookupSetNetworkIDFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    networkID = result.networkid();\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupGetStateFromSeed(vector<unsigned char>& dst,\n+                                          const unsigned int offset,\n+                                          const uint32_t listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetStateFromSeed result;\n+\n+    result.set_listenport(listenPort);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetStateFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupGetStateFromSeed(const vector<unsigned char>& src,\n+                                          const unsigned int offset,\n+                                          uint32_t& listenPort)\n+{\n+    LOG_MARKER();\n+\n+    LookupGetStateFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupGetStateFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    listenPort = result.listenport();\n+\n+    return true;\n+}\n+\n+bool Messenger::SetLookupSetStateFromSeed(vector<unsigned char>& dst,\n+                                          const unsigned int offset,\n+                                          const AccountStore& accountStore)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetStateFromSeed result;\n+\n+    SerializableToProtobufByteArray(accountStore, *result.mutable_accounts());\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetStateFromSeed initialization failed.\");\n+        return false;\n+    }\n+\n+    return SerializeToArray(result, dst, offset);\n+}\n+\n+bool Messenger::GetLookupSetStateFromSeed(const vector<unsigned char>& src,\n+                                          const unsigned int offset,\n+                                          AccountStore& accountStore)\n+{\n+    LOG_MARKER();\n+\n+    LookupSetStateFromSeed result;\n+\n+    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+\n+    if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"LookupSetStateFromSeed initialization failed.\");\n         return false;\n     }\n \n-    listenPort = result.listenport();\n+    ProtobufByteArrayToSerializable(result.accounts(), accountStore);\n \n     return true;\n }\n \n-bool Messenger::SetLookupSetDSInfoFromSeed(\n-    vector<unsigned char>& dst, const unsigned int offset,\n-    const vector<pair<PubKey, Peer>>& dsNodes)\n+bool Messenger::SetLookupSetLookupOffline(vector<unsigned char>& dst,\n+                                          const unsigned int offset,\n+                                          const uint32_t listenPort)\n {\n     LOG_MARKER();\n \n-    LookupSetDSInfoFromSeed result;\n+    LookupSetLookupOffline result;\n \n-    for (const auto& node : dsNodes)\n-    {\n-        LookupSetDSInfoFromSeed::DSNode* protodsnode = result.add_dsnodes();\n-        SerializableToProtobufByteArray(node.first,\n-                                        *protodsnode->mutable_pubkey());\n-        SerializableToProtobufByteArray(node.second,\n-                                        *protodsnode->mutable_peer());\n-    }\n+    result.set_listenport(listenPort);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetDSInfoFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupSetLookupOffline initialization failed.\");\n         return false;\n     }\n \n     return SerializeToArray(result, dst, offset);\n }\n \n-bool Messenger::GetLookupSetDSInfoFromSeed(const vector<unsigned char>& src,\n-                                           const unsigned int offset,\n-                                           vector<pair<PubKey, Peer>>& dsNodes)\n+bool Messenger::GetLookupSetLookupOffline(const vector<unsigned char>& src,\n+                                          const unsigned int offset,\n+                                          uint32_t& listenPort)\n {\n     LOG_MARKER();\n \n-    LookupSetDSInfoFromSeed result;\n+    LookupSetLookupOffline result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetDSInfoFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupSetLookupOffline initialization failed.\");\n         return false;\n     }\n \n-    for (int i = 0; i < result.dsnodes_size(); i++)\n-    {\n-        PubKey pubkey;\n-        Peer peer;\n-\n-        ProtobufByteArrayToSerializable(result.dsnodes(i).pubkey(), pubkey);\n-        ProtobufByteArrayToSerializable(result.dsnodes(i).peer(), peer);\n-        dsNodes.emplace_back(pubkey, peer);\n-    }\n+    listenPort = result.listenport();\n \n     return true;\n }\n \n-bool Messenger::SetLookupGetDSBlockFromSeed(vector<unsigned char>& dst,\n-                                            const unsigned int offset,\n-                                            const uint64_t lowBlockNum,\n-                                            const uint64_t highBlockNum,\n-                                            const uint32_t listenPort)\n+bool Messenger::SetLookupSetLookupOnline(vector<unsigned char>& dst,\n+                                         const unsigned int offset,\n+                                         const uint32_t listenPort)\n {\n     LOG_MARKER();\n \n-    LookupGetDSBlockFromSeed result;\n+    LookupSetLookupOnline result;\n \n-    result.set_lowblocknum(lowBlockNum);\n-    result.set_highblocknum(highBlockNum);\n     result.set_listenport(listenPort);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetDSBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupSetLookupOnline initialization failed.\");\n         return false;\n     }\n \n     return SerializeToArray(result, dst, offset);\n }\n \n-bool Messenger::GetLookupGetDSBlockFromSeed(const vector<unsigned char>& src,\n-                                            const unsigned int offset,\n-                                            uint64_t& lowBlockNum,\n-                                            uint64_t& highBlockNum,\n-                                            uint32_t& listenPort)\n+bool Messenger::GetLookupSetLookupOnline(const vector<unsigned char>& src,\n+                                         const unsigned int offset,\n+                                         uint32_t& listenPort)\n {\n     LOG_MARKER();\n \n-    LookupGetDSBlockFromSeed result;\n+    LookupSetLookupOnline result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetDSBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupSetLookupOnline initialization failed.\");\n         return false;\n     }\n \n-    lowBlockNum = result.lowblocknum();\n-    highBlockNum = result.highblocknum();\n     listenPort = result.listenport();\n \n     return true;\n }\n \n-bool Messenger::SetLookupSetDSBlockFromSeed(vector<unsigned char>& dst,\n-                                            const unsigned int offset,\n-                                            const uint64_t lowBlockNum,\n-                                            const uint64_t highBlockNum,\n-                                            const vector<DSBlock>& dsBlocks)\n+bool Messenger::SetLookupGetOfflineLookups(vector<unsigned char>& dst,\n+                                           const unsigned int offset,\n+                                           const uint32_t listenPort)\n {\n     LOG_MARKER();\n \n-    LookupSetDSBlockFromSeed result;\n-\n-    result.set_lowblocknum(lowBlockNum);\n-    result.set_highblocknum(highBlockNum);\n+    LookupGetOfflineLookups result;\n \n-    for (const auto& dsblock : dsBlocks)\n-    {\n-        SerializableToProtobufByteArray(\n-            dsblock, *result.add_dsblocks()->mutable_dsblock());\n-    }\n+    result.set_listenport(listenPort);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetDSBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupGetOfflineLookups initialization failed.\");\n         return false;\n     }\n \n     return SerializeToArray(result, dst, offset);\n }\n \n-bool Messenger::GetLookupSetDSBlockFromSeed(const vector<unsigned char>& src,\n-                                            const unsigned int offset,\n-                                            uint64_t& lowBlockNum,\n-                                            uint64_t& highBlockNum,\n-                                            vector<DSBlock>& dsBlocks)\n+bool Messenger::GetLookupGetOfflineLookups(const vector<unsigned char>& src,\n+                                           const unsigned int offset,\n+                                           uint32_t& listenPort)\n {\n     LOG_MARKER();\n \n-    LookupSetDSBlockFromSeed result;\n+    LookupGetOfflineLookups result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetDSBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupGetOfflineLookups initialization failed.\");\n         return false;\n     }\n \n-    lowBlockNum = result.lowblocknum();\n-    highBlockNum = result.highblocknum();\n-\n-    for (int i = 0; i < result.dsblocks_size(); i++)\n-    {\n-        DSBlock dsblock;\n-        ProtobufByteArrayToSerializable(result.dsblocks(i).dsblock(), dsblock);\n-        dsBlocks.emplace_back(dsblock);\n-    }\n+    listenPort = result.listenport();\n \n     return true;\n }\n \n-bool Messenger::SetLookupGetTxBlockFromSeed(vector<unsigned char>& dst,\n-                                            const unsigned int offset,\n-                                            const uint64_t lowBlockNum,\n-                                            const uint64_t highBlockNum,\n-                                            const uint32_t listenPort)\n+bool Messenger::SetLookupSetOfflineLookups(vector<unsigned char>& dst,\n+                                           const unsigned int offset,\n+                                           const vector<Peer>& nodes)\n {\n     LOG_MARKER();\n \n-    LookupGetTxBlockFromSeed result;\n+    LookupSetOfflineLookups result;\n \n-    result.set_lowblocknum(lowBlockNum);\n-    result.set_highblocknum(highBlockNum);\n-    result.set_listenport(listenPort);\n+    for (const auto& node : nodes)\n+    {\n+        SerializableToProtobufByteArray(node, *result.add_nodes());\n+    }\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetTxBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupSetOfflineLookups initialization failed.\");\n         return false;\n     }\n \n     return SerializeToArray(result, dst, offset);\n }\n \n-bool Messenger::GetLookupGetTxBlockFromSeed(const vector<unsigned char>& src,\n-                                            const unsigned int offset,\n-                                            uint64_t& lowBlockNum,\n-                                            uint64_t& highBlockNum,\n-                                            uint32_t& listenPort)\n+bool Messenger::GetLookupSetOfflineLookups(const vector<unsigned char>& src,\n+                                           const unsigned int offset,\n+                                           vector<Peer>& nodes)\n {\n     LOG_MARKER();\n \n-    LookupGetTxBlockFromSeed result;\n+    LookupSetOfflineLookups result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetTxBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"LookupSetOfflineLookups initialization failed.\");\n         return false;\n     }\n \n-    lowBlockNum = result.lowblocknum();\n-    highBlockNum = result.highblocknum();\n-    listenPort = result.listenport();\n+    for (int i = 0; i < result.nodes_size(); i++)\n+    {\n+        Peer node;\n+        ProtobufByteArrayToSerializable(result.nodes(i), node);\n+        nodes.emplace_back(node);\n+    }\n \n     return true;\n }\n \n-bool Messenger::SetLookupSetTxBlockFromSeed(vector<unsigned char>& dst,\n-                                            const unsigned int offset,\n-                                            const uint64_t lowBlockNum,\n-                                            const uint64_t highBlockNum,\n-                                            const vector<TxBlock>& txBlocks)\n+bool Messenger::SetLookupGetStartPoWFromSeed(vector<unsigned char>& dst,\n+                                             const unsigned int offset,\n+                                             const uint32_t listenPort)\n {\n     LOG_MARKER();\n \n-    LookupSetTxBlockFromSeed result;\n-\n-    result.set_lowblocknum(lowBlockNum);\n-    result.set_highblocknum(highBlockNum);\n+    LookupGetStartPoWFromSeed result;\n \n-    for (const auto& txblock : txBlocks)\n-    {\n-        SerializableToProtobufByteArray(\n-            txblock, *result.add_txblocks()->mutable_txblock());\n-    }\n+    result.set_listenport(listenPort);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetTxBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING,\n+                    \"LookupGetStartPoWFromSeed initialization failed.\");\n         return false;\n     }\n \n     return SerializeToArray(result, dst, offset);\n }\n \n-bool Messenger::GetLookupSetTxBlockFromSeed(const vector<unsigned char>& src,\n-                                            const unsigned int offset,\n-                                            uint64_t& lowBlockNum,\n-                                            uint64_t& highBlockNum,\n-                                            vector<TxBlock>& txBlocks)\n+bool Messenger::GetLookupGetStartPoWFromSeed(const vector<unsigned char>& src,\n+                                             const unsigned int offset,\n+                                             uint32_t& listenPort)\n {\n     LOG_MARKER();\n \n-    LookupSetTxBlockFromSeed result;\n+    LookupGetStartPoWFromSeed result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetTxBlockFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING,\n+                    \"LookupGetStartPoWFromSeed initialization failed.\");\n         return false;\n     }\n \n-    lowBlockNum = result.lowblocknum();\n-    highBlockNum = result.highblocknum();\n-\n-    for (int i = 0; i < result.txblocks_size(); i++)\n-    {\n-        TxBlock txblock;\n-        ProtobufByteArrayToSerializable(result.txblocks(i).txblock(), txblock);\n-        txBlocks.emplace_back(txblock);\n-    }\n+    listenPort = result.listenport();\n \n     return true;\n }\n \n-bool Messenger::SetLookupGetTxBodyFromSeed(vector<unsigned char>& dst,\n-                                           const unsigned int offset,\n-                                           const vector<unsigned char>& txHash,\n-                                           const uint32_t listenPort)\n+// ============================================================================\n+// Consensus messages\n+// ============================================================================\n+\n+bool Messenger::SetConsensusCommit(vector<unsigned char>& dst,\n+                                   const unsigned int offset,\n+                                   const uint32_t consensusID,\n+                                   const vector<unsigned char>& blockHash,\n+                                   const uint16_t backupID,\n+                                   const CommitPoint& commit,\n+                                   const pair<PrivKey, PubKey>& backupKey)\n {\n     LOG_MARKER();\n \n-    LookupGetTxBodyFromSeed result;\n+    ConsensusCommit result;\n \n-    result.set_txhash(txHash.data(), txHash.size());\n-    result.set_listenport(listenPort);\n+    result.mutable_consensusinfo()->set_consensusid(consensusID);\n+    result.mutable_consensusinfo()->set_blockhash(blockHash.data(),\n+                                                  blockHash.size());\n+    result.mutable_consensusinfo()->set_backupid(backupID);\n+    SerializableToProtobufByteArray(\n+        commit, *result.mutable_consensusinfo()->mutable_commit());\n+\n+    if (!result.consensusinfo().IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"ConsensusCommit.Data initialization failed.\");\n+        return false;\n+    }\n+\n+    vector<unsigned char> tmp(result.consensusinfo().ByteSize());\n+    result.consensusinfo().SerializeToArray(tmp.data(), tmp.size());\n+\n+    Signature signature;\n+\n+    if (!Schnorr::GetInstance().Sign(tmp, backupKey.first, backupKey.second,\n+                                     signature))\n+    {\n+        LOG_GENERAL(WARNING, \"Failed to sign commit.\");\n+        return false;\n+    }\n+\n+    SerializableToProtobufByteArray(signature, *result.mutable_signature());\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetTxBodyFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"ConsensusCommit initialization failed.\");\n         return false;\n     }\n \n     return SerializeToArray(result, dst, offset);\n }\n \n-bool Messenger::GetLookupGetTxBodyFromSeed(const vector<unsigned char>& src,\n-                                           const unsigned int offset,\n-                                           vector<unsigned char>& txHash,\n-                                           uint32_t& listenPort)\n+bool Messenger::GetConsensusCommit(\n+    const vector<unsigned char>& src, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    uint16_t& backupID, CommitPoint& commit,\n+    const deque<pair<PubKey, Peer>>& committeeKeys)\n {\n     LOG_MARKER();\n \n-    LookupGetTxBodyFromSeed result;\n+    ConsensusCommit result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupGetTxBodyFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"ConsensusCommit initialization failed.\");\n         return false;\n     }\n \n-    txHash.resize(result.txhash().size());\n-    copy(result.txhash().begin(), result.txhash().end(), txHash.begin());\n-    listenPort = result.listenport();\n+    if (result.consensusinfo().consensusid() != consensusID)\n+    {\n+        LOG_GENERAL(WARNING,\n+                    \"Consensus ID mismatch. Expected: \"\n+                        << consensusID\n+                        << \" Actual: \" << result.consensusinfo().consensusid());\n+        return false;\n+    }\n \n-    return true;\n-}\n+    if ((result.consensusinfo().blockhash().size() != blockHash.size())\n+        || !equal(blockHash.begin(), blockHash.end(),\n+                  result.consensusinfo().blockhash().begin()))\n+    {\n+        LOG_GENERAL(WARNING, \"Block hash mismatch.\");\n+        return false;\n+    }\n \n-bool Messenger::SetLookupSetTxBodyFromSeed(vector<unsigned char>& dst,\n-                                           const unsigned int offset,\n-                                           const vector<unsigned char>& txHash,\n-                                           const Transaction& txBody)\n-{\n-    LOG_MARKER();\n+    backupID = result.consensusinfo().backupid();\n \n-    LookupSetTxBodyFromSeed result;\n+    if (backupID >= committeeKeys.size())\n+    {\n+        LOG_GENERAL(WARNING,\n+                    \"Backup ID beyond shard size. Backup ID: \"\n+                        << backupID << \" Shard size: \" << committeeKeys.size());\n+        return false;\n+    }\n \n-    result.set_txhash(txHash.data(), txHash.size());\n-    SerializableToProtobufByteArray(txBody, *result.mutable_txbody());\n+    ProtobufByteArrayToSerializable(result.consensusinfo().commit(), commit);\n+\n+    vector<unsigned char> tmp(result.consensusinfo().ByteSize());\n+    result.consensusinfo().SerializeToArray(tmp.data(), tmp.size());\n+\n+    Signature signature;\n \n-    if (!result.IsInitialized())\n+    ProtobufByteArrayToSerializable(result.signature(), signature);\n+\n+    if (!Schnorr::GetInstance().Verify(tmp, signature,\n+                                       committeeKeys.at(backupID).first))\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetTxBodyFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"Invalid signature in commit.\");\n         return false;\n     }\n \n-    return SerializeToArray(result, dst, offset);\n+    return true;\n }\n \n-bool Messenger::GetLookupSetTxBodyFromSeed(const vector<unsigned char>& src,\n-                                           const unsigned int offset,\n-                                           vector<unsigned char>& txHash,\n-                                           Transaction& txBody)\n+bool Messenger::SetConsensusChallenge(\n+    vector<unsigned char>& dst, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, const CommitPoint& aggregatedCommit,\n+    const PubKey& aggregatedKey, const Challenge& challenge,\n+    const pair<PrivKey, PubKey>& leaderKey)\n {\n     LOG_MARKER();\n \n-    LookupSetTxBodyFromSeed result;\n+    ConsensusChallenge result;\n \n-    result.ParseFromArray(src.data() + offset, src.size() - offset);\n+    result.mutable_consensusinfo()->set_consensusid(consensusID);\n+    result.mutable_consensusinfo()->set_blockhash(blockHash.data(),\n+                                                  blockHash.size());\n+    result.mutable_consensusinfo()->set_leaderid(leaderID);\n+    SerializableToProtobufByteArray(\n+        aggregatedCommit,\n+        *result.mutable_consensusinfo()->mutable_aggregatedcommit());\n+    SerializableToProtobufByteArray(\n+        aggregatedKey,\n+        *result.mutable_consensusinfo()->mutable_aggregatedkey());\n+    SerializableToProtobufByteArray(\n+        challenge, *result.mutable_consensusinfo()->mutable_challenge());\n \n-    if (!result.IsInitialized())\n+    if (!result.consensusinfo().IsInitialized())\n     {\n-        LOG_GENERAL(WARNING, \"LookupSetTxBodyFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"ConsensusChallenge.Data initialization failed.\");\n         return false;\n     }\n \n-    txHash.resize(result.txhash().size());\n-    copy(result.txhash().begin(), result.txhash().end(), txHash.begin());\n-    ProtobufByteArrayToSerializable(result.txbody(), txBody);\n-\n-    return true;\n-}\n+    vector<unsigned char> tmp(result.consensusinfo().ByteSize());\n+    result.consensusinfo().SerializeToArray(tmp.data(), tmp.size());\n \n-bool Messenger::SetLookupSetNetworkIDFromSeed(vector<unsigned char>& dst,\n-                                              const unsigned int offset,\n-                                              const string& networkID)\n-{\n-    LOG_MARKER();\n+    Signature signature;\n \n-    LookupSetNetworkIDFromSeed result;\n+    if (!Schnorr::GetInstance().Sign(tmp, leaderKey.first, leaderKey.second,\n+                                     signature))\n+    {\n+        LOG_GENERAL(WARNING, \"Failed to sign commit.\");\n+        return false;\n+    }\n \n-    result.set_networkid(networkID);\n+    SerializableToProtobufByteArray(signature, *result.mutable_signature());\n \n     if (!result.IsInitialized())\n     {\n-        LOG_GENERAL(WARNING,\n-                    \"LookupSetNetworkIDFromSeed initialization failed.\");\n+        LOG_GENERAL(WARNING, \"ConsensusChallenge initialization failed.\");\n         return false;\n     }\n \n     return SerializeToArray(result, dst, offset);\n }\n \n-bool Messenger::GetLookupSetNetworkIDFromSeed(const vector<unsigned char>& src,\n-                                              const unsigned int offset,\n-                                              string& networkID)\n+bool Messenger::GetConsensusChallenge(\n+    const vector<unsigned char>& src, const unsigned int offset,\n+    const uint32_t consensusID, const vector<unsigned char>& blockHash,\n+    const uint16_t leaderID, CommitPoint& aggregatedCommit,\n+    PubKey& aggregatedKey, Challenge& challenge, const PubKey& leaderKey)\n {\n     LOG_MARKER();\n \n-    LookupSetNetworkIDFromSeed result;\n+    ConsensusChallenge result;\n \n     result.ParseFromArray(src.data() + offset, src.size() - offset);\n \n     if (!result.IsInitialized())\n+    {\n+        LOG_GENERAL(WARNING, \"ConsensusChallenge initialization failed.\");\n+        return false;\n+    }\n+\n+    if (result.consensusinfo().consensusid() != consensusID)\n     {\n         LOG_GENERAL(WARNING,\n-                    \"LookupSetNetworkIDFromSeed initialization failed.\");\n+                    \"Consensus ID mismatch. Expected: \"\n+                        << consensusID\n+                        << \" Actual: \" << result.consensusinfo().consensusid());\n         return false;\n     }\n \n-    networkID = result.networkid();\n+    if ((result.consensusinfo().blockhash().size() != blockHash.size())\n+        || !equal(blockHash.begin(), blockHash.end(),\n+                  result.consensusinfo().blockhash().begin()))\n+    {\n+        LOG_GENERAL(WARNING, \"Block hash mismatch.\");\n+        return false;\n+    }\n \n-    return true;\n-}\n+    if (result.consensusinfo().leaderid() != leaderID)\n+    {\n+        LOG_GENERAL(WARNING,\n+                    \"Leader ID mismatch. Expected: \"\n+                        << leaderID\n+                        << \" Actual: \" << result.consensusinfo().leaderid());\n+        return false;\n+    }\n \n-bool Messenger::SetLookupGetStateFromSeed(vector<unsigned char>& dst,\n-                                          const unsigned int offset,\n-                                          const uint32_t listenPort)\n-{\n-    LOG_MARKER();\n+    ProtobufByteArrayToSerializable(result.consensusinfo().aggregatedcommit(),\n+                                    aggregatedCommit);\n+    ProtobufByteArrayToSerializable(result.consensusinfo().aggregatedkey(),\n+                                    aggregatedKey);\n+    ProtobufByteArrayToSerializable(result.consensusinfo().challenge(),\n+                                    challenge);\n \n-    LookupGetStateFromSeed result;\n+    vector<unsigned char> tmp(result.consensusinfo().ByteSize());\n+    result.consensusinfo().SerializeToArray(tmp.data(), tmp.size());\n \n-    result.set_listenport(listenPort);\n+    Signature signature;\n \n-    if (!result.IsInitialized())\n+    ProtobufByteArrayToSerializable(result.signature(), signature);\n+\n+    if (!Schnorr::GetInstance().Verify(tmp, signature, leaderKey))\n     {\n-        LOG_GENER","path":"src/libMessage/Messenger.cpp","position":null,"original_position":2586,"commit_id":"5904d3cf91377414f79ab1ba485baa2916d4bc41","original_commit_id":"5904d3cf91377414f79ab1ba485baa2916d4bc41","user":{"login":"ckyang","id":13886288,"node_id":"MDQ6VXNlcjEzODg2Mjg4","avatar_url":"https://avatars0.githubusercontent.com/u/13886288?v=4","gravatar_id":"","url":"https://api.github.com/users/ckyang","html_url":"https://github.com/ckyang","followers_url":"https://api.github.com/users/ckyang/followers","following_url":"https://api.github.com/users/ckyang/following{/other_user}","gists_url":"https://api.github.com/users/ckyang/gists{/gist_id}","starred_url":"https://api.github.com/users/ckyang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckyang/subscriptions","organizations_url":"https://api.github.com/users/ckyang/orgs","repos_url":"https://api.github.com/users/ckyang/repos","events_url":"https://api.github.com/users/ckyang/events{/privacy}","received_events_url":"https://api.github.com/users/ckyang/received_events","type":"User","site_admin":false},"body":"How about using for(const auto i : result.consensusinfo().bitmap())?","created_at":"2018-09-17T05:40:03Z","updated_at":"2018-09-17T05:53:36Z","html_url":"https://github.com/Zilliqa/Zilliqa/pull/590#discussion_r217952201","pull_request_url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/comments/217952201"},"html":{"href":"https://github.com/Zilliqa/Zilliqa/pull/590#discussion_r217952201"},"pull_request":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590"}}},"pull_request":{"url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590","id":215817238,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE1ODE3MjM4","html_url":"https://github.com/Zilliqa/Zilliqa/pull/590","diff_url":"https://github.com/Zilliqa/Zilliqa/pull/590.diff","patch_url":"https://github.com/Zilliqa/Zilliqa/pull/590.patch","issue_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/590","number":590,"state":"open","locked":false,"title":"[Refactor] Integrate protobuf in consensus messages","user":{"login":"ansnunez","id":19547037,"node_id":"MDQ6VXNlcjE5NTQ3MDM3","avatar_url":"https://avatars1.githubusercontent.com/u/19547037?v=4","gravatar_id":"","url":"https://api.github.com/users/ansnunez","html_url":"https://github.com/ansnunez","followers_url":"https://api.github.com/users/ansnunez/followers","following_url":"https://api.github.com/users/ansnunez/following{/other_user}","gists_url":"https://api.github.com/users/ansnunez/gists{/gist_id}","starred_url":"https://api.github.com/users/ansnunez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansnunez/subscriptions","organizations_url":"https://api.github.com/users/ansnunez/orgs","repos_url":"https://api.github.com/users/ansnunez/repos","events_url":"https://api.github.com/users/ansnunez/events{/privacy}","received_events_url":"https://api.github.com/users/ansnunez/received_events","type":"User","site_admin":false},"body":"## Description\r\n<!-- What is the overall goal of your pull request? -->\r\n<!-- What is the context of your pull request? -->\r\n<!-- What are the related issues and pull requests? -->\r\nThis PR integrates Protobuf into all the consensus messages from announcement to final collective sig.\r\n\r\n## Review Suggestion\r\n<!-- How should the reviewers get started on reviewing your pull request-->\r\n<!-- How can the reviewers verify the pull request is working as expected -->\r\nThe changes for commit, response, challenge, and collective sig are pretty much straightforward.\r\nThe tricky part to review is the announcement.\r\n\r\nIn the old way, `StartConsensus` required two parameters: the announcement message and the length within that message that will be co-signed by the peers (Usually this will be the block header).\r\nIn the new way, we let the `Messenger` class give us back a separate vector for the message to be co-signed.\r\n\r\nAnother tricky thing is that `ProcessFinalBlockConsensus` and `ProcessMicroblockConsensus` need to pre-read the consensus ID part of the incoming consensus message to know if it should be buffered or not. So, I have had to provide a `GetConsensusID` interface through `ConsensusCommon` and then through `Messenger` for all possible consensus message types.\r\n\r\nFinally, I have chosen to remove the test `ConsensusUser` instead of updating it as well. Its position in the `msg_handlers` will have to be taken out eventually (#571).\r\n\r\n## Status\r\n\r\n### Implementation\r\n<!-- Add more TODOs before \"ready for review\", if any  -->\r\n- [x] **ready for review**\r\n\r\n### Integration Test (Core Team)\r\n<!-- This is for core team only, ignore this if you are a community contributor -->\r\n\r\n<!-- append the commit digest to inform the others of the versions you have tested -->\r\n- [x] local machine test\r\n<!-- - [ ] local machine test (commit: bbbbbbbb) -->\r\n<!-- - [ ] local machine test (commit: cccccccc) -->\r\n<!-- - [ ] local machine test (commit: dddddddd) -->\r\n- [x] mid-scale cloud test (200 nodes)\r\n<!-- - [ ] small-scale cloud test (commit: bbbbbbbb) -->\r\n<!-- - [ ] small-scale cloud test (commit: cccccccc) -->\r\n<!-- - [ ] small-scale cloud test (commit: dddddddd) -->\r\n","created_at":"2018-09-16T11:10:32Z","updated_at":"2018-09-17T05:53:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b4fa6184306eb1420b5cdbc842e669318fa73aa","assignee":{"login":"ansnunez","id":19547037,"node_id":"MDQ6VXNlcjE5NTQ3MDM3","avatar_url":"https://avatars1.githubusercontent.com/u/19547037?v=4","gravatar_id":"","url":"https://api.github.com/users/ansnunez","html_url":"https://github.com/ansnunez","followers_url":"https://api.github.com/users/ansnunez/followers","following_url":"https://api.github.com/users/ansnunez/following{/other_user}","gists_url":"https://api.github.com/users/ansnunez/gists{/gist_id}","starred_url":"https://api.github.com/users/ansnunez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansnunez/subscriptions","organizations_url":"https://api.github.com/users/ansnunez/orgs","repos_url":"https://api.github.com/users/ansnunez/repos","events_url":"https://api.github.com/users/ansnunez/events{/privacy}","received_events_url":"https://api.github.com/users/ansnunez/received_events","type":"User","site_admin":false},"assignees":[{"login":"ansnunez","id":19547037,"node_id":"MDQ6VXNlcjE5NTQ3MDM3","avatar_url":"https://avatars1.githubusercontent.com/u/19547037?v=4","gravatar_id":"","url":"https://api.github.com/users/ansnunez","html_url":"https://github.com/ansnunez","followers_url":"https://api.github.com/users/ansnunez/followers","following_url":"https://api.github.com/users/ansnunez/following{/other_user}","gists_url":"https://api.github.com/users/ansnunez/gists{/gist_id}","starred_url":"https://api.github.com/users/ansnunez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansnunez/subscriptions","organizations_url":"https://api.github.com/users/ansnunez/orgs","repos_url":"https://api.github.com/users/ansnunez/repos","events_url":"https://api.github.com/users/ansnunez/events{/privacy}","received_events_url":"https://api.github.com/users/ansnunez/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":990370924,"node_id":"MDU6TGFiZWw5OTAzNzA5MjQ=","url":"https://api.github.com/repos/Zilliqa/Zilliqa/labels/Ready","name":"Ready","color":"8ded6a","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590/commits","review_comments_url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590/comments","review_comment_url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/590/comments","statuses_url":"https://api.github.com/repos/Zilliqa/Zilliqa/statuses/5904d3cf91377414f79ab1ba485baa2916d4bc41","head":{"label":"Zilliqa:feature/protobuf5","ref":"feature/protobuf5","sha":"5904d3cf91377414f79ab1ba485baa2916d4bc41","user":{"login":"Zilliqa","id":32560879,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNTYwODc5","avatar_url":"https://avatars1.githubusercontent.com/u/32560879?v=4","gravatar_id":"","url":"https://api.github.com/users/Zilliqa","html_url":"https://github.com/Zilliqa","followers_url":"https://api.github.com/users/Zilliqa/followers","following_url":"https://api.github.com/users/Zilliqa/following{/other_user}","gists_url":"https://api.github.com/users/Zilliqa/gists{/gist_id}","starred_url":"https://api.github.com/users/Zilliqa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zilliqa/subscriptions","organizations_url":"https://api.github.com/users/Zilliqa/orgs","repos_url":"https://api.github.com/users/Zilliqa/repos","events_url":"https://api.github.com/users/Zilliqa/events{/privacy}","received_events_url":"https://api.github.com/users/Zilliqa/received_events","type":"Organization","site_admin":false},"repo":{"id":115495630,"node_id":"MDEwOlJlcG9zaXRvcnkxMTU0OTU2MzA=","name":"Zilliqa","full_name":"Zilliqa/Zilliqa","private":false,"owner":{"login":"Zilliqa","id":32560879,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNTYwODc5","avatar_url":"https://avatars1.githubusercontent.com/u/32560879?v=4","gravatar_id":"","url":"https://api.github.com/users/Zilliqa","html_url":"https://github.com/Zilliqa","followers_url":"https://api.github.com/users/Zilliqa/followers","following_url":"https://api.github.com/users/Zilliqa/following{/other_user}","gists_url":"https://api.github.com/users/Zilliqa/gists{/gist_id}","starred_url":"https://api.github.com/users/Zilliqa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zilliqa/subscriptions","organizations_url":"https://api.github.com/users/Zilliqa/orgs","repos_url":"https://api.github.com/users/Zilliqa/repos","events_url":"https://api.github.com/users/Zilliqa/events{/privacy}","received_events_url":"https://api.github.com/users/Zilliqa/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Zilliqa/Zilliqa","description":"Zilliqa is the world's first high-throughput public blockchain platform - designed to scale to thousands ​of transactions per second.","fork":false,"url":"https://api.github.com/repos/Zilliqa/Zilliqa","forks_url":"https://api.github.com/repos/Zilliqa/Zilliqa/forks","keys_url":"https://api.github.com/repos/Zilliqa/Zilliqa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zilliqa/Zilliqa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zilliqa/Zilliqa/teams","hooks_url":"https://api.github.com/repos/Zilliqa/Zilliqa/hooks","issue_events_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/events{/number}","events_url":"https://api.github.com/repos/Zilliqa/Zilliqa/events","assignees_url":"https://api.github.com/repos/Zilliqa/Zilliqa/assignees{/user}","branches_url":"https://api.github.com/repos/Zilliqa/Zilliqa/branches{/branch}","tags_url":"https://api.github.com/repos/Zilliqa/Zilliqa/tags","blobs_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zilliqa/Zilliqa/statuses/{sha}","languages_url":"https://api.github.com/repos/Zilliqa/Zilliqa/languages","stargazers_url":"https://api.github.com/repos/Zilliqa/Zilliqa/stargazers","contributors_url":"https://api.github.com/repos/Zilliqa/Zilliqa/contributors","subscribers_url":"https://api.github.com/repos/Zilliqa/Zilliqa/subscribers","subscription_url":"https://api.github.com/repos/Zilliqa/Zilliqa/subscription","commits_url":"https://api.github.com/repos/Zilliqa/Zilliqa/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zilliqa/Zilliqa/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zilliqa/Zilliqa/contents/{+path}","compare_url":"https://api.github.com/repos/Zilliqa/Zilliqa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zilliqa/Zilliqa/merges","archive_url":"https://api.github.com/repos/Zilliqa/Zilliqa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zilliqa/Zilliqa/downloads","issues_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues{/number}","pulls_url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls{/number}","milestones_url":"https://api.github.com/repos/Zilliqa/Zilliqa/milestones{/number}","notifications_url":"https://api.github.com/repos/Zilliqa/Zilliqa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zilliqa/Zilliqa/labels{/name}","releases_url":"https://api.github.com/repos/Zilliqa/Zilliqa/releases{/id}","deployments_url":"https://api.github.com/repos/Zilliqa/Zilliqa/deployments","created_at":"2017-12-27T07:42:33Z","updated_at":"2018-09-16T11:11:02Z","pushed_at":"2018-09-17T05:31:57Z","git_url":"git://github.com/Zilliqa/Zilliqa.git","ssh_url":"git@github.com:Zilliqa/Zilliqa.git","clone_url":"https://github.com/Zilliqa/Zilliqa.git","svn_url":"https://github.com/Zilliqa/Zilliqa","homepage":"https://www.zilliqa.com","size":18638,"stargazers_count":641,"watchers_count":641,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":137,"mirror_url":null,"archived":false,"open_issues_count":63,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":137,"open_issues":63,"watchers":641,"default_branch":"master"}},"base":{"label":"Zilliqa:master","ref":"master","sha":"8b90b058e592e6c97a4a618f44114607b1bae2fb","user":{"login":"Zilliqa","id":32560879,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNTYwODc5","avatar_url":"https://avatars1.githubusercontent.com/u/32560879?v=4","gravatar_id":"","url":"https://api.github.com/users/Zilliqa","html_url":"https://github.com/Zilliqa","followers_url":"https://api.github.com/users/Zilliqa/followers","following_url":"https://api.github.com/users/Zilliqa/following{/other_user}","gists_url":"https://api.github.com/users/Zilliqa/gists{/gist_id}","starred_url":"https://api.github.com/users/Zilliqa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zilliqa/subscriptions","organizations_url":"https://api.github.com/users/Zilliqa/orgs","repos_url":"https://api.github.com/users/Zilliqa/repos","events_url":"https://api.github.com/users/Zilliqa/events{/privacy}","received_events_url":"https://api.github.com/users/Zilliqa/received_events","type":"Organization","site_admin":false},"repo":{"id":115495630,"node_id":"MDEwOlJlcG9zaXRvcnkxMTU0OTU2MzA=","name":"Zilliqa","full_name":"Zilliqa/Zilliqa","private":false,"owner":{"login":"Zilliqa","id":32560879,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyNTYwODc5","avatar_url":"https://avatars1.githubusercontent.com/u/32560879?v=4","gravatar_id":"","url":"https://api.github.com/users/Zilliqa","html_url":"https://github.com/Zilliqa","followers_url":"https://api.github.com/users/Zilliqa/followers","following_url":"https://api.github.com/users/Zilliqa/following{/other_user}","gists_url":"https://api.github.com/users/Zilliqa/gists{/gist_id}","starred_url":"https://api.github.com/users/Zilliqa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zilliqa/subscriptions","organizations_url":"https://api.github.com/users/Zilliqa/orgs","repos_url":"https://api.github.com/users/Zilliqa/repos","events_url":"https://api.github.com/users/Zilliqa/events{/privacy}","received_events_url":"https://api.github.com/users/Zilliqa/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Zilliqa/Zilliqa","description":"Zilliqa is the world's first high-throughput public blockchain platform - designed to scale to thousands ​of transactions per second.","fork":false,"url":"https://api.github.com/repos/Zilliqa/Zilliqa","forks_url":"https://api.github.com/repos/Zilliqa/Zilliqa/forks","keys_url":"https://api.github.com/repos/Zilliqa/Zilliqa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zilliqa/Zilliqa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zilliqa/Zilliqa/teams","hooks_url":"https://api.github.com/repos/Zilliqa/Zilliqa/hooks","issue_events_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/events{/number}","events_url":"https://api.github.com/repos/Zilliqa/Zilliqa/events","assignees_url":"https://api.github.com/repos/Zilliqa/Zilliqa/assignees{/user}","branches_url":"https://api.github.com/repos/Zilliqa/Zilliqa/branches{/branch}","tags_url":"https://api.github.com/repos/Zilliqa/Zilliqa/tags","blobs_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zilliqa/Zilliqa/statuses/{sha}","languages_url":"https://api.github.com/repos/Zilliqa/Zilliqa/languages","stargazers_url":"https://api.github.com/repos/Zilliqa/Zilliqa/stargazers","contributors_url":"https://api.github.com/repos/Zilliqa/Zilliqa/contributors","subscribers_url":"https://api.github.com/repos/Zilliqa/Zilliqa/subscribers","subscription_url":"https://api.github.com/repos/Zilliqa/Zilliqa/subscription","commits_url":"https://api.github.com/repos/Zilliqa/Zilliqa/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zilliqa/Zilliqa/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zilliqa/Zilliqa/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zilliqa/Zilliqa/contents/{+path}","compare_url":"https://api.github.com/repos/Zilliqa/Zilliqa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zilliqa/Zilliqa/merges","archive_url":"https://api.github.com/repos/Zilliqa/Zilliqa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zilliqa/Zilliqa/downloads","issues_url":"https://api.github.com/repos/Zilliqa/Zilliqa/issues{/number}","pulls_url":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls{/number}","milestones_url":"https://api.github.com/repos/Zilliqa/Zilliqa/milestones{/number}","notifications_url":"https://api.github.com/repos/Zilliqa/Zilliqa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zilliqa/Zilliqa/labels{/name}","releases_url":"https://api.github.com/repos/Zilliqa/Zilliqa/releases{/id}","deployments_url":"https://api.github.com/repos/Zilliqa/Zilliqa/deployments","created_at":"2017-12-27T07:42:33Z","updated_at":"2018-09-16T11:11:02Z","pushed_at":"2018-09-17T05:31:57Z","git_url":"git://github.com/Zilliqa/Zilliqa.git","ssh_url":"git@github.com:Zilliqa/Zilliqa.git","clone_url":"https://github.com/Zilliqa/Zilliqa.git","svn_url":"https://github.com/Zilliqa/Zilliqa","homepage":"https://www.zilliqa.com","size":18638,"stargazers_count":641,"watchers_count":641,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":137,"mirror_url":null,"archived":false,"open_issues_count":63,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":137,"open_issues":63,"watchers":641,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590"},"html":{"href":"https://github.com/Zilliqa/Zilliqa/pull/590"},"issue":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/590"},"comments":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/issues/590/comments"},"review_comments":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590/comments"},"review_comment":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/pulls/590/commits"},"statuses":{"href":"https://api.github.com/repos/Zilliqa/Zilliqa/statuses/5904d3cf91377414f79ab1ba485baa2916d4bc41"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ckyang"}}