Skip to content

Commit 8882bd0

Browse files
authored
feat: installer script (#301)
1 parent df2125e commit 8882bd0

File tree

2 files changed

+149
-9
lines changed

2 files changed

+149
-9
lines changed

README.md

+29-9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ Please note that `era-test-node` is still in its **alpha** stage. Some features
4646

4747
## 📥 Installation & Setup
4848

49+
### Using the installation script
50+
51+
1. Download the installation script and mark as executable:
52+
```bash
53+
curl --proto '=https' -sSf https://raw.githubusercontent.com/matter-labs/era-test-node/main/scripts/install.sh > install.sh
54+
chmod +x install.sh
55+
```
56+
57+
2. Run the script with `sudo` (version can optionally be specified via the `--version` argument):
58+
```bash
59+
sudo ./install.sh
60+
```
61+
62+
3. Start the node:
63+
```bash
64+
era_test_node run
65+
```
66+
67+
### Manually
68+
4969
1. Download `era-test-node` from latest [Release](https://github.com/matter-labs/era-test-node/releases/latest)
5070

5171
2. Extract the binary and mark as executable:
@@ -68,7 +88,7 @@ Please note that `era-test-node` is still in its **alpha** stage. Some features
6888

6989
## 📄 System Contracts
7090

71-
The system contract within the node can be specified via the `--dev-system-contracts` option.
91+
The system contract within the node can be specified via the `--dev-system-contracts` option.
7292
It can take one of the following options:
7393
* `built-in`: Use the compiled built-in contracts
7494
* `built-in-no-verify`: Use the compiled built-in contracts, but without signature verification
@@ -91,7 +111,7 @@ The logging can be configured during runtime via the [`config_setLogLevel`](./SU
91111
## 📃 Caching
92112

93113
The node will cache certain network request by default to disk in the `.cache` directory. Alternatively the caching can be disabled or set to in-memory only
94-
via the `--cache=none|memory|disk` parameter.
114+
via the `--cache=none|memory|disk` parameter.
95115

96116
```bash
97117
era_test_node --cache=none run
@@ -159,7 +179,7 @@ Payer: 0x4eaf936c172b5e5511959167e8ab4f7031113ca3
159179
Gas - Limit: 2_487_330 | Used: 969_330 | Refunded: 1_518_000
160180
Use --show-gas-details flag or call config_setShowGasDetails to display more info
161181

162-
==== Console logs:
182+
==== Console logs:
163183

164184
==== 22 call traces. Use --show-calls flag or call config_setShowCalls to display more info.
165185
Call(Normal) 0x4eaf936c172b5e5511959167e8ab4f7031113ca3 validateTransaction(bytes32, bytes32, tuple) 1830339
@@ -171,16 +191,16 @@ Use --show-gas-details flag or call config_setShowGasDetails to display more inf
171191

172192
You can use the following options to get more granular information during transaction processing:
173193

174-
- `--show-storage-logs <SHOW_STORAGE_LOGS>`: Show storage log information.
175-
[default: none]
194+
- `--show-storage-logs <SHOW_STORAGE_LOGS>`: Show storage log information.
195+
[default: none]
176196
[possible values: none, read, paid, write, all]
177197

178-
- `--show-vm-details <SHOW_VM_DETAILS>`: Show VM details information.
179-
[default: none]
198+
- `--show-vm-details <SHOW_VM_DETAILS>`: Show VM details information.
199+
[default: none]
180200
[possible values: none, all]
181201

182-
- `--show-gas-details <SHOW_GAS_DETAILS>`: Show Gas details information.
183-
[default: none]
202+
- `--show-gas-details <SHOW_GAS_DETAILS>`: Show Gas details information.
203+
[default: none]
184204
[possible values: none, all]
185205

186206
Example:

scripts/install.sh

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
ERA_TEST_NODE_REPO="https://github.com/matter-labs/era-test-node"
6+
7+
function script_usage() {
8+
cat << EOF
9+
Era Test Node Installer v0.1.0
10+
11+
USAGE:
12+
-h | --help Display help information
13+
-v | --version Downloads a specific version of Era Test Node (default: latest release)
14+
-d | --destination The path to the folder where the binary will be installed (default: /usr/local/bin)
15+
EOF
16+
}
17+
18+
function parse_args() {
19+
version=$(get_latest_version)
20+
destination="/usr/local/bin"
21+
22+
while [[ $# -gt 0 ]]; do
23+
arg="$1"
24+
shift
25+
case $arg in
26+
-h | --help)
27+
script_usage
28+
exit 0
29+
;;
30+
-v | --version)
31+
version="$1"
32+
shift
33+
;;
34+
-d | --destination)
35+
destination="$1"
36+
shift
37+
;;
38+
*)
39+
echo "Invalid argument was provided: $arg"
40+
exit 1
41+
;;
42+
esac
43+
done
44+
}
45+
46+
function main() {
47+
parse_args "$@"
48+
49+
echo "Running install script for Era Test Node..."
50+
51+
get_os_info
52+
download_binary
53+
prepare_binary
54+
55+
echo "Era Test Node has been successfully installed!"
56+
}
57+
58+
function prepare_binary() {
59+
echo "Preparing binary..."
60+
61+
tar xz -f "$file_name"
62+
rm "$file_name"
63+
mv era_test_node "$destination/era_test_node"
64+
chmod +x "$destination/era_test_node"
65+
66+
echo "Succesfully prepared binary!"
67+
}
68+
69+
function download_binary() {
70+
file_name="era_test_node-$version-$architecture-$os.tar.gz"
71+
url="$ERA_TEST_NODE_REPO/releases/download/$version/$file_name"
72+
73+
echo "Downloading Era Test Node binary from: $url..."
74+
wget $url
75+
76+
echo "Successfully downloaded Era Test Node Binary!"
77+
}
78+
79+
function get_os_info() {
80+
unamestr="$(uname)"
81+
case "$unamestr" in
82+
"Linux")
83+
os="unknown-linux-gnu"
84+
arch=$(lscpu | awk '/Architecture:/{print $2}')
85+
;;
86+
"Darwin")
87+
os="apple-darwin"
88+
arch=$(arch)
89+
;;
90+
*)
91+
echo "ERROR: Era Test Node only supports Linux and MacOS! Detected OS: $unamestr"
92+
exit 1
93+
;;
94+
esac
95+
96+
case "$arch" in
97+
"x86_64")
98+
architecture="x86_64"
99+
;;
100+
"arm64")
101+
architecture="aarch64"
102+
;;
103+
*)
104+
echo "ERROR: Unsupported architecture detected!"
105+
exit 1
106+
;;
107+
esac
108+
109+
echo "Operating system: $os"
110+
echo "Architecture: $architecture"
111+
}
112+
113+
function get_latest_version() {
114+
echo v$(curl --proto '=https' -sSf https://raw.githubusercontent.com/matter-labs/era-test-node/main/Cargo.toml | \
115+
grep "version" -m 1 | \
116+
awk '{print $3}' | \
117+
sed 's/"//g')
118+
}
119+
120+
main "$@"

0 commit comments

Comments
 (0)