-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate EngineArgs into NodeCommand (#13748)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
- Loading branch information
Showing
7 changed files
with
99 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//! clap [Args](clap::Args) for engine purposes | ||
use clap::Args; | ||
|
||
use crate::node_config::{DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, DEFAULT_PERSISTENCE_THRESHOLD}; | ||
|
||
/// Parameters for configuring the engine driver. | ||
#[derive(Debug, Clone, Args, PartialEq, Eq)] | ||
#[command(next_help_heading = "Engine")] | ||
pub struct EngineArgs { | ||
/// Configure persistence threshold for engine experimental. | ||
#[arg(long = "engine.persistence-threshold", default_value_t = DEFAULT_PERSISTENCE_THRESHOLD)] | ||
pub persistence_threshold: u64, | ||
|
||
/// Configure the target number of blocks to keep in memory. | ||
#[arg(long = "engine.memory-block-buffer-target", default_value_t = DEFAULT_MEMORY_BLOCK_BUFFER_TARGET)] | ||
pub memory_block_buffer_target: u64, | ||
|
||
/// Enable state root task | ||
#[arg(long = "engine.state-root-task")] | ||
pub state_root_task_enabled: bool, | ||
|
||
/// Enable comparing trie updates from the state root task to the trie updates from the regular | ||
/// state root calculation. | ||
#[arg(long = "engine.state-root-task-compare-updates")] | ||
pub state_root_task_compare_updates: bool, | ||
} | ||
|
||
impl Default for EngineArgs { | ||
fn default() -> Self { | ||
Self { | ||
persistence_threshold: DEFAULT_PERSISTENCE_THRESHOLD, | ||
memory_block_buffer_target: DEFAULT_MEMORY_BLOCK_BUFFER_TARGET, | ||
state_root_task_enabled: false, | ||
state_root_task_compare_updates: false, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use clap::Parser; | ||
|
||
/// A helper type to parse Args more easily | ||
#[derive(Parser)] | ||
struct CommandParser<T: Args> { | ||
#[command(flatten)] | ||
args: T, | ||
} | ||
|
||
#[test] | ||
fn test_parse_engine_args() { | ||
let default_args = EngineArgs::default(); | ||
let args = CommandParser::<EngineArgs>::parse_from(["reth"]).args; | ||
assert_eq!(args, default_args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters