Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build and push client docker images #31

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
367a2c0
add in download from release channel
gregcusack Mar 27, 2024
bcfbde6
change how tar tar is downloaded and unpacked
gregcusack Mar 30, 2024
239fb4d
remove boxed_error. cast to dyn Error
gregcusack Mar 30, 2024
c13e851
update DeployMethod. remove --deploy-method flag
gregcusack Mar 30, 2024
0dd8967
add buildtype enum
gregcusack Mar 30, 2024
13d6d71
rm Skip DeployMethod. use strum
gregcusack Apr 1, 2024
28188ce
add in genesis::new
gregcusack Mar 27, 2024
0cc0043
add generate faucet keypair
gregcusack Mar 28, 2024
a42258c
add validator type enum
gregcusack Mar 28, 2024
c2d1c1b
add generate bootstrap accounts. and struct for generating other vali…
gregcusack Mar 28, 2024
2b55941
add in genesis build and genesis flags
gregcusack Mar 28, 2024
f31b79d
wip. bug in docker build
gregcusack Mar 29, 2024
fac42c4
build docker bootstrap image
gregcusack Mar 29, 2024
c9c94a3
push bootstrap to dockerhub registry. modify dockerconfig. create Doc…
gregcusack Mar 29, 2024
32c833c
add create and deploy bootstrap secrets
gregcusack Apr 1, 2024
5495c3a
add bootstrap validator selector
gregcusack Apr 1, 2024
2612e4e
wip. adding replicaset but need validator config flags
gregcusack Apr 1, 2024
be36f9f
add validator config
gregcusack Apr 1, 2024
3801270
add pod requests. need for scheduling
gregcusack Apr 1, 2024
b5d9dfb
create bootstrap validator replicaset
gregcusack Apr 1, 2024
7b43c3e
refactor. add validator struct to clean up main
gregcusack Apr 2, 2024
1a0f829
deploy bootstrap validator
gregcusack Apr 2, 2024
0b69996
wip. added bootstrap service. need lb service
gregcusack Apr 2, 2024
f7bff73
deploy and wait for validator ready. need readme update
gregcusack Apr 2, 2024
c90172b
update readme. update progress. fix selector bug
gregcusack Apr 2, 2024
8804371
add metrics
gregcusack Apr 2, 2024
56a6d17
create N validator accounts
gregcusack Apr 2, 2024
a720a5c
create and deploy validator secrets
gregcusack Apr 2, 2024
c89a6c8
create validator selectors
gregcusack Apr 3, 2024
530505c
add in build and push validator docker images
gregcusack Apr 3, 2024
0471db4
wip. more work
gregcusack Apr 3, 2024
26ddaad
i forgot to build the validator docker images first
gregcusack Apr 3, 2024
3be12a6
working. build and deploy validators
gregcusack Apr 3, 2024
06fe5e0
update scripts to work with agave and solana validator versions
gregcusack Apr 4, 2024
ddfcdb9
create rpc validator accounts
gregcusack Apr 4, 2024
d3ef0d3
wip. just added rpc startup script
gregcusack Apr 4, 2024
27ed63c
add and deploy rpc secrets
gregcusack Apr 4, 2024
75e6bfd
build and push rpc docker image
gregcusack Apr 4, 2024
f83ef38
add selectors for rpc
gregcusack Apr 4, 2024
957dee9
wip. need to deploy services as well. cant rpc can't contact other no…
gregcusack Apr 5, 2024
104ebc0
working. bug in rpc stasrtup script
gregcusack Apr 5, 2024
553ee0e
wait for >= 1 rpc node to deploy before launching validators
gregcusack Apr 5, 2024
47aefa9
add in create client accounts
gregcusack Apr 5, 2024
dc54636
wip. getting client-accounts into genesis and bootstrap
gregcusack Apr 5, 2024
121cea9
wip. need new client image for each client. has to have client data d…
gregcusack Apr 5, 2024
23242bd
wip. need to build client docker image
gregcusack Apr 8, 2024
0f444c6
not copying client stuff in correctly in docker. wip
gregcusack Apr 8, 2024
03d0e48
wip. can build clients. need to push now
gregcusack Apr 9, 2024
37bbe85
push client images (threaded). working
gregcusack Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,319 changes: 6,556 additions & 763 deletions Cargo.lock

Large diffs are not rendered by default.

96 changes: 94 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,32 @@ license = "Apache-2.0"
edition = "2021"

[dependencies]
clap = "2.33.1"
anyhow = "1.0.80"
bzip2 = "0.4.4"
clap = { version = "3.2.22", features = ["cargo"] }
console = "0.15.8"
git2 = "0.18.3"
indicatif = "0.17.8"
k8s-openapi ={ version = "0.20.0", features = ["v1_28"] }
kube = "0.87.2"
log = "0.4.21"
solana-logger = "1.18.7"
rand = "0.8.5"
rayon = "1.9.0"
reqwest = { version = "0.11.23", features = ["blocking", "brotli", "deflate", "gzip", "rustls-tls", "json"] }
rustls = { version = "0.21.10", default-features = false, features = ["quic"] }
solana-accounts-db = "1.18.8"
solana-core = "1.18.8"
solana-ledger = "1.18.8"
solana-logger = "1.18.8"
solana-sdk = "1.18.8"
strum = "0.26.2"
strum_macros = "0.26.2"
subtle = "2.4.1"
tar = "0.4.40"
tokio = { version = "1.29.1", features = ["full"] }
url = "2.5.0"
# See "zeroize versioning issues" below if you are updating this version.
zeroize = { version = "1.3", default-features = false }

[build-dependencies]
rustc_version = "0.4"
Expand All @@ -25,3 +44,76 @@ path = "src/main.rs"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

#
# === zeroize versioning issues ===
#
# A number of packages used explicit upper bound on the `zeroize` package, such
# as `>=1, <1.4`. The problem is that cargo still does not duplicate `zeroize`
# if a newer version is available and requested by another package and just
# fails the whole dependency resolution process.
#
# This is described in
#
# https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-requirements
#
# So we have to patch `zeroize` dependency specifications in the projects that
# introduce these constraints. They have already removed these constraints in
# newer versions, but we have not updated yet. As we update, we need to remove
# these patch requests.
#
# When our dependencies are upgraded, we can remove these patches. Before that
# we might need to maintain these patches in sync with our full dependency tree.

# Our dependency tree has `aes-gcm-siv` v0.10.3 and the `zeroize` restriction
# was removed in the next commit just after the release. So it seems safe to
# patch to this commit.
#
# `aes-gcm-siv` v0.10.3 release:
#
# https://github.com/RustCrypto/AEADs/releases/tag/aes-gcm-siv-v0.10.3
#
# Corresponds to commit
#
# https://github.com/RustCrypto/AEADs/commit/6f16f4577a1fc839a2346cf8c5531c85a44bf5c0
#
# Comparison with `6105d7a5591aefa646a95d12b5e8d3f55a9214ef` pinned here:
#
# https://github.com/RustCrypto/AEADs/compare/aes-gcm-siv-v0.10.3..6105d7a5591aefa646a95d12b5e8d3f55a9214ef
#
[patch.crates-io.aes-gcm-siv]
git = "https://github.com/RustCrypto/AEADs"
rev = "6105d7a5591aefa646a95d12b5e8d3f55a9214ef"

# Our dependency tree has `curve25519-dalek` v3.2.1. They have removed the
# constraint in the next major release. The commit that removes the `zeroize`
# constraint was added to multiple release branches, but not to the 3.2 branch.
#
# `curve25519-dalek` maintainers are saying they do not want to invest any more
# time in the 3.2 release:
#
# https://github.com/dalek-cryptography/curve25519-dalek/issues/452#issuecomment-1749809428
#
# So we have to fork and create our own release, based on v3.2.1, with the
# commit that removed `zeroize` constraint on the `main` branch cherry-picked on
# top.
#
# `curve25519-dalek` v3.2.1 release:
#
# https://github.com/dalek-cryptography/curve25519-dalek/releases/tag/3.2.1
#
# Corresponds to commit
#
# https://github.com/dalek-cryptography/curve25519-dalek/commit/29e5c29b0e5c6821e4586af58b0d0891dd2ec639
#
# Comparison with `b500cdc2a920cd5bff9e2dd974d7b97349d61464`:
#
# https://github.com/dalek-cryptography/curve25519-dalek/compare/3.2.1...solana-labs:curve25519-dalek:b500cdc2a920cd5bff9e2dd974d7b97349d61464
#
# Or, using the branch name instead of the hash:
#
# https://github.com/dalek-cryptography/curve25519-dalek/compare/3.2.1...solana-labs:curve25519-dalek:3.2.1-unpin-zeroize
#
[patch.crates-io.curve25519-dalek]
git = "https://github.com/solana-labs/curve25519-dalek.git"
rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464"
60 changes: 31 additions & 29 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,48 @@

## Steps
- [x] Connect to kubernetes endpoint and check if namespace exists
- [ ] Setup build config Local
- [x] Setup build config Local
- [x] Build from local commit
- [ ] Build from tar (release version)
- [ ] Create Genesis
- [ ] Generate faucet and bootstrap accounts
- [ ] Build genesis
- [ ] Docker Build
- [ ] Build Bootstrap Image
- [ ] Push Image to registry
- [x] Build from tar (release version)
- [x] Create Genesis
- [x] Generate faucet and bootstrap accounts
- [x] Build genesis
- [x] Docker Build and Push to registry
- [x] Bootstrap
- [x] Validator (regular)
- [x] RPC nodes
- [x] Client
- [ ] Create & Deploy Secrets
- [ ] Bootstrap
- [ ] Validator (regular)
- [ ] RPC nodes
- [x] Bootstrap
- [x] Validator (regular)
- [x] RPC nodes
- [ ] Client
- [ ] Create & Deploy Selector
- [ ] Bootstrap
- [ ] Validator (regular)
- [ ] RPC nodes
- [x] Bootstrap
- [x] Validator (regular)
- [x] RPC nodes
- [ ] Client
- [ ] Create & Deploy Replica Set
- [ ] Bootstrap
- [ ] Validator (regular)
- [ ] RPC nodes
- [x] Bootstrap
- [x] Validator (regular)
- [x] RPC nodes
- [ ] Client
- [ ] Create & Deploy Services
- [ ] Bootstrap
- [ ] Validator (regular)
- [ ] RPC nodes
- [x] Bootstrap
- [x] Validator (regular)
- [x] RPC nodes
- [ ] Client
- [ ] Check Bootstrap is deployed and running
- [ ] Build and deploy Load Balancer (sits in front of bootstrap and RPC nodes)
- [x] Check Bootstrap is deployed and running
- [x] Build and deploy Load Balancer (sits in front of bootstrap and RPC nodes)
- [ ] Add metrics
- [ ] Bootstrap
- [ ] Validator (regular)
- [ ] RPC nodes
- [x] Bootstrap
- [x] Validator (regular)
- [x] RPC nodes
- [ ] Client
- [ ] Create accounts
- [ ] Validator (regular)
- [ ] RPC
- [ ] Client
- [x] Validator (regular)
- [x] RPC
- [x] Client
- [ ] Add feature flags to configure:
- [ ] Bootstrap
- [ ] Validator (regular)
Expand All @@ -69,7 +71,7 @@ Above, we start with bootstrap, and then we do validators (regular), and then we
- Use command line flags to set type of client, tx-count, etc

- [ ] Add in kubernetes deployment flags
- [ ] CPU/Memory Requests
- [x] CPU/Memory Requests
- [ ] Node Affinity -> Regions
- [ ] Node Affinity -> Node Type (Equinix/Lumen)

Expand Down
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,104 @@ kubectl create ns <namespace>
```

### Run
#### Build Agave from local agave repo
```
cargo run --bin cluster --
-n <namespace>
--deploy-method local
--num_validators <number-of-non-bootstrap-voting-validators>
--local-path <path-to-local-agave-monorepo>
```

#### Build specific Agave release
```
cargo run --bin cluster --
-n <namespace>
--num_validators <number-of-non-bootstrap-voting-validators>
--release-channel <agave-version: e.g. v1.17.28> # note: MUST include the "v"
```

#### Build from Local Repo and Configure Genesis and Bootstrap Validator Image
Example:
```
cargo run --bin cluster --
-n <namespace>
--num-validators <number-of-non-bootstrap-voting-validators>
--deploy-method local
--local-path /home/sol/solana
# genesis config. Optional: Many of these have defaults
--hashes-per-tick <hashes-per-tick>
--enable-warmup-epochs <true|false>
--faucet-lamports <faucet-lamports>
--bootstrap-validator-sol <validator-sol>
--bootstrap-validator-stake-sol <validator-stake>
--max-genesis-archive-unpacked-size <size in bytes>
--target-lamports-per-signature <lamports-per-signature>
--slots-per-epoch <slots-per-epoch>
# docker config
--registry <docker-registry> # e.g. gregregistry
--docker-build
--tag <docker-image-tag> # e.g. v1
--base-image <base-image> # e.g. ubuntu:20.04
--image-name <docker-image-name> # e.g. cluster-image
# validator config
--full-rpc
--internal-node-sol <Sol>
--internal-node-stake-sol <Sol>
# kubernetes config
--cpu-requests <cores>
--memory-requests <memory>
```

#### RPC Nodes
You can add in RPC nodes. These sit behind a load balancer. Load balancer distributed loads across all RPC nodes that the bootstrap. Set the number of RPC nodes with:
```
--num-rpc-nodes <num-nodes>
```

## Metrics
1) Setup metrics database:
```
cd scripts/
./init-metrics -c <database-name> <metrics-username>
# enter password when promted
```
2) add the following to your `cluster` command from above
```
--metrics-host https://internal-metrics.solana.com # need the `https://` here
--metrics-port 8086
--metrics-db <database-name> # from (1)
--metrics-username <metrics-username> # from (1)
--metrics-password <metrics-password> # from (1)
```


## Kubernetes Cheatsheet
Create namespace:
```
kubectl create ns <namespace>
```

Delete namespace:
```
kubectl delete ns <namespace>
```

Get running pods:
```
kubectl get pods -n <namespace>
```

Get pod logs:
```
kubectl logs -n <namespace> <pod-name>
```

Exec into pod:
```
kubectl exec -it -n <namespace> <pod-name> -- /bin/bash
```

Get information about pod:
```
kubectl describe pod -n <namespace> <pod-name>
```
62 changes: 62 additions & 0 deletions fetch-spl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
#
# Fetches the latest SPL programs and produces the solana-genesis command-line
# arguments needed to install them
#

set -e

upgradeableLoader=BPFLoaderUpgradeab1e11111111111111111111111

fetch_program() {
declare name=$1
declare version=$2
declare address=$3
declare loader=$4

declare so=spl_$name-$version.so

if [[ $loader == "$upgradeableLoader" ]]; then
genesis_args+=(--upgradeable-program "$address" "$loader" "$so" none)
else
genesis_args+=(--bpf-program "$address" "$loader" "$so")
fi

if [[ -r $so ]]; then
return
fi

if [[ -r ~/.cache/solana-spl/$so ]]; then
cp ~/.cache/solana-spl/"$so" "$so"
else
echo "Downloading $name $version"
so_name="spl_${name//-/_}.so"
(
set -x
curl -L --retry 5 --retry-delay 2 --retry-connrefused \
-o "$so" \
"https://github.com/solana-labs/solana-program-library/releases/download/$name-v$version/$so_name"
)

mkdir -p ~/.cache/solana-spl
cp "$so" ~/.cache/solana-spl/"$so"
fi

}

fetch_program token 3.5.0 TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA BPFLoader2111111111111111111111111111111111
fetch_program token-2022 0.9.0 TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb BPFLoaderUpgradeab1e11111111111111111111111
fetch_program memo 1.0.0 Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo BPFLoader1111111111111111111111111111111111
fetch_program memo 3.0.0 MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr BPFLoader2111111111111111111111111111111111
fetch_program associated-token-account 1.1.2 ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL BPFLoader2111111111111111111111111111111111
fetch_program feature-proposal 1.0.0 Feat1YXHhH6t1juaWF74WLcfv4XoNocjXA6sPWHNgAse BPFLoader2111111111111111111111111111111111

echo "${genesis_args[@]}" > spl-genesis-args.sh

echo
echo "Available SPL programs:"
ls -l spl_*.so

echo
echo "solana-genesis command-line arguments (spl-genesis-args.sh):"
cat spl-genesis-args.sh
Loading