Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Finalized block event triggers tx maintanance #12305

Merged
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
4995ead
finalized block event triggers tx maintanance
michalkucharczyk Sep 20, 2022
339636e
tx-pool: enactment helper introduced
michalkucharczyk Sep 22, 2022
cce685b
tx-pool: ChainApi: added tree_route method
michalkucharczyk Sep 26, 2022
a7c8035
enactment logic implemented + tests
michalkucharczyk Sep 26, 2022
cd27bc5
Some additional tests
michalkucharczyk Sep 27, 2022
9090201
minor improvements
michalkucharczyk Sep 27, 2022
8479b64
trigger CI job
michalkucharczyk Sep 27, 2022
e86d1bb
Merge remote-tracking branch 'origin/master' into mku-finalized-event…
michalkucharczyk Sep 27, 2022
deb7eab
fix compilation errors
michalkucharczyk Sep 28, 2022
cff7bd8
formatting
michalkucharczyk Sep 28, 2022
69040e9
trait removed
michalkucharczyk Sep 28, 2022
e367ffd
implementation slightly simplified
michalkucharczyk Sep 28, 2022
eb0a3b0
get rid of Arc<> in EnactmentState return value
michalkucharczyk Sep 28, 2022
c78f904
minor improvement
michalkucharczyk Sep 28, 2022
0c89000
Apply suggestions from code review
michalkucharczyk Sep 30, 2022
e75b180
Apply suggestions from code review
michalkucharczyk Sep 30, 2022
3a7f433
comment updated + formatting
michalkucharczyk Sep 30, 2022
a285f57
Apply suggestions from code review
michalkucharczyk Oct 1, 2022
26f8d96
formatting
michalkucharczyk Oct 1, 2022
4826e06
Merge remote-tracking branch 'origin/master' into mku-finalized-event…
michalkucharczyk Oct 3, 2022
7d59e8d
finalization notification bug fix
michalkucharczyk Oct 3, 2022
d0cc123
added error message on tree_route failure
michalkucharczyk Oct 3, 2022
7d8f162
Merge remote-tracking branch 'origin/master' into mku-finalized-event…
michalkucharczyk Oct 4, 2022
57b9192
Apply suggestions from code review
michalkucharczyk Oct 4, 2022
1e3af7e
use provided tree_route in Finalized event
michalkucharczyk Oct 4, 2022
cfd7f63
Option removed from ChainApi::tree_route
michalkucharczyk Oct 4, 2022
637a7ab
doc added, test and logs improved
michalkucharczyk Oct 4, 2022
6bfceca
handle_enactment aligned with original implementation
michalkucharczyk Oct 4, 2022
80f5216
use async-await
andresilva Oct 4, 2022
79c6739
Apply suggestions from code review
michalkucharczyk Oct 4, 2022
d7de511
Apply suggestions from code review
michalkucharczyk Oct 4, 2022
29e31b3
formatting + warn->debug
michalkucharczyk Oct 4, 2022
4bebf96
compilation error fix
michalkucharczyk Oct 4, 2022
0ef2a75
enactment_state initializers added
michalkucharczyk Oct 5, 2022
3793021
enactment_state: Option removed
michalkucharczyk Oct 5, 2022
d0d3d54
Merge remote-tracking branch 'origin/master' into mku-finalized-event…
michalkucharczyk Oct 5, 2022
8d26c23
manual-seal: compilation & tests fix
michalkucharczyk Oct 5, 2022
937daab
manual-seal: tests fixed
michalkucharczyk Oct 5, 2022
fef7e86
tests cleanup
michalkucharczyk Oct 5, 2022
49e4b4c
another compilation error fixed
michalkucharczyk Oct 5, 2022
3f038b5
TreeRoute::new added
michalkucharczyk Oct 7, 2022
0b6b28b
get rid of pub hack
michalkucharczyk Oct 7, 2022
36fb53b
one more test added
michalkucharczyk Oct 7, 2022
7d081b6
Merge remote-tracking branch 'origin/mku-finalized-tx-maintenance-imp…
michalkucharczyk Oct 7, 2022
65c41f5
formatting
michalkucharczyk Oct 7, 2022
7519a1b
Merge remote-tracking branch 'origin/master' into mku-finalized-event…
michalkucharczyk Oct 7, 2022
8e74825
Merge remote-tracking branch 'origin/master' into mku-finalized-event…
michalkucharczyk Oct 7, 2022
763c51c
TreeRoute::new doc added + formatting
michalkucharczyk Oct 7, 2022
1b49dd1
Apply suggestions from code review
michalkucharczyk Oct 7, 2022
cf98315
(bool,Option) simplified to Option
michalkucharczyk Oct 7, 2022
7f35983
log message improved
michalkucharczyk Oct 7, 2022
f46d5b6
Merge remote-tracking branch 'origin/master' into mku-finalized-event…
michalkucharczyk Oct 10, 2022
32a9522
yet another review suggestions applied
michalkucharczyk Oct 10, 2022
64a2ec0
get rid of hash in handle_enactment
michalkucharczyk Oct 10, 2022
61f9b92
Apply suggestions from code review
michalkucharczyk Oct 11, 2022
df3eec6
Update client/transaction-pool/src/lib.rs
michalkucharczyk Oct 11, 2022
d35c651
minor corrections
michalkucharczyk Oct 11, 2022
649bbf3
EnactmentState moved to new file
michalkucharczyk Oct 11, 2022
dab0fc3
File header corrected
michalkucharczyk Oct 11, 2022
63072de
error formatting aligned with codebase
michalkucharczyk Oct 11, 2022
e6ba411
Apply suggestions from code review
michalkucharczyk Oct 11, 2022
fdc6bd5
remove commented code
andresilva Oct 11, 2022
6ae40f6
small nits
andresilva Oct 11, 2022
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 client/transaction-pool/benches/basics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ impl ChainApi for TestApi {
) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error> {
Ok(None)
}

fn tree_route(
&self,
_from: <Self::Block as BlockT>::Hash,
_to: <Self::Block as BlockT>::Hash,
) -> Result<Option<sp_blockchain::TreeRoute<Self::Block>>, Self::Error> {
Ok(None)
}
}

fn uxt(transfer: Transfer) -> Extrinsic {
Expand Down
32 changes: 26 additions & 6 deletions client/transaction-pool/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::{marker::PhantomData, pin::Pin, sync::Arc};
use prometheus_endpoint::Registry as PrometheusRegistry;
use sc_client_api::{blockchain::HeaderBackend, BlockBackend};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::{HeaderMetadata, TreeRoute};
use sp_core::traits::SpawnEssentialNamed;
use sp_runtime::{
generic::BlockId,
Expand Down Expand Up @@ -111,8 +112,11 @@ impl<Client, Block> FullChainApi<Client, Block> {
impl<Client, Block> graph::ChainApi for FullChainApi<Client, Block>
where
Block: BlockT,
Client:
ProvideRuntimeApi<Block> + BlockBackend<Block> + BlockIdTo<Block> + HeaderBackend<Block>,
Client: ProvideRuntimeApi<Block>
+ BlockBackend<Block>
+ BlockIdTo<Block>
+ HeaderBackend<Block>
+ HeaderMetadata<Block, Error = sp_blockchain::Error>,
Client: Send + Sync + 'static,
Client::Api: TaggedTransactionQueue<Block>,
{
Expand Down Expand Up @@ -190,6 +194,16 @@ where
) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error> {
self.client.header(*at).map_err(Into::into)
}

fn tree_route(
&self,
from: <Self::Block as BlockT>::Hash,
to: <Self::Block as BlockT>::Hash,
) -> Result<Option<TreeRoute<Self::Block>>, Self::Error> {
sp_blockchain::tree_route::<Block, Client>(&*self.client, from, to)
.map_err(Into::into)
.map(Into::into)
}
}

/// Helper function to validate a transaction using a full chain API.
Expand All @@ -202,8 +216,11 @@ fn validate_transaction_blocking<Client, Block>(
) -> error::Result<TransactionValidity>
where
Block: BlockT,
Client:
ProvideRuntimeApi<Block> + BlockBackend<Block> + BlockIdTo<Block> + HeaderBackend<Block>,
Client: ProvideRuntimeApi<Block>
+ BlockBackend<Block>
+ BlockIdTo<Block>
+ HeaderBackend<Block>
+ HeaderMetadata<Block, Error = sp_blockchain::Error>,
Client: Send + Sync + 'static,
Client::Api: TaggedTransactionQueue<Block>,
{
Expand Down Expand Up @@ -264,8 +281,11 @@ where
impl<Client, Block> FullChainApi<Client, Block>
where
Block: BlockT,
Client:
ProvideRuntimeApi<Block> + BlockBackend<Block> + BlockIdTo<Block> + HeaderBackend<Block>,
Client: ProvideRuntimeApi<Block>
+ BlockBackend<Block>
+ BlockIdTo<Block>
+ HeaderBackend<Block>
+ HeaderMetadata<Block, Error = sp_blockchain::Error>,
Client: Send + Sync + 'static,
Client::Api: TaggedTransactionQueue<Block>,
{
Expand Down
8 changes: 8 additions & 0 deletions client/transaction-pool/src/graph/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration};

use futures::{channel::mpsc::Receiver, Future};
use sc_transaction_pool_api::error;
use sp_blockchain::TreeRoute;
use sp_runtime::{
generic::BlockId,
traits::{self, Block as BlockT, SaturatedConversion},
Expand Down Expand Up @@ -97,6 +98,13 @@ pub trait ChainApi: Send + Sync {
&self,
at: &BlockId<Self::Block>,
) -> Result<Option<<Self::Block as BlockT>::Header>, Self::Error>;

/// Returns a tree route
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
fn tree_route(
&self,
from: <Self::Block as BlockT>::Hash,
to: <Self::Block as BlockT>::Hash,
) -> Result<Option<TreeRoute<Self::Block>>, Self::Error>;
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
}

/// Pool configuration options.
Expand Down
Loading