Skip to content

Commit 94eaeb4

Browse files
authored
Merge pull request #405 from subspace/release-preparation
Release preparation
2 parents faf1b42 + 0ebf7b3 commit 94eaeb4

File tree

6 files changed

+94
-50
lines changed

6 files changed

+94
-50
lines changed

Dockerfile-node

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ FROM ubuntu:20.04
3939

4040
RUN \
4141
apt-get update && \
42-
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates && \
42+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl && \
4343
apt-get clean && \
4444
rm -rf /var/lib/apt/lists/*
4545

46+
HEALTHCHECK CMD curl \
47+
-H "Content-Type: application/json" \
48+
-d '{ "id": 1, "jsonrpc": "2.0", "method": "system_health", "params": [] }' \
49+
-f "http://localhost:9933"
50+
4651
COPY --from=0 /code/subspace-node /subspace-node
4752

4853
RUN mkdir /var/subspace && chown nobody:nogroup /var/subspace

crates/sc-consensus-subspace-rpc/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ where
557557

558558
if let Some(mut sender) = maybe_sender {
559559
if let Err(error) = sender.send(()).await {
560-
warn!("Failed to acknowledge archived segment: {error}");
560+
if !error.is_disconnected() {
561+
warn!("Failed to acknowledge archived segment: {error}");
562+
}
561563
}
562564
}
563565

crates/subspace-farmer/src/archiving.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,17 @@ impl Archiving {
171171
Some(archived_segment) => {
172172
let segment_index = archived_segment.root_block.segment_index();
173173
let (acknowledge_sender, acknowledge_receiver) = oneshot::channel();
174+
// Acknowledge immediately to allow node to continue sync quickly,
175+
// but this will miss some segments in case farmer crashed in the
176+
// meantime. Ideally we'd acknowledge after, but it makes node wait
177+
// for it and the whole process very sequential.
178+
if let Err(error) = client.acknowledge_archived_segment(segment_index).await {
179+
error!("Failed to send archived segment acknowledgement: {error}");
180+
}
174181
if let Err(error) = archived_segments_sync_sender.send((archived_segment, acknowledge_sender)) {
175182
error!("Failed to send archived segment for plotting: {error}");
176183
}
177184
let _ = acknowledge_receiver.await;
178-
if let Err(error) = client.acknowledge_archived_segment(segment_index).await {
179-
error!("Failed to send archived segment acknowledgement: {error}");
180-
}
181185
},
182186
None => {
183187
debug!("Subscription has forcefully closed from node side!");

crates/subspace-farmer/src/bin/subspace-farmer/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ enum Command {
6464
}
6565

6666
fn parse_human_readable_size(s: &str) -> Result<u64, std::num::ParseIntError> {
67-
const SUFFIXES: &[(&str, u64)] = &[("G", 10u64.pow(9)), ("T", 10u64.pow(12))];
67+
const SUFFIXES: &[(&str, u64)] = &[
68+
("G", 10u64.pow(9)),
69+
("GB", 10u64.pow(9)),
70+
("T", 10u64.pow(12)),
71+
("TB", 10u64.pow(12)),
72+
];
6873

6974
SUFFIXES
7075
.iter()

crates/subspace-node/src/bin/subspace-node.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,11 @@ fn main() -> std::result::Result<(), Error> {
268268
primary_chain_node_config,
269269
true,
270270
)
271-
.map_err(|_| {
272-
sc_service::Error::Other("Failed to build a full subspace node".into())
271+
.map_err(|error| {
272+
sc_service::Error::Other(format!(
273+
"Failed to build a full subspace node: {}",
274+
error
275+
))
273276
})?
274277
};
275278

@@ -290,10 +293,11 @@ fn main() -> std::result::Result<(), Error> {
290293
&secondary_chain_cli,
291294
tokio_handle,
292295
)
293-
.map_err(|_| {
294-
sc_service::Error::Other(
295-
"Failed to create secondary chain configuration".into(),
296-
)
296+
.map_err(|error| {
297+
sc_service::Error::Other(format!(
298+
"Failed to create secondary chain configuration: {}",
299+
error
300+
))
297301
})?;
298302

299303
let secondary_chain_full_node_fut = cirrus_node::service::new_full(

docs/farming.md

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ⚠️ Living document
2+
3+
**‼️ NOTE: This is a living document reflecting current state of the codebase, make sure to open this page from the [release you want to install](https://github.com/subspace/subspace/releases) and not directly ‼️**
14

25
# 👨‍🌾 Getting Started Farming
36

@@ -36,12 +39,11 @@ The address of your account will be necessary at the last step.
3639
# Copy all of the lines below, they are all part of the same command
3740
.\NODE_FILE_NAME.exe `
3841
--chain testnet `
39-
--wasm-execution compiled `
40-
--execution wasm `
41-
--bootnodes "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr" `
42+
--execution native `
43+
--unsafe-pruning `
44+
--pruning 1024 `
45+
--keep-blocks 1024 `
4246
--validator `
43-
--telemetry-url "wss://telemetry.polkadot.io/submit/ 1" `
44-
--telemetry-url "wss://telemetry.subspace.network/submit 1" `
4547
--name INSERT_YOUR_ID
4648
```
4749
5. You should see something similar in the terminal:
@@ -71,7 +73,8 @@ The address of your account will be necessary at the last step.
7173
```PowerShell
7274
# Replace `FARMER_FILE_NAME.exe` with the name of the node file you downloaded from releases
7375
# Replace `WALLET_ADDRESS` below with your account address from Polkadot.js wallet
74-
.\FARMER_FILE_NAME.exe farm --reward-address WALLET_ADDRESS
76+
# Replace `PLOT_SIZE` with plot size in gigabytes or terabytes, for instance 100G or 2T (but leave at least 10G of disk space for node)
77+
.\FARMER_FILE_NAME.exe farm --reward-address WALLET_ADDRESS --plot-size PLOT_SIZE
7578
```
7679

7780
## 🐧 Linux Instructions
@@ -87,12 +90,11 @@ The address of your account will be necessary at the last step.
8790
# Copy all of the lines below, they are all part of the same command
8891
./NODE_FILE_NAME \
8992
--chain testnet \
90-
--wasm-execution compiled \
9193
--execution wasm \
92-
--bootnodes "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr" \
94+
--unsafe-pruning \
95+
--pruning 1024 \
96+
--keep-blocks 1024 \
9397
--validator \
94-
--telemetry-url "wss://telemetry.polkadot.io/submit/ 1" \
95-
--telemetry-url "wss://telemetry.subspace.network/submit 1" \
9698
--name INSERT_YOUR_ID
9799
```
98100
5. You should see something similar in the terminal:
@@ -121,7 +123,8 @@ The address of your account will be necessary at the last step.
121123
```bash
122124
# Replace `FARMER_FILE_NAME` with the name of the node file you downloaded from releases
123125
# Replace `WALLET_ADDRESS` below with your account address from Polkadot.js wallet
124-
./FARMER_FILE_NAME farm --reward-address WALLET_ADDRESS
126+
# Replace `PLOT_SIZE` with plot size in gigabytes or terabytes, for instance 100G or 2T (but leave at least 10G of disk space for node)
127+
./FARMER_FILE_NAME farm --reward-address WALLET_ADDRESS --plot-size PLOT_SIZE
125128
```
126129

127130
## 🍎 macOS Instructions
@@ -141,12 +144,11 @@ After this, simply repeat the step you prompted for (step 4 or 6). This time, cl
141144
# Copy all of the lines below, they are all part of the same command
142145
./NODE_FILE_NAME \
143146
--chain testnet \
144-
--wasm-execution compiled \
145147
--execution wasm \
146-
--bootnodes "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr" \
148+
--unsafe-pruning \
149+
--pruning 1024 \
150+
--keep-blocks 1024 \
147151
--validator \
148-
--telemetry-url "wss://telemetry.polkadot.io/submit/ 1" \
149-
--telemetry-url "wss://telemetry.subspace.network/submit 1" \
150152
--name INSERT_YOUR_ID
151153
```
152154
5. You should see something similar in the terminal:
@@ -175,7 +177,8 @@ After this, simply repeat the step you prompted for (step 4 or 6). This time, cl
175177
```bash
176178
# Replace `FARMER_FILE_NAME` with the name of the node file you downloaded from releases
177179
# Replace `WALLET_ADDRESS` below with your account address from Polkadot.js wallet
178-
./FARMER_FILE_NAME farm --reward-address WALLET_ADDRESS
180+
# Replace `PLOT_SIZE` with plot size in gigabytes or terabytes, for instance 100G or 2T (but leave at least 10G of disk space for node)
181+
./FARMER_FILE_NAME farm --reward-address WALLET_ADDRESS --plot-size PLOT_SIZE
179182
```
180183
7. It may prompt again in here. Refer to the note on step 4.
181184

@@ -186,7 +189,7 @@ Create `subspace` directory and `docker-compose.yml` in it with following conten
186189
version: "3.7"
187190
services:
188191
node:
189-
# Replace `snapshot-DATE` with latest release (like `snapshot-2022-mar-09`)
192+
# Replace `snapshot-DATE` with latest release (like `snapshot-2022-apr-29`)
190193
image: ghcr.io/subspace/node:snapshot-DATE
191194
volumes:
192195
# Instead of specifying volume (which will store data in `/var/lib/docker`), you can
@@ -202,24 +205,29 @@ services:
202205
command: [
203206
"--chain", "testnet",
204207
"--base-path", "/var/subspace",
205-
"--wasm-execution", "compiled",
206208
"--execution", "wasm",
207-
"--bootnodes", "/dns/farm-rpc.subspace.network/tcp/30333/p2p/12D3KooWPjMZuSYj35ehced2MTJFf95upwpHKgKUrFRfHwohzJXr",
209+
"--unsafe-pruning",
210+
"--pruning", "1024",
211+
"--keep-blocks", "1024",
208212
"--port", "30333",
209-
"--telemetry-url", "wss://telemetry.polkadot.io/submit/ 1",
210-
"--telemetry-url", "wss://telemetry.subspace.network/submit/ 1",
211213
"--rpc-cors", "all",
212214
"--rpc-methods", "safe",
213215
"--unsafe-ws-external",
214216
"--validator",
215217
# Replace `INSERT_YOUR_ID` with your node ID (will be shown in telemetry)
216218
"--name", "INSERT_YOUR_ID"
217219
]
220+
healthcheck:
221+
timeout: 5s
222+
# If node setup takes longer then expected, you want to increase `interval` and `retries` number.
223+
interval: 30s
224+
retries: 5
218225

219226
farmer:
220227
depends_on:
221-
- node
222-
# Replace `snapshot-DATE` with latest release (like `snapshot-2022-mar-09`)
228+
node:
229+
condition: service_healthy
230+
# Replace `snapshot-DATE` with latest release (like `snapshot-2022-apr-29`)
223231
image: ghcr.io/subspace/farmer:snapshot-DATE
224232
# Un-comment following 2 lines to unlock farmer's RPC
225233
# ports:
@@ -237,7 +245,9 @@ services:
237245
"--node-rpc-url", "ws://node:9944",
238246
"--ws-server-listen-addr", "0.0.0.0:9955",
239247
# Replace `WALLET_ADDRESS` with your Polkadot.js wallet address
240-
"--reward-address", "WALLET_ADDRESS"
248+
"--reward-address", "WALLET_ADDRESS",
249+
# Replace `PLOT_SIZE` with plot size in gigabytes or terabytes, for instance 100G or 2T (but leave at least 10G of disk space for node)
250+
"--plot-size", "PLOT_SIZE"
241251
]
242252
volumes:
243253
node-data:
@@ -246,10 +256,11 @@ volumes:
246256
247257
After which follow these steps:
248258
* Now edit created file:
249-
1. Replace `snapshot-DATE` with the latest release (not pre-release!) snapshot (like `snapshot-2022-mar-09`)
250-
2. Replace `INSERT_YOUR_ID` with desired name that will be shown in telemetry (doesn't impact anything else)
251-
3. Replace `WALLET_ADDRESS` with your wallet address
252-
4. If you want to store files on a separate disk or customize port, read comments in the file
259+
* Replace `snapshot-DATE` with the latest release (not pre-release!) snapshot (like `snapshot-2022-apr-29`)
260+
* Replace `INSERT_YOUR_ID` with desired name that will be shown in telemetry (doesn't impact anything else)
261+
* Replace `WALLET_ADDRESS` with your wallet address
262+
* Replace `PLOT_SIZE` with plot size in gigabytes or terabytes, for instance 100G or 2T (but leave at least 10G of disk space for node)
263+
* If you want to store files on a separate disk or customize port, read comments in the file
253264
* Ensure [Docker](https://www.docker.com/) is installed and running
254265
* Now go to directory with `docker-compose.yml` and type `docker-compose up -d` to start everything
255266

@@ -264,7 +275,6 @@ Visit [Polkadot.js explorer](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ffarm-
264275
## Invalid Solution
265276
If you are getting `invalid solution` errors (visible on the terminal that Node runs), please follow "Switching to a new snapshot" steps below and start afresh.
266277

267-
---
268278
## Switching to a new snapshot
269279

270280
### CLI
@@ -284,18 +294,20 @@ Now follow installation guide.
284294

285295
### Docker
286296

287-
In case of Docker setup run `docker-compose down` (and manually delete custom directories if you have specified them).
297+
In case of Docker setup run `docker-compose down -v` (and manually delete custom directories if you have specified them).
288298

289299
Now follow installation guide.
290300

291301
## Help
292302

293303
There are extra commands and parameters you can use on farmer or node, use the `--help` after any other command to display additional options.
294304

295-
Below are some helpful farmer commands:
305+
Below are some helpful samples:
296306

297-
- `farm --reward-address WALLET_ADDRESS` : starts background plotting and farming together, farmed testnet coins will be sent to `WALLET_ADDRESS`
298-
- `wipe` : erases the plot and identity (including plot, commitment, object mappings and identity files)
307+
- `./FARMER_FILE_NAME farm --custom-path /path/to/data ...` : will store data in `/path/to/data` instead of default location
308+
- `./FARMER_FILE_NAME wipe --custom-path /path/to/data` : erases everything related to farmer if data were stored in `/path/to/data`
309+
- `./NODE_FILE_NAME --base-path /path/to/data --chain testnet ...` : start node and store data in `/path/to/data` instead of default location
310+
- `./NODE_FILE_NAME purge-chain --base-path /path/to/data --chain testnet` : erases data related to the node if data were stored in `/path/to/data`
299311

300312
Examples:
301313
```bash
@@ -304,6 +316,20 @@ Examples:
304316
./FARMER_FILE_NAME wipe
305317
```
306318

319+
## [Advanced] Running an archival node
320+
321+
Instructions above will get you full node (doesn't store the history and state of the whole blockchain, only last 1024
322+
blocks). If you want to opt in to storing the whole history (archival node), remove following parameters (lines) from
323+
above instructions before starting your node:
324+
* `--unsafe-pruning`
325+
* `--pruning 1024`
326+
* `--keep-blocks 1024`
327+
328+
Archival node is useful if you run an RPC node and want to support querying older blockchain history.
329+
330+
NOTE: You can't switch between full and archival node without wiping it, so if you need that, follow steps in
331+
[Switching to a new snapshot](#switching-to-a-new-snapshot) section above.
332+
307333
## [Advanced] Build from source (Linux)
308334

309335
If you're running unsupported Linux distribution or CPU architecture, you may try to build binaries yourself from source.
@@ -316,17 +342,15 @@ You'll have to have [Rust toolchain](https://rustup.rs/) installed as well as LL
316342
sudo apt-get install llvm clang
317343
```
318344

319-
Now clone the source and build snapshot `snapshot-2022-mar-09` (replace occurrences with the snapshot you want to build):
345+
Now clone the source and build snapshot `snapshot-2022-apr-29` (replace occurrences with the snapshot you want to build):
320346
```bash
321347
git clone https://github.com/subspace/subspace.git
322348
cd subspace
323-
git checkout snapshot-2022-mar-09
324-
wget -O chain-spec.json https://github.com/subspace/subspace/releases/download/snapshot-2022-mar-09/chain-spec-raw-snapshot-2022-mar-09.json
349+
git checkout snapshot-2022-apr-29
325350
cargo build \
326351
--profile production \
327352
--bin subspace-node \
328-
--bin subspace-farmer \
329-
--features=subspace-node/json-chain-spec
353+
--bin subspace-farmer
330354
```
331355

332356
You'll find two binaries under `target/production` directory once it succeeds, after which refer to instructions above on how to use them.

0 commit comments

Comments
 (0)