Skip to content

Commit

Permalink
Merge pull request #769 from opentensor/devnet
Browse files Browse the repository at this point in the history
Testnet Deployment 280824
  • Loading branch information
unconst authored Aug 28, 2024
2 parents 1f3851f + aaf9149 commit 97b11de
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 87 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.devcontainer
.github
.vscode
!scripts/init.sh
target
target/
.dockerignore
Dockerfile
33 changes: 13 additions & 20 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,42 @@
name: Publish Docker Image

on:
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
workflow_dispatch:
release:
types: [published]

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

jobs:
publish:
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: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
Expand All @@ -52,4 +45,4 @@ jobs:
tags: |
${{ steps.meta.outputs.tags }}
ghcr.io/${{ github.repository }}:latest
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,12 @@ codegen-units = 1

[features]
default = []
try-runtime = ["node-subtensor/try-runtime", "node-subtensor-runtime/try-runtime"]
runtime-benchmarks = ["node-subtensor/runtime-benchmarks", "node-subtensor-runtime/runtime-benchmarks"]
try-runtime = [
"node-subtensor/try-runtime",
"node-subtensor-runtime/try-runtime",
]
runtime-benchmarks = [
"node-subtensor/runtime-benchmarks",
"node-subtensor-runtime/runtime-benchmarks",
]
metadata-hash = ["node-subtensor-runtime/metadata-hash"]
57 changes: 18 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,65 +1,44 @@

ARG BASE_IMAGE=ubuntu:20.04

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

# This is being set so that no interactive components are allowed when updating.
# 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" \
ai.opentensor.image.description="Opentensor Subtensor Blockchain" \
ai.opentensor.image.revision="${VCS_REF}" \
ai.opentensor.image.created="${BUILD_DATE}" \
ai.opentensor.image.documentation="https://docs.bittensor.com"

# show backtraces
ENV RUST_BACKTRACE 1

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

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

RUN mkdir -p /subtensor && \
mkdir /subtensor/scripts

# Scripts
COPY ./scripts/init.sh /subtensor/scripts/

# Capture dependencies
COPY Cargo.lock Cargo.toml /subtensor/
# Copy entire repository
COPY . /build
WORKDIR /build

# Specs
COPY ./snapshot.json /subtensor/snapshot.json
COPY ./raw_spec_testfinney.json /subtensor/raw_spec_testfinney.json
COPY ./raw_spec_finney.json /subtensor/raw_spec_finney.json
# Build the project
RUN cargo build -p node-subtensor --profile production --features="runtime-benchmarks metadata-hash" --locked

# Copy our sources
COPY ./node /subtensor/node
COPY ./pallets /subtensor/pallets
COPY ./runtime /subtensor/runtime
COPY ./support /subtensor/support
# Verify the binary was produced
RUN test -e /build/target/production/node-subtensor

# Copy our toolchain
COPY rust-toolchain.toml /subtensor/
RUN /subtensor/scripts/init.sh

# Cargo build
WORKDIR /subtensor
RUN cargo build --profile production --features runtime-benchmarks --locked
EXPOSE 30333 9933 9944


FROM $BASE_IMAGE AS subtensor

COPY --from=builder /subtensor/snapshot.json /
COPY --from=builder /subtensor/raw_spec_testfinney.json /
COPY --from=builder /subtensor/raw_spec_finney.json /
COPY --from=builder /subtensor/target/production/node-subtensor /usr/local/bin
# Copy all chainspec files
COPY --from=builder /build/*.json /

# Copy final binary
COPY --from=builder /build/target/production/node-subtensor /usr/local/bin
6 changes: 4 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-commitments/runtime-benchmarks"
"pallet-commitments/runtime-benchmarks",
]
pow-faucet = []

Expand All @@ -103,5 +103,7 @@ try-runtime = [
"frame-system/try-runtime",
"pallet-transaction-payment/try-runtime",
"sp-runtime/try-runtime",
"pallet-commitments/try-runtime"
"pallet-commitments/try-runtime",
]

metadata-hash = ["node-subtensor-runtime/metadata-hash"]
44 changes: 22 additions & 22 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 192,
spec_version: 195,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -1030,27 +1030,27 @@ impl pallet_admin_utils::Config for Runtime {
construct_runtime!(
pub struct Runtime
{
System: frame_system,
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip,
Timestamp: pallet_timestamp,
Aura: pallet_aura,
Grandpa: pallet_grandpa,
Balances: pallet_balances,
TransactionPayment: pallet_transaction_payment,
SubtensorModule: pallet_subtensor,
Triumvirate: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
TriumvirateMembers: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
SenateMembers: pallet_membership::<Instance2>::{Pallet, Call, Storage, Event<T>, Config<T>},
Utility: pallet_utility,
Sudo: pallet_sudo,
Multisig: pallet_multisig,
Preimage: pallet_preimage,
Proxy: pallet_proxy,
Registry: pallet_registry,
Commitments: pallet_commitments,
AdminUtils: pallet_admin_utils,
SafeMode: pallet_safe_mode,
Scheduler: pallet_scheduler,
System: frame_system = 0,
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 1,
Timestamp: pallet_timestamp = 2,
Aura: pallet_aura = 3,
Grandpa: pallet_grandpa = 4,
Balances: pallet_balances = 5,
TransactionPayment: pallet_transaction_payment = 6,
SubtensorModule: pallet_subtensor = 7,
Triumvirate: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 8,
TriumvirateMembers: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 9,
SenateMembers: pallet_membership::<Instance2>::{Pallet, Call, Storage, Event<T>, Config<T>} = 10,
Utility: pallet_utility = 11,
Sudo: pallet_sudo = 12,
Multisig: pallet_multisig = 13,
Preimage: pallet_preimage = 14,
Scheduler: pallet_scheduler = 15,
Proxy: pallet_proxy = 16,
Registry: pallet_registry = 17,
Commitments: pallet_commitments = 18,
AdminUtils: pallet_admin_utils = 19,
SafeMode: pallet_safe_mode = 20,
}
);

Expand Down

0 comments on commit 97b11de

Please sign in to comment.