diff --git a/src/avalanche/peermanager.h b/src/avalanche/peermanager.h --- a/src/avalanche/peermanager.h +++ b/src/avalanche/peermanager.h @@ -389,6 +389,7 @@ size_t getConflictingProofCount() { return conflictingProofPool.countProofs(); } + size_t getOrphanProofCount() { return orphanProofPool.countProofs(); } const ProofRadixTree &getShareableProofsSnapshot() const { return shareableProofs; diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp --- a/src/rpc/avalanche.cpp +++ b/src/rpc/avalanche.cpp @@ -673,6 +673,9 @@ {RPCResult::Type::NUM, "conflicting_proof_count", "The number of known avalanche proofs that conflict with " "valid proofs."}, + {RPCResult::Type::NUM, "orphan_proof_count", + "The number of known avalanche proofs that are " + "orphaned."}, {RPCResult::Type::STR_AMOUNT, "total_stake_amount", "The total staked amount over all the valid proofs in " + Currency::get().ticker + "."}, @@ -755,6 +758,7 @@ network.pushKV("connected_proof_count", connectedProofCount); network.pushKV("conflicting_proof_count", pm.getConflictingProofCount()); + network.pushKV("orphan_proof_count", pm.getOrphanProofCount()); network.pushKV("total_stake_amount", totalStakes); network.pushKV("connected_stake_amount", connectedStakes); diff --git a/test/functional/abc_rpc_getavalancheinfo.py b/test/functional/abc_rpc_getavalancheinfo.py --- a/test/functional/abc_rpc_getavalancheinfo.py +++ b/test/functional/abc_rpc_getavalancheinfo.py @@ -28,7 +28,7 @@ '-enableavalanche=1', '-enableavalancheproofreplacement=1', f'-avalancheconflictingproofcooldown={self.conflicting_proof_cooldown}', - '-avaproofstakeutxoconfirmations=1', + '-avaproofstakeutxoconfirmations=2', '-avacooldown=', '-avatimeout=100', '-enableavalanchepeerdiscovery=1', @@ -42,6 +42,9 @@ privkey, proof = gen_proof(node) is_legacy = isinstance(proof, LegacyAvalancheProof) + # Make the proof mature + node.generate(1) + def handle_legacy_format(expected): # Add the payout address to the expected output if the legacy format # is diabled @@ -66,6 +69,7 @@ "proof_count": 0, "connected_proof_count": 0, "conflicting_proof_count": 0, + "orphan_proof_count": 0, "total_stake_amount": Decimal('0.00'), "connected_stake_amount": Decimal('0.00'), "node_count": 0, @@ -94,6 +98,7 @@ "proof_count": 0, "connected_proof_count": 0, "conflicting_proof_count": 0, + "orphan_proof_count": 0, "total_stake_amount": Decimal('0.00'), "connected_stake_amount": Decimal('0.00'), "node_count": 0, @@ -118,6 +123,7 @@ "proof_count": 0, "connected_proof_count": 0, "conflicting_proof_count": 0, + "orphan_proof_count": 0, "total_stake_amount": Decimal('0.00'), "connected_stake_amount": Decimal('0.00'), "node_count": 0, @@ -142,6 +148,9 @@ conflicting_proof = node.buildavalancheproof( 10, 9999, bytes_to_wif(_privkey.get_bytes()), stakes) + # Make the proof and its conflicting proof mature + node.generate(1) + n = get_ava_p2p_interface(node) success = node.addavalanchenode( n.nodeid, _privkey.get_pubkey().get_bytes().hex(), _proof.serialize().hex()) @@ -151,6 +160,10 @@ node.setmocktime(mock_time) n.send_avaproof(avalanche_proof_from_hex(conflicting_proof)) + # Generate an orphan (immature) proof + _, orphan_proof = gen_proof(node) + n.send_avaproof(orphan_proof) + self.wait_until( lambda: node.getavalancheinfo() == handle_legacy_format({ "active": True, @@ -165,6 +178,7 @@ "proof_count": N, "connected_proof_count": N, "conflicting_proof_count": N, + "orphan_proof_count": 1, "total_stake_amount": coinbase_amount * N, "connected_stake_amount": coinbase_amount * N, "node_count": N, @@ -196,6 +210,7 @@ "proof_count": N, "connected_proof_count": N - D, "conflicting_proof_count": N, + "orphan_proof_count": 1, "total_stake_amount": coinbase_amount * N, "connected_stake_amount": coinbase_amount * (N - D), "node_count": N - D, @@ -215,6 +230,9 @@ _privkey, _proof = gen_proof(node) + # Make the proof mature + node.generate(1) + delegation = node.delegateavalancheproof( f"{_proof.limited_proofid:0{64}x}", bytes_to_wif(_privkey.get_bytes()), @@ -238,10 +256,12 @@ "stake_amount": coinbase_amount, }, "network": { - "proof_count": N, + # Orphan became mature + "proof_count": N + 1, "connected_proof_count": N - D, "conflicting_proof_count": N, - "total_stake_amount": coinbase_amount * N, + "orphan_proof_count": 0, + "total_stake_amount": coinbase_amount * (N + 1), "connected_stake_amount": coinbase_amount * (N - D), "node_count": N - D + P, "connected_node_count": N - D, @@ -265,10 +285,11 @@ "stake_amount": coinbase_amount, }, "network": { - "proof_count": N, + "proof_count": N + 1, "connected_proof_count": 0, "conflicting_proof_count": N, - "total_stake_amount": coinbase_amount * N, + "orphan_proof_count": 0, + "total_stake_amount": coinbase_amount * (N + 1), "connected_stake_amount": 0, "node_count": 0, "connected_node_count": 0,