Skip to content

Commit

Permalink
Rename dev_traffic to no_dev_txs; ensure tx generation remains the de…
Browse files Browse the repository at this point in the history
…fault
  • Loading branch information
vicsn committed Mar 9, 2024
1 parent 281acb5 commit de2bd05
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .devnet/start.sh
Expand Up @@ -37,7 +37,7 @@ start_snarkos_in_tmux() {
tmux new-session -d -s snarkos-session
# Send the snarkOS start command to the tmux session with the NODE_ID
tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-traffic --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m
tmux send-keys -t "snarkos-session" "snarkos start --nodisplay --bft 0.0.0.0:5000 --rest 0.0.0.0:3030 --peers $NODE_IP:4130 --validators $NODE_IP:5000 --verbosity $VERBOSITY --dev $NODE_ID --dev-num-validators $NUM_INSTANCES --validator --metrics" C-m
exit # Exit root user
EOF
Expand Down
18 changes: 9 additions & 9 deletions cli/src/commands/start.rs
Expand Up @@ -138,8 +138,8 @@ pub struct Start {
#[clap(long)]
pub dev_num_validators: Option<u16>,
/// If developtment mode is enabled, specify whether node 0 should generate traffic to drive the network
#[clap(default_value = "false", long = "dev-traffic")]
pub dev_traffic: bool,
#[clap(default_value = "false", long = "no-dev-txs")]
pub no_dev_txs: bool,
/// Specify the path to a directory containing the ledger
#[clap(long = "storage_path")]
pub storage_path: Option<PathBuf>,
Expand Down Expand Up @@ -527,13 +527,13 @@ impl Start {
None => StorageMode::from(self.dev),
};

// Determine whether to generate background traffic in dev mode.
let dev_traffic = match self.dev {
Some(_) => self.dev_traffic,
// Determine whether to generate background transactions in dev mode.
let dev_txs = match self.dev {
Some(_) => !self.no_dev_txs,
None => {
// If the `dev_traffic` flag is set, inform the user that it is ignored.
if self.dev_traffic {
eprintln!("The '--dev-traffic' flag is ignored because '--dev' is not set");
// If the `no_dev_txs` flag is set, inform the user that it is ignored.
if self.no_dev_txs {
eprintln!("The '--no-dev-txs' flag is ignored because '--dev' is not set");
}
false
}
Expand All @@ -542,7 +542,7 @@ impl Start {
// Initialize the node.
let bft_ip = if self.dev.is_some() { self.bft } else { None };
match node_type {
NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, dev_traffic).await,
NodeType::Validator => Node::new_validator(self.node, bft_ip, rest_ip, self.rest_rps, account, &trusted_peers, &trusted_validators, genesis, cdn, storage_mode, dev_txs).await,
NodeType::Prover => Node::new_prover(self.node, account, &trusted_peers, genesis, storage_mode).await,
NodeType::Client => Node::new_client(self.node, rest_ip, self.rest_rps, account, &trusted_peers, genesis, cdn, storage_mode).await,
}
Expand Down
4 changes: 2 additions & 2 deletions devnet.sh
Expand Up @@ -64,12 +64,12 @@ for validator_index in "${validator_indices[@]}"; do

# Send the command to start the validator to the new window and capture output to the log file
if [ "$validator_index" -eq 0 ]; then
tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-traffic --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m
tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file --metrics" C-m
else
# Create a new window with a unique name
window_index=$((validator_index + index_offset))
tmux new-window -t "devnet:$window_index" -n "window$validator_index"
tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-traffic --dev-num-validators $total_validators --validator --logfile $log_file" C-m
tmux send-keys -t "devnet:window$validator_index" "snarkos start --nodisplay --dev $validator_index --dev-num-validators $total_validators --validator --logfile $log_file" C-m
fi
done

Expand Down
4 changes: 2 additions & 2 deletions node/src/node.rs
Expand Up @@ -50,7 +50,7 @@ impl<N: Network> Node<N> {
genesis: Block<N>,
cdn: Option<String>,
storage_mode: StorageMode,
dev_traffic: bool,
dev_txs: bool,
) -> Result<Self> {
Ok(Self::Validator(Arc::new(
Validator::new(
Expand All @@ -64,7 +64,7 @@ impl<N: Network> Node<N> {
genesis,
cdn,
storage_mode,
dev_traffic,
dev_txs,
)
.await?,
)))
Expand Down
12 changes: 6 additions & 6 deletions node/src/validator/mod.rs
Expand Up @@ -83,7 +83,7 @@ impl<N: Network, C: ConsensusStorage<N>> Validator<N, C> {
genesis: Block<N>,
cdn: Option<String>,
storage_mode: StorageMode,
dev_traffic: bool,
dev_txs: bool,
) -> Result<Self> {
// Prepare the shutdown flag.
let shutdown: Arc<AtomicBool> = Default::default();
Expand Down Expand Up @@ -140,7 +140,7 @@ impl<N: Network, C: ConsensusStorage<N>> Validator<N, C> {
shutdown,
};
// Initialize the transaction pool.
node.initialize_transaction_pool(storage_mode, dev_traffic)?;
node.initialize_transaction_pool(storage_mode, dev_txs)?;

// Initialize the REST server.
if let Some(rest_ip) = rest_ip {
Expand Down Expand Up @@ -340,7 +340,7 @@ impl<N: Network, C: ConsensusStorage<N>> Validator<N, C> {
// }

/// Initialize the transaction pool.
fn initialize_transaction_pool(&self, storage_mode: StorageMode, dev_traffic: bool) -> Result<()> {
fn initialize_transaction_pool(&self, storage_mode: StorageMode, dev_txs: bool) -> Result<()> {
use snarkvm::console::{
program::{Identifier, Literal, ProgramID, Value},
types::U64,
Expand All @@ -355,7 +355,7 @@ impl<N: Network, C: ConsensusStorage<N>> Validator<N, C> {
// If the node is running in development mode, only generate if you are allowed.
StorageMode::Development(id) => {
// If the node is not the first node, or if we should not create dev traffic, do not start the loop.
if id != 0 || !dev_traffic {
if id != 0 || !dev_txs {
return Ok(());
}
}
Expand Down Expand Up @@ -473,7 +473,7 @@ mod tests {
let node = SocketAddr::from_str("0.0.0.0:4130").unwrap();
let rest = SocketAddr::from_str("0.0.0.0:3030").unwrap();
let storage_mode = StorageMode::Development(0);
let dev_traffic = true;
let dev_txs = true;

// Initialize an (insecure) fixed RNG.
let mut rng = ChaChaRng::seed_from_u64(1234567890u64);
Expand All @@ -497,7 +497,7 @@ mod tests {
genesis,
None,
storage_mode,
dev_traffic,
dev_txs,
)
.await
.unwrap();
Expand Down

0 comments on commit de2bd05

Please sign in to comment.