diff --git a/src/avalanche/processor.h b/src/avalanche/processor.h --- a/src/avalanche/processor.h +++ b/src/avalanche/processor.h @@ -249,12 +249,6 @@ class NotificationsHandler; std::unique_ptr chainNotificationsHandler; - /** - * Flag indicating that the proof must be registered at first new block - * after IBD - */ - bool mustRegisterProof = false; - Processor(interfaces::Chain &chain, CConnman *connmanIn, NodePeerManager *nodePeerManagerIn, std::unique_ptr peerDataIn, CKey sessionKeyIn); diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -209,10 +209,9 @@ void updatedBlockTip() override { LOCK(m_processor->cs_peerManager); - if (m_processor->mustRegisterProof && - !::ChainstateActive().IsInitialBlockDownload()) { - m_processor->peerManager->getPeerId(m_processor->peerData->proof); - m_processor->mustRegisterProof = false; + if (m_processor->peerData && m_processor->peerData->proof) { + m_processor->peerManager->registerProof( + m_processor->peerData->proof); } m_processor->peerManager->updatedBlockTip(); @@ -225,10 +224,7 @@ : connman(connmanIn), nodePeerManager(nodePeerManagerIn), queryTimeoutDuration(AVALANCHE_DEFAULT_QUERY_TIMEOUT), round(0), peerManager(std::make_unique()), - peerData(std::move(peerDataIn)), sessionKey(std::move(sessionKeyIn)), - // Schedule proof registration at the first new block after IBD. - // FIXME: get rid of this flag - mustRegisterProof(!!peerData) { + peerData(std::move(peerDataIn)), sessionKey(std::move(sessionKeyIn)) { // Make sure we get notified of chain state changes. chainNotificationsHandler = chain.handleNotifications(std::make_shared(this)); diff --git a/test/functional/abc_rpc_avalancheproof.py b/test/functional/abc_rpc_avalancheproof.py --- a/test/functional/abc_rpc_avalancheproof.py +++ b/test/functional/abc_rpc_avalancheproof.py @@ -101,23 +101,15 @@ assert_raises_rpc_error(-22, "Proof has invalid format", node.decodeavalancheproof, proof[:-2]) - # Restart the node, making sure it is initially in IBD mode - minchainwork = int(node.getblockchaininfo()["chainwork"], 16) + 1 + # Restart the node with this proof self.restart_node(0, self.extra_args[0] + [ "-avaproof={}".format(proof), "-avamasterkey=cND2ZvtabDbJ1gucx9GWH6XT9kgTAqfb6cotPt5Q5CyxVDhid2EN", - "-minimumchainwork=0x{:x}".format(minchainwork), ]) - self.log.info( - "The proof verification should be delayed until IBD is complete") - assert node.getblockchaininfo()["initialblockdownload"] is True - # Our proof cannot be verified during IBD, so we should have no peer - assert not node.getavalanchepeerinfo() - # Mining one more block should cause us to leave IBD + self.log.info("The proof is registered at first chaintip update") + assert_equal(len(node.getavalanchepeerinfo()), 0) node.generate(1) - # Our proof is now verified and our node is added as a peer - assert node.getblockchaininfo()["initialblockdownload"] is False wait_until(lambda: len(node.getavalanchepeerinfo()) == 1, timeout=5) if self.is_wallet_compiled():