Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export api from the transaction pool to query ready transaction by tag #3705

Open
2 tasks done
NingLin-P opened this issue Mar 14, 2024 · 0 comments
Open
2 tasks done
Labels
I5-enhancement An additional feature request. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@NingLin-P
Copy link
Contributor

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Motivation

In subspace, we have fraud proof extrinsic that are expensive to validate compared to other normal extrinsic. Fraud proof is attached with a provide tag and a priority so that fraud proof with the same tag and lower priority will be rejected if there is already a fraud proof with a higher priority in the transaction pool.

However, this only happens after the incoming fraud proof is validated, while we know the tag and priority of a fraud proof before it is validated, we would like to use the tag to query if the transaction pool already contains another fraud proof with the same tag and higher priority, if so we can drop the incoming fraud proof directly without validating it to save some resource.

Request

Similar to the ready_by_hash, export an API ready_by_tag from the transaction pool to get ready transaction by tag

Solution

The required changes are also similar to the ready_by_hash implementation:

ValidatedPool

/// Get ready transaction by tag
pub fn ready_by_tag(&self, tag: &Tag) -> Option<TransactionFor<B>> {
    self.pool.read().ready_by_tag(tag)
}

BasePool

/// Returns pool transaction by tag.
pub fn ready_by_tag(&self, tag: &Tag) -> Option<Arc<Transaction<Hash, Ex>>> {
    self.ready.by_tag(tag)
}

ReadyTransactions

/// Retrieve transaction by tag
pub fn by_tag(&self, tag: &Tag) -> Option<Arc<Transaction<Hash, Ex>>> {
    match self.provided_tags().get(tag) {
        Some(hash) => self.by_hash(hash),
        None => None
    }
}

Are you willing to help with this request?

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I5-enhancement An additional feature request. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

1 participant