Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions multinode-demo/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,14 @@ tune_networking() {
# Reference: https://medium.com/@CameronSparr/increase-os-udp-buffers-to-improve-performance-51d167bb1360
[[ $(uname) = Linux ]] && (
set -x
# TODO: Check values and warn instead, it's a little rude to set them here.
sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null
sudo sysctl -w net.core.rmem_default=26214400 1>/dev/null 2>/dev/null
# test the existence of the sysctls before trying to set them
sysctl net.core.rmem_max 2>/dev/null 1>/dev/null &&
sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null

sysctl net.core.rmem_default 2>/dev/null 1>/dev/null &&
sudo sysctl -w net.core.rmem_default=26214400 1>/dev/null 2>/dev/null
)
return 0
}

SOLANA_CONFIG_DIR=${SNAP_DATA:-$PWD}/config
Expand Down
14 changes: 10 additions & 4 deletions multinode-demo/leader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ fi

tune_networking

# migrate from old ledger format? why not...
if [[ ! -f "$SOLANA_CONFIG_DIR"/ledger.log &&
-f "$SOLANA_CONFIG_DIR"/genesis.log ]]; then
(shopt -s nullglob &&
cat "$SOLANA_CONFIG_DIR"/genesis.log \
"$SOLANA_CONFIG_DIR"/tx-*.log) > "$SOLANA_CONFIG_DIR"/ledger.log
fi

# shellcheck disable=SC2086 # $program should not be quoted
exec $program \
-l "$SOLANA_CONFIG_DIR"/leader.json \
< <(shopt -s nullglob && cat "$SOLANA_CONFIG_DIR"/genesis.log \
"$SOLANA_CONFIG_DIR"/tx-*.log) \
> "$SOLANA_CONFIG_DIR"/tx-"$(date -u +%Y%m%d%H%M%S%N)".log
--identity "$SOLANA_CONFIG_DIR"/leader.json \
--ledger "$SOLANA_CONFIG_DIR"/ledger.log
59 changes: 0 additions & 59 deletions multinode-demo/myip.sh

This file was deleted.

4 changes: 2 additions & 2 deletions multinode-demo/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ if $node_type_leader; then
echo "Creating $SOLANA_CONFIG_DIR/mint.json with $num_tokens tokens"
$solana_keygen -o "$mint_path"

echo "Creating $SOLANA_CONFIG_DIR/genesis.log"
$solana_genesis --tokens="$num_tokens" < "$mint_path" > "$SOLANA_CONFIG_DIR"/genesis.log
echo "Creating $SOLANA_CONFIG_DIR/ledger.log"
$solana_genesis --tokens="$num_tokens" < "$mint_path" > "$SOLANA_CONFIG_DIR"/ledger.log

echo "Creating $SOLANA_CONFIG_DIR/leader.json"
$solana_fullnode_config --keypair="$id_path" "${leader_address_args[@]}" > "$SOLANA_CONFIG_DIR"/leader.json
Expand Down
14 changes: 11 additions & 3 deletions multinode-demo/validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,16 @@ ls -lh "$SOLANA_LEADER_CONFIG_DIR"

tune_networking

# migrate from old ledger format? why not...
if [[ ! -f "$SOLANA_LEADER_CONFIG_DIR"/ledger.log &&
-f "$SOLANA_LEADER_CONFIG_DIR"/genesis.log ]]; then
(shopt -s nullglob &&
cat "$SOLANA_LEADER_CONFIG_DIR"/genesis.log \
"$SOLANA_LEADER_CONFIG_DIR"/tx-*.log) > "$SOLANA_LEADER_CONFIG_DIR"/ledger.log
fi

# shellcheck disable=SC2086 # $program should not be quoted
exec $program \
-l "$SOLANA_CONFIG_DIR"/validator.json -t "$leader_address:$leader_port" \
< <(shopt -s nullglob && cat "$SOLANA_LEADER_CONFIG_DIR"/genesis.log \
"$SOLANA_LEADER_CONFIG_DIR"/tx-*.log)
--identity "$SOLANA_CONFIG_DIR"/validator.json \
--testnet "$leader_address:$leader_port" \
--ledger "$SOLANA_LEADER_CONFIG_DIR"/ledger.log
49 changes: 19 additions & 30 deletions src/bin/fullnode.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
extern crate atty;
extern crate clap;
extern crate env_logger;
extern crate getopts;
extern crate log;
extern crate serde_json;
extern crate solana;

use atty::{is, Stream};
use clap::{App, Arg};
use solana::crdt::{NodeInfo, TestNode};
use solana::fullnode::{Config, FullNode, InFile, OutFile};
use solana::fullnode::{Config, FullNode, LedgerFile};
use solana::service::Service;
use solana::signature::{KeyPair, KeyPairUtil};
use std::fs::File;
Expand All @@ -22,8 +20,8 @@ fn main() -> () {
let matches = App::new("fullnode")
.arg(
Arg::with_name("identity")
.short("l")
.long("local")
.short("i")
.long("identity")
.value_name("FILE")
.takes_value(true)
.help("run with the identity found in FILE"),
Expand All @@ -34,27 +32,23 @@ fn main() -> () {
.long("testnet")
.value_name("HOST:PORT")
.takes_value(true)
.help("testnet; connect to the network at this gossip entry point"),
.help("connect to the network at this gossip entry point"),
)
.arg(
Arg::with_name("output")
.short("o")
.long("output")
Arg::with_name("ledger")
.short("L")
.long("ledger")
.value_name("FILE")
.takes_value(true)
.help("output log to FILE, defaults to stdout (ignored by validators)"),
.help("use FILE as persistent ledger (defaults to stdin/stdout)"),
)
.get_matches();
if is(Stream::Stdin) {
eprintln!("nothing found on stdin, expected a log file");
exit(1);
}

let bind_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8000);
let mut keypair = KeyPair::new();
let mut repl_data = NodeInfo::new_leader_with_pubkey(keypair.pubkey(), &bind_addr);
if let Some(l) = matches.value_of("identity") {
let path = l.to_string();
if let Some(i) = matches.value_of("identity") {
let path = i.to_string();
if let Ok(file) = File::open(path.clone()) {
let parse: serde_json::Result<Config> = serde_json::from_reader(file);
if let Ok(data) = parse {
Expand All @@ -69,27 +63,22 @@ fn main() -> () {
exit(1);
}
}
let ledger = if let Some(l) = matches.value_of("ledger") {
LedgerFile::Path(l.to_string())
} else {
LedgerFile::StdInOut
};

let mut node = TestNode::new_with_bind_addr(repl_data, bind_addr);
let fullnode = if let Some(t) = matches.value_of("testnet") {
let testnet_address_string = t.to_string();
let testnet_addr = testnet_address_string.parse().unwrap();
FullNode::new(
node,
false,
InFile::StdIn,
Some(keypair),
Some(testnet_addr),
None,
)

FullNode::new(node, false, ledger, Some(keypair), Some(testnet_addr))
} else {
node.data.leader_id = node.data.id;

let outfile = if let Some(o) = matches.value_of("output") {
OutFile::Path(o.to_string())
} else {
OutFile::StdOut
};
FullNode::new(node, true, InFile::StdIn, None, None, Some(outfile))
FullNode::new(node, true, ledger, None, None)
};
fullnode.join().expect("join");
}
42 changes: 17 additions & 25 deletions src/fullnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use service::Service;
use signature::{KeyPair, KeyPairUtil};
use std::collections::VecDeque;
use std::fs::{File, OpenOptions};
use std::io::{sink, stdin, stdout, BufReader};
use std::io::{stdin, stdout, BufReader};
use std::io::{Read, Write};
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, Ordering};
Expand All @@ -30,13 +30,8 @@ pub struct FullNode {
thread_hdls: Vec<JoinHandle<()>>,
}

pub enum InFile {
StdIn,
Path(String),
}

pub enum OutFile {
StdOut,
pub enum LedgerFile {
StdInOut,
Path(String),
}

Expand Down Expand Up @@ -66,16 +61,24 @@ impl FullNode {
pub fn new(
mut node: TestNode,
leader: bool,
infile: InFile,
ledger: LedgerFile,
keypair_for_validator: Option<KeyPair>,
network_entry_for_validator: Option<SocketAddr>,
outfile_for_leader: Option<OutFile>,
) -> FullNode {
info!("creating bank...");
let bank = Bank::default();
let infile: Box<Read> = match infile {
InFile::Path(path) => Box::new(File::open(path).unwrap()),
InFile::StdIn => Box::new(stdin()),
let (infile, outfile): (Box<Read>, Box<Write + Send>) = match ledger {
LedgerFile::Path(path) => (
Box::new(File::open(path.clone()).expect("opening ledger file")),
Box::new(
OpenOptions::new()
.create(true)
.append(true)
.open(path)
.expect("opening ledger file"),
),
),
LedgerFile::StdInOut => (Box::new(stdin()), Box::new(stdout())),
};
let reader = BufReader::new(infile);
let entries = entry_writer::read_entries(reader).map(|e| e.expect("failed to parse entry"));
Expand Down Expand Up @@ -117,17 +120,6 @@ impl FullNode {
server
} else {
node.data.leader_id = node.data.id;
let outfile_for_leader: Box<Write + Send> = match outfile_for_leader {
Some(OutFile::Path(file)) => Box::new(
OpenOptions::new()
.create(true)
.append(true)
.open(file)
.expect("opening ledger file"),
),
Some(OutFile::StdOut) => Box::new(stdout()),
None => Box::new(sink()),
};

let server = FullNode::new_leader(
bank,
Expand All @@ -137,7 +129,7 @@ impl FullNode {
None,
node,
exit.clone(),
outfile_for_leader,
outfile,
);
info!(
"leader ready... local request address: {} (advertising {})",
Expand Down
Loading