From 435d15ccc9b243ff11d4a31dd103fdbfac3e7efd Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 28 Aug 2024 10:41:36 +0200 Subject: [PATCH 1/4] fix and explicitly set pallet indicies --- runtime/src/lib.rs | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 4229544762..8cffeadad7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -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::::{Pallet, Call, Storage, Origin, Event, Config}, - TriumvirateMembers: pallet_membership::::{Pallet, Call, Storage, Event, Config}, - SenateMembers: pallet_membership::::{Pallet, Call, Storage, Event, Config}, - 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::::{Pallet, Call, Storage, Origin, Event, Config} = 8, + TriumvirateMembers: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 9, + SenateMembers: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 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, } ); From 9ddc2eb339f81d2fbaad41444e48d3b9c39de0b8 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 28 Aug 2024 14:28:27 +0200 Subject: [PATCH 2/4] bump spec version --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 8cffeadad7..ca8f839114 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -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: 194, + spec_version: 195, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From bc15020bcb3ad2444d1d97ce24692caee81617b4 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Wed, 28 Aug 2024 13:18:10 -0400 Subject: [PATCH 3/4] completely revamp Dockerfile to be better :O --- .dockerignore | 5 +++-- Dockerfile | 51 +++++++++++++++++---------------------------------- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/.dockerignore b/.dockerignore index 6b7ebf6483..2886a059a9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ .devcontainer .github .vscode -!scripts/init.sh -target \ No newline at end of file +target/ +.dockerignore +Dockerfile diff --git a/Dockerfile b/Dockerfile index 2fc6cbcc6c..e4bc5e9ee7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ - ARG BASE_IMAGE=ubuntu:20.04 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="operations@opentensor.ai" \ @@ -15,51 +14,35 @@ LABEL ai.opentensor.image.authors="operations@opentensor.ai" \ ai.opentensor.image.created="${BUILD_DATE}" \ ai.opentensor.image.documentation="https://docs.bittensor.com" -# show backtraces +# Set up Rust environment ENV RUST_BACKTRACE 1 - -# Necessary libraries for Rust execution 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 mkdir -p /subtensor && \ - mkdir /subtensor/scripts - -# Scripts -COPY ./scripts/init.sh /subtensor/scripts/ +RUN rustup update nightly +RUN rustup update stable +RUN rustup target add wasm32-unknown-unknown --toolchain nightly -# 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 --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 From bb932e24c4d5f8f465b614f59d863a821ead3d1a Mon Sep 17 00:00:00 2001 From: Samuel Dare Date: Wed, 28 Aug 2024 22:30:20 +0400 Subject: [PATCH 4/4] chore: add metadatahash, build images only on publish tags --- .github/workflows/docker.yml | 33 +++++++++++++-------------------- Cargo.toml | 11 +++++++++-- Dockerfile | 12 ++++-------- node/Cargo.toml | 6 ++++-- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 19bda74639..72e3f1b129 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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: @@ -52,4 +45,4 @@ jobs: tags: | ${{ steps.meta.outputs.tags }} ghcr.io/${{ github.repository }}:latest - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} diff --git a/Cargo.toml b/Cargo.toml index e3c2814ffc..f9a7968b90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] diff --git a/Dockerfile b/Dockerfile index e4bc5e9ee7..2dd2e23700 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG BASE_IMAGE=ubuntu:20.04 -FROM $BASE_IMAGE as builder +FROM $BASE_IMAGE AS builder SHELL ["/bin/bash", "-c"] # Set noninteractive mode for apt-get @@ -10,29 +10,25 @@ 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.revision="${VCS_REF}" \ - ai.opentensor.image.created="${BUILD_DATE}" \ ai.opentensor.image.documentation="https://docs.bittensor.com" # Set up Rust environment -ENV RUST_BACKTRACE 1 +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/* RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" - -RUN rustup update nightly RUN rustup update stable -RUN rustup target add wasm32-unknown-unknown --toolchain nightly +RUN rustup target add wasm32-unknown-unknown --toolchain stable # Copy entire repository COPY . /build WORKDIR /build # Build the project -RUN cargo build -p node-subtensor --profile production --features runtime-benchmarks --locked +RUN cargo build -p node-subtensor --profile production --features="runtime-benchmarks metadata-hash" --locked # Verify the binary was produced RUN test -e /build/target/production/node-subtensor diff --git a/node/Cargo.toml b/node/Cargo.toml index 0e1a418a32..3c5c91b927 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -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 = [] @@ -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"]