From 3e4b947598f2de1e6716d7ed0d36a1dd2a58167b Mon Sep 17 00:00:00 2001 From: yukang Date: Tue, 15 Aug 2023 18:43:47 +0800 Subject: [PATCH] entries in Gap will not be fill proposals --- test/src/specs/tx_pool/descendant.rs | 23 +++++++++++++++++------ tx-pool/src/pool.rs | 2 -- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/src/specs/tx_pool/descendant.rs b/test/src/specs/tx_pool/descendant.rs index 04b5a5bc4b..ed23bb7db3 100644 --- a/test/src/specs/tx_pool/descendant.rs +++ b/test/src/specs/tx_pool/descendant.rs @@ -1,3 +1,5 @@ +use ckb_jsonrpc_types::Status; + use crate::specs::tx_pool::utils::prepare_tx_family; use crate::utils::{blank, commit, propose}; use crate::{Node, Spec}; @@ -166,21 +168,30 @@ impl Spec for SubmitTransactionWhenItsParentInProposed { // 1. Propose `tx_family.a` into proposed-pool. let family = prepare_tx_family(node); - node.submit_transaction(family.a()); - node.submit_block(&propose(node, &[family.a()])); + let tx_a = family.a(); + node.submit_transaction(tx_a); + node.submit_block(&propose(node, &[tx_a])); (0..=window.closest()).for_each(|_| { node.submit_block(&blank(node)); }); + // tx_a should in Proposed status + let tx_a_status = node.get_transaction(tx_a.hash()); + assert_eq!(tx_a_status.status, Status::Proposed); + // 2. Submit `tx_family.b` into pending-pool. Then we expect that miner propose it. node.submit_transaction(family.b()); let block = node.new_block_with_blocking(|template| template.proposals.is_empty()); + let union_proposal_ids = block.union_proposal_ids(); assert!( - block - .union_proposal_ids() - .contains(&family.b().proposal_short_id()), + union_proposal_ids.contains(&family.b().proposal_short_id()), "Miner should propose tx_family.b since it has never been proposed, actual: {:?}", - block.union_proposal_ids(), + union_proposal_ids, + ); + assert!( + !union_proposal_ids.contains(&tx_a.proposal_short_id()), + "Miner should not propose tx_family.a since it has been proposed, actual: {:?}", + union_proposal_ids, ); node.submit_block(&block); } diff --git a/tx-pool/src/pool.rs b/tx-pool/src/pool.rs index caa05c12d5..b7952f4838 100644 --- a/tx-pool/src/pool.rs +++ b/tx-pool/src/pool.rs @@ -390,8 +390,6 @@ impl TxPool { let mut proposals = HashSet::with_capacity(limit); self.pool_map .fill_proposals(limit, exclusion, &mut proposals, Status::Pending); - self.pool_map - .fill_proposals(limit, exclusion, &mut proposals, Status::Gap); proposals }