Skip to content

Commit 328b42c

Browse files
AurelienFTxgreenx
andauthored
Linking TxPoolV2 in place of V1 (#2263)
Closes #2020 Closes #1961 Closes #868 Closes #2185 Closes #2186 Closes #2255 Closes #2160 Closes #1967 Closes #2187 ## Description Remove code of the previous txpool and connect all modules to this one TODO: Improve description @AurelienFT ## Checklist - [x] Breaking changes are clearly marked as such in the PR description and changelog - [x] New behavior is reflected in tests - [x] [The specification](https://github.com/FuelLabs/fuel-specs/) matches the implemented behavior (link update PR if changes are needed) ### Before requesting review - [x] I have reviewed the code myself - [x] I have created follow-up issues caused by this PR and linked them here --------- Co-authored-by: Green Baneling <XgreenX9999@gmail.com>
1 parent a6f31c8 commit 328b42c

File tree

128 files changed

+1011
-8892
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1011
-8892
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
### Added
1010
- [2309](https://github.com/FuelLabs/fuel-core/pull/2309): Limit number of concurrent queries to the graphql service.
1111
- [2216](https://github.com/FuelLabs/fuel-core/pull/2216): Add more function to the state and task of TxPoolV2 to handle the future interactions with others modules (PoA, BlockProducer, BlockImporter and P2P)
12+
- [2263](https://github.com/FuelLabs/fuel-core/pull/2263): Use the Txpool v2 in the whole codebase
1213

1314
### Removed
1415
- [2306](https://github.com/FuelLabs/fuel-core/pull/2306): Removed hack for genesis asset contract from the code.
@@ -27,8 +28,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2728
- [2131](https://github.com/FuelLabs/fuel-core/pull/2131): Add flow in TxPool in order to ask to newly connected peers to share their transaction pool
2829
- [2182](https://github.com/FuelLabs/fuel-core/pull/2151): Limit number of transactions that can be fetched via TxSource::next
2930
- [2189](https://github.com/FuelLabs/fuel-core/pull/2151): Select next DA height to never include more than u16::MAX -1 transactions from L1.
30-
- [2162](https://github.com/FuelLabs/fuel-core/pull/2162): Pool structure with dependencies, etc.. for the next transaction pool module. Also adds insertion/verification process in PoolV2 and tests refactoring
3131
- [2265](https://github.com/FuelLabs/fuel-core/pull/2265): Integrate Block Committer API for DA Block Costs.
32+
- [2162](https://github.com/FuelLabs/fuel-core/pull/2162): Pool structure with dependencies, etc.. for the next transaction pool module. Also adds insertion/verification process in PoolV2 and tests refactoring
3233
- [2280](https://github.com/FuelLabs/fuel-core/pull/2280): Allow comma separated relayer addresses in cli
3334
- [2299](https://github.com/FuelLabs/fuel-core/pull/2299): Support blobs in the predicates.
3435
- [2300](https://github.com/FuelLabs/fuel-core/pull/2300): Added new function to `fuel-core-client` for checking whether a blob exists.

Cargo.lock

Lines changed: 2 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ members = [
2525
"crates/services/producer",
2626
"crates/services/relayer",
2727
"crates/services/sync",
28-
"crates/services/txpool",
2928
"crates/services/txpool_v2",
3029
"crates/services/upgradable-executor",
3130
"crates/services/upgradable-executor/wasm-executor",
@@ -77,8 +76,7 @@ fuel-core-p2p = { version = "0.37.1", path = "./crates/services/p2p" }
7776
fuel-core-producer = { version = "0.37.1", path = "./crates/services/producer" }
7877
fuel-core-relayer = { version = "0.37.1", path = "./crates/services/relayer" }
7978
fuel-core-sync = { version = "0.37.1", path = "./crates/services/sync" }
80-
fuel-core-txpool = { version = "0.37.1", path = "./crates/services/txpool" }
81-
fuel-core-txpool-v2 = { version = "0.37.1", path = "./crates/services/txpool_v2" }
79+
fuel-core-txpool = { version = "0.37.1", path = "./crates/services/txpool_v2" }
8280
fuel-core-storage = { version = "0.37.1", path = "./crates/storage", default-features = false }
8381
fuel-core-trace = { version = "0.37.1", path = "./crates/trace" }
8482
fuel-core-types = { version = "0.37.1", path = "./crates/types", default-features = false }

benches/benches/block_target_gas.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use fuel_core::{
2727
Config,
2828
FuelService,
2929
},
30-
txpool::types::Word,
3130
};
3231
use fuel_core_benches::{
3332
default_gas_costs::default_gas_costs,
@@ -57,6 +56,7 @@ use fuel_core_types::{
5756
GTFArgs,
5857
Instruction,
5958
RegId,
59+
Word,
6060
},
6161
fuel_crypto::{
6262
secp256r1,
@@ -428,11 +428,8 @@ fn run_with_service_with_extra_inputs(
428428
let mut sub = shared.block_importer.block_importer.subscribe();
429429
shared
430430
.txpool_shared_state
431-
.insert(vec![std::sync::Arc::new(tx)])
431+
.insert(tx)
432432
.await
433-
.into_iter()
434-
.next()
435-
.expect("Should be at least 1 element")
436433
.expect("Should include transaction successfully");
437434
let res = sub.recv().await.expect("Should produce a block");
438435
assert_eq!(res.tx_status.len(), 2, "res.tx_status: {:?}", res.tx_status);

benches/benches/transaction_throughput.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,15 @@ where
104104
for _ in 0..iters {
105105
let mut test_builder = test_builder.clone();
106106
let sealed_block = {
107-
let transactions = transactions
108-
.iter()
109-
.map(|tx| Arc::new(tx.clone()))
110-
.collect();
107+
let transactions: Vec<Transaction> =
108+
transactions.iter().cloned().collect();
111109
// start the producer node
112110
let TestContext { srv, client, .. } =
113111
test_builder.finalize().await;
114112

115113
// insert all transactions
116-
let results =
117-
srv.shared.txpool_shared_state.insert(transactions).await;
118-
for result in results {
119-
let result = result.expect("Should insert transaction");
120-
assert_eq!(result.removed.len(), 0);
114+
for tx in transactions {
115+
srv.shared.txpool_shared_state.insert(tx).await.unwrap();
121116
}
122117
let _ = client.produce_blocks(1, None).await;
123118

bin/e2e-test-client/tests/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use fuel_core::service::{
44
};
55

66
// Add methods on commands
7-
use fuel_core::txpool::types::ContractId;
87
use fuel_core_chain_config::{
98
SnapshotMetadata,
109
SnapshotReader,
1110
};
1211
use fuel_core_e2e_client::config::SuiteConfig;
12+
use fuel_core_types::fuel_tx::ContractId;
1313
use std::{
1414
fs,
1515
str::FromStr,

bin/fuel-core/src/cli/run.rs

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ use fuel_core::{
3333
RelayerConsensusConfig,
3434
VMConfig,
3535
},
36-
txpool::{
37-
config::BlackList,
36+
txpool::config::{
37+
BlackList,
3838
Config as TxPoolConfig,
39+
HeavyWorkConfig,
40+
PoolLimits,
41+
ServiceChannelLimits,
3942
},
4043
types::{
4144
fuel_tx::ContractId,
@@ -438,22 +441,50 @@ impl Command {
438441

439442
let TxPoolArgs {
440443
tx_pool_ttl,
444+
tx_ttl_check_interval,
441445
tx_max_number,
442-
tx_max_depth,
446+
tx_max_total_bytes,
447+
tx_max_total_gas,
448+
tx_max_chain_count,
443449
tx_number_active_subscriptions,
444450
tx_blacklist_addresses,
445451
tx_blacklist_coins,
446452
tx_blacklist_messages,
447453
tx_blacklist_contracts,
454+
tx_number_threads_to_verify_transactions,
455+
tx_size_of_verification_queue,
456+
tx_number_threads_p2p_sync,
457+
tx_size_of_p2p_sync_queue,
458+
tx_max_pending_read_requests,
459+
tx_max_pending_write_requests,
448460
} = tx_pool;
449461

450-
let blacklist = BlackList::new(
462+
let black_list = BlackList::new(
451463
tx_blacklist_addresses,
452464
tx_blacklist_coins,
453465
tx_blacklist_messages,
454466
tx_blacklist_contracts,
455467
);
456468

469+
let pool_limits = PoolLimits {
470+
max_txs: tx_max_number,
471+
max_gas: tx_max_total_gas,
472+
max_bytes_size: tx_max_total_bytes,
473+
};
474+
475+
let pool_heavy_work_config = HeavyWorkConfig {
476+
number_threads_to_verify_transactions:
477+
tx_number_threads_to_verify_transactions,
478+
size_of_verification_queue: tx_size_of_verification_queue,
479+
number_threads_p2p_sync: tx_number_threads_p2p_sync,
480+
size_of_p2p_sync_queue: tx_size_of_p2p_sync_queue,
481+
};
482+
483+
let service_channel_limits = ServiceChannelLimits {
484+
max_pending_read_pool_requests: tx_max_pending_read_requests,
485+
max_pending_write_pool_requests: tx_max_pending_write_requests,
486+
};
487+
457488
let config = Config {
458489
graphql_config: GraphQLConfig {
459490
addr,
@@ -477,15 +508,17 @@ impl Command {
477508
vm: VMConfig {
478509
backtrace: vm_backtrace,
479510
},
480-
txpool: TxPoolConfig::new(
481-
tx_max_number,
482-
tx_max_depth,
511+
txpool: TxPoolConfig {
512+
max_txs_chain_count: tx_max_chain_count,
513+
max_txs_ttl: tx_pool_ttl.into(),
514+
ttl_check_interval: tx_ttl_check_interval.into(),
483515
utxo_validation,
484-
metrics,
485-
tx_pool_ttl.into(),
486-
tx_number_active_subscriptions,
487-
blacklist,
488-
),
516+
max_tx_update_subscriptions: tx_number_active_subscriptions,
517+
black_list,
518+
pool_limits,
519+
heavy_work: pool_heavy_work_config,
520+
service_channel_limits,
521+
},
489522
block_producer: ProducerConfig {
490523
coinbase_recipient,
491524
metrics,

bin/fuel-core/src/cli/run/p2p.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ pub struct P2PArgs {
189189
/// For peer reputations, the maximum time since last heartbeat before penalty
190190
#[clap(long = "heartbeat-max-time-since-last", default_value = "40", env)]
191191
pub heartbeat_max_time_since_last: u64,
192+
193+
/// Number of threads to read from the database.
194+
#[clap(long = "p2p-database-read-threads", default_value = "2", env)]
195+
pub database_read_threads: usize,
196+
197+
/// Number of threads to read from the tx pool.
198+
#[clap(long = "p2p-txpool-threads", default_value = "0", env)]
199+
pub tx_pool_threads: usize,
192200
}
193201

194202
#[derive(Debug, Clone, Args)]
@@ -335,6 +343,8 @@ impl P2PArgs {
335343
info_interval: Some(Duration::from_secs(self.info_interval)),
336344
identify_interval: Some(Duration::from_secs(self.identify_interval)),
337345
metrics,
346+
database_read_threads: self.database_read_threads,
347+
tx_pool_threads: self.tx_pool_threads,
338348
state: NotInitialized,
339349
};
340350
Ok(Some(config))

bin/fuel-core/src/cli/run/tx_pool.rs

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Clap configuration related to TxPool service.
22
3-
use fuel_core::txpool::types::ContractId;
43
use fuel_core_types::{
54
fuel_tx::{
65
Address,
6+
ContractId,
77
UtxoId,
88
},
99
fuel_types::Nonce,
@@ -15,13 +15,25 @@ pub struct TxPoolArgs {
1515
#[clap(long = "tx-pool-ttl", default_value = "5m", env)]
1616
pub tx_pool_ttl: humantime::Duration,
1717

18+
/// The interval for checking the time to live of transactions.
19+
#[clap(long = "tx-ttl-check-interval", default_value = "1m", env)]
20+
pub tx_ttl_check_interval: humantime::Duration,
21+
1822
/// The max number of transactions that the `TxPool` can simultaneously store.
1923
#[clap(long = "tx-max-number", default_value = "4064", env)]
2024
pub tx_max_number: usize,
2125

22-
/// The max depth of the dependent transactions that supported by the `TxPool`.
23-
#[clap(long = "tx-max-depth", default_value = "10", env)]
24-
pub tx_max_depth: usize,
26+
/// The max number of gas the `TxPool` can simultaneously store.
27+
#[clap(long = "tx-max-total-gas", default_value = "30000000000", env)]
28+
pub tx_max_total_gas: u64,
29+
30+
/// The max number of bytes that the `TxPool` can simultaneously store.
31+
#[clap(long = "tx-max-total-bytes", default_value = "131072000", env)]
32+
pub tx_max_total_bytes: usize,
33+
34+
/// The max number of tx in a chain of dependent transactions that supported by the `TxPool`.
35+
#[clap(long = "tx-max-depth", default_value = "32", env)]
36+
pub tx_max_chain_count: usize,
2537

2638
/// The maximum number of active subscriptions that supported by the `TxPool`.
2739
#[clap(long = "tx-number-active-subscriptions", default_value = "4064", env)]
@@ -42,6 +54,34 @@ pub struct TxPoolArgs {
4254
/// The list of banned contracts ignored by the `TxPool`.
4355
#[clap(long = "tx-blacklist-contracts", value_delimiter = ',', env)]
4456
pub tx_blacklist_contracts: Vec<ContractId>,
57+
58+
/// Number of threads for managing verifications/insertions.
59+
#[clap(
60+
long = "tx-number-threads-to-verify-transactions",
61+
default_value = "4",
62+
env
63+
)]
64+
pub tx_number_threads_to_verify_transactions: usize,
65+
66+
/// Maximum number of tasks in the verifications/insertions queue.
67+
#[clap(long = "tx-size-of-verification-queue", default_value = "2000", env)]
68+
pub tx_size_of_verification_queue: usize,
69+
70+
/// Number of threads for managing the p2p synchronisation.
71+
#[clap(long = "tx-number-threads-p2p-sync", default_value = "2", env)]
72+
pub tx_number_threads_p2p_sync: usize,
73+
74+
/// Maximum number of tasks in the p2p synchronisation queue.
75+
#[clap(long = "tx-size-of-p2p-sync-queue", default_value = "20", env)]
76+
pub tx_size_of_p2p_sync_queue: usize,
77+
78+
/// Maximum number of pending write requests in the service.
79+
#[clap(long = "tx-max-pending-write-requests", default_value = "500", env)]
80+
pub tx_max_pending_write_requests: usize,
81+
82+
/// Maximum number of pending read requests in the service.
83+
#[clap(long = "tx-max-pending-read-requests", default_value = "1000", env)]
84+
pub tx_max_pending_read_requests: usize,
4585
}
4686

4787
#[cfg(test)]

crates/fuel-core/src/database/coin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ use fuel_core_storage::{
1818
Result as StorageResult,
1919
StorageAsRef,
2020
};
21-
use fuel_core_txpool::types::TxId;
2221
use fuel_core_types::{
2322
entities::coins::coin::CompressedCoin,
2423
fuel_tx::{
2524
Address,
25+
TxId,
2626
UtxoId,
2727
},
2828
};

0 commit comments

Comments
 (0)