-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathaggregation_mode.sh
More file actions
executable file
·149 lines (122 loc) · 5.84 KB
/
aggregation_mode.sh
File metadata and controls
executable file
·149 lines (122 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# This guide assumes you already clone the github repository
# You have to cd to the repository
# Set new server name
while :; do
echo -e "\nEnter new server name:"
read -p "> " new_server_name
if [[ ! "$new_server_name" =~ ^[a-zA-Z0-9-]+$ ]]; then
echo "Invalid characters used in the server name. Please use only alphanumeric characters and hyphens (-)."
else
echo -e "\nSetting new server name to '$new_server_name'..."
echo "Old server name: $old_server_name"
sudo hostnamectl set-hostname "$new_server_name"
sudo sed -i "s/$old_server_name/$new_server_name/g" /etc/hosts
echo "Please reconnect to the server to see the name change."
break
fi
done
# Enable linger
sudo loginctl enable-linger user
# Install other dependencies
sudo apt install -y gcc pkg-config libssl-dev build-essential apt-transport-https ca-certificates curl software-properties-common nvtop clang
sudo apt-get install -y protobuf-compiler
# Install docker
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
# Install tailscale
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list
sudo apt-get update
sudo apt-get install tailscale
sudo tailscale up --ssh --advertise-tags=tag:server && sudo tailscale set --auto-update
# Install CUDA
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install -y nvidia-driver-580
sudo apt autoremove
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
sudo apt install -y cuda-toolkit-12-9
## Add to ~/.bashrc
export PATH=/usr/local/cuda-12.9/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# If see errors
#sudo apt-mark unhold cuda-drivers cuda-toolkit-12-6 nvidia-dkms-565-server nvidia-fabricmanager-565 nvidia-headless-565-server nvidia-utils-565-server
#sudo apt update
#sudo apt install nvidia-driver-570
#sudo apt autoremove
#sudo apt autoclean
sudo reboot
nvidia-smi # To check if the driver is installed correctly
# Setup Docker and CUDA
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
# Install SP1
curl -L https://sp1.succinct.xyz | bash
source $HOME/.bashrc
sp1up
# Install Risc0
curl -L https://risczero.com/install | bash
source $HOME/.bashrc
rzup install
# Install cast
curl -L https://foundry.paradigm.xyz | bash
source $HOME/.bashrc
foundryup
# Create directories
mkdir -p ~/config
mkdir -p ~/.config/systemd/user
mkdir -p ~/.keystores
# Create keystore
cast wallet import proof_aggregation.keystore -k $HOME/.keystores -i
# Create config file for SP1
./infra/aggregation_mode/config_file.sh ./infra/aggregation_mode/config-proof-aggregator-sp1.template.yaml $HOME/config/config-proof-aggregator-sp1.yaml
read -p "Enter a block number for SP1 (last_aggregated_block): " num && echo "{\"last_aggregated_block\":$num}" > $HOME/config/proof-aggregator-sp1.last_aggregated_block.json
# Create config file for Risc0
./infra/aggregation_mode/config_file.sh ./infra/aggregation_mode/config-proof-aggregator-risc0.template.yaml $HOME/config/config-proof-aggregator-risc0.yaml
read -p "Enter a block number for Risc0 (last_aggregated_block): " num && echo "{\"last_aggregated_block\":$num}" > $HOME/config/proof-aggregator-risc0.last_aggregated_block.json
mkdir -p $HOME/repos/aggregation_mode/mainnet
cd $HOME/repos/aggregation_mode/mainnet
git clone https://github.com/yetanotherco/aligned_layer.git
# Build the proof_aggregator
#make proof_aggregator_install
cargo install --path aggregation_mode/proof_aggregator --features prove,gpu --bin proof_aggregator_gpu --locked
cargo install --path aggregation_mode/proof_aggregator --features prove --bin proof_aggregator_cpu --locked # This builds risc0 with CPU but sp1 is runnable with GPU
# Copy run script
cp ./infra/aggregation_mode/run.sh $HOME/run.sh
chmod 744 $HOME/run.sh
# Setup systemd service
cp ./infra/aggregation_mode/aggregation_mode.service $HOME/.config/systemd/user/aggregation_mode.service
cp ./infra/aggregation_mode/aggregation_mode.timer $HOME/.config/systemd/user/aggregation_mode.timer
#sudo systemctl enable aggregation_mode.service
systemctl --user enable aggregation_mode.timer
systemctl --user start aggregation_mode.timer
# Run the proof_aggregator manually if you want
systemctl --user start aggregation_mode.service
# Check timer status
systemctl --user status aggregation_mode.timer
# Check logs
journalctl -xfeu aggregation_mode.service --user -n10