Skip to content

Commit 724b684

Browse files
committed
Flip defaults for txpool prewarming
1 parent 3eb8dd2 commit 724b684

4 files changed

Lines changed: 58 additions & 21 deletions

File tree

crates/engine/primitives/src/config.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl Default for TreeConfig {
230230
always_compare_trie_updates: false,
231231
disable_state_cache: false,
232232
disable_prewarming: false,
233-
txpool_prewarming: false,
233+
txpool_prewarming: true,
234234
state_provider_metrics: false,
235235
cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE,
236236
has_enough_parallelism: has_enough_parallelism(),
@@ -307,7 +307,7 @@ impl TreeConfig {
307307
always_compare_trie_updates,
308308
disable_state_cache,
309309
disable_prewarming,
310-
txpool_prewarming: false,
310+
txpool_prewarming: true,
311311
state_provider_metrics,
312312
cross_block_cache_size,
313313
has_enough_parallelism,
@@ -534,6 +534,12 @@ impl TreeConfig {
534534
self
535535
}
536536

537+
/// Setter for whether to disable txpool transaction prewarming.
538+
pub const fn without_txpool_prewarming(mut self, disabled: bool) -> Self {
539+
self.txpool_prewarming = !disabled;
540+
self
541+
}
542+
537543
/// Setter for whether to always compare trie updates from the state root task to the trie
538544
/// updates from the regular state root calculation.
539545
pub const fn with_always_compare_trie_updates(
@@ -797,6 +803,12 @@ impl TreeConfig {
797803
mod tests {
798804
use super::TreeConfig;
799805

806+
#[test]
807+
fn txpool_prewarming_is_enabled_by_default_and_can_be_disabled() {
808+
assert!(TreeConfig::default().txpool_prewarming());
809+
assert!(!TreeConfig::default().without_txpool_prewarming(true).txpool_prewarming());
810+
}
811+
800812
#[test]
801813
fn state_root_task_requires_parallelism_without_overrides() {
802814
assert!(TreeConfig::default().with_has_enough_parallelism(true).use_state_root_task());

crates/ethereum/node/tests/e2e/selfdestruct.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ fn selfdestruct_contract_init_code() -> Bytes {
141141
async fn test_selfdestruct_post_dencun() -> eyre::Result<()> {
142142
reth_tracing::init_test_tracing();
143143

144-
let tree_config = TreeConfig::default().without_prewarming(true).without_state_cache(false);
144+
let tree_config = TreeConfig::default()
145+
.without_prewarming(true)
146+
.without_txpool_prewarming(true)
147+
.without_state_cache(false);
145148
let (mut nodes, wallet) =
146149
setup_engine::<EthereumNode>(1, cancun_spec(), false, tree_config, eth_payload_attributes)
147150
.await?;
@@ -235,7 +238,10 @@ async fn test_selfdestruct_post_dencun() -> eyre::Result<()> {
235238
async fn test_selfdestruct_same_tx_post_dencun() -> eyre::Result<()> {
236239
reth_tracing::init_test_tracing();
237240

238-
let tree_config = TreeConfig::default().without_prewarming(true).without_state_cache(false);
241+
let tree_config = TreeConfig::default()
242+
.without_prewarming(true)
243+
.without_txpool_prewarming(true)
244+
.without_state_cache(false);
239245
let (mut nodes, wallet) =
240246
setup_engine::<EthereumNode>(1, cancun_spec(), false, tree_config, eth_payload_attributes)
241247
.await?;
@@ -310,7 +316,10 @@ async fn test_selfdestruct_same_tx_post_dencun() -> eyre::Result<()> {
310316
async fn test_selfdestruct_pre_dencun() -> eyre::Result<()> {
311317
reth_tracing::init_test_tracing();
312318

313-
let tree_config = TreeConfig::default().without_prewarming(true).without_state_cache(false);
319+
let tree_config = TreeConfig::default()
320+
.without_prewarming(true)
321+
.without_txpool_prewarming(true)
322+
.without_state_cache(false);
314323
let (mut nodes, wallet) = setup_engine::<EthereumNode>(
315324
1,
316325
shanghai_spec(),
@@ -420,7 +429,10 @@ async fn test_selfdestruct_pre_dencun() -> eyre::Result<()> {
420429
async fn test_selfdestruct_same_tx_preexisting_account_post_dencun() -> eyre::Result<()> {
421430
reth_tracing::init_test_tracing();
422431

423-
let tree_config = TreeConfig::default().without_prewarming(true).without_state_cache(false);
432+
let tree_config = TreeConfig::default()
433+
.without_prewarming(true)
434+
.without_txpool_prewarming(true)
435+
.without_state_cache(false);
424436
let (mut nodes, wallet) =
425437
setup_engine::<EthereumNode>(1, cancun_spec(), false, tree_config, eth_payload_attributes)
426438
.await?;

crates/node/core/src/args/engine.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct DefaultEngineValues {
3232
invalid_header_hit_eviction_threshold: u8,
3333
state_cache_disabled: bool,
3434
prewarming_disabled: bool,
35-
txpool_prewarming_enabled: bool,
35+
txpool_prewarming_disabled: bool,
3636
state_provider_metrics: bool,
3737
cross_block_cache_size: usize,
3838
state_root_task_compare_updates: bool,
@@ -106,9 +106,9 @@ impl DefaultEngineValues {
106106
self
107107
}
108108

109-
/// Set whether to enable txpool prewarming by default
110-
pub const fn with_txpool_prewarming_enabled(mut self, v: bool) -> Self {
111-
self.txpool_prewarming_enabled = v;
109+
/// Set whether to disable txpool prewarming by default
110+
pub const fn with_txpool_prewarming_disabled(mut self, v: bool) -> Self {
111+
self.txpool_prewarming_disabled = v;
112112
self
113113
}
114114

@@ -269,7 +269,7 @@ impl Default for DefaultEngineValues {
269269
invalid_header_hit_eviction_threshold: DEFAULT_INVALID_HEADER_HIT_EVICTION_THRESHOLD,
270270
state_cache_disabled: false,
271271
prewarming_disabled: false,
272-
txpool_prewarming_enabled: false,
272+
txpool_prewarming_disabled: false,
273273
state_provider_metrics: false,
274274
cross_block_cache_size: DEFAULT_CROSS_BLOCK_CACHE_SIZE_MB,
275275
state_root_task_compare_updates: false,
@@ -358,9 +358,9 @@ pub struct EngineArgs {
358358
#[arg(long = "engine.disable-prewarming", alias = "engine.disable-caching-and-prewarming", default_value_t = DefaultEngineValues::get_global().prewarming_disabled)]
359359
pub prewarming_disabled: bool,
360360

361-
/// Enable best-effort txpool transaction prewarming between payloads.
362-
#[arg(long = "engine.txpool-prewarming", default_value_t = DefaultEngineValues::get_global().txpool_prewarming_enabled)]
363-
pub txpool_prewarming_enabled: bool,
361+
/// Disable best-effort txpool transaction prewarming between payloads.
362+
#[arg(long = "engine.disable-txpool-prewarming", default_value_t = DefaultEngineValues::get_global().txpool_prewarming_disabled)]
363+
pub txpool_prewarming_disabled: bool,
364364

365365
/// CAUTION: This CLI flag has no effect anymore. The parallel sparse trie is always enabled.
366366
#[deprecated]
@@ -567,7 +567,7 @@ impl Default for EngineArgs {
567567
invalid_header_hit_eviction_threshold,
568568
state_cache_disabled,
569569
prewarming_disabled,
570-
txpool_prewarming_enabled,
570+
txpool_prewarming_disabled,
571571
state_provider_metrics,
572572
cross_block_cache_size,
573573
state_root_task_compare_updates,
@@ -603,7 +603,7 @@ impl Default for EngineArgs {
603603
caching_and_prewarming_enabled: true,
604604
state_cache_disabled,
605605
prewarming_disabled,
606-
txpool_prewarming_enabled,
606+
txpool_prewarming_disabled,
607607
parallel_sparse_trie_enabled: true,
608608
parallel_sparse_trie_disabled: false,
609609
state_provider_metrics,
@@ -676,7 +676,7 @@ impl EngineArgs {
676676
.with_invalid_header_hit_eviction_threshold(self.invalid_header_hit_eviction_threshold)
677677
.without_state_cache(self.state_cache_disabled)
678678
.without_prewarming(self.prewarming_disabled)
679-
.with_txpool_prewarming(self.txpool_prewarming_enabled)
679+
.without_txpool_prewarming(self.txpool_prewarming_disabled)
680680
.with_state_provider_metrics(self.state_provider_metrics)
681681
.with_always_compare_trie_updates(self.state_root_task_compare_updates)
682682
.with_cross_block_cache_size(self.cross_block_cache_size * 1024 * 1024)
@@ -733,6 +733,19 @@ mod tests {
733733
);
734734
}
735735

736+
#[test]
737+
fn txpool_prewarming_is_enabled_by_default_and_can_be_disabled() {
738+
let args = CommandParser::<EngineArgs>::parse_from(["reth"]).args;
739+
assert!(!args.txpool_prewarming_disabled);
740+
assert!(args.tree_config().txpool_prewarming());
741+
742+
let args =
743+
CommandParser::<EngineArgs>::parse_from(["reth", "--engine.disable-txpool-prewarming"])
744+
.args;
745+
assert!(args.txpool_prewarming_disabled);
746+
assert!(!args.tree_config().txpool_prewarming());
747+
}
748+
736749
#[test]
737750
fn default_backpressure_threshold_uses_parsed_persistence_args() {
738751
let args = CommandParser::<EngineArgs>::parse_from([
@@ -795,7 +808,7 @@ mod tests {
795808
caching_and_prewarming_enabled: true,
796809
state_cache_disabled: true,
797810
prewarming_disabled: true,
798-
txpool_prewarming_enabled: true,
811+
txpool_prewarming_disabled: true,
799812
parallel_sparse_trie_enabled: true,
800813
parallel_sparse_trie_disabled: false,
801814
state_provider_metrics: true,
@@ -841,7 +854,7 @@ mod tests {
841854
"--engine.legacy-state-root",
842855
"--engine.disable-state-cache",
843856
"--engine.disable-prewarming",
844-
"--engine.txpool-prewarming",
857+
"--engine.disable-txpool-prewarming",
845858
"--engine.state-provider-metrics",
846859
"--engine.cross-block-cache-size",
847860
"256",

docs/vocs/docs/pages/cli/reth/node.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,8 @@ Engine:
10111011
--engine.disable-prewarming
10121012
Disable parallel prewarming
10131013
1014-
--engine.txpool-prewarming
1015-
Enable best-effort txpool transaction prewarming between payloads
1014+
--engine.disable-txpool-prewarming
1015+
Disable best-effort txpool transaction prewarming between payloads
10161016
10171017
--engine.state-provider-metrics
10181018
Enable state provider latency metrics. This allows the engine to collect and report stats about how long state provider calls took during execution, but this does introduce slight overhead to state provider calls

0 commit comments

Comments
 (0)