-
Notifications
You must be signed in to change notification settings - Fork 843
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
Arc
definition in TransactionPool
#7042
Arc
definition in TransactionPool
#7042
Conversation
/// Get hash of transaction. | ||
fn hash_of(&self, transaction: &B::Extrinsic) -> H; | ||
fn hash_of(&self, transaction: &Arc<B::Extrinsic>) -> H; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Arc is not needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean we are already passing reference to the extrinsics data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah 👍
/// Import a transaction into the pool. | ||
/// | ||
/// This will return future. | ||
fn import(&self, transaction: B::Extrinsic) -> TransactionImportFuture; | ||
fn import(&self, transaction: Arc<B::Extrinsic>) -> TransactionImportFuture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This currently does not make sense. We would need to change submit_one
/ submit_and_watch
API to accept Arc.
Otherwise we create Arc, then dereference it and create new one within transcaction pool implementation.
For the sake of the simplicity I would only rework
When it comes to |
@dharjeezy are you planning to continue working on this? |
yes. i will get it done through the week/weekend. |
@@ -471,7 +471,8 @@ where | |||
|
|||
debug!(target: LOG_TARGET, "Propagating transaction [{:?}]", hash); | |||
if let Some(transaction) = self.transaction_pool.transaction(hash) { | |||
let propagated_to = self.do_propagate_transactions(&[(hash.clone(), transaction)]); | |||
let propagated_to = | |||
self.do_propagate_transactions(&[(hash.clone(), Arc::new(transaction))]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we avoid Arc::new
here?
I think that this transaction
method could also provide an Arc
reference, here:
polkadot-sdk/substrate/client/service/src/lib.rs
Lines 562 to 567 in 682f8cd
fn transaction(&self, hash: &H) -> Option<B::Extrinsic> { | |
self.pool.ready_transaction(hash).and_then( | |
// Only propagable transactions should be resolved for network service. | |
|tx| if tx.is_propagable() { Some((**tx.data()).clone()) } else { None }, | |
) | |
} |
This is just method of the same trait (sc-network-transactions::config::TransactionPool
), so should be easily doable:
fn transaction(&self, hash: &H) -> Option<B::Extrinsic>; |
Would you change it too?
prdoc/pr_5978.prdoc
Outdated
title: `networking::TransactionPool` should accept `Arc` | ||
doc: | ||
- audience: Node Dev | ||
description: The TransactionPool trait now accepts an `Arc` for transactions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: The TransactionPool trait now accepts an `Arc` for transactions. | |
description: The `sc_network_transactions::config::TransactionPool` trait now accepts an `Arc` for transactions. |
substrate/client/service/src/lib.rs
Outdated
self.pool.ready_transaction(hash).and_then( | ||
// Only propagable transactions should be resolved for network service. | ||
|tx| if tx.is_propagable() { Some((**tx.data()).clone()) } else { None }, | ||
|tx| if tx.is_propagable() { Some(Arc::new((**tx.data()).clone())) } else { None }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need new Arc
, something like this should work:
|tx| if tx.is_propagable() { Some(Arc::new((**tx.data()).clone())) } else { None }, | |
|tx| tx.is_propagable().then(|| { tx.data().clone() }), |
prdoc/pr_5978.prdoc
Outdated
@@ -0,0 +1,9 @@ | |||
title: `networking::TransactionPool` should accept `Arc` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name of the file is incorrect. Please rename it to: pr_7042.prdoc
prdoc/pr_5978.prdoc
Outdated
title: `networking::TransactionPool` should accept `Arc` | ||
doc: | ||
- audience: Node Dev | ||
description: The `sc_network_transactions::config::TransactionPool` trait now accepts an `Arc` for transactions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: The `sc_network_transactions::config::TransactionPool` trait now accepts an `Arc` for transactions. | |
description: The `sc_network_transactions::config::TransactionPool` trait now returns an `Arc` for transactions. |
Looks good, thank you! |
bot fmt |
@michalkucharczyk https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/8096196 was started for your command Comment |
@michalkucharczyk Command |
b2004ed
* master: (58 commits) [pallet-revive] pack exceeding syscall arguments into registers (#7319) cumulus: bump PARENT_SEARCH_DEPTH and add test for 12-core elastic scaling (#6983) xcm: fix for DenyThenTry Barrier (#7169) Migrating polkadot-runtime-common slots benchmarking to v2 (#6614) Add development chain-spec file for minimal/parachain templates for Omni Node compatibility (#6529) `Arc` definition in `TransactionPool` (#7042) [sync] Let new subscribers know about already connected peers (backward-compatible) (#7344) Removed unused dependencies (partial progress) (#7329) Improve debugging by using `#[track_caller]` in system `assert_last_event` and `assert_has_event` (#7142) `set_validation_data` register weight manually, do not use refund when the pre dispatch is zero. (#7327) Fix the link to the chain snapshots (#7330) revive: Fix compilation of `uapi` crate when `unstable-hostfn` is not set (#7318) [pallet-revive] eth-rpc minor fixes (#7325) sync-templates: enable syncing from stable release patches (#7227) Bridges: emulated tests small nits/improvements (#7322) fix(cmd bench-omni): build omni-bencher with production profile (#7299) Nits for collectives-westend XCM benchmarks setup (#7215) bench all weekly - and fix for pallet_multisig lib (#6789) Deprecate ParaBackingState API (#6867) Fix setting the image properly (#7315) ...
closes #5978