Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
5a52bfa
publish mac and x86 separately
sam0x17 Mar 12, 2025
10d9843
Merge pull request #1400 from opentensor/devnet
sam0x17 Mar 12, 2025
eaf68ad
test action
Mar 12, 2025
e10602a
remove type
Mar 12, 2025
4b9673b
add `if: github.event.pull_request.merged` + add dependencies steps
Mar 12, 2025
29e931c
I am temporarily commenting on the condition
Mar 12, 2025
4325362
test with small files
Mar 13, 2025
d79a8db
add working-directory
Mar 13, 2025
d61dec0
fix path for dirs
Mar 13, 2025
095909c
add nodes to sdk tests
Mar 13, 2025
6d7c0bd
comment job
Mar 13, 2025
0f93d9c
Merge pull request #1403 from opentensor/feat/roman/test-action-for-n…
basfroman Mar 13, 2025
22c4870
move nodes from ignored folder
Mar 13, 2025
0cd3b1e
update nodes with the same architecture
Mar 13, 2025
2422d43
test save artifacts
Mar 13, 2025
29976d7
simple files artifacts
Mar 13, 2025
554bd92
comment if
Mar 13, 2025
e58d65e
fix bug + comment big logic
Mar 13, 2025
bcf06b4
bump version
Mar 13, 2025
daba1a2
try with real build for both type of blocks
Mar 13, 2025
5496d06
improve runner
Mar 13, 2025
91ddab4
undo runner (should be the same architecture)
Mar 13, 2025
2d9a80c
remove incompatible nodes
Mar 13, 2025
ea6116f
add new
Mar 13, 2025
e346f20
Merge pull request #1404 from opentensor/feat/roman/artifacts
basfroman Mar 13, 2025
66c0e8a
add runtimeAPI for new dyn staking fee
camfairchild Mar 13, 2025
72127ea
use options for netuids
camfairchild Mar 13, 2025
5ceba80
add origin/dest hk and ck
camfairchild Mar 13, 2025
3d3817c
use option for hotkeys
camfairchild Mar 13, 2025
fbe3488
combine origin and dest info
camfairchild Mar 13, 2025
53fa520
add test
camfairchild Mar 13, 2025
0897a2e
calculate staking fee based on everything
camfairchild Mar 13, 2025
ec4ff92
bump spec
camfairchild Mar 13, 2025
5fe2cf5
Merge pull request #1407 from opentensor/feat/dyn-staking-fee-api
sam0x17 Mar 13, 2025
ad43ed6
Merge pull request #1408 from opentensor/feat/new-staking-fee-not-on-…
sam0x17 Mar 13, 2025
3200a1f
Merge branch 'devnet-ready' into devnet-ready-with-nodes
Mar 13, 2025
2dfdf37
use new args
camfairchild Mar 14, 2025
a198d9d
fix test for new args
camfairchild Mar 14, 2025
d24410e
change api test to test passthrough
camfairchild Mar 14, 2025
2b2a02e
add fee calc test
camfairchild Mar 14, 2025
5b659e4
Merge pull request #1410 from opentensor/feat/fix-fee-calc-args-and-test
sam0x17 Mar 14, 2025
1ccef34
Merge branch 'refs/heads/devnet-ready' into devnet-ready-with-nodes
Mar 14, 2025
9899290
add Dockerfile-localnet
Mar 14, 2025
621cedf
remove
Mar 14, 2025
15b64fc
update localnet.sh
Mar 14, 2025
b717c99
Add Dockerfile-localnet
Mar 14, 2025
9ac6678
Add docker-localnet.yml workflow
Mar 14, 2025
fb29517
Update localnet.sh (add RUN_IN_DOCKER local env var)
Mar 14, 2025
d2a0307
del workflow
Mar 14, 2025
7d1371d
update branch
Mar 14, 2025
74b7493
Merge pull request #1411 from opentensor/feat/roman/add-local-node-do…
basfroman Mar 14, 2025
0ef2ac5
fix name
Mar 14, 2025
4c84bc2
Merge pull request #1412 from opentensor/feat/roman/fix-localnet-docker
basfroman Mar 14, 2025
733353b
Merge pull request #1396 from opentensor/fix-docker-again-again
sam0x17 Mar 14, 2025
27f1072
add check localnet workflow
Mar 14, 2025
8f4e3ec
fix
Mar 15, 2025
da7cd72
Merge pull request #1414 from opentensor/feat/roman/fix-localnet-docker
basfroman Mar 15, 2025
67f160b
Merge branch 'devnet-ready' into devnet-ready-with-nodes
Mar 15, 2025
377be73
naming
Mar 15, 2025
f940aeb
branch
Mar 15, 2025
5d8c281
Merge pull request #1415 from opentensor/feat/roman/add-localnet-dock…
sam0x17 Mar 15, 2025
a60153e
tune down logs
JohnReedV Mar 15, 2025
dc2b0eb
Merge pull request #1416 from opentensor/tune-down-logging
JohnReedV Mar 17, 2025
03a64fe
add dissolve sn73 migration
camfairchild Mar 17, 2025
f7e6a4f
disable schedule dissolve
camfairchild Mar 17, 2025
3dd9113
fix clippy
camfairchild Mar 17, 2025
fe6594f
comment out sched dissolve tests
camfairchild Mar 17, 2025
07b2cf3
comment out tests
camfairchild Mar 17, 2025
4c95e60
add test for migration
camfairchild Mar 17, 2025
73a31eb
remove sn owner hotkey
camfairchild Mar 17, 2025
bb75470
add storage removal test
camfairchild Mar 17, 2025
59305bb
clpy
camfairchild Mar 17, 2025
3b61e9b
clear reg allowed maps
camfairchild Mar 17, 2025
3690b93
test clear reg allowed maps
camfairchild Mar 17, 2025
acfddae
set reg allowed maps in test
camfairchild Mar 17, 2025
9eed8c2
cargo fmt
sam0x17 Mar 17, 2025
cf27022
add logging
camfairchild Mar 17, 2025
e2e5ccf
fmt
camfairchild Mar 17, 2025
cefe888
add more logging and write to map
camfairchild Mar 17, 2025
0dc9f2d
use format string for hk logging
camfairchild Mar 17, 2025
c5e0aef
check for new reg before running migration
camfairchild Mar 17, 2025
2b7067a
make sure maps filled
camfairchild Mar 17, 2025
1e40637
add test for other netuid not touched
camfairchild Mar 17, 2025
cbe1912
Merge pull request #1418 from opentensor/feat/sn-73-dissolve-migration
sam0x17 Mar 17, 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
21 changes: 21 additions & 0 deletions .github/workflows/check-docker-localnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Localnet Docker Image

on:
pull_request:

jobs:
build:
runs-on: SubtensorCI

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker Image
run: docker build -f Dockerfile-localnet -t localnet .
69 changes: 69 additions & 0 deletions .github/workflows/docker-localnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish Localnet Docker Image

on:
release:
types: [published]
workflow_dispatch:
inputs:
branch-or-tag:
description: "Branch or tag to use for the Docker image tag and ref to checkout (optional)"
required: false
default: ""
push:
branches:
- devnet-ready

permissions:
contents: read
packages: write
actions: read
security-events: write

jobs:
publish:
runs-on: SubtensorCI

steps:
- name: Determine Docker tag and ref
id: tag
run: |
branch_or_tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
echo "Determined branch or tag: $branch_or_tag"
echo "tag=$branch_or_tag" >> $GITHUB_ENV
echo "ref=$branch_or_tag" >> $GITHUB_ENV

# Check if this is a tagged release (not devnet-ready/devnet/testnet)
if [[ "$branch_or_tag" != "devnet-ready" ]]; then
echo "latest_tag=true" >> $GITHUB_ENV
else
echo "latest_tag=false" >> $GITHUB_ENV
fi

- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.ref }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile-localnet
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}-localnet:${{ env.tag }}
${{ env.latest_tag == 'true' && format('ghcr.io/{0}-localnet:latest', github.repository) || '' }}
50 changes: 48 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ permissions:
security-events: write

jobs:
publish:
publish-x86:
runs-on: SubtensorCI

steps:
Expand Down Expand Up @@ -64,7 +64,53 @@ jobs:
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository }}:${{ env.tag }}
${{ env.latest_tag == 'true' && format('ghcr.io/{0}:latest', github.repository) || '' }}
publish-arm:
runs-on: SubtensorCI

steps:
- name: Determine Docker tag and ref
id: tag
run: |
branch_or_tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
echo "Determined branch or tag: $branch_or_tag"
echo "tag=$branch_or_tag" >> $GITHUB_ENV
echo "ref=$branch_or_tag" >> $GITHUB_ENV

# Check if this is a tagged release (not devnet-ready/devnet/testnet)
if [[ "${{ github.event_name }}" == "release" && "$branch_or_tag" != "devnet-ready" && "$branch_or_tag" != "devnet" && "$branch_or_tag" != "testnet" ]]; then
echo "latest_tag=true" >> $GITHUB_ENV
else
echo "latest_tag=false" >> $GITHUB_ENV
fi

- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ env.ref }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/arm64
tags: |
ghcr.io/${{ github.repository }}:${{ env.tag }}
${{ env.latest_tag == 'true' && format('ghcr.io/{0}:latest', github.repository) || '' }}
65 changes: 65 additions & 0 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ARG BASE_IMAGE=ubuntu:latest

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

# Set noninteractive mode for apt-get
ARG DEBIAN_FRONTEND=noninteractive

LABEL ai.opentensor.image.authors="[email protected]" \
ai.opentensor.image.vendor="Opentensor Foundation" \
ai.opentensor.image.title="opentensor/subtensor-localnet" \
ai.opentensor.image.description="Opentensor Subtensor Blockchain" \
ai.opentensor.image.documentation="https://docs.bittensor.com"

# Set up Rust environment
ENV RUST_BACKTRACE=1

RUN apt-get update
RUN apt-get install -y curl build-essential protobuf-compiler clang git pkg-config libssl-dev llvm libudev-dev

# 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

## Build fast-blocks node
RUN ./scripts/localnet.sh --build-only
# Build non-fast-blocks
RUN ./scripts/localnet.sh False --build-only

# Verify the binaries was produced
RUN test -e /build/target/fast-blocks/release/node-subtensor
RUN test -e /build/target/non-fast-blocks/release/node-subtensor

FROM $BASE_IMAGE AS subtensor-localnet

# Copy binaries
COPY --from=builder /build/target/fast-blocks/release/node-subtensor target/fast-blocks/release/node-subtensor
RUN chmod +x target/fast-blocks/release/node-subtensor

COPY --from=builder /build/target/non-fast-blocks/release/node-subtensor target/non-fast-blocks/release/node-subtensor
RUN chmod +x target/non-fast-blocks/release/node-subtensor

COPY --from=builder /build/snapshot.json /snapshot.json

COPY --from=builder /build/scripts/localnet.sh scripts/localnet.sh
RUN chmod +x /scripts/localnet.sh

## Ubdate certificates
RUN apt-get update && apt-get install -y ca-certificates

# Do not build (just run)
ENV BUILD_BINARY=0
# Switch to local run with IP 0.0.0.0 within docker image
ENV RUN_IN_DOCKER=1
# Expose ports
EXPOSE 30334 30335 9944 9945

ENTRYPOINT ["/scripts/localnet.sh"]
CMD ["True"]
1 change: 1 addition & 0 deletions pallets/subtensor/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sp_api::decl_runtime_apis! {
fn get_stake_info_for_coldkey( coldkey_account: AccountId32 ) -> Vec<StakeInfo<AccountId32>>;
fn get_stake_info_for_coldkeys( coldkey_accounts: Vec<AccountId32> ) -> Vec<(AccountId32, Vec<StakeInfo<AccountId32>>)>;
fn get_stake_info_for_hotkey_coldkey_netuid( hotkey_account: AccountId32, coldkey_account: AccountId32, netuid: u16 ) -> Option<StakeInfo<AccountId32>>;
fn get_stake_fee( origin: Option<(AccountId32, u16)>, origin_coldkey_account: AccountId32, destination: Option<(AccountId32, u16)>, destination_coldkey_account: AccountId32, amount: u64 ) -> u64;
}

pub trait SubnetRegistrationRuntimeApi {
Expand Down
70 changes: 36 additions & 34 deletions pallets/subtensor/src/macros/dispatches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ mod dispatches {
) -> DispatchResultWithPostInfo {
// Ensure it's called with root privileges (scheduler has root privileges)
ensure_root(origin)?;
log::info!("swap_coldkey: {:?} -> {:?}", old_coldkey, new_coldkey);
log::debug!("swap_coldkey: {:?} -> {:?}", old_coldkey, new_coldkey);

Self::do_swap_coldkey(&old_coldkey, &new_coldkey, swap_cost)
}
Expand Down Expand Up @@ -1389,40 +1389,42 @@ mod dispatches {
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(31)), DispatchClass::Operational, Pays::Yes))]
pub fn schedule_dissolve_network(
origin: OriginFor<T>,
netuid: u16,
_origin: OriginFor<T>,
_netuid: u16,
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;

let current_block: BlockNumberFor<T> = <frame_system::Pallet<T>>::block_number();
let duration: BlockNumberFor<T> = DissolveNetworkScheduleDuration::<T>::get();
let when: BlockNumberFor<T> = current_block.saturating_add(duration);

let call = Call::<T>::dissolve_network {
coldkey: who.clone(),
netuid,
};

let bound_call = T::Preimages::bound(LocalCallOf::<T>::from(call.clone()))
.map_err(|_| Error::<T>::FailedToSchedule)?;

T::Scheduler::schedule(
DispatchTime::At(when),
None,
63,
frame_system::RawOrigin::Root.into(),
bound_call,
)
.map_err(|_| Error::<T>::FailedToSchedule)?;

// Emit the SwapScheduled event
Self::deposit_event(Event::DissolveNetworkScheduled {
account: who.clone(),
netuid,
execution_block: when,
});

Ok(().into())
Err(Error::<T>::CallDisabled.into())

// let who = ensure_signed(origin)?;

// let current_block: BlockNumberFor<T> = <frame_system::Pallet<T>>::block_number();
// let duration: BlockNumberFor<T> = DissolveNetworkScheduleDuration::<T>::get();
// let when: BlockNumberFor<T> = current_block.saturating_add(duration);

// let call = Call::<T>::dissolve_network {
// coldkey: who.clone(),
// netuid,
// };

// let bound_call = T::Preimages::bound(LocalCallOf::<T>::from(call.clone()))
// .map_err(|_| Error::<T>::FailedToSchedule)?;

// T::Scheduler::schedule(
// DispatchTime::At(when),
// None,
// 63,
// frame_system::RawOrigin::Root.into(),
// bound_call,
// )
// .map_err(|_| Error::<T>::FailedToSchedule)?;

// // Emit the SwapScheduled event
// Self::deposit_event(Event::DissolveNetworkScheduled {
// account: who.clone(),
// netuid,
// execution_block: when,
// });

// Ok(().into())
}

/// ---- Set prometheus information for the neuron.
Expand Down
2 changes: 2 additions & 0 deletions pallets/subtensor/src/macros/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,7 @@ mod errors {
TransferDisallowed,
/// Activity cutoff is being set too low.
ActivityCutoffTooLow,
/// Call is disabled
CallDisabled,
}
}
4 changes: 3 additions & 1 deletion pallets/subtensor/src/macros/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ mod hooks {
// Remove Stake map entries
.saturating_add(migrations::migrate_remove_stake_map::migrate_remove_stake_map::<T>())
// Remove unused maps entries
.saturating_add(migrations::migrate_remove_unused_maps_and_values::migrate_remove_unused_maps_and_values::<T>());
.saturating_add(migrations::migrate_remove_unused_maps_and_values::migrate_remove_unused_maps_and_values::<T>())
// Migrate dissolve sn73
.saturating_add(migrations::migrate_dissolve_sn73::migrate_dissolve_sn73::<T>());
weight
}

Expand Down
Loading
Loading