Skip to content

Commit c04c841

Browse files
committed
Merge branch 'devnet-ready' into cargo-audit
2 parents 7081d6d + fe5f5aa commit c04c841

File tree

29 files changed

+1338
-226
lines changed

29 files changed

+1338
-226
lines changed

.dockerignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.devcontainer
22
.github
33
.vscode
4-
!scripts/init.sh
5-
target
4+
target/
5+
.dockerignore
6+
Dockerfile

.github/workflows/check-rust.yml

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -295,57 +295,8 @@ jobs:
295295
with:
296296
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}
297297

298-
- name: cargo test --workspace
299-
run: cargo test --workspace
300-
301-
# runs cargo test --workspace --features=runtime-benchmarks
302-
cargo-test-benchmarks:
303-
name: cargo test w/benchmarks
304-
runs-on: SubtensorCI
305-
strategy:
306-
matrix:
307-
rust-branch:
308-
- stable
309-
rust-target:
310-
- x86_64-unknown-linux-gnu
311-
# - x86_64-apple-darwin
312-
os:
313-
- ubuntu-latest
314-
# - macos-latest
315-
include:
316-
- os: ubuntu-latest
317-
# - os: macos-latest
318-
env:
319-
RELEASE_NAME: development
320-
# RUSTFLAGS: -A warnings
321-
RUSTV: ${{ matrix.rust-branch }}
322-
RUST_BACKTRACE: full
323-
RUST_BIN_DIR: target/${{ matrix.rust-target }}
324-
SKIP_WASM_BUILD: 1
325-
TARGET: ${{ matrix.rust-target }}
326-
steps:
327-
- name: Check-out repository under $GITHUB_WORKSPACE
328-
uses: actions/checkout@v4
329-
330-
- name: Install dependencies
331-
run: |
332-
sudo apt-get update &&
333-
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
334-
335-
- name: Install Rust ${{ matrix.rust-branch }}
336-
uses: actions-rs/[email protected]
337-
with:
338-
toolchain: ${{ matrix.rust-branch }}
339-
components: rustfmt, clippy
340-
profile: minimal
341-
342-
- name: Utilize Rust shared cached
343-
uses: Swatinem/[email protected]
344-
with:
345-
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}
346-
347-
- name: cargo test --workspace --features=runtime-benchmarks
348-
run: cargo test --workspace --features=runtime-benchmarks
298+
- name: cargo test --workspace --all-features
299+
run: cargo test --workspace --all-features
349300

350301
# ensures cargo fix has no trivial changes that can be applied
351302
cargo-fix:

.github/workflows/docker.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,42 @@
11
name: Publish Docker Image
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
tags:
8-
- '*'
9-
pull_request:
10-
branches:
11-
- main
12-
workflow_dispatch:
4+
release:
5+
types: [published]
136

147
permissions:
15-
contents: read
16-
packages: write
17-
actions: read
18-
security-events: write
8+
contents: read
9+
packages: write
10+
actions: read
11+
security-events: write
1912

2013
jobs:
2114
publish:
2215
runs-on: SubtensorCI
23-
16+
2417
steps:
2518
- name: Checkout code
2619
uses: actions/checkout@v4
27-
20+
2821
- name: Set up QEMU
2922
uses: docker/setup-qemu-action@v2
30-
23+
3124
- name: Set up Docker Buildx
3225
uses: docker/setup-buildx-action@v2
33-
26+
3427
- name: Login to GHCR
3528
uses: docker/login-action@v2
3629
with:
3730
registry: ghcr.io
3831
username: ${{ github.actor }}
3932
password: ${{ secrets.GITHUB_TOKEN }}
40-
33+
4134
- name: Extract metadata (tags, labels) for Docker
4235
id: meta
4336
uses: docker/metadata-action@v4
4437
with:
4538
images: ghcr.io/${{ github.repository }}
46-
39+
4740
- name: Build and push Docker image
4841
uses: docker/build-push-action@v4
4942
with:
@@ -52,4 +45,4 @@ jobs:
5245
tags: |
5346
${{ steps.meta.outputs.tags }}
5447
ghcr.io/${{ github.repository }}:latest
55-
labels: ${{ steps.meta.outputs.labels }}
48+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
**/*.lock
88

9+
*.ipynb
10+
911
# Generated by code coverage
1012
*.profraw
1113
*.profdata

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ repository = "https://github.com/opentensor/subtensor"
1111

1212
[dependencies]
1313
node-subtensor = { path = "node", version = "4.0.0-dev" }
14-
pallet-commitments = { path = "pallets/commitments", version = "4.0.0-dev" }
15-
pallet-subtensor = { path = "pallets/subtensor", version = "4.0.0-dev" }
1614
node-subtensor-runtime = { path = "runtime", version = "4.0.0-dev" }
17-
subtensor-macros = { path = "support/macros", version = "0.1.0" }
1815

1916
[build-dependencies]
2017
subtensor-linting = { path = "support/linting", version = "0.1.0" }
@@ -167,3 +164,15 @@ opt-level = 3
167164
inherits = "release"
168165
lto = true
169166
codegen-units = 1
167+
168+
[features]
169+
default = []
170+
try-runtime = [
171+
"node-subtensor/try-runtime",
172+
"node-subtensor-runtime/try-runtime",
173+
]
174+
runtime-benchmarks = [
175+
"node-subtensor/runtime-benchmarks",
176+
"node-subtensor-runtime/runtime-benchmarks",
177+
]
178+
metadata-hash = ["node-subtensor-runtime/metadata-hash"]

Dockerfile

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,44 @@
1-
21
ARG BASE_IMAGE=ubuntu:20.04
32

4-
FROM $BASE_IMAGE as builder
3+
FROM $BASE_IMAGE AS builder
54
SHELL ["/bin/bash", "-c"]
65

7-
# This is being set so that no interactive components are allowed when updating.
6+
# Set noninteractive mode for apt-get
87
ARG DEBIAN_FRONTEND=noninteractive
98

109
LABEL ai.opentensor.image.authors="[email protected]" \
1110
ai.opentensor.image.vendor="Opentensor Foundation" \
1211
ai.opentensor.image.title="opentensor/subtensor" \
1312
ai.opentensor.image.description="Opentensor Subtensor Blockchain" \
14-
ai.opentensor.image.revision="${VCS_REF}" \
15-
ai.opentensor.image.created="${BUILD_DATE}" \
1613
ai.opentensor.image.documentation="https://docs.bittensor.com"
1714

18-
# show backtraces
19-
ENV RUST_BACKTRACE 1
20-
21-
# Necessary libraries for Rust execution
15+
# Set up Rust environment
16+
ENV RUST_BACKTRACE=1
2217
RUN apt-get update && \
2318
apt-get install -y curl build-essential protobuf-compiler clang git && \
2419
rm -rf /var/lib/apt/lists/*
2520

26-
# Install cargo and Rust
2721
RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y
2822
ENV PATH="/root/.cargo/bin:${PATH}"
23+
RUN rustup update stable
24+
RUN rustup target add wasm32-unknown-unknown --toolchain stable
2925

30-
RUN mkdir -p /subtensor && \
31-
mkdir /subtensor/scripts
32-
33-
# Scripts
34-
COPY ./scripts/init.sh /subtensor/scripts/
35-
36-
# Capture dependencies
37-
COPY Cargo.lock Cargo.toml /subtensor/
26+
# Copy entire repository
27+
COPY . /build
28+
WORKDIR /build
3829

39-
# Specs
40-
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
30+
# Build the project
31+
RUN cargo build -p node-subtensor --profile production --features="runtime-benchmarks metadata-hash" --locked
4332

44-
# Copy our sources
45-
COPY ./node /subtensor/node
46-
COPY ./pallets /subtensor/pallets
47-
COPY ./runtime /subtensor/runtime
48-
COPY ./support /subtensor/support
33+
# Verify the binary was produced
34+
RUN test -e /build/target/production/node-subtensor
4935

50-
# Copy our toolchain
51-
COPY rust-toolchain.toml /subtensor/
52-
RUN /subtensor/scripts/init.sh
53-
54-
# Cargo build
55-
WORKDIR /subtensor
56-
RUN cargo build --profile production --features runtime-benchmarks --locked
5736
EXPOSE 30333 9933 9944
5837

59-
6038
FROM $BASE_IMAGE AS subtensor
6139

62-
COPY --from=builder /subtensor/snapshot.json /
63-
COPY --from=builder /subtensor/raw_spec_testfinney.json /
64-
COPY --from=builder /subtensor/raw_spec_finney.json /
65-
COPY --from=builder /subtensor/target/production/node-subtensor /usr/local/bin
40+
# Copy all chainspec files
41+
COPY --from=builder /build/*.json /
42+
43+
# Copy final binary
44+
COPY --from=builder /build/target/production/node-subtensor /usr/local/bin

docs/delegate-info.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,5 +390,19 @@
390390
"url": "https://cortex.foundation/",
391391
"description": "Cortex Foundation is committed to advancing the integration of decentralized AI. Our validator is designed for transparency, reliability, and community engagement.",
392392
"signature": "7a6274ff6b0f7ddca97e37ef4a9b90781012ff3cf7baa3159f6feaafc43c557975aad324ea608d6b8abeb21f8f3ca2595e54b81a7564574d0242b803d969618a"
393+
},
394+
{
395+
"address":"5F27Eqz2PhyMtGMEce898x31DokNqRVxkm5AhDDe6rDGNvoY",
396+
"name": "Love",
397+
"url": "https://love.cosimo.fund",
398+
"description": "Love validator exists to accelerate open source AI and be good stewards of the Bittensorr network",
399+
"signature": "c221a3de3be031c149a7be912b3b75e0355605f041dc975153302b23b4d93e45e9cc7453532491e92076ccd333a4c1f95f4a2229aae8f4fcfb88e5dec3f14c87"
400+
},
401+
{
402+
"address": "5Hb63SvXBXqZ8zw6mwW1A39fHdqUrJvohXgepyhp2jgWedSB",
403+
"name": "TAO Miner's Union",
404+
"url": "https://minersunion.ai",
405+
"description": "The first Bittensor validator that empowers you to choose which subnets to incentivize. Committed to transparency and integrity, we ensure fair and honest validation processes that contribute to the growth and strength of the network.",
406+
"signature": "e8c68bc766a06f36c633e1f68d5aca4c4090a26e394372f64d5b00cc13621f361ec9df85fc9f0d247dbc1fe452bd53ffc0224dee2bc85c9d82cb250e4ac10984"
393407
}
394408
]

node/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ runtime-benchmarks = [
9292
"frame-system/runtime-benchmarks",
9393
"sc-service/runtime-benchmarks",
9494
"sp-runtime/runtime-benchmarks",
95-
"pallet-commitments/runtime-benchmarks"
95+
"pallet-commitments/runtime-benchmarks",
9696
]
9797
pow-faucet = []
9898

@@ -103,5 +103,7 @@ try-runtime = [
103103
"frame-system/try-runtime",
104104
"pallet-transaction-payment/try-runtime",
105105
"sp-runtime/try-runtime",
106-
"pallet-commitments/try-runtime"
106+
"pallet-commitments/try-runtime",
107107
]
108+
109+
metadata-hash = ["node-subtensor-runtime/metadata-hash"]

pallets/admin-utils/src/lib.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub use pallet::*;
44
pub mod weights;
55
pub use weights::WeightInfo;
66

7+
use frame_system::pallet_prelude::BlockNumberFor;
78
use sp_runtime::{traits::Member, RuntimeAppPublic};
89

910
mod benchmarking;
@@ -1128,6 +1129,73 @@ pub mod pallet {
11281129

11291130
Ok(())
11301131
}
1132+
1133+
/// Sets the duration of the coldkey swap schedule.
1134+
///
1135+
/// This extrinsic allows the root account to set the duration for the coldkey swap schedule.
1136+
/// The coldkey swap schedule determines how long it takes for a coldkey swap operation to complete.
1137+
///
1138+
/// # Arguments
1139+
/// * `origin` - The origin of the call, which must be the root account.
1140+
/// * `duration` - The new duration for the coldkey swap schedule, in number of blocks.
1141+
///
1142+
/// # Errors
1143+
/// * `BadOrigin` - If the caller is not the root account.
1144+
///
1145+
/// # Weight
1146+
/// Weight is handled by the `#[pallet::weight]` attribute.
1147+
#[pallet::call_index(54)]
1148+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1149+
pub fn sudo_set_coldkey_swap_schedule_duration(
1150+
origin: OriginFor<T>,
1151+
duration: BlockNumberFor<T>,
1152+
) -> DispatchResult {
1153+
// Ensure the call is made by the root account
1154+
ensure_root(origin)?;
1155+
1156+
// Set the new duration of schedule coldkey swap
1157+
pallet_subtensor::Pallet::<T>::set_coldkey_swap_schedule_duration(duration);
1158+
1159+
// Log the change
1160+
log::trace!("ColdkeySwapScheduleDurationSet( duration: {:?} )", duration);
1161+
1162+
Ok(())
1163+
}
1164+
1165+
/// Sets the duration of the dissolve network schedule.
1166+
///
1167+
/// This extrinsic allows the root account to set the duration for the dissolve network schedule.
1168+
/// The dissolve network schedule determines how long it takes for a network dissolution operation to complete.
1169+
///
1170+
/// # Arguments
1171+
/// * `origin` - The origin of the call, which must be the root account.
1172+
/// * `duration` - The new duration for the dissolve network schedule, in number of blocks.
1173+
///
1174+
/// # Errors
1175+
/// * `BadOrigin` - If the caller is not the root account.
1176+
///
1177+
/// # Weight
1178+
/// Weight is handled by the `#[pallet::weight]` attribute.
1179+
#[pallet::call_index(55)]
1180+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1181+
pub fn sudo_set_dissolve_network_schedule_duration(
1182+
origin: OriginFor<T>,
1183+
duration: BlockNumberFor<T>,
1184+
) -> DispatchResult {
1185+
// Ensure the call is made by the root account
1186+
ensure_root(origin)?;
1187+
1188+
// Set the duration of schedule dissolve network
1189+
pallet_subtensor::Pallet::<T>::set_dissolve_network_schedule_duration(duration);
1190+
1191+
// Log the change
1192+
log::trace!(
1193+
"DissolveNetworkScheduleDurationSet( duration: {:?} )",
1194+
duration
1195+
);
1196+
1197+
Ok(())
1198+
}
11311199
}
11321200
}
11331201

0 commit comments

Comments
 (0)