Skip to content

Commit 1df522d

Browse files
authored
Merge pull request #1530 from opentensor/devnet
testnet deploy 4/10/2025
2 parents 277ca13 + 5716978 commit 1df522d

File tree

8 files changed

+444
-325
lines changed

8 files changed

+444
-325
lines changed

Diff for: .github/workflows/try-runtime.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99
jobs:
1010
check-devnet:
1111
name: check devnet
12+
if: github.base_ref != 'main'
1213
runs-on: SubtensorCI
1314
steps:
1415
- name: Checkout sources
@@ -29,7 +30,7 @@ jobs:
2930

3031
check-testnet:
3132
name: check testnet
32-
# if: github.base_ref == 'testnet' || github.base_ref == 'devnet' || github.base_ref == 'main'
33+
if: github.base_ref != 'main'
3334
runs-on: SubtensorCI
3435
steps:
3536
- name: Checkout sources

Diff for: Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Dockerfile

+38-24
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,62 @@
1-
ARG BASE_IMAGE=ubuntu:latest
2-
3-
FROM $BASE_IMAGE AS builder
4-
SHELL ["/bin/bash", "-c"]
5-
6-
# Set noninteractive mode for apt-get
7-
ARG DEBIAN_FRONTEND=noninteractive
1+
ARG BASE_IMAGE=rust:1.83
2+
FROM $BASE_IMAGE AS base_builder
83

94
LABEL ai.opentensor.image.authors="operations@opentensor.ai" \
105
ai.opentensor.image.vendor="Opentensor Foundation" \
116
ai.opentensor.image.title="opentensor/subtensor" \
127
ai.opentensor.image.description="Opentensor Subtensor Blockchain" \
138
ai.opentensor.image.documentation="https://docs.bittensor.com"
149

10+
RUN rustup update stable
11+
RUN rustup target add wasm32-unknown-unknown --toolchain stable
12+
13+
1514
# Set up Rust environment
1615
ENV RUST_BACKTRACE=1
17-
RUN apt-get update && \
18-
apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev && \
19-
rm -rf /var/lib/apt/lists/*
16+
RUN apt-get update && apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev
17+
RUN rm -rf /var/lib/apt/lists/*
2018

2119
# Copy entire repository
2220
COPY . /build
2321
WORKDIR /build
2422

25-
# Install Rust
26-
RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y
27-
ENV PATH="/root/.cargo/bin:${PATH}"
28-
RUN rustup toolchain install
29-
RUN rustup target add wasm32-unknown-unknown
30-
23+
#
24+
# Image for building prod
25+
#
26+
FROM base_builder AS prod_builder
3127
# Build the project
3228
RUN cargo build -p node-subtensor --profile production --features="metadata-hash" --locked
33-
34-
# Slim down image
35-
RUN rm -rf /root/.cargo
36-
3729
# Verify the binary was produced
3830
RUN test -e /build/target/production/node-subtensor
39-
4031
EXPOSE 30333 9933 9944
4132

33+
#
34+
# Final prod image
35+
#
4236
FROM $BASE_IMAGE AS subtensor
43-
4437
# Copy all chainspec files
45-
COPY --from=builder /build/chainspecs/*.json /
38+
COPY --from=prod_builder /build/*.json /
39+
# Copy final binary
40+
COPY --from=prod_builder /build/target/production/node-subtensor /usr/local/bin
41+
42+
43+
#
44+
# Image for building local
45+
#
46+
FROM base_builder AS local_builder
47+
# Build the project
48+
RUN cargo build --workspace --profile release --features="pow-faucet"
49+
# Verify the binary was produced
50+
RUN test -e /build/target/release/node-subtensor
51+
EXPOSE 30333 9933 9944
4652

53+
54+
#
55+
# Final local image
56+
#
57+
FROM $BASE_IMAGE AS subtensor-local
58+
# Copy all chainspec files
59+
COPY --from=local_builder /build/*.json /
4760
# Copy final binary
48-
COPY --from=builder /build/target/production/node-subtensor /usr/local/bin
61+
COPY --from=local_builder /build/target/release/node-subtensor /usr/local/bin
62+
RUN "node-subtensor" build-spec --disable-default-bootnode --raw --chain local > /localnet.json

Diff for: docker-compose.localnet.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
volumes:
2+
subtensor-alice:
3+
subtensor-bob:
4+
5+
services:
6+
common: &common
7+
image: ghcr.io/opentensor/subtensor:latest-local
8+
cpu_count: 4
9+
mem_limit: 40000000000
10+
memswap_limit: 80000000000
11+
environment:
12+
- CARGO_HOME=/var/www/node-subtensor/.cargo
13+
14+
alice:
15+
<<: *common
16+
container_name: subtensor-alice
17+
build:
18+
context: .
19+
dockerfile: Dockerfile
20+
target: subtensor-local
21+
ports:
22+
- "9944:9944"
23+
- "30334:30334"
24+
expose:
25+
- 9944
26+
- 30334
27+
volumes:
28+
- subtensor-alice:/tmp/blockchain
29+
command:
30+
- /bin/bash
31+
- -c
32+
- |
33+
node-subtensor \
34+
--base-path /tmp/blockchain \
35+
--chain localnet.json \
36+
--rpc-external \
37+
--rpc-methods=unsafe \
38+
--alice \
39+
--port 30334 \
40+
--rpc-port 9944 \
41+
--validator \
42+
--rpc-cors=all \
43+
--allow-private-ipv4 \
44+
--discover-local \
45+
--unsafe-force-node-key-generation
46+
47+
bob:
48+
<<: *common
49+
container_name: subtensor-bob
50+
expose:
51+
- 9945
52+
- 30335
53+
ports:
54+
- "9945:9945"
55+
- "30335:30335"
56+
volumes:
57+
- subtensor-bob:/tmp/blockchain
58+
command:
59+
- /bin/bash
60+
- -c
61+
- |
62+
node-subtensor \
63+
--base-path /tmp/blockchain \
64+
--chain localnet.json \
65+
--bob \
66+
--rpc-methods=unsafe \
67+
--rpc-external \
68+
--port 30335 \
69+
--rpc-port 9945 \
70+
--validator \
71+
--rpc-cors=all \
72+
--allow-private-ipv4 \
73+
--discover-local \
74+
--unsafe-force-node-key-generation

Diff for: docs/running-subtensor-locally.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
11
# Running subtensor node locally
22

3-
See the [**Subtensor Nodes** section in Bittensor Developer Documentation](https://docs.bittensor.com/subtensor-nodes).
3+
For General information on running Subtensors, see
4+
[**Subtensor Nodes** section in Bittensor Developer Documentation](https://docs.bittensor.com/subtensor-nodes).
5+
6+
### Running a localnet subtensor node
7+
8+
Running a localnet in docker compose is the easiest way to quickly iterate on
9+
chain state, like building on the evm.
10+
11+
1. install docker and docker compose, along with cloning this repository.
12+
13+
1. build the images from source on the desired branch using
14+
`docker compose -f docker-compose.localnet.yml build`. Note this will take
15+
quite a while.
16+
17+
1. Run the docker compose file via
18+
`docker compose -f docker-compose.localnet.yml up -d`
19+
20+
Now you should have a full local validator running. To test your connection, you
21+
can use the following script to check `//Alice`'s balance. Alice is a sudo
22+
account in localnet.
23+
24+
```py
25+
# pip install substrate-interface
26+
from substrateinterface import Keypair, SubstrateInterface
27+
28+
substrate = SubstrateInterface(url="ws://127.0.0.1:9945")
29+
hotkey = Keypair.create_from_uri('//Alice')
30+
result = substrate.query("System", "Account", [hotkey.ss58_address])
31+
print(result.value)
32+
```

Diff for: pallets/subtensor/src/staking/stake_utils.rs

-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ impl<T: Config> Pallet<T> {
6868
Self::get_current_block_as_u64().saturating_sub(start_call_block)
6969
});
7070

71-
// Use halving time hyperparameter. The meaning of this parameter can be best explained under
72-
// the assumption of a constant price and SubnetMovingAlpha == 0.5: It is how many blocks it
73-
// will take in order for the distance between current EMA of price and current price to shorten
74-
// by half.
7571
let halving_time = EMAPriceHalvingBlocks::<T>::get(netuid);
7672
let current_ma_unsigned = U96F32::saturating_from_num(SubnetMovingAlpha::<T>::get());
7773
let alpha: U96F32 = current_ma_unsigned.saturating_mul(blocks_since_start_call.safe_div(

0 commit comments

Comments
 (0)