Skip to content

Commit 5d60be2

Browse files
committed
Merge remote-tracking branch 'origin/main' into sam-always-run-e2e-tests
2 parents a12f938 + de10267 commit 5d60be2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+596
-389
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ members = [
88
resolver = "2"
99

1010
[workspace.lints.clippy]
11+
indexing-slicing = "deny"
12+
arithmetic-side-effects = "deny"
1113
type_complexity = "allow"
14+
unwrap-used = "deny"
1215

1316
[workspace.dependencies]
1417
cargo-husky = { version = "1", default-features = false }

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RUN /subtensor/scripts/init.sh
5252

5353
# Cargo build
5454
WORKDIR /subtensor
55-
RUN cargo build --release --features runtime-benchmarks --locked
55+
RUN cargo build --profile production --features runtime-benchmarks --locked
5656
EXPOSE 30333 9933 9944
5757

5858

@@ -61,4 +61,4 @@ FROM $BASE_IMAGE AS subtensor
6161
COPY --from=builder /subtensor/snapshot.json /
6262
COPY --from=builder /subtensor/raw_spec.json /
6363
COPY --from=builder /subtensor/raw_testspec.json /
64-
COPY --from=builder /subtensor/target/release/node-subtensor /usr/local/bin
64+
COPY --from=builder /subtensor/target/production/node-subtensor /usr/local/bin

docs/running-subtensor-locally.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ rm -rf /tmp/blockchain
162162
Install subtensor by compiling with `cargo`:
163163

164164
```bash
165-
cargo build --release --features=runtime-benchmarks
165+
cargo build --profile production --features=runtime-benchmarks
166166
```
167167

168168
## Run the subtensor node
@@ -174,32 +174,33 @@ You can now run the public subtensor node either as a lite node or as an archive
174174
To run a lite node connected to the mainchain, execute the below command (note the `--sync=warp` flag which runs the subtensor node in lite mode):
175175

176176
```bash title="With --sync=warp setting, for lite node"
177-
./target/release/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=warp --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
177+
./target/production/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
178178
```
179179

180180
### Archive node on mainchain
181181

182182
To run an archive node connected to the mainchain, execute the below command (note the `--sync=full` which syncs the node to the full chain and `--pruning archive` flags, which disables the node's automatic pruning of older historical data):
183183

184184
```bash title="With --sync=full and --pruning archive setting, for archive node"
185-
./target/release/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=full --pruning archive --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
185+
./target/production/node-subtensor --chain raw_spec.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /ip4/13.58.175.193/tcp/30333/p2p/12D3KooWDe7g2JbNETiKypcKT1KsCEZJbTzEHCn8hpd4PHZ6pdz5 --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
186186
```
187187

188188
### Lite node on testchain
189189

190190
To run a lite node connected to the testchain, execute the below command:
191191

192192
```bash title="With bootnodes set to testnet and --sync=warp setting, for lite node."
193-
./target/release/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=warp --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
193+
./target/production/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=warp --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
194194
```
195195

196196
### Archive node on testchain
197197

198198
To run an archive node connected to the testchain, execute the below command:
199199

200200
```bash title="With bootnodes set to testnet and --sync=full and --pruning archive setting, for archive node"
201-
./target/release/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=full --pruning archive --execution wasm --wasm-execution compiled --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
201+
./target/production/node-subtensor --chain raw_testspec.json --base-path /tmp/blockchain --sync=full --pruning archive --port 30333 --max-runtime-instances 32 --rpc-max-response-size 2048 --rpc-cors all --rpc-port 9944 --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr --no-mdns --in-peers 8000 --out-peers 8000 --prometheus-external --rpc-external
202202
```
203203

204204
## Running on cloud
205+
205206
We have not tested these installation scripts on any cloud service. In addition, if you are using Runpod cloud service, then note that this service is already [containerized](https://docs.runpod.io/pods/overview). Hence, the only option available to you is to compile from the source, as described in the above [Method 2: Using Source Code](#method-2-using-source-code) section. Note that these scripts have not been tested on Runpod.

docs/rust-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
title: Installation
33
---
4-
5-
This guide is for reference only, please check the latest information on getting starting with Substrate
4+
This guide is for reference only, please check the latest information on getting starting with Substrate
65
[here](https://docs.substrate.io/main-docs/install/).
76

87
This page will guide you through the **2 steps** needed to prepare a computer for **Substrate** development.
@@ -207,7 +206,7 @@ Use the `WASM_BUILD_TOOLCHAIN` environment variable to specify the Rust nightly
207206
project should use for Wasm compilation:
208207

209208
```bash
210-
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build --release
209+
WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build --profile production
211210
```
212211

213212
> Note that this only builds _the runtime_ with the specified nightly. The rest of project will be
@@ -223,3 +222,4 @@ rustup uninstall nightly
223222
rustup install nightly-<yyyy-MM-dd>
224223
rustup target add wasm32-unknown-unknown --toolchain nightly-<yyyy-MM-dd>
225224
```
225+

justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export RUST_BACKTRACE := "full"
44
export SKIP_WASM_BUILD := "1"
55
export RUST_BIN_DIR := "target/x86_64-unknown-linux-gnu"
66
export TARGET := "x86_64-unknown-linux-gnu"
7-
export RUSTV := "nightly-2024-03-05"
7+
export RUSTV := "stable"
88
export RELEASE_NAME := "development"
99

1010
fmt:
@@ -25,13 +25,13 @@ benchmarks:
2525

2626
clippy:
2727
@echo "Running cargo clippy..."
28-
cargo +{{RUSTV}} clippy -- -D clippy::panic \
28+
cargo +{{RUSTV}} clippy --workspace --all-targets -- -D \
2929
-D clippy::todo \
3030
-D clippy::unimplemented
3131

3232
clippy-fix:
3333
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
34-
cargo +{{RUSTV}} clippy --fix --allow-dirty -- -A clippy::panic \
34+
cargo +{{RUSTV}} clippy --fix --allow-dirty --workspace --all-targets -- -A \
3535
-A clippy::todo \
3636
-A clippy::unimplemented
3737
fix:

node/src/chain_spec/finney.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::*;
55

66
pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
77
let path: PathBuf = std::path::PathBuf::from("./snapshot.json");
8-
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
8+
let wasm_binary = WASM_BINARY.ok_or("Development wasm not available".to_string())?;
99

1010
// We mmap the file into memory first, as this is *a lot* faster than using
1111
// `serde_json::from_reader`. See https://github.com/serde-rs/json/issues/160
@@ -53,7 +53,9 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
5353
let key_account = sp_runtime::AccountId32::from(key);
5454

5555
processed_balances.push((key_account, *amount));
56-
balances_issuance += *amount;
56+
balances_issuance = balances_issuance
57+
.checked_add(*amount)
58+
.ok_or("Balances issuance overflowed".to_string())?;
5759
}
5860

5961
// Give front-ends necessary data to present to users

node/src/chain_spec/testnet.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn finney_testnet_config() -> Result<ChainSpec, String> {
2020
};
2121

2222
let old_state: ColdkeyHotkeys =
23-
json::from_slice(&bytes).map_err(|e| format!("Error parsing genesis file: {}", e))?;
23+
json::from_slice(&bytes).map_err(|e| format!("Error parsing genesis file: {e}"))?;
2424

2525
let mut processed_stakes: Vec<(
2626
sp_runtime::AccountId32,
@@ -53,7 +53,9 @@ pub fn finney_testnet_config() -> Result<ChainSpec, String> {
5353
let key_account = sp_runtime::AccountId32::from(key);
5454

5555
processed_balances.push((key_account, *amount));
56-
balances_issuance += *amount;
56+
balances_issuance = balances_issuance
57+
.checked_add(*amount)
58+
.ok_or("Balances issuance overflowed".to_string())?;
5759
}
5860

5961
// Give front-ends necessary data to present to users
Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
cargo build --release --features runtime-benchmarks
2-
./target/release/node-subtensor benchmark pallet \
3-
--chain=local \
4-
--execution=wasm \
5-
--wasm-execution=compiled \
6-
--pallet=pallet_admin_utils \
7-
--extrinsic="*" \
8-
--steps 50 \
9-
--repeat 20 \
10-
--output=pallets/admin-utils/src/weights.rs \
11-
--template=./.maintain/frame-weight-template.hbs
1+
cargo build --profile production --features runtime-benchmarks
2+
./target/production/node-subtensor benchmark pallet \
3+
--chain=local \
4+
--pallet=pallet_admin_utils \
5+
--extrinsic="*" \
6+
--steps 50 \
7+
--repeat 20 \
8+
--output=pallets/admin-utils/src/weights.rs \
9+
--template=./.maintain/frame-weight-template.hbs

pallets/admin-utils/src/benchmarking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Benchmarking setup
22
#![cfg(feature = "runtime-benchmarks")]
3+
#![allow(clippy::arithmetic_side_effects)]
34
use super::*;
45

56
#[allow(unused)]

pallets/admin-utils/tests/mock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::arithmetic_side_effects, clippy::unwrap_used)]
2+
13
use frame_support::{
24
assert_ok, derive_impl, parameter_types,
35
traits::{Everything, Hooks},

0 commit comments

Comments
 (0)