From 8a859adcbca2ed45c143003fb9cd367d554c5740 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Mon, 29 Jul 2024 14:38:37 -0600 Subject: [PATCH 1/2] Add commission option, same value applies to all staked nodes --- src/genesis.rs | 3 +++ src/kubernetes.rs | 3 +++ src/main.rs | 12 ++++++++++++ src/startup_scripts.rs | 6 +++++- src/validator_config.rs | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/genesis.rs b/src/genesis.rs index b5bb7cd..8d403f8 100644 --- a/src/genesis.rs +++ b/src/genesis.rs @@ -63,6 +63,7 @@ pub struct GenesisFlags { pub cluster_type: String, pub bootstrap_validator_sol: Option, pub bootstrap_validator_stake_sol: Option, + pub commission: u8, } impl std::fmt::Display for GenesisFlags { @@ -358,6 +359,8 @@ impl Genesis { format!("Invalid Unicode data in path: {:?}", err), ) })?, + "--vote-commission-percentage".to_string(), + self.flags.commission.to_string(), ]; if self.flags.enable_warmup_epochs { diff --git a/src/kubernetes.rs b/src/kubernetes.rs index 0dbff3e..c23a937 100644 --- a/src/kubernetes.rs +++ b/src/kubernetes.rs @@ -539,6 +539,9 @@ impl<'a> Kubernetes<'a> { flags.push("--internal-node-stake-sol".to_string()); flags.push(self.validator_config.internal_node_stake_sol.to_string()); + flags.push("--commission".to_string()); + flags.push(self.validator_config.commission.to_string()); + flags.push("--internal-node-sol".to_string()); flags.push(self.validator_config.internal_node_sol.to_string()); diff --git a/src/main.rs b/src/main.rs index 0851234..3068916 100644 --- a/src/main.rs +++ b/src/main.rs @@ -246,6 +246,14 @@ fn parse_matches() -> clap::ArgMatches { .default_value(&DEFAULT_INTERNAL_NODE_STAKE_SOL.to_string()) .help("Amount to stake internal nodes (Sol)."), ) + .arg( + Arg::with_name("commission") + .long("commission") + .value_name("PERCENTAGE") + .takes_value(true) + .default_value("100") + .help("The commission taken by nodes on staking rewards (0-100) [default: 100]") + ) //RPC config .arg( Arg::with_name("number_of_rpc_nodes") @@ -450,6 +458,8 @@ async fn main() -> Result<(), Box> { cluster_data_root.get_root_path(), ); + let commission = value_t_or_exit!(matches, "commission", u8); + let genesis_flags = GenesisFlags { hashes_per_tick: matches .value_of("hashes_per_tick") @@ -498,6 +508,7 @@ async fn main() -> Result<(), Box> { .expect("Invalid value for bootstrap_validator_stake_sol") }, ), + commission, }; let internal_node_stake_sol = value_t_or_exit!(matches, "internal_node_stake_sol", f64); @@ -508,6 +519,7 @@ async fn main() -> Result<(), Box> { let mut validator_config = ValidatorConfig { internal_node_sol, internal_node_stake_sol, + commission, shred_version: None, // set after genesis created max_ledger_size: if limit_ledger_size < DEFAULT_MIN_MAX_LEDGER_SHREDS { clap::Error::with_description( diff --git a/src/startup_scripts.rs b/src/startup_scripts.rs index f4cc6d2..c6500f3 100644 --- a/src/startup_scripts.rs +++ b/src/startup_scripts.rs @@ -230,6 +230,7 @@ args=( airdrops_enabled=1 node_sol= stake_sol= +commission= identity=validator-accounts/identity.json vote_account=validator-accounts/vote.json no_restart=0 @@ -288,6 +289,9 @@ while [[ -n $1 ]]; do elif [[ $1 == --internal-node-stake-sol ]]; then stake_sol=$2 shift 2 + elif [[ $1 == --commission ]]; then + commission=$2 + shift 2 elif [[ $1 == --internal-node-sol ]]; then node_sol=$2 shift 2 @@ -559,7 +563,7 @@ setup_validator() { exit 1 fi - if ! run_solana_command "solana -u $LOAD_BALANCER_RPC_URL create-vote-account --allow-unsafe-authorized-withdrawer validator-accounts/vote.json $IDENTITY_FILE $IDENTITY_FILE -k $IDENTITY_FILE" "Create Vote Account"; then + if ! run_solana_command "solana -u $LOAD_BALANCER_RPC_URL create-vote-account --allow-unsafe-authorized-withdrawer validator-accounts/vote.json $IDENTITY_FILE $IDENTITY_FILE -k $IDENTITY_FILE --commission $commission" "Create Vote Account"; then if $vote_account_already_exists; then echo "Vote account already exists. Skipping remaining commands." else diff --git a/src/validator_config.rs b/src/validator_config.rs index 4a92178..f91b361 100644 --- a/src/validator_config.rs +++ b/src/validator_config.rs @@ -4,6 +4,7 @@ use solana_sdk::pubkey::Pubkey; pub struct ValidatorConfig { pub internal_node_sol: f64, pub internal_node_stake_sol: f64, + pub commission: u8, pub shred_version: Option, pub max_ledger_size: Option, pub skip_poh_verify: bool, From ac4fdbccef613ab3b5765f09f45f04a16541ca22 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Mon, 29 Jul 2024 16:46:24 -0600 Subject: [PATCH 2/2] Remove superfluous default in help --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3068916..c83b65b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -252,7 +252,7 @@ fn parse_matches() -> clap::ArgMatches { .value_name("PERCENTAGE") .takes_value(true) .default_value("100") - .help("The commission taken by nodes on staking rewards (0-100) [default: 100]") + .help("The commission taken by nodes on staking rewards (0-100)") ) //RPC config .arg(