Skip to content

Commit f68834e

Browse files
Add Quick Start tutorial
- add script for installing Go from source, platform agnostic - add script for installing Rollkit cli by building it from source under the hood
1 parent 938bf85 commit f68834e

File tree

6 files changed

+197
-1
lines changed

6 files changed

+197
-1
lines changed

.vitepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ function sidebarHome() {
215215
items: [
216216
// { text: 'Starter Rollup with Docker', link: '/tutorials/rollup-docker'},
217217
// { text: 'Starter Rollup', link: '/tutorials/starter-rollup'},
218+
{
219+
text: "Quick start guide",
220+
link: "/tutorials/quick-start",
221+
},
218222
{
219223
text: "GM world rollup: Part 1, local devnet",
220224
link: "/tutorials/gm-world",

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ hero:
1313
actions:
1414
- theme: brand
1515
text: Starter Rollup
16-
link: /tutorials/gm-world
16+
link: /tutorials/quick-start
1717
- theme: alt
1818
text: Introduction
1919
link: /learn/intro

scripts/install-go.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash -e
2+
3+
# This script installs or updates to the latest version of Go.
4+
# Multi-platform (Linux and macOS)
5+
# Multi-architecture (amd64, arm64, arm) support
6+
7+
error_string=("Error: This command has to be run with superuser"
8+
"privileges (under the root user on most systems).")
9+
if [[ $(id -u) -ne 0 ]]; then echo "${error_string[@]}" >&2; exit 1; fi
10+
11+
deps=( curl jq )
12+
unset bail
13+
for i in "${deps[@]}"; do command -v "$i" >/dev/null 2>&1 || { bail="$?"; echo "$i" is not available; }; done
14+
if [ "$bail" ]; then exit "$bail"; fi
15+
16+
version="$(curl -s 'https://go.dev/dl/?mode=json' | jq -r '.[0].version')"
17+
current="$(/usr/local/go/bin/go version 2>/dev/null | awk '{print $3}')"
18+
if [[ "$current" == "$version" ]]; then
19+
echo "Go is already up-to-date at version ${version}"
20+
exit 0
21+
fi
22+
23+
update_go() {
24+
local arch="$1"
25+
local os="$2"
26+
27+
local go_url="https://golang.org/dl/${version}.${os}-${arch}.tar.gz"
28+
29+
curl -so "/tmp/${version}.${os}-${arch}.tar.gz" -L "$go_url" && \
30+
rm -rf /usr/local/go && tar -C /usr/local -xzf /tmp/${version}.${os}-${arch}.tar.gz
31+
32+
tar -C /usr/local -xzf "/tmp/${version}.${os}-${arch}.tar.gz" && \
33+
echo "Go updated to version ${version}"
34+
35+
rm "/tmp/${version}.${os}-${arch}.tar.gz"
36+
}
37+
38+
case "$(uname -s)" in
39+
Linux)
40+
case "$(uname -m)" in
41+
armv6l|armv7l)
42+
update_go "armv6l" "linux"
43+
;;
44+
arm64)
45+
update_go "arm64" "linux"
46+
;;
47+
x86_64)
48+
update_go "amd64" "linux"
49+
;;
50+
*)
51+
echo "Unsupported architecture: $(uname -m)" >&2
52+
exit 1
53+
;;
54+
esac
55+
;;
56+
Darwin)
57+
case "$(uname -m)" in
58+
arm64)
59+
update_go "arm64" "darwin"
60+
;;
61+
x86_64)
62+
update_go "amd64" "darwin"
63+
;;
64+
*)
65+
echo "Unsupported architecture: $(uname -m)" >&2
66+
exit 1
67+
;;
68+
esac
69+
;;
70+
*)
71+
echo "Unsupported operating system: $(uname -s)" >&2
72+
exit 1
73+
;;
74+
esac
75+
76+
# Define the Go binary path
77+
GO_BIN_PATH="/usr/local/go/bin"
78+
79+
# Function to add path to the specific shell config file
80+
add_path_to_config() {
81+
local config_file="$1"
82+
83+
# Check if the Go bin path is already in the config file to prevent duplicates
84+
if ! grep -q "export PATH=.*$GO_BIN_PATH" "$config_file" ; then
85+
echo "export PATH=\$PATH:$GO_BIN_PATH" >> "$config_file"
86+
echo "Added $GO_BIN_PATH to $config_file"
87+
else
88+
echo "$GO_BIN_PATH is already in $config_file"
89+
fi
90+
}
91+
92+
# Determine shell and appropriate config file
93+
if [[ -n "$ZSH_VERSION" ]]; then
94+
# Assuming the user is using Zsh
95+
CONFIG_FILE="$HOME/.zshenv"
96+
elif [[ -n "$BASH_VERSION" ]]; then
97+
# Check if .bash_profile exists, otherwise use .profile
98+
if [[ -f "$HOME/.bash_profile" ]]; then
99+
CONFIG_FILE="$HOME/.bash_profile"
100+
else
101+
CONFIG_FILE="$HOME/.profile"
102+
fi
103+
else
104+
echo "Unsupported shell. Only Bash and Zsh are supported."
105+
exit 1
106+
fi
107+
108+
# Check if the Go bin path is already in the PATH
109+
if [[ ":$PATH:" != *":$GO_BIN_PATH:"* ]]; then
110+
echo "Adding $GO_BIN_PATH to PATH."
111+
add_path_to_config "$CONFIG_FILE"
112+
# Source the config file to update the current session
113+
source "$CONFIG_FILE"
114+
echo "$GO_BIN_PATH added to PATH successfully."
115+
else
116+
echo "$GO_BIN_PATH is already in PATH."
117+
fi
118+
119+
/usr/local/go/bin/go version

scripts/install-rollkit.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
echo "Downloading Rollkit source code..."
4+
git clone https://github.com/rollkit/rollkit.git
5+
6+
if ! which go > /dev/null; then
7+
echo "Go is not installed. Attempting to install Go..."
8+
if ! which go > /dev/null; then
9+
echo "Go is not installed. Attempting to install Go using the provided script..."
10+
curl -sL https://raw.githubusercontent.com/rollkit/docs/main/scripts/install-go.sh | sh
11+
if ! which go > /dev/null; then
12+
echo "Failed to install Go. Please install it manually and rerun this script."
13+
exit 1
14+
fi
15+
fi
16+
fi
17+
18+
cd rollkit || { echo "Failed to find the unpacked directory."; exit 1; }
19+
git checkout v0.13.2
20+
echo "Building and installing Rollkit..."
21+
make install
22+
echo "Cleaning up..."
23+
cd ..
24+
echo "Installation completed successfully."
25+

tutorials/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ that best suit your needs.
1717
In this section, you'll find:
1818

1919
* Rollkit
20+
* [Quick Start](/tutorials/quick-start.md)
2021
* [GM world rollup: Part 1, local devnet](/tutorials/gm-world.md)
2122
* [GM world frontend](/tutorials/gm-world-frontend.md)
2223
* [Wordle app](/tutorials/wordle.md)

tutorials/quick-start.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
description: Quickly start a rollup node using the Rollkit CLI.
3+
---
4+
5+
# Quick Start Guide
6+
7+
Welcome to Rollkit, a sovereign rollup framework! The easiest way to launch your sovereign rollup node is by using the Rollkit CLI.
8+
9+
### 📦 Install Rollkit (CLI)
10+
11+
To install Rollkit, run the following command in your terminal:
12+
13+
```bash
14+
curl -s https://install.rollkit.dev | sh
15+
```
16+
17+
Verify the installation by checking the Rollkit version:
18+
19+
```bash
20+
rollkit version
21+
```
22+
23+
A successful installation will display the version number and its associated git commit hash.
24+
25+
### 🚀 Run Your Sovereign Rollup Node
26+
27+
To start a basic sovereign rollup node, execute:
28+
29+
```bash
30+
rollkit start
31+
```
32+
33+
Upon execution, the CLI will output log entries that provide insights into the node's initialization and operation:
34+
35+
```bash
36+
I[2024-05-01|09:58:46.001] Found private validator module=main keyFile=/root/.rollkit/config/priv_validator_key.json stateFile=/root/.rollkit/data/priv_validator_state.json
37+
I[2024-05-01|09:58:46.002] Found node key module=main path=/root/.rollkit/config/node_key.json
38+
I[2024-05-01|09:58:46.002] Found genesis file module=main path=/root/.rollkit/config/genesis.json
39+
...
40+
I[2024-05-01|09:58:46.080] Started node module=main
41+
I[2024-05-01|09:58:46.081] Creating and publishing block module=BlockManager height=223
42+
I[2024-05-01|09:58:46.082] Finalized block module=BlockManager height=223 num_txs_res=0 num_val_updates=0 block_app_hash=
43+
```
44+
45+
### 🎉 Conclusion
46+
47+
That's it! Your sovereign rollup node is now up and running. It's incredibly simple to start a blockchain (which is essentially what a rollup is) these days using Rollkit. Explore further and discover how you can build useful applications on Rollkit. Good luck!

0 commit comments

Comments
 (0)