Skip to content

devnet deploy 4/10/2025 #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b048418
feat: macos builds and local testnet
GentikSolm Jan 1, 2025
573f678
fix: docker containers need rpc external mode
GentikSolm Jan 1, 2025
f94c19a
feat: documentation on running a subtensor localnet, and testing it.
GentikSolm Jan 2, 2025
8d5a1ae
fix: build localnet with proper flags
GentikSolm Jan 6, 2025
64af769
Change update_moving_price() function
shamil-gadelshin Apr 2, 2025
9becc64
bump spec version
sam0x17 Apr 4, 2025
ccaa561
don't run try-runtime devnet or testnet on hotfix PRs
sam0x17 Apr 4, 2025
d5dd338
Bump openssl from 0.10.70 to 0.10.72
dependabot[bot] Apr 4, 2025
719a6f5
Merge pull request #1510 from opentensor/ema-hotfix
sam0x17 Apr 4, 2025
34510ba
Deduplicate subnet symbols
gztensor Apr 7, 2025
82c776b
Merge remote-tracking branch 'origin/devnet-ready' into sam-fix-hotfi…
sam0x17 Apr 7, 2025
fb3d0c2
Replace eihwaz with cyr_yeru
gztensor Apr 7, 2025
23c9087
Merge pull request #1515 from opentensor/sam-fix-hotfix-merge-conflic…
sam0x17 Apr 7, 2025
8690ec9
Merge remote-tracking branch 'origin/devnet-ready' into dependabot/ca…
sam0x17 Apr 7, 2025
a809766
Merge pull request #1511 from opentensor/dependabot/cargo/openssl-0.1…
sam0x17 Apr 7, 2025
4bdf627
Merge branch 'devnet-ready' into fix/sn-symbols
gztensor Apr 7, 2025
038a21f
Merge pull request #1514 from opentensor/fix/sn-symbols
sam0x17 Apr 7, 2025
fab9238
Merge branch 'devnet-ready' into devnet-ready
GentikSolm Apr 8, 2025
bfb54ba
fix: dockerfile caseing
GentikSolm Apr 8, 2025
7a38b75
Merge pull request #1122 from GentikSolm/devnet-ready
sam0x17 Apr 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/try-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
jobs:
check-devnet:
name: check devnet
if: github.base_ref != 'main'
runs-on: SubtensorCI
steps:
- name: Checkout sources
Expand All @@ -29,7 +30,7 @@ jobs:

check-testnet:
name: check testnet
# if: github.base_ref == 'testnet' || github.base_ref == 'devnet' || github.base_ref == 'main'
if: github.base_ref != 'main'
runs-on: SubtensorCI
steps:
- name: Checkout sources
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 38 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,62 @@
ARG BASE_IMAGE=ubuntu:latest

FROM $BASE_IMAGE AS builder
SHELL ["/bin/bash", "-c"]

# Set noninteractive mode for apt-get
ARG DEBIAN_FRONTEND=noninteractive
ARG BASE_IMAGE=rust:1.83
FROM $BASE_IMAGE AS base_builder

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

RUN rustup update stable
RUN rustup target add wasm32-unknown-unknown --toolchain stable


# Set up Rust environment
ENV RUST_BACKTRACE=1
RUN apt-get update && \
apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev
RUN rm -rf /var/lib/apt/lists/*

# Copy entire repository
COPY . /build
WORKDIR /build

# Install Rust
RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup toolchain install
RUN rustup target add wasm32-unknown-unknown

#
# Image for building prod
#
FROM base_builder AS prod_builder
# Build the project
RUN cargo build -p node-subtensor --profile production --features="metadata-hash" --locked

# Slim down image
RUN rm -rf /root/.cargo

# Verify the binary was produced
RUN test -e /build/target/production/node-subtensor

EXPOSE 30333 9933 9944

#
# Final prod image
#
FROM $BASE_IMAGE AS subtensor

# Copy all chainspec files
COPY --from=builder /build/chainspecs/*.json /
COPY --from=prod_builder /build/*.json /
# Copy final binary
COPY --from=prod_builder /build/target/production/node-subtensor /usr/local/bin


#
# Image for building local
#
FROM base_builder AS local_builder
# Build the project
RUN cargo build --workspace --profile release --features="pow-faucet"
# Verify the binary was produced
RUN test -e /build/target/release/node-subtensor
EXPOSE 30333 9933 9944


#
# Final local image
#
FROM $BASE_IMAGE AS subtensor-local
# Copy all chainspec files
COPY --from=local_builder /build/*.json /
# Copy final binary
COPY --from=builder /build/target/production/node-subtensor /usr/local/bin
COPY --from=local_builder /build/target/release/node-subtensor /usr/local/bin
RUN "node-subtensor" build-spec --disable-default-bootnode --raw --chain local > /localnet.json
74 changes: 74 additions & 0 deletions docker-compose.localnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
volumes:
subtensor-alice:
subtensor-bob:

services:
common: &common
image: ghcr.io/opentensor/subtensor:latest-local
cpu_count: 4
mem_limit: 40000000000
memswap_limit: 80000000000
environment:
- CARGO_HOME=/var/www/node-subtensor/.cargo

alice:
<<: *common
container_name: subtensor-alice
build:
context: .
dockerfile: Dockerfile
target: subtensor-local
ports:
- "9944:9944"
- "30334:30334"
expose:
- 9944
- 30334
volumes:
- subtensor-alice:/tmp/blockchain
command:
- /bin/bash
- -c
- |
node-subtensor \
--base-path /tmp/blockchain \
--chain localnet.json \
--rpc-external \
--rpc-methods=unsafe \
--alice \
--port 30334 \
--rpc-port 9944 \
--validator \
--rpc-cors=all \
--allow-private-ipv4 \
--discover-local \
--unsafe-force-node-key-generation

bob:
<<: *common
container_name: subtensor-bob
expose:
- 9945
- 30335
ports:
- "9945:9945"
- "30335:30335"
volumes:
- subtensor-bob:/tmp/blockchain
command:
- /bin/bash
- -c
- |
node-subtensor \
--base-path /tmp/blockchain \
--chain localnet.json \
--bob \
--rpc-methods=unsafe \
--rpc-external \
--port 30335 \
--rpc-port 9945 \
--validator \
--rpc-cors=all \
--allow-private-ipv4 \
--discover-local \
--unsafe-force-node-key-generation
31 changes: 30 additions & 1 deletion docs/running-subtensor-locally.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# Running subtensor node locally

See the [**Subtensor Nodes** section in Bittensor Developer Documentation](https://docs.bittensor.com/subtensor-nodes).
For General information on running Subtensors, see
[**Subtensor Nodes** section in Bittensor Developer Documentation](https://docs.bittensor.com/subtensor-nodes).

### Running a localnet subtensor node

Running a localnet in docker compose is the easiest way to quickly iterate on
chain state, like building on the evm.

1. install docker and docker compose, along with cloning this repository.

1. build the images from source on the desired branch using
`docker compose -f docker-compose.localnet.yml build`. Note this will take
quite a while.

1. Run the docker compose file via
`docker compose -f docker-compose.localnet.yml up -d`

Now you should have a full local validator running. To test your connection, you
can use the following script to check `//Alice`'s balance. Alice is a sudo
account in localnet.

```py
# pip install substrate-interface
from substrateinterface import Keypair, SubstrateInterface

substrate = SubstrateInterface(url="ws://127.0.0.1:9945")
hotkey = Keypair.create_from_uri('//Alice')
result = substrate.query("System", "Account", [hotkey.ss58_address])
print(result.value)
```
4 changes: 0 additions & 4 deletions pallets/subtensor/src/staking/stake_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ impl<T: Config> Pallet<T> {
Self::get_current_block_as_u64().saturating_sub(start_call_block)
});

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