Skip to content

Conversation

@AurelienFT
Copy link
Contributor

@AurelienFT AurelienFT commented Mar 12, 2025

Linked Issues/PRs

Resolve #2860

Description

When a pre-confirmation status has arrived to the pool the pool can take action to updates some states

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

@AurelienFT AurelienFT requested a review from a team as a code owner March 12, 2025 08:59
@AurelienFT AurelienFT self-assigned this Mar 12, 2025
self.expired_transactions_and_dependents(tx_and_dependents_ids);
}
PoolTxUpdateRequest::PreconfirmedTransactions { txs } => {
self.preconfirmed_transactions(txs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pass an iterator instead?

Suggested change
self.preconfirmed_transactions(txs);
self.preconfirmed_transactions(txs.iter());

}
}

fn preconfirmed_transactions(&mut self, txs: Vec<(TxId, PreconfirmationStatus)>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn preconfirmed_transactions(&mut self, txs: Vec<(TxId, PreconfirmationStatus)>) {
fn preconfirmed_transactions(&mut self, txs: impl Iterator<Item = &(TxId, PreconfirmationStatus)>) {

perhaps?

}

fn remove_and_coin_dependents(&mut self, tx_ids: (Vec<TxId>, Error)) {
fn expired_transactions_and_dependents(&mut self, tx_ids: (Vec<TxId>, Error)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can take an iterator here too, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the type transformation it requires to write to make this works when calling this function because of the tuple, I would pass this one.

#[derive(Clone)]
pub struct SharedState {
pub(crate) request_remove_sender: mpsc::Sender<PoolRemoveRequest>,
pub(crate) request_remove_sender: mpsc::Sender<PoolTxUpdateRequest>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub(crate) request_remove_sender: mpsc::Sender<PoolTxUpdateRequest>,
pub(crate) request_update_sender: mpsc::Sender<PoolTxUpdateRequest>,


pub fn notify_preconfirmed_txs(&self, txs: Vec<(TxId, PreconfirmationStatus)>) {
if let Err(e) = self
.request_remove_sender
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.request_remove_sender
.request_update_sender

.collect();

if let Err(e) = self
.request_remove_sender
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.request_remove_sender
.request_update_sender

thread_management_sender: Sender<ThreadManagementRequest>,
pub(super) request_insert_sender: Sender<PoolInsertRequest>,
pub(super) request_remove_sender: Sender<PoolRemoveRequest>,
pub(super) request_remove_sender: Sender<PoolTxUpdateRequest>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub(super) request_remove_sender: Sender<PoolTxUpdateRequest>,
pub(super) request_update_sender: Sender<PoolTxUpdateRequest>,

pub fn new_known_tx<'a>(
&mut self,
new_known_tx: ArcPoolTx,
new_known_tx_outputs: impl Iterator<Item = &'a Output>,
Copy link
Member

@rymnc rymnc Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps this Output/iterator should be boxed?
difficult to say without knowing average size of outputs that we have, but in the case the user has 255 outputs this would be overusing the cache and move other imp code out of the cpu cache

since we have a limit on the total number of outputs, perhaps we can use smallvec?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(i only write this because of the comment that says "we expect it to be called a lot")


pub(super) enum PoolRemoveRequest {
pub(super) enum PoolTxUpdateRequest {
PreconfirmedTransactions {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of doing that, the transaction pool should subscribe for all pre-confirmation that comes from the TxStatusUpdater.

In that case you also don't need SkippedTransactions, because you will receive PreConfirmationSqueezedOut.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this in a new PR (easier): #2882 . However it's still the service that receive the data and pass it to the worker if necessary to minimize the usage of the worker thread.

Comment on lines +112 to +113
| Output::Change { .. }
| Output::Variable { .. } => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved outputs only contain Change and Variable outputs=D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, we need to make a note to add an integration test to check that we can submit transaction that uses Change or Variable output form its parent after receiving a preconfiramtion

Base automatically changed from add_timer_based_expiration_pending_pool to master March 13, 2025 08:31
@AurelienFT AurelienFT requested a review from netrome as a code owner March 13, 2025 08:31
@AurelienFT
Copy link
Contributor Author

Closing in favor of #2882 to address @xgreenx comment. Thanks for the review @rymnc I adressed your comments in the new PR.

@AurelienFT AurelienFT closed this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use outputs from the pre-confirmation status to update TxPool sooner

4 participants