mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix: make config backwards compat (#6768)
This commit is contained in:
@ -4,7 +4,7 @@ use reth_discv4::Discv4Config;
|
||||
use reth_network::{NetworkConfigBuilder, PeersConfig, SessionsConfig};
|
||||
use reth_primitives::PruneModes;
|
||||
use secp256k1::SecretKey;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use std::{path::PathBuf, time::Duration};
|
||||
|
||||
/// Configuration for the reth node.
|
||||
@ -186,7 +186,10 @@ 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")]
|
||||
#[serde(
|
||||
serialize_with = "humantime_serde::serialize",
|
||||
deserialize_with = "deserialize_duration"
|
||||
)]
|
||||
pub max_duration: Option<Duration>,
|
||||
}
|
||||
|
||||
@ -280,6 +283,24 @@ impl Default for PruneConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper type to support older versions of Duration deserialization.
|
||||
fn deserialize_duration<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum AnyDuration {
|
||||
#[serde(deserialize_with = "humantime_serde::deserialize")]
|
||||
Human(Option<Duration>),
|
||||
Duration(Option<Duration>),
|
||||
}
|
||||
|
||||
AnyDuration::deserialize(deserializer).map(|d| match d {
|
||||
AnyDuration::Human(duration) | AnyDuration::Duration(duration) => duration,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Config;
|
||||
@ -443,5 +464,192 @@ storage_history = { distance = 16384 }
|
||||
'0xdac17f958d2ee523a2206206994597c13d831ec7' = { distance = 1000 }
|
||||
#";
|
||||
let _conf: Config = toml::from_str(alpha_0_0_11).unwrap();
|
||||
|
||||
let alpha_0_0_18 = r"#
|
||||
[stages.headers]
|
||||
downloader_max_concurrent_requests = 100
|
||||
downloader_min_concurrent_requests = 5
|
||||
downloader_max_buffered_responses = 100
|
||||
downloader_request_limit = 1000
|
||||
commit_threshold = 10000
|
||||
|
||||
[stages.total_difficulty]
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.bodies]
|
||||
downloader_request_limit = 200
|
||||
downloader_stream_batch_size = 1000
|
||||
downloader_max_buffered_blocks_size_bytes = 2147483648
|
||||
downloader_min_concurrent_requests = 5
|
||||
downloader_max_concurrent_requests = 100
|
||||
|
||||
[stages.sender_recovery]
|
||||
commit_threshold = 5000000
|
||||
|
||||
[stages.execution]
|
||||
max_blocks = 500000
|
||||
max_changes = 5000000
|
||||
max_cumulative_gas = 1500000000000
|
||||
[stages.execution.max_duration]
|
||||
secs = 600
|
||||
nanos = 0
|
||||
|
||||
[stages.account_hashing]
|
||||
clean_threshold = 500000
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.storage_hashing]
|
||||
clean_threshold = 500000
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.merkle]
|
||||
clean_threshold = 50000
|
||||
|
||||
[stages.transaction_lookup]
|
||||
commit_threshold = 5000000
|
||||
|
||||
[stages.index_account_history]
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.index_storage_history]
|
||||
commit_threshold = 100000
|
||||
|
||||
[peers]
|
||||
refill_slots_interval = '5s'
|
||||
trusted_nodes = []
|
||||
connect_trusted_nodes_only = false
|
||||
max_backoff_count = 5
|
||||
ban_duration = '12h'
|
||||
|
||||
[peers.connection_info]
|
||||
max_outbound = 100
|
||||
max_inbound = 30
|
||||
max_concurrent_outbound_dials = 10
|
||||
|
||||
[peers.reputation_weights]
|
||||
bad_message = -16384
|
||||
bad_block = -16384
|
||||
bad_transactions = -16384
|
||||
already_seen_transactions = 0
|
||||
timeout = -4096
|
||||
bad_protocol = -2147483648
|
||||
failed_to_connect = -25600
|
||||
dropped = -4096
|
||||
bad_announcement = -1024
|
||||
|
||||
[peers.backoff_durations]
|
||||
low = '30s'
|
||||
medium = '3m'
|
||||
high = '15m'
|
||||
max = '1h'
|
||||
|
||||
[sessions]
|
||||
session_command_buffer = 32
|
||||
session_event_buffer = 260
|
||||
|
||||
[sessions.limits]
|
||||
|
||||
[sessions.initial_internal_request_timeout]
|
||||
secs = 20
|
||||
nanos = 0
|
||||
|
||||
[sessions.protocol_breach_request_timeout]
|
||||
secs = 120
|
||||
nanos = 0
|
||||
#";
|
||||
let conf: Config = toml::from_str(alpha_0_0_18).unwrap();
|
||||
assert_eq!(conf.stages.execution.max_duration, Some(Duration::from_secs(10 * 60)));
|
||||
|
||||
let alpha_0_0_19 = r"#
|
||||
[stages.headers]
|
||||
downloader_max_concurrent_requests = 100
|
||||
downloader_min_concurrent_requests = 5
|
||||
downloader_max_buffered_responses = 100
|
||||
downloader_request_limit = 1000
|
||||
commit_threshold = 10000
|
||||
|
||||
[stages.total_difficulty]
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.bodies]
|
||||
downloader_request_limit = 200
|
||||
downloader_stream_batch_size = 1000
|
||||
downloader_max_buffered_blocks_size_bytes = 2147483648
|
||||
downloader_min_concurrent_requests = 5
|
||||
downloader_max_concurrent_requests = 100
|
||||
|
||||
[stages.sender_recovery]
|
||||
commit_threshold = 5000000
|
||||
|
||||
[stages.execution]
|
||||
max_blocks = 500000
|
||||
max_changes = 5000000
|
||||
max_cumulative_gas = 1500000000000
|
||||
max_duration = '10m'
|
||||
|
||||
[stages.account_hashing]
|
||||
clean_threshold = 500000
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.storage_hashing]
|
||||
clean_threshold = 500000
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.merkle]
|
||||
clean_threshold = 50000
|
||||
|
||||
[stages.transaction_lookup]
|
||||
commit_threshold = 5000000
|
||||
|
||||
[stages.index_account_history]
|
||||
commit_threshold = 100000
|
||||
|
||||
[stages.index_storage_history]
|
||||
commit_threshold = 100000
|
||||
|
||||
[peers]
|
||||
refill_slots_interval = '5s'
|
||||
trusted_nodes = []
|
||||
connect_trusted_nodes_only = false
|
||||
max_backoff_count = 5
|
||||
ban_duration = '12h'
|
||||
|
||||
[peers.connection_info]
|
||||
max_outbound = 100
|
||||
max_inbound = 30
|
||||
max_concurrent_outbound_dials = 10
|
||||
|
||||
[peers.reputation_weights]
|
||||
bad_message = -16384
|
||||
bad_block = -16384
|
||||
bad_transactions = -16384
|
||||
already_seen_transactions = 0
|
||||
timeout = -4096
|
||||
bad_protocol = -2147483648
|
||||
failed_to_connect = -25600
|
||||
dropped = -4096
|
||||
bad_announcement = -1024
|
||||
|
||||
[peers.backoff_durations]
|
||||
low = '30s'
|
||||
medium = '3m'
|
||||
high = '15m'
|
||||
max = '1h'
|
||||
|
||||
[sessions]
|
||||
session_command_buffer = 32
|
||||
session_event_buffer = 260
|
||||
|
||||
[sessions.limits]
|
||||
|
||||
[sessions.initial_internal_request_timeout]
|
||||
secs = 20
|
||||
nanos = 0
|
||||
|
||||
[sessions.protocol_breach_request_timeout]
|
||||
secs = 120
|
||||
nanos = 0
|
||||
#";
|
||||
let _conf: Config = toml::from_str(alpha_0_0_19).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user