Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
aa5bea3
add ready_at_light fallback
iulianbarbu May 14, 2025
b54e528
update test
iulianbarbu May 14, 2025
9e4b754
improve comment
iulianbarbu May 14, 2025
be1d112
fix comment
iulianbarbu May 14, 2025
a42f414
Update from github-actions[bot] running command 'prdoc'
github-actions[bot] May 14, 2025
489e1c9
fix prdoc
iulianbarbu May 14, 2025
475ae31
Merge branch 'master' into ib-add-fallback-for-ready-at-light
iulianbarbu May 14, 2025
67bc04f
try another prdoc fix
iulianbarbu May 14, 2025
83f970b
revert old test and create a new one
iulianbarbu May 15, 2025
6c0b382
add missing assert
iulianbarbu May 15, 2025
9a29656
Update substrate/client/transaction-pool/src/fork_aware_txpool/fork_a…
iulianbarbu May 15, 2025
87418e1
Merge branch 'master' into ib-add-fallback-for-ready-at-light
iulianbarbu May 15, 2025
6727942
refactor the ready_at_light best view search
iulianbarbu May 15, 2025
b858a23
adjust docs
iulianbarbu May 15, 2025
c2e0bd9
Update from github-actions[bot] running command 'fmt'
github-actions[bot] May 15, 2025
ebc78b0
Update prdoc/pr_8533.prdoc
iulianbarbu May 16, 2025
eae2c1d
Update substrate/client/transaction-pool/src/fork_aware_txpool/fork_a…
iulianbarbu May 16, 2025
5940d41
Update substrate/client/transaction-pool/src/fork_aware_txpool/fork_a…
iulianbarbu May 16, 2025
3a1d6be
Merge branch 'master' into ib-add-fallback-for-ready-at-light
iulianbarbu May 16, 2025
d11101e
polish iterating through enacted blocks
iulianbarbu May 16, 2025
ebcf7aa
fix comment
iulianbarbu May 18, 2025
fbd6669
Merge branch 'master' into ib-add-fallback-for-ready-at-light
iulianbarbu May 18, 2025
64d0e7a
fix build error
iulianbarbu May 18, 2025
ccc8cf2
Update substrate/client/transaction-pool/tests/fatp.rs
iulianbarbu May 19, 2025
1fe3507
Update substrate/client/transaction-pool/src/fork_aware_txpool/mod.rs
iulianbarbu May 19, 2025
9d47e15
more polishing after review
iulianbarbu May 19, 2025
5d7c1fb
more polishing
iulianbarbu May 19, 2025
ee17e1e
Update from github-actions[bot] running command 'fmt'
github-actions[bot] May 19, 2025
897ddfb
tests polishing
iulianbarbu May 19, 2025
15afbb3
return most recent view ready txs if finalized block number can't be …
iulianbarbu May 19, 2025
f0bc263
one more round of polish
iulianbarbu May 19, 2025
2570fa3
address nit
iulianbarbu May 21, 2025
a9a337d
address basti comments
iulianbarbu May 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions prdoc/pr_8533.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: '`fatxpool`: add fallback for ready at light'
doc:
- audience: Node Dev
description: |
Add fallback for `ready_at_light` for the case of not finding a best view that can be used to return a set of ready transactions.
crates:
- name: sc-transaction-pool
bump: major
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,19 @@ where
"fatp::ready_at_light"
);
Box::new(tmp_view.pool.validated_pool().ready())
} else if let Some((most_recent_view, _)) = self
.view_store
.most_recent_view
.read()
.and_then(|at| self.view_store.get_view_at(at, true))
{
// Fallback for the case of not having a best view to use
// for getting a ready transactions set. Even if some of
// the ready txs provided by the most recent view are invalid
// or already included in the blocks, a few of them might still
// be valid for `at` hash, which is still better than including
// nothing.
Box::new(most_recent_view.pool.validated_pool().ready())
} else {
let empty: ReadyIteratorFor<ChainApi> = Box::new(std::iter::empty());
debug!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
//! ### Light maintain
//! The [maintain](#maintain) procedure can sometimes be quite heavy, and it may not be accomplished
//! within the time window expected by the block builder. On top of that block builder may want to
//! build few blocks in the raw, not giving the pool enough time to accomplish possible ongoing
//! build few blocks in the row, not giving the pool enough time to accomplish possible ongoing
//! maintain process.
//!
//! To address this, there is a [light version][`ready_at_light`] of the maintain procedure. It
Expand Down
35 changes: 30 additions & 5 deletions substrate/client/transaction-pool/tests/fatp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2312,11 +2312,7 @@ fn fatp_ready_light_long_fork_retracted_works() {
let xt3 = uxt(Dave, 200);
let xt4 = uxt(Eve, 200);

let submissions = vec![pool.submit_at(
genesis,
SOURCE,
vec![xt0.clone(), xt1.clone(), xt2.clone(), xt3.clone()],
)];
let submissions = vec![pool.submit_at(genesis, SOURCE, vec![xt0.clone(), xt1.clone()])];
let results = block_on(futures::future::join_all(submissions));
assert!(results.iter().all(|r| { r.is_ok() }));

Expand All @@ -2325,15 +2321,44 @@ fn fatp_ready_light_long_fork_retracted_works() {
block_on(pool.maintain(event));

let header01b = api.push_block_with_parent(genesis, vec![xt0.clone()], true);
// Call `ready_at_light` at genesis direct descendent, even if not notified as best or
// finalized. Should still return ready txs based on the most recent view processed by the
// txpool.
let mut ready_iterator = pool.ready_at_light(header01b.hash()).now_or_never().unwrap();
assert!(ready_iterator.next().is_some());
assert!(ready_iterator.next().is_some());
assert!(ready_iterator.next().is_none());

let header02b = api.push_block_with_parent(header01b.hash(), vec![xt1.clone()], true);
let header03b = api.push_block_with_parent(header02b.hash(), vec![xt2.clone()], true);

// Submit a few more txs to the pool.
let submissions = vec![pool.submit_at(
// `at` is ignored.
genesis,
SOURCE,
vec![xt2.clone(), xt3.clone()],
)];
let results = block_on(futures::future::join_all(submissions));
assert!(results.iter().all(|r| { r.is_ok() }));

// Calling `ready_at_light` now on the last block of a fork, with no block notified as best.
// We should still get the ready txs from the most recent view processed by the txpool,
// but now with a few more txs which were submitted previously.
let mut ready_iterator = pool.ready_at_light(header03b.hash()).now_or_never().unwrap();
assert!(ready_iterator.next().is_some());
assert!(ready_iterator.next().is_some());
assert!(ready_iterator.next().is_some());
assert!(ready_iterator.next().is_some());
assert!(ready_iterator.next().is_none());

let event = new_best_block_event(&pool, Some(header01a.hash()), header01b.hash());
block_on(pool.maintain(event));

// Calling `ready_at_light` on the new best block (`header03b`) should consider its fork up to
// the finalized block for the search of the best view, and coincidentaly, that's the only view
// of the tree route, being the view created for NBB `header03b`. The returned ready txs are the
// ones left in the best view's pool after prunning the txs.
let mut ready_iterator = pool.ready_at_light(header03b.hash()).now_or_never().unwrap();
let ready01 = ready_iterator.next();
assert_eq!(ready01.unwrap().hash, api.hash_and_length(&xt3).0);
Expand Down
Loading