Skip to content

Commit 0ce8638

Browse files
committed
Merge branch 'main' into fix/chainspecs
2 parents 15878cb + f62d824 commit 0ce8638

Some content is hidden

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

56 files changed

+562
-302
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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ COPY Cargo.lock Cargo.toml /subtensor/
3838

3939
# Specs
4040
COPY ./snapshot.json /subtensor/snapshot.json
41+
COPY ./raw_spec_testfinney.json /subtensor/raw_spec_testfinney.json
42+
COPY ./raw_spec_finney.json /subtensor/raw_spec_finney.json
4143

4244
# Copy our sources
4345
COPY ./node /subtensor/node
@@ -50,11 +52,13 @@ RUN /subtensor/scripts/init.sh
5052

5153
# Cargo build
5254
WORKDIR /subtensor
53-
RUN cargo build --release --features runtime-benchmarks --locked
55+
RUN cargo build --profile production --features runtime-benchmarks --locked
5456
EXPOSE 30333 9933 9944
5557

5658

5759
FROM $BASE_IMAGE AS subtensor
5860

5961
COPY --from=builder /subtensor/snapshot.json /
60-
COPY --from=builder /subtensor/target/release/node-subtensor /usr/local/bin
62+
COPY --from=builder /subtensor/raw_spec_testfinney.json /
63+
COPY --from=builder /subtensor/raw_spec_finney.json /
64+
COPY --from=builder /subtensor/target/production/node-subtensor /usr/local/bin

docs/running-subtensor-locally.md

Lines changed: 5 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,31 +174,31 @@ 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_finney.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_finney.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_spec_testfinney.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_spec_testfinney.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

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

node/src/command.rs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use sp_runtime::traits::HashingFor;
1717

1818
use node_subtensor_runtime::Block;
1919
use sc_cli::SubstrateCli;
20-
use sc_service::PartialComponents;
20+
use sc_service::{Configuration, PartialComponents};
2121

2222
impl SubstrateCli for Cli {
2323
fn impl_name() -> String {
@@ -209,8 +209,56 @@ pub fn run() -> sc_cli::Result<()> {
209209
None => {
210210
let runner = cli.create_runner(&cli.run)?;
211211
runner.run_node_until_exit(|config| async move {
212+
let config = override_default_heap_pages(config, 60_000);
212213
service::new_full(config).map_err(sc_cli::Error::Service)
213214
})
214215
}
215216
}
216217
}
218+
219+
/// Override default heap pages
220+
fn override_default_heap_pages(config: Configuration, pages: u64) -> Configuration {
221+
Configuration {
222+
default_heap_pages: Some(pages),
223+
impl_name: config.impl_name,
224+
impl_version: config.impl_version,
225+
role: config.role,
226+
tokio_handle: config.tokio_handle,
227+
transaction_pool: config.transaction_pool,
228+
network: config.network,
229+
keystore: config.keystore,
230+
database: config.database,
231+
trie_cache_maximum_size: config.trie_cache_maximum_size,
232+
state_pruning: config.state_pruning,
233+
blocks_pruning: config.blocks_pruning,
234+
chain_spec: config.chain_spec,
235+
wasm_method: config.wasm_method,
236+
wasm_runtime_overrides: config.wasm_runtime_overrides,
237+
rpc_addr: config.rpc_addr,
238+
rpc_max_connections: config.rpc_max_connections,
239+
rpc_cors: config.rpc_cors,
240+
rpc_methods: config.rpc_methods,
241+
rpc_max_request_size: config.rpc_max_request_size,
242+
rpc_max_response_size: config.rpc_max_response_size,
243+
rpc_id_provider: config.rpc_id_provider,
244+
rpc_max_subs_per_conn: config.rpc_max_subs_per_conn,
245+
rpc_port: config.rpc_port,
246+
rpc_message_buffer_capacity: config.rpc_message_buffer_capacity,
247+
rpc_batch_config: config.rpc_batch_config,
248+
rpc_rate_limit: config.rpc_rate_limit,
249+
prometheus_config: config.prometheus_config,
250+
telemetry_endpoints: config.telemetry_endpoints,
251+
offchain_worker: config.offchain_worker,
252+
force_authoring: config.force_authoring,
253+
disable_grandpa: config.disable_grandpa,
254+
dev_key_seed: config.dev_key_seed,
255+
tracing_targets: config.tracing_targets,
256+
tracing_receiver: config.tracing_receiver,
257+
max_runtime_instances: config.max_runtime_instances,
258+
announce_block: config.announce_block,
259+
data_path: config.data_path,
260+
base_path: config.base_path,
261+
informant_output_format: config.informant_output_format,
262+
runtime_cache_size: config.runtime_cache_size,
263+
}
264+
}
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)]

0 commit comments

Comments
 (0)