fix: Duration serde execution stage (#6691)

This commit is contained in:
Matthias Seitz
2024-02-20 13:09:11 +01:00
committed by GitHub
parent a5dc8d6679
commit ca2c883cd6
5 changed files with 19 additions and 2 deletions

1
Cargo.lock generated
View File

@ -5905,6 +5905,7 @@ name = "reth-config"
version = "0.1.0-alpha.19"
dependencies = [
"confy",
"humantime-serde",
"reth-discv4",
"reth-net-nat",
"reth-network",

View File

@ -212,6 +212,7 @@ tracing-appender = "0.2"
thiserror = "1.0"
serde_json = "1.0.94"
serde = { version = "1.0", default-features = false }
humantime-serde = "1.1"
rand = "0.8.5"
schnellru = "0.2"
strum = "0.26"

View File

@ -17,9 +17,10 @@ reth-net-nat.workspace = true
reth-discv4.workspace = true
reth-primitives.workspace = true
# io
# serde
serde.workspace = true
serde_json.workspace = true
humantime-serde.workspace = true
# crypto
secp256k1 = { workspace = true, features = ["global-context", "rand-std", "recovery"] }

View File

@ -186,6 +186,7 @@ pub struct ExecutionConfig {
/// The maximum cumulative amount of gas to process before the execution stage commits.
pub max_cumulative_gas: Option<u64>,
/// The maximum time spent on blocks processing before the execution stage commits.
#[serde(with = "humantime_serde")]
pub max_duration: Option<Duration>,
}
@ -282,6 +283,7 @@ impl Default for PruneConfig {
#[cfg(test)]
mod tests {
use super::Config;
use std::time::Duration;
const EXTENSION: &str = "toml";
@ -313,6 +315,18 @@ mod tests {
})
}
#[test]
fn test_load_execution_stage() {
with_tempdir("config-load-test", |config_path| {
let mut config = Config::default();
config.stages.execution.max_duration = Some(Duration::from_secs(10 * 60));
confy::store_path(config_path, &config).unwrap();
let loaded_config: Config = confy::load_path(config_path).unwrap();
assert_eq!(config, loaded_config);
})
}
// ensures config deserialization is backwards compatible
#[test]
fn test_backwards_compatibility() {

View File

@ -46,7 +46,7 @@ tokio-util = { workspace = true, features = ["codec"] }
# io
serde = { workspace = true, optional = true }
humantime-serde = { version = "1.1", optional = true }
humantime-serde = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
# metrics