Skip to content

Commit a7869d9

Browse files
authored
Added initial implementations for packet forwarder in vortexor (#5027)
* Added initial implementations for packet forwarder clippy problems enable loggings reverted a change in cargo.toml in streamer log vortexor pubkey in log file * clippy issue * clippy issue * clippy issue * code cleanup * removed unnecessary clone * refactor redirect_stderr_to_file into solana-log-utils * missing cargo.lock file * missing library files * removed confusing short names for arguments * Use solana-logger and removed log-utils * Use solana-logger 2.3.1
1 parent b704875 commit a7869d9

File tree

15 files changed

+280
-83
lines changed

15 files changed

+280
-83
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ log-*.txt
1919
log-*/
2020
!log-collector/
2121
!log-analyzer/*
22+
!log-utils/
2223

2324
# intellij files
2425
.idea/

Cargo.lock

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ solana-loader-v4-interface = "=2.2.1"
443443
solana-loader-v4-program = { path = "programs/loader-v4", version = "=2.3.0" }
444444
solana-local-cluster = { path = "local-cluster", version = "=2.3.0" }
445445
solana-log-collector = { path = "log-collector", version = "=2.3.0" }
446-
solana-logger = "=2.2.1"
446+
solana-logger = "=2.3.1"
447447
solana-measure = { path = "measure", version = "=2.3.0" }
448448
solana-merkle-tree = { path = "merkle-tree", version = "=2.3.0" }
449449
solana-message = "=2.2.1"

programs/sbf/Cargo.lock

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

programs/sbf/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ solana-feature-set = "=2.2.4"
4646
solana-fee = { path = "../../fee", version = "=2.3.0" }
4747
solana-ledger = { path = "../../ledger", version = "=2.3.0" }
4848
solana-log-collector = { path = "../../log-collector", version = "=2.3.0" }
49-
solana-logger = "=2.2.1"
49+
solana-logger = "=2.3.1"
5050
solana-measure = { path = "../../measure", version = "=2.3.0" }
5151
solana-poseidon = { path = "../../poseidon/", version = "=2.3.0" }
5252
solana-program = "=2.2.1"

svm/examples/Cargo.lock

+14-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

svm/examples/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ solana-account-decoder = { path = "../../account-decoder" }
3131
solana-bpf-loader-program = { path = "../../programs/bpf_loader" }
3232
solana-client = { path = "../../client" }
3333
solana-compute-budget = { path = "../../compute-budget" }
34-
solana-logger = "=2.2.1"
34+
solana-logger = "=2.3.1"
3535
solana-perf = { path = "../../perf" }
3636
solana-program-runtime = { path = "../../program-runtime" }
3737
solana-rpc-client-api = { path = "../../rpc-client-api" }

validator/src/bin/solana-test-validator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use {
22
agave_validator::{
33
admin_rpc_service, cli, dashboard::Dashboard, ledger_lockfile, lock_ledger,
4-
println_name_value, redirect_stderr_to_file,
4+
println_name_value,
55
},
66
clap::{crate_name, value_t, value_t_or_exit, values_t_or_exit},
77
crossbeam_channel::unbounded,
@@ -14,6 +14,7 @@ use {
1414
},
1515
solana_core::consensus::tower_storage::FileTowerStorage,
1616
solana_faucet::faucet::run_local_faucet_with_port,
17+
solana_logger::redirect_stderr_to_file,
1718
solana_rpc::{
1819
rpc::{JsonRpcConfig, RpcBigtableConfig},
1920
rpc_pubsub_service::PubSubConfig,

validator/src/commands/run/execute.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use {
22
crate::{
3-
admin_rpc_service,
4-
admin_rpc_service::{load_staked_nodes_overrides, StakedNodesOverrides},
3+
admin_rpc_service::{self, load_staked_nodes_overrides, StakedNodesOverrides},
54
bootstrap,
65
cli::{self},
7-
ledger_lockfile, lock_ledger, redirect_stderr_to_file,
6+
ledger_lockfile, lock_ledger,
87
},
98
clap::{crate_name, value_t, value_t_or_exit, values_t, values_t_or_exit, ArgMatches},
109
crossbeam_channel::unbounded,
@@ -46,6 +45,7 @@ use {
4645
},
4746
use_snapshot_archives_at_startup::{self, UseSnapshotArchivesAtStartup},
4847
},
48+
solana_logger::redirect_stderr_to_file,
4949
solana_perf::recycler::enable_recycler_warming,
5050
solana_poh::poh_service,
5151
solana_rpc::{

validator/src/lib.rs

-65
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ use {
66
indicatif::{ProgressDrawTarget, ProgressStyle},
77
std::{
88
borrow::Cow,
9-
env,
109
fmt::Display,
1110
fs::{File, OpenOptions},
1211
path::Path,
1312
process::exit,
14-
thread::JoinHandle,
1513
time::Duration,
1614
},
1715
};
@@ -22,69 +20,6 @@ pub mod cli;
2220
pub mod commands;
2321
pub mod dashboard;
2422

25-
#[cfg(unix)]
26-
fn redirect_stderr(filename: &str) {
27-
use std::os::unix::io::AsRawFd;
28-
match OpenOptions::new().create(true).append(true).open(filename) {
29-
Ok(file) => unsafe {
30-
libc::dup2(file.as_raw_fd(), libc::STDERR_FILENO);
31-
},
32-
Err(err) => eprintln!("Unable to open {filename}: {err}"),
33-
}
34-
}
35-
36-
// Redirect stderr to a file with support for logrotate by sending a SIGUSR1 to the process.
37-
//
38-
// Upon success, future `log` macros and `eprintln!()` can be found in the specified log file.
39-
pub fn redirect_stderr_to_file(logfile: Option<String>) -> Option<JoinHandle<()>> {
40-
// Default to RUST_BACKTRACE=1 for more informative validator logs
41-
if env::var_os("RUST_BACKTRACE").is_none() {
42-
env::set_var("RUST_BACKTRACE", "1")
43-
}
44-
45-
match logfile {
46-
None => {
47-
solana_logger::setup_with_default_filter();
48-
None
49-
}
50-
Some(logfile) => {
51-
#[cfg(unix)]
52-
{
53-
use log::info;
54-
let mut signals =
55-
signal_hook::iterator::Signals::new([signal_hook::consts::SIGUSR1])
56-
.unwrap_or_else(|err| {
57-
eprintln!("Unable to register SIGUSR1 handler: {err:?}");
58-
exit(1);
59-
});
60-
61-
solana_logger::setup_with_default_filter();
62-
redirect_stderr(&logfile);
63-
Some(
64-
std::thread::Builder::new()
65-
.name("solSigUsr1".into())
66-
.spawn(move || {
67-
for signal in signals.forever() {
68-
info!(
69-
"received SIGUSR1 ({}), reopening log file: {:?}",
70-
signal, logfile
71-
);
72-
redirect_stderr(&logfile);
73-
}
74-
})
75-
.unwrap(),
76-
)
77-
}
78-
#[cfg(not(unix))]
79-
{
80-
println!("logrotate is not supported on this platform");
81-
solana_logger::setup_file_with_default(&logfile, solana_logger::DEFAULT_FILTER);
82-
None
83-
}
84-
}
85-
}
86-
}
87-
8823
pub fn format_name_value(name: &str, value: &str) -> String {
8924
format!("{} {}", style(name).bold(), value)
9025
}

vortexor/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ license = { workspace = true }
1212
edition = { workspace = true }
1313

1414
[dependencies]
15+
agave-banking-stage-ingress-types = { workspace = true }
1516
async-channel = { workspace = true }
1617
bytes = { workspace = true }
1718
clap = { workspace = true }
@@ -32,10 +33,12 @@ quinn = { workspace = true }
3233
quinn-proto = { workspace = true }
3334
rand = { workspace = true }
3435
rustls = { workspace = true }
36+
signal-hook = { workspace = true }
3537
smallvec = { workspace = true }
3638
socket2 = { workspace = true }
3739
solana-clap-utils = { workspace = true }
3840
solana-core = { workspace = true }
41+
solana-logger = { workspace = true }
3942
solana-measure = { workspace = true }
4043
solana-metrics = { workspace = true }
4144
solana-net-utils = { workspace = true }
@@ -51,7 +54,6 @@ x509-parser = { workspace = true }
5154

5255
[dev-dependencies]
5356
assert_matches = { workspace = true }
54-
solana-logger = { workspace = true }
5557
solana-streamer = { workspace = true, features = ["dev-context-only-utils"] }
5658

5759
[lib]

vortexor/src/cli.rs

+19
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,23 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> {
172172
.validator(is_parsable::<u64>)
173173
.help("Milliseconds to wait in the TPU receiver for packet coalescing."),
174174
)
175+
.arg(
176+
Arg::with_name("logfile")
177+
.long("log")
178+
.value_name("FILE")
179+
.takes_value(true)
180+
.help(
181+
"Redirect logging to the specified file, '-' for standard error. Sending the \
182+
SIGUSR1 signal to the vortexor process will cause it to re-open the log file.",
183+
),
184+
)
185+
.arg(
186+
Arg::with_name("destination")
187+
.long("destination")
188+
.value_name("HOST:PORT")
189+
.takes_value(true)
190+
.multiple(true)
191+
.validator(solana_net_utils::is_host_port)
192+
.help("The destination validator address to which the vortexor will forward transactions."),
193+
)
175194
}

vortexor/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod cli;
2+
pub mod sender;
23
pub mod vortexor;

0 commit comments

Comments
 (0)