Skip to content

Commit

Permalink
entries in Gap will not be fill proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Aug 15, 2023
1 parent 0374910 commit 3e4b947
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 17 additions & 6 deletions test/src/specs/tx_pool/descendant.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions tx-pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3e4b947

Please sign in to comment.