Add some debugging goodies.

This commit is contained in:
c0gent 2018-07-28 15:43:13 -07:00
parent 15a42e7817
commit 38528624f3
No known key found for this signature in database
GPG Key ID: 9CC25E71A743E892
11 changed files with 167 additions and 22 deletions

2
.gitignore vendored
View File

@ -23,3 +23,5 @@ Cargo.lock
/src/junk
/bak
*.gz
massif*

View File

@ -12,6 +12,10 @@ autobins = false
name = "peer_node"
path = "src/bin/peer_node.rs"
[features]
# Used for debugging memory usage.
exit_upon_epoch_1000 = []
[dependencies]
log = "*"
env_logger = "*"
@ -51,4 +55,8 @@ git = "https://github.com/poanetwork/hbbft"
# branch = "master"
branch = "afck-agreement"
# path = "../hbbft"
# features = ["serialization-protobuf"]
# features = ["serialization-protobuf"]
[profile.release]
debug = true
debug-assertions = true

View File

@ -28,7 +28,9 @@ Type `./run-node 0 --help` or `cargo run -- --help` for command line options.
See the
[`run-node`](https://github.com/poanetwork/hydrabadger/blob/master/run-node)
script for additional optional environment variables that can be set.
script for additional optional environment variables that can be set. To turn
on debug log output: `export HYDRABADGER_LOG_ADDTL=debug` and/or `echo "export
HYDRABADGER_LOG_ADDTL=debug" >> ~/.profile`.
### Current State

21
gdb-node Normal file → Executable file
View File

@ -16,23 +16,32 @@
#
#
let HOST_PORT=300$1
let PEER_0_PORT=$HOST_PORT-1
let PEER_1_PORT=$HOST_PORT+1
let HOST_ID=$1
let PEER_0_ID=$HOST_ID==0?$HOST_ID+2:$HOST_ID-1
let PEER_1_ID=$HOST_ID+1
printf -v HOST_PORT "3%03d" $HOST_ID
printf -v PEER_0_PORT "3%03d" $PEER_0_ID
printf -v PEER_1_PORT "3%03d" $PEER_1_ID
HYDRABADGER_LOG=peer_node::hydrabadger=error,warn,info,$HYDRABADGER_LOG_ADDTL
if [[ $HYDRABADGER_RELEASE ]]
then
case "$HYDRABADGER_RELEASE" in
0) RELEASE="" ;;
false) RELEASE="" ;;
*) RELEASE="--release" ;;
0|false) RELEASE=""; DIRECTORY="debug" ;;
*) RELEASE="--release"; DIRECTORY="release" ;;
esac
else
RELEASE="--release"
DIRECTORY="release"
fi
cargo build $RELEASE
# printf "\nLimiting process memory limit to 400MiB...\n\n"
# ulimit -Sv 400000
bash -c "\
HYDRABADGER_LOG=$HYDRABADGER_LOG gdb -ex=r --args target/release/peer_node \
-b localhost:$HOST_PORT \

54
ltrace-node Executable file
View File

@ -0,0 +1,54 @@
#/bin/bash
# Starts a Hydrabadger node
# =========================
#
# Optional environment variables:
#
# * HYDRABADGER_LOG_ADDTL:
#
# Appends additional logging args (debug, trace, filters, etc.).
#
# * HYDRABADGER_RELEASE:
#
# Builds in debug mode if `HYDRABADGER_RELEASE` == `0` or `false`.
# Slows down output and makes reading log easier.
#
#
let HOST_ID=$1
let PEER_0_ID=$HOST_ID==0?$HOST_ID+2:$HOST_ID-1
let PEER_1_ID=$HOST_ID+1
printf -v HOST_PORT "3%03d" $HOST_ID
printf -v PEER_0_PORT "3%03d" $PEER_0_ID
printf -v PEER_1_PORT "3%03d" $PEER_1_ID
HYDRABADGER_LOG=peer_node::hydrabadger=error,warn,info,$HYDRABADGER_LOG_ADDTL
if [[ $HYDRABADGER_RELEASE ]]
then
case "$HYDRABADGER_RELEASE" in
0|false) RELEASE=""; DIRECTORY="debug" ;;
*) RELEASE="--release"; DIRECTORY="release" ;;
esac
else
RELEASE="--release"
DIRECTORY="release"
fi
cargo build $RELEASE
# printf "\nLimiting process memory limit to 400MiB...\n\n"
# ulimit -Sv 400000
mkdir tmp
bash -c "\
HYDRABADGER_LOG=$HYDRABADGER_LOG ltrace target/$DIRECTORY/peer_node \
-b localhost:$HOST_PORT \
-r localhost:$PEER_0_PORT \
-r localhost:$PEER_1_PORT\
$2 $3 $4 $5 $6 $7 $8 \
2>&1 | tee tmp/ltrace_peer_node_$1.log
"

View File

@ -17,7 +17,7 @@
#
let HOST_ID=$1
let PEER_0_ID=$HOST_ID-1
let PEER_0_ID=$HOST_ID==0?$HOST_ID+2:$HOST_ID-1
let PEER_1_ID=$HOST_ID+1
printf -v HOST_PORT "3%03d" $HOST_ID
@ -29,18 +29,21 @@ HYDRABADGER_LOG=peer_node::hydrabadger=error,warn,info,$HYDRABADGER_LOG_ADDTL
if [[ $HYDRABADGER_RELEASE ]]
then
case "$HYDRABADGER_RELEASE" in
0) RELEASE="" ;;
false) RELEASE="" ;;
*) RELEASE="--release" ;;
0|false) RELEASE=""; DIRECTORY="debug" ;;
*) RELEASE="--release"; DIRECTORY="release" ;;
esac
else
RELEASE="--release"
DIRECTORY="release"
fi
cargo build $RELEASE
# printf "\nLimiting process memory limit to 400MiB...\n\n"
# ulimit -Sv 400000
bash -c "\
HYDRABADGER_LOG=$HYDRABADGER_LOG cargo run --bin peer_node \
$RELEASE \
-- \
HYDRABADGER_LOG=$HYDRABADGER_LOG target/$DIRECTORY/peer_node \
-b localhost:$HOST_PORT \
-r localhost:$PEER_0_PORT \
-r localhost:$PEER_1_PORT\

View File

@ -247,7 +247,7 @@ impl Handler {
}
},
s @ _ => panic!("::handle_key_gen_part: State must be `GeneratingKeys`. \
State: \n{:?}", s.discriminant()),
State: \n{:?} \n\n[FIXME: Enqueue these parts!]\n\n", s.discriminant()),
}
}
@ -686,6 +686,11 @@ impl Future for Handler {
for batch in step.output.drain(..) {
info!(" BATCH: \n{:?}", batch);
if cfg!(exit_upon_epoch_1000) && batch.epoch() >= 1000 {
return Ok(Async::Ready(()))
}
if let Some(jp) = batch.join_plan() {
// FIXME: Only sent to unconnected nodes:
debug!("Outputting join plan: {:?}", jp);

View File

@ -40,12 +40,12 @@ use super::{Error, State, StateDsct, Handler};
const EXTRA_DELAY_MS: u64 = 0;
const BATCH_SIZE: usize = 200;
const NEW_TXNS_PER_INTERVAL: usize = 10;
const NEW_TXN_INTERVAL_MS: u64 = 2000;
const TXN_BYTES: usize = 8;
const NEW_TXNS_PER_INTERVAL: usize = 5;
const NEW_TXN_INTERVAL_MS: u64 = 5000;
const TXN_BYTES: usize = 2;
// The minimum number of peers needed to spawn a HB instance.
const HB_PEER_MINIMUM_COUNT: usize = 9;
const HB_PEER_MINIMUM_COUNT: usize = 3;

View File

@ -247,7 +247,7 @@ impl State {
info!("== HONEY BADGER INITIALIZED ==");
info!("");
{
{ // TODO: Consolidate or remove:
let pk_set = qhb.dyn_hb().netinfo().public_key_set();
let pk_map = qhb.dyn_hb().netinfo().public_key_map();
info!("");
@ -311,7 +311,7 @@ impl State {
info!("== HONEY BADGER INITIALIZED ==");
info!("");
{
{ // TODO: Consolidate or remove:
let pk_set = qhb.dyn_hb().netinfo().public_key_set();
let pk_map = qhb.dyn_hb().netinfo().public_key_map();
info!("");

View File

@ -1,4 +1,6 @@
#![feature(alloc_system, allocator_api)]
extern crate alloc_system;
extern crate clap;
extern crate env_logger;
#[macro_use] extern crate log;
@ -26,6 +28,11 @@ extern crate parking_lot;
extern crate clear_on_drop;
extern crate hbbft;
use alloc_system::System;
#[global_allocator]
static A: System = System;
// pub mod network;
pub mod hydrabadger;
pub mod blockchain;

55
valgrind-node Executable file
View File

@ -0,0 +1,55 @@
#/bin/bash
# Starts a Hydrabadger node
# =========================
#
# Optional environment variables:
#
# * HYDRABADGER_LOG_ADDTL:
#
# Appends additional logging args (debug, trace, filters, etc.).
#
# * HYDRABADGER_RELEASE:
#
# Builds in debug mode if `HYDRABADGER_RELEASE` == `0` or `false`.
# Slows down output and makes reading log easier.
#
#
let HOST_ID=$1
let PEER_0_ID=$HOST_ID==0?$HOST_ID+2:$HOST_ID-1
let PEER_1_ID=$HOST_ID+1
printf -v HOST_PORT "3%03d" $HOST_ID
printf -v PEER_0_PORT "3%03d" $PEER_0_ID
printf -v PEER_1_PORT "3%03d" $PEER_1_ID
HYDRABADGER_LOG=peer_node::hydrabadger=error,warn,info,$HYDRABADGER_LOG_ADDTL
if [[ $HYDRABADGER_RELEASE ]]
then
case "$HYDRABADGER_RELEASE" in
0|false) RELEASE=""; DIRECTORY="debug" ;;
*) RELEASE="--release"; DIRECTORY="release" ;;
esac
else
RELEASE="--release"
DIRECTORY="release"
fi
cargo build $RELEASE
# printf "\nLimiting process memory limit to 400MiB...\n\n"
# ulimit -Sv 400000
bash -c "\
HYDRABADGER_LOG=$HYDRABADGER_LOG \
valgrind --tool=massif --massif-out-file="tmp/massif.out.node_$HOST_ID" \
target/$DIRECTORY/peer_node \
-b localhost:$HOST_PORT \
-r localhost:$PEER_0_PORT \
-r localhost:$PEER_1_PORT\
$2 $3 $4 $5 $6 $7 $8
"
# --pages-as-heap=yes \