Skip to content

Commit

Permalink
feat(rpc): Add flags to disable read tx timeout (#11856)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00101010 authored Oct 22, 2024
1 parent df57aed commit 60337d9
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 1 deletion.
3 changes: 3 additions & 0 deletions book/cli/reth/db.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/db/diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
--table <TABLE>
The table name to diff. If not specified, all tables are diffed.
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/debug/build-block.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
--trusted-setup-file <PATH>
Overrides the KZG trusted setup by reading from the supplied file
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/debug/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Networking:
-d, --disable-discovery
Disable the discovery service
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/debug/in-memory-merkle.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Networking:
-d, --disable-discovery
Disable the discovery service
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/debug/merkle.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Networking:
-d, --disable-discovery
Disable the discovery service
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/debug/replay-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Networking:
-d, --disable-discovery
Disable the discovery service
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
--no-state
Disables stages that require state.
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/init-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
<STATE_DUMP_FILE>
JSONL file with state dump.
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Dev testnet:
--dev
Start the node in dev mode
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/p2p.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/prune.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/recover/storage-tries.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/stage/drop.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
<STAGE>
Possible values:
- headers: The headers stage within the pipeline
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/stage/dump.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/stage/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
--metrics <SOCKET>
Enable Prometheus metrics.
Expand Down
3 changes: 3 additions & 0 deletions book/cli/reth/stage/unwind.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ Database:
[possible values: true, false]
--db.read-transaction-timeout <READ_TRANSACTION_TIMEOUT>
Read transaction timeout in seconds, 0 means no timeout
Networking:
-d, --disable-discovery
Disable the discovery service
Expand Down
14 changes: 13 additions & 1 deletion crates/node/core/src/args/database.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! clap [Args](clap::Args) for database configuration

use std::time::Duration;

use crate::version::default_client_version;
use clap::{
builder::{PossibleValue, TypedValueParser},
error::ErrorKind,
Arg, Args, Command, Error,
};
use reth_db::ClientVersion;
use reth_db::{mdbx::MaxReadTransactionDuration, ClientVersion};
use reth_storage_errors::db::LogLevel;

/// Parameters for database configuration
Expand All @@ -20,6 +22,9 @@ pub struct DatabaseArgs {
/// NFS volume.
#[arg(long = "db.exclusive")]
pub exclusive: Option<bool>,
/// Read transaction timeout in seconds, 0 means no timeout.
#[arg(long = "db.read-transaction-timeout")]
pub read_transaction_timeout: Option<u64>,
}

impl DatabaseArgs {
Expand All @@ -33,9 +38,16 @@ impl DatabaseArgs {
&self,
client_version: ClientVersion,
) -> reth_db::mdbx::DatabaseArguments {
let max_read_transaction_duration = match self.read_transaction_timeout {
None => None, // if not specified, use default value
Some(0) => Some(MaxReadTransactionDuration::Unbounded), // if 0, disable timeout
Some(secs) => Some(MaxReadTransactionDuration::Set(Duration::from_secs(secs))),
};

reth_db::mdbx::DatabaseArguments::new(client_version)
.with_log_level(self.log_level)
.with_exclusive(self.exclusive)
.with_max_read_transaction_duration(max_read_transaction_duration)
}
}

Expand Down

0 comments on commit 60337d9

Please sign in to comment.