Skip to content

Commit

Permalink
feat: Update start-chain.sh script
Browse files Browse the repository at this point in the history
This commit includes additional functionality and improvements to the start-chain.sh script.
  • Loading branch information
deadlium committed May 4, 2024
1 parent 3a178be commit a69a8f7
Show file tree
Hide file tree
Showing 116 changed files with 699 additions and 623 deletions.
364 changes: 182 additions & 182 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ solana-core = { path = "core", version = "=1.18.0" }
solana-cost-model = { path = "cost-model", version = "=1.18.0" }
solana-download-utils = { path = "download-utils", version = "=1.18.0" }
solana-entry = { path = "entry", version = "=1.18.0" }
solana-faucet = { path = "faucet", version = "=1.18.0" }
svm-station-faucet = { path = "faucet", version = "=1.18.0" }
solana-frozen-abi = { path = "frozen-abi", version = "=1.18.0" }
solana-frozen-abi-macro = { path = "frozen-abi/macro", version = "=1.18.0" }
solana-genesis = { path = "genesis", version = "=1.18.0" }
solana-genesis-utils = { path = "genesis-utils", version = "=1.18.0" }
svm-station-genesis = { path = "genesis", version = "=1.18.0" }
svm-station-genesis-utils = { path = "genesis-utils", version = "=1.18.0" }
solana-geyser-plugin-interface = { path = "geyser-plugin-interface", version = "=1.18.0" }
solana-geyser-plugin-manager = { path = "geyser-plugin-manager", version = "=1.18.0" }
solana-gossip = { path = "gossip", version = "=1.18.0" }
Expand Down Expand Up @@ -371,7 +371,7 @@ solana-storage-bigtable = { path = "storage-bigtable", version = "=1.18.0" }
solana-storage-proto = { path = "storage-proto", version = "=1.18.0" }
solana-streamer = { path = "streamer", version = "=1.18.0" }
solana-system-program = { path = "programs/system", version = "=1.18.0" }
air-solana = { path = "test-validator", version = "=1.18.0" }
svm-station-test-validator = { path = "test-validator", version = "=1.18.0" }
solana-thin-client = { path = "thin-client", version = "=1.18.0" }
solana-tpu-client = { path = "tpu-client", version = "=1.18.0", default-features = false }
solana-transaction-status = { path = "transaction-status", version = "=1.18.0" }
Expand Down
118 changes: 117 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,125 @@ sudo dnf install openssl-devel systemd-devel pkg-config zlib-devel llvm clang cm
### 7. Run the Project

```bash
path/to/build/directory/air-solana
path/to/build/directory/svm-station-test-validator
```

## Running the Solana Chain

### Step 1 **Prepare Account**

Create the 4 keypair for solana you will need to run your solana chain.

This command generates a cryptographic key pair specifically for a node in the Solana blockchain network. The generated keys will be used to identify and authenticate the validator ,voter, staker on the network.

- #### chain faucet key
```shell
./target/debug/svm-station-keygen new --no-passphrase -so $HOME/.svmstationd/keys/faucet.json --force
```
- #### chain validator key

```shell
./target/debug/svm-station-keygen new --no-passphrase -so $HOME/.svmstationd/keys/validator-identity.json --force
```
- #### chain validator's voter key
```shell
./target/debug/svm-station-keygen new --no-passphrase -so $HOME/.svmstationd/keys/validator-vote-account.json --force
```

- #### chain validator's staker key

```shell
./target/debug/svm-station-keygen new --no-passphrase -so $HOME/.svmstationd/keys/validator-stake-account.json --force
```

### Step 2 **Initialize the Program**

fetch_spl_programs.sh is to automate the process of fetching the latest Solana Program Library (SPL) programs generating the necessary command-line arguments for installing them using the Solana blockchain's solana-genesis tool.

```shell
chmod +x fetch_spl_programs.sh
./fetch_spl_programs.sh <path to program> # path to download spl program example : = "program"
```

### Step 3 **Create Genesis**

This is a command-line invocation of the solana-genesis tool, which is used for initializing a new Solana blockchain network.

Configuration :

- The command sets various configurations such as the number of hashes per tick, the amount of lamports in the faucet account, and the stake for the bootstrap validator
- It specifies the paths to JSON files containing the validator's identity, vote account, and stake account keys
- It specifies the directory where blockchain data will be stored.

Example : “chain/ledger”

Loading Programs :

- The command loads several BPF (Berkeley Packet Filter) programs into the blockchain network. These programs include the Token program, Memo program, Associated Token Account program, and Feature Proposal program from the Solana Program Library
- Each program is specified with its program ID, loader ID, and the path to its corresponding BPF program file.

```shell
./target/debug/svm-station-genesis \
--ledger $HOME/.svmstationd/station-svm-chain/ \
--hashes-per-tick sleep \
--faucet-lamports 10000000000000000000 \
--bootstrap-validator-lamports 100000000000000000 \
--bootstrap-validator-stake-lamports 1000000000000000 \
--bootstrap-validator $HOME/.svmstationd/keys/validator-identity.json \
$HOME/.svmstationd/keys/validator-vote-account.json \
$HOME/.svmstationd/keys/validator-stake-account.json \
--cluster-type testnet \
--ticks-per-slot 44 \
--slots-per-epoch 432000 \
--bpf-program_ TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111 $HOME/.svmstationd/spl_token-3.5.0.so \
--bpf-program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb BPFLoaderUpgradeab1e11111111111111111111111111 $HOME/.svmstationd/spl_token-2022-0.9.0.so \
--bpf-program Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo BPFLoader1111111111111111111111111111111111 $HOME/.svmstationd/spl_memo-1.0.0.so \
--bpf-program MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr BPFLoader2111111111111111111111111111111111 $HOME/.svmstationd/spl_memo-3.0.0.so \
--bpf-program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111 $HOME/.svmstationd/spl_associated-token-account-1.1.2.so \
--bpf-program Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse BPFLoader2111111111111111111111111111111111 $HOME/.svmstationd/spl_feature-proposal-1.0.0.so
```


### Step 4 **Start Node**

solana-validator runs the Solana validator node with specific configurations.

Identity and Vote Account : The validator's identity and vote account are specified via JSON files located in the ‘chain/keys’ directory.

Ledger Configuration: The directory where blockchain ledger data will be stored is specified as ‘chain/ledger’

Network Configuration:

- The gossip port is set to 8001, enabling communication between nodes.
- RPC (Remote Procedure Call) services are configured to listen on 0.0.0.0:8899 for incoming requests.
- The full RPC API is enabled, allowing clients to access various Solana RPC methods.
- The RPC faucet address is set to 127.0.0.1:9900, indicating the local address for the faucet service

```shell
./target/debug/svm-station-validator \
--identity $HOME/.svmstationd/keys/validator-identity.json \
--vote-account $HOME/.svmstationd/keys/validator-vote-account.json \
--ledger $HOME/.svmstationd/station-svm-chain/ \
--rpc-port 8899 \
--gossip-port 8001 \
--snapshot-interval-slots 1000 \
--no-incremental-snapshots \
--rpc-faucet-address 127.0.0.1:9900 \
--rpc-bind-address 0.0.0.0 \
--bind-address 0.0.0.0 \
--log - \
--no-poh-speed-test \
--no-wait-for-vote-to-start-leader \
--full-rpc-api \
--allow-private-addr \
--enable-rpc-transaction-history \
--enable-extended-tx-metadata-storage \
--require-tower \
--no-os-network-limits-test &
```


## Acknowledgments

- This project is built upon the [Solana blockchain](https://github.com/solana-labs). We extend our gratitude to the Solana Labs and the community for their foundational work.
Expand Down
4 changes: 2 additions & 2 deletions accounts-cluster-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ solana-accounts-db = { workspace = true }
solana-clap-utils = { workspace = true }
solana-cli-config = { workspace = true }
solana-client = { workspace = true }
solana-faucet = { workspace = true }
svm-station-faucet = { workspace = true }
solana-gossip = { workspace = true }
solana-logger = { workspace = true }
solana-measure = { workspace = true }
Expand All @@ -34,7 +34,7 @@ spl-token = { workspace = true, features = ["no-entrypoint"] }
[dev-dependencies]
solana-core = { workspace = true }
solana-local-cluster = { workspace = true }
air-solana = { workspace = true }
svm-station-test-validator = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
4 changes: 2 additions & 2 deletions accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,14 @@ pub mod test {
super::*,
solana_accounts_db::inline_spl_token,
solana_core::validator::ValidatorConfig,
solana_faucet::faucet::run_local_faucet,
svm_station_faucet::faucet::run_local_faucet,
solana_local_cluster::{
local_cluster::{ClusterConfig, LocalCluster},
validator_configs::make_identical_validator_configs,
},
solana_measure::measure::Measure,
solana_sdk::{native_token::sol_to_lamports, poh_config::PohConfig},
air_solana::TestValidator,
svm_station_test_validator::TestValidator,
spl_token::{
solana_program::program_pack::Pack,
state::{Account, Mint},
Expand Down
6 changes: 3 additions & 3 deletions bench-tps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ solana-cli-config = { workspace = true }
solana-client = { workspace = true }
solana-connection-cache = { workspace = true }
solana-core = { workspace = true }
solana-faucet = { workspace = true }
solana-genesis = { workspace = true }
svm-station-faucet = { workspace = true }
svm-station-genesis = { workspace = true }
solana-gossip = { workspace = true }
solana-logger = { workspace = true }
solana-measure = { workspace = true }
Expand All @@ -44,7 +44,7 @@ thiserror = { workspace = true }
[dev-dependencies]
serial_test = { workspace = true }
solana-local-cluster = { workspace = true }
air-solana = { workspace = true }
svm-station-test-validator = { workspace = true }
tempfile = { workspace = true }

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/keypairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
bench_tps_client::BenchTpsClient,
},
log::*,
solana_genesis::Base64Account,
svm_station_genesis::Base64Account,
solana_sdk::signature::{Keypair, Signer},
std::{collections::HashMap, fs::File, path::Path, process::exit, sync::Arc},
};
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use {
thin_client::ThinClient,
tpu_client::{TpuClient, TpuClientConfig},
},
solana_genesis::Base64Account,
svm_station_genesis::Base64Account,
solana_gossip::gossip_service::{discover_cluster, get_client, get_multi_client},
solana_rpc_client::rpc_client::RpcClient,
solana_sdk::{
Expand Down
4 changes: 2 additions & 2 deletions bench-tps/tests/bench_tps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
tpu_client::{TpuClient, TpuClientConfig},
},
solana_core::validator::ValidatorConfig,
solana_faucet::faucet::run_local_faucet,
svm_station_faucet::faucet::run_local_faucet,
solana_local_cluster::{
local_cluster::{ClusterConfig, LocalCluster},
validator_configs::make_identical_validator_configs,
Expand All @@ -27,7 +27,7 @@ use {
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
air_solana::TestValidatorGenesis,
svm_station_test_validator::TestValidatorGenesis,
std::{sync::Arc, time::Duration},
};

Expand Down
2 changes: 1 addition & 1 deletion ci/bench/part2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ _ cargo +"$rust_nightly" bench --manifest-path runtime/Cargo.toml ${V:+--verbose
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

(
# solana-keygen required when building C programs
# svm-station-keygen required when building C programs
_ cargo build --manifest-path=keygen/Cargo.toml
export PATH="$PWD/target/debug":$PATH

Expand Down
6 changes: 3 additions & 3 deletions ci/localnet-sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ killNodes() {
# Try to use the RPC exit API to cleanly exit the first two nodes
# (dynamic nodes, -x, are just killed)
echo "--- RPC exit"
$solana_validator --ledger "$SOLANA_CONFIG_DIR"/bootstrap-validator exit --force || true
$solana_validator --ledger "$SOLANA_CONFIG_DIR"/validator exit --force || true
$svm_station_validator --ledger "$SOLANA_CONFIG_DIR"/bootstrap-validator exit --force || true
$svm_station_validator --ledger "$SOLANA_CONFIG_DIR"/validator exit --force || true

# Give the nodes a splash of time to cleanly exit before killing them
sleep 2
Expand Down Expand Up @@ -316,7 +316,7 @@ while [[ $iteration -le $iterations ]]; do
(
set -x
client_keypair=/tmp/client-id.json-$$
$solana_keygen new --no-passphrase -fso $client_keypair || exit $?
$svm_station_keygen new --no-passphrase -fso $client_keypair || exit $?
$solana_gossip --allow-private-addr spy -n 127.0.0.1:8001 --num-nodes-exactly $numNodes || exit $?
rm -rf $client_keypair
) || flag_error
Expand Down
2 changes: 1 addition & 1 deletion ci/run-sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ while [[ $latest_slot -le $((snapshot_slot + 1)) ]]; do
latest_slot=$($solana_cli --url http://localhost:8899 slot --commitment processed)
done

$solana_validator --ledger config/ledger exit --force || true
$svm_station_validator --ledger config/ledger exit --force || true

wait $pid

Expand Down
2 changes: 1 addition & 1 deletion ci/test-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi
BENCH_FILE=bench_output.log
BENCH_ARTIFACT=current_bench_results.log

# solana-keygen required when building C programs
# svm-station-keygen required when building C programs
_ cargo build --manifest-path=keygen/Cargo.toml
export PATH="$PWD/target/debug":$PATH

Expand Down
2 changes: 1 addition & 1 deletion ci/test-stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test-stable-sbf)
# rustfilt required for dumping SBF assembly listings
"$cargo" install rustfilt

# solana-keygen required when building C programs
# svm-station-keygen required when building C programs
_ "$cargo" build --manifest-path=keygen/Cargo.toml

export PATH="$PWD/target/debug":$PATH
Expand Down
8 changes: 4 additions & 4 deletions clap-utils/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl DefaultSigner {
std::io::Error::new(
std::io::ErrorKind::Other,
format!(
"No default signer found, run \"solana-keygen new -o {}\" to create a new one",
"No default signer found, run \"svm-station-keygen new -o {}\" to create a new one",
self.path
),
)
Expand Down Expand Up @@ -776,7 +776,7 @@ pub fn signer_from_path_with_config(
SignerSourceKind::Filepath(path) => match read_keypair_file(&path) {
Err(e) => Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("could not read keypair file \"{path}\". Run \"solana-keygen new\" to create a keypair file: {e}"),
format!("could not read keypair file \"{path}\". Run \"svm-station-keygen new\" to create a keypair file: {e}"),
)
.into()),
Ok(file) => Ok(Box::new(file)),
Expand Down Expand Up @@ -900,7 +900,7 @@ pub fn resolve_signer_from_path(
std::io::ErrorKind::Other,
format!(
"could not read keypair file \"{path}\". \
Run \"solana-keygen new\" to create a keypair file: {e}"
Run \"svm-station-keygen new\" to create a keypair file: {e}"
),
)
.into()),
Expand Down Expand Up @@ -1022,7 +1022,7 @@ pub fn keypair_from_path(
std::io::ErrorKind::Other,
format!(
"could not read keypair file \"{path}\". \
Run \"solana-keygen new\" to create a keypair file: {e}"
Run \"svm-station-keygen new\" to create a keypair file: {e}"
),
)
.into()),
Expand Down
8 changes: 4 additions & 4 deletions clap-v3-utils/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl DefaultSigner {
std::io::Error::new(
std::io::ErrorKind::Other,
format!(
"No default signer found, run \"solana-keygen new -o {}\" to create a new one",
"No default signer found, run \"svm-station-keygen new -o {}\" to create a new one",
self.path
),
)
Expand Down Expand Up @@ -777,7 +777,7 @@ pub fn signer_from_path_with_config(
SignerSourceKind::Filepath(path) => match read_keypair_file(&path) {
Err(e) => Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("could not read keypair file \"{path}\". Run \"solana-keygen new\" to create a keypair file: {e}"),
format!("could not read keypair file \"{path}\". Run \"svm-station-keygen new\" to create a keypair file: {e}"),
)
.into()),
Ok(file) => Ok(Box::new(file)),
Expand Down Expand Up @@ -902,7 +902,7 @@ pub fn resolve_signer_from_path(
std::io::ErrorKind::Other,
format!(
"could not read keypair file \"{path}\". \
Run \"solana-keygen new\" to create a keypair file: {e}"
Run \"svm-station-keygen new\" to create a keypair file: {e}"
),
)
.into()),
Expand Down Expand Up @@ -1133,7 +1133,7 @@ fn encodable_key_from_path<K: EncodableKey + SeedDerivable>(
std::io::ErrorKind::Other,
format!(
"could not read keypair file \"{path}\". \
Run \"solana-keygen new\" to create a keypair file: {e}"
Run \"svm-station-keygen new\" to create a keypair file: {e}"
),
)
.into()),
Expand Down
6 changes: 3 additions & 3 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ solana-cli-config = { workspace = true }
solana-cli-output = { workspace = true }
solana-client = { workspace = true }
solana-config-program = { workspace = true }
solana-faucet = { workspace = true }
svm-station-faucet = { workspace = true }
solana-loader-v4-program = { workspace = true }
solana-logger = { workspace = true }
solana-program-runtime = { workspace = true }
Expand All @@ -57,11 +57,11 @@ tiny-bip39 = { workspace = true }
[dev-dependencies]
assert_matches = { workspace = true }
solana-streamer = { workspace = true }
air-solana = { workspace = true }
svm-station-test-validator = { workspace = true }
tempfile = { workspace = true }

[[bin]]
name = "solana"
name = "svm-station"
path = "src/main.rs"

[package.metadata.docs.rs]
Expand Down
Loading

0 comments on commit a69a8f7

Please sign in to comment.