Skip to content

Commit

Permalink
update scripts to work with agave and solana validator versions
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcusack committed Apr 4, 2024
1 parent 3be12a6 commit 06fe5e0
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 18 deletions.
4 changes: 2 additions & 2 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- [x] Build genesis
- [x] Docker Build and Push to registry
- [x] Bootstrap
- [ ] Validator (regular)
- [x] Validator (regular)
- [ ] RPC nodes
- [ ] Client
- [ ] Create & Deploy Secrets
Expand All @@ -37,7 +37,7 @@
- [ ] Client
- [ ] Create & Deploy Services
- [x] Bootstrap
- [ ] Validator (regular)
- [x] Validator (regular)
- [ ] RPC nodes
- [ ] Client
- [x] Check Bootstrap is deployed and running
Expand Down
8 changes: 4 additions & 4 deletions src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use {

pub const DEFAULT_FAUCET_LAMPORTS: u64 = 500000000000000000; // from agave/
pub const DEFAULT_MAX_GENESIS_ARCHIVE_UNPACKED_SIZE: u64 = 1073741824; // from agave/
pub const DEFAULT_INTERNAL_NODE_STAKE_SOL: f64 = 1.0;
pub const DEFAULT_INTERNAL_NODE_SOL: f64 = 10.0;
pub const DEFAULT_BOOTSTRAP_NODE_STAKE_SOL: f64 = 1.0;
pub const DEFAULT_BOOTSTRAP_NODE_SOL: f64 = 10.0;
pub const DEFAULT_INTERNAL_NODE_STAKE_SOL: f64 = 10.0;
pub const DEFAULT_INTERNAL_NODE_SOL: f64 = 100.0;
pub const DEFAULT_BOOTSTRAP_NODE_STAKE_SOL: f64 = 10.0;
pub const DEFAULT_BOOTSTRAP_NODE_SOL: f64 = 100.0;

fn fetch_spl(fetch_spl_file: &PathBuf) -> Result<(), Box<dyn Error>> {
let output = Command::new("bash")
Expand Down
8 changes: 8 additions & 0 deletions src/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,12 @@ impl<'a> Kubernetes<'a> {
self.pod_requests.requests.clone(),
)
}

pub fn create_validator_service(
&self,
service_name: &str,
label_selector: &BTreeMap<String, String>,
) -> Service {
k8s_helpers::create_service(service_name, self.namespace.as_str(), label_selector, false)
}
}
12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,5 +774,17 @@ async fn main() {
return;
}
};

// let service_name = format!("validator-service-{index}");
let validator_service = kub_controller.create_validator_service(
&format!("validator-service-{validator_index}"),
validator.replica_set_labels(),
);
match kub_controller.deploy_service(&validator_service).await {
Ok(_) => info!("validator service ({validator_index}) deployed successfully"),
Err(err) => {
error!("Error! Failed to deploy validator service: {validator_index}. err: {err}")
}
}
}
}
12 changes: 6 additions & 6 deletions src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ impl BuildConfig {
}

pub async fn prepare(&self) -> Result<(), Box<dyn Error>> {
if self.build_type == BuildType::Skip {
info!("skipping build");
return Ok(());
}
match &self.deploy_method {
DeployMethod::ReleaseChannel(channel) => match self.setup_tar_deploy(channel).await {
Ok(tar_directory) => {
Expand All @@ -77,7 +81,7 @@ impl BuildConfig {
async fn setup_tar_deploy(&self, release_channel: &String) -> Result<PathBuf, Box<dyn Error>> {
let file_name = "solana-release";
let tar_filename = format!("{file_name}.tar.bz2");
info!("tar file: {}", tar_filename);
info!("tar file: {tar_filename}");
self.download_release_from_channel(&tar_filename, release_channel)
.await?;

Expand All @@ -92,11 +96,7 @@ impl BuildConfig {
}

fn setup_local_deploy(&self) -> Result<(), Box<dyn Error>> {
if self.build_type != BuildType::Skip {
self.build()?;
} else {
info!("Build skipped due to --build-type skip");
}
self.build()?;
Ok(())
}

Expand Down
18 changes: 16 additions & 2 deletions src/scripts/bootstrap-validator-startup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@ nohup solana-faucet --keypair bootstrap-accounts/faucet.json &
# Start the bootstrap validator node
# shellcheck disable=SC1091
source /home/solana/k8s-cluster-scripts/common.sh
no_restart=0

program="agave-validator"
# Define the paths to the validator cli. pre 1.18 is `solana-validator`. post 1.18 is `agave-validator`
agave_validator="/home/solana/.cargo/bin/agave-validator"
solana_validator="/home/solana/.cargo/bin/solana-validator"

no_restart=0
# Initialize program variable
program=""

# Check if agave-validator exists and is executable
if [[ -x "$agave_validator" ]]; then
program="agave-validator"
elif [[ -x "$solana_validator" ]]; then
program="solana-validator"
else
echo "Neither agave-validator nor solana-validator could be found or is not executable."
exit 1
fi

echo "PROGRAM: $program"

Expand Down
25 changes: 21 additions & 4 deletions src/scripts/validator-startup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,34 @@ args=(
--no-os-network-limits-test
)
airdrops_enabled=1
# next two values will be overwritten based on command line args. default is set here: k8s-cluster/src/genesis.rs
node_sol=
stake_sol=
identity=validator-accounts/identity.json
vote_account=validator-accounts/vote.json
no_restart=0
gossip_entrypoint=$BOOTSTRAP_GOSSIP_ADDRESS
ledger_dir=/home/solana/ledger
faucet_address=$LOAD_BALANCER_FAUCET_ADDRESS

# Define the paths to the validator cli. pre 1.18 is `solana-validator`. post 1.18 is `agave-validator`
agave_validator="/home/solana/.cargo/bin/agave-validator"
solana_validator="/home/solana/.cargo/bin/solana-validator"

# Initialize program variable
program=""

# Check if agave-validator exists and is executable
if [[ -x "$agave_validator" ]]; then
program="agave-validator"
elif [[ -x "$solana_validator" ]]; then
program="solana-validator"
else
echo "Neither agave-validator nor solana-validator could be found or is not executable."
exit 1
fi

echo "PROGRAM: $program"

usage() {
if [[ -n $1 ]]; then
echo "$*"
Expand Down Expand Up @@ -236,9 +256,6 @@ default_arg --allow-private-addr
default_arg --gossip-port 8001
default_arg --rpc-port 8899

program="agave-validator"
echo "program: $program"

PS4="$(basename "$0"): "
echo "PS4: $PS4"

Expand Down

0 comments on commit 06fe5e0

Please sign in to comment.