Skip to content

Commit

Permalink
Merge branch 'main' into emergency
Browse files Browse the repository at this point in the history
  • Loading branch information
distributedstatemachine committed Jul 4, 2024
2 parents 471e937 + 1934f33 commit 4e68a5b
Show file tree
Hide file tree
Showing 77 changed files with 110,299 additions and 258,529 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/check-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ jobs:
echo "network spec_version: $spec_version"
if (( $(echo "$local_spec_version <= $spec_version" | bc -l) )); then echo "$local_spec_version ≯ $spec_version ❌"; exit 1; fi
echo "$local_spec_version > $spec_version ✅"
check-devnet-migrations:
name: check devnet migrations
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Run Try Runtime Checks
uses: "paritytech/try-runtime-gha@v0.1.0"
with:
runtime-package: "node-subtensor-runtime"
node-uri: "wss://dev.chain.opentensor.ai:443"
checks: "pre-and-post"
extra-args: "--disable-spec-version-check --no-weight-warnings"
16 changes: 15 additions & 1 deletion .github/workflows/check-finney.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Finney Deploy Check

on:
pull_request:
branches: [finney]
branches: [finney, main]

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -37,3 +37,17 @@ jobs:
echo "network spec_version: $spec_version"
if (( $(echo "$local_spec_version <= $spec_version" | bc -l) )); then echo "$local_spec_version ≯ $spec_version ❌"; exit 1; fi
echo "$local_spec_version > $spec_version ✅"
check-finney-migrations:
name: check finney migrations
runs-on: SubtensorCI
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Run Try Runtime Checks
uses: "paritytech/try-runtime-gha@v0.1.0"
with:
runtime-package: "node-subtensor-runtime"
node-uri: "wss://entrypoint-finney.opentensor.ai:443"
checks: "pre-and-post"
extra-args: "--disable-spec-version-check --no-weight-warnings"
41 changes: 0 additions & 41 deletions .github/workflows/check-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,47 +339,6 @@ jobs:
- name: Check features
run: zepter run check

check-finney-migrations:
name: check finney migrations
runs-on: SubtensorCI
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Run Try Runtime Checks
uses: "paritytech/try-runtime-gha@v0.1.0"
with:
runtime-package: "node-subtensor-runtime"
node-uri: "wss://entrypoint-finney.opentensor.ai:443"
checks: "pre-and-post"
extra-args: "--disable-spec-version-check --no-weight-warnings"

check-devnet-migrations:
name: check devnet migrations
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Run Try Runtime Checks
uses: "paritytech/try-runtime-gha@v0.1.0"
with:
runtime-package: "node-subtensor-runtime"
node-uri: "wss://dev.chain.opentensor.ai:443"
checks: "pre-and-post"
extra-args: "--disable-spec-version-check --no-weight-warnings"

check-testnet-migrations:
name: check testnet migrations
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Run Try Runtime Checks
uses: "paritytech/try-runtime-gha@v0.1.0"
with:
runtime-package: "node-subtensor-runtime"
node-uri: "wss://test.chain.opentensor.ai:443"
checks: "pre-and-post"
extra-args: "--disable-spec-version-check --no-weight-warnings"
15 changes: 15 additions & 0 deletions .github/workflows/check-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,18 @@ jobs:
echo "network spec_version: $spec_version"
if (( $(echo "$local_spec_version <= $spec_version" | bc -l) )); then echo "$local_spec_version ≯ $spec_version ❌"; exit 1; fi
echo "$local_spec_version > $spec_version ✅"
check-testnet-migrations:
name: check testnet migrations
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Run Try Runtime Checks
uses: "paritytech/try-runtime-gha@v0.1.0"
with:
runtime-package: "node-subtensor-runtime"
node-uri: "wss://test.chain.opentensor.ai:443"
checks: "pre-and-post"
extra-args: "--disable-spec-version-check --no-weight-warnings"
71 changes: 71 additions & 0 deletions .github/workflows/update-chainspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Update Chainspecs

concurrency:
group: update-chainspec-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches: [main, testnet, staging, staging-ready]

workflow_dispatch:
inputs:
verbose:
description: "Output more information when triggered manually"
required: false
default: ""

env:
CARGO_TERM_COLOR: always
VERBOSE: ${{ github.events.input.verbose }}

jobs:
update-chainspecs:
runs-on: SubtensorCI
permissions:
contents: write

strategy:
matrix:
rust-branch:
- nightly-2024-03-05
rust-target:
- x86_64-unknown-linux-gnu
os:
- ubuntu-latest
include:
- os: ubuntu-latest
env:
RELEASE_NAME: development
RUSTV: ${{ matrix.rust-branch }}
RUST_BACKTRACE: full
RUST_BIN_DIR: target/${{ matrix.rust-target }}
TARGET: ${{ matrix.rust-target }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
- name: Install Rust ${{ matrix.rust-branch }}
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: ${{ matrix.rust-branch }}
components: rustfmt, clippy
profile: minimal

- name: Utilize Shared Rust Cache
uses: Swatinem/rust-cache@v2.2.1
with:
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}

- name: Build chainspecs
run: ./scripts/build_all_chainspecs.sh

- uses: stefanzweifel/git-auto-commit-action@v5
name: Commit any updated chainspecs
with:
commit_message: Update chainspecs
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ specs/*.json
.idea

# Runtime upgrade snapshot
bt.snap
bt.snap

# localnet spec
scripts/specs/local.json
2 changes: 2 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ members = [
resolver = "2"

[workspace.lints.clippy]
indexing-slicing = "deny"
arithmetic-side-effects = "deny"
type_complexity = "allow"
unwrap-used = "deny"

[workspace.dependencies]
cargo-husky = { version = "1", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ COPY Cargo.lock Cargo.toml /subtensor/

# Specs
COPY ./snapshot.json /subtensor/snapshot.json
COPY ./raw_spec.json /subtensor/raw_spec.json
COPY ./raw_testspec.json /subtensor/raw_testspec.json
COPY ./raw_spec_testfinney.json /subtensor/raw_spec_testfinney.json
COPY ./raw_spec_finney.json /subtensor/raw_spec_finney.json

# Copy our sources
COPY ./node /subtensor/node
Expand All @@ -59,6 +59,6 @@ EXPOSE 30333 9933 9944
FROM $BASE_IMAGE AS subtensor

COPY --from=builder /subtensor/snapshot.json /
COPY --from=builder /subtensor/raw_spec.json /
COPY --from=builder /subtensor/raw_testspec.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
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
version: "3.8"

volumes:
mainnet-lite-volume:
Expand Down Expand Up @@ -38,7 +38,7 @@ services:
- |
node-subtensor \
--base-path /tmp/blockchain \
--chain raw_spec.json \
--chain raw_spec_finney.json \
--rpc-external --rpc-cors all \
--no-mdns \
--in-peers 500 --out-peers 500 \
Expand All @@ -56,7 +56,7 @@ services:
- |
node-subtensor \
--base-path /tmp/blockchain \
--chain raw_spec.json \
--chain raw_spec_finney.json \
--rpc-external --rpc-cors all \
--no-mdns \
--in-peers 500 --out-peers 500 \
Expand All @@ -74,7 +74,7 @@ services:
- |
node-subtensor \
--base-path /tmp/blockchain \
--chain raw_testspec.json \
--chain raw_spec_testfinney.json \
--rpc-external --rpc-cors all \
--no-mdns \
--in-peers 500 --out-peers 500 \
Expand All @@ -94,7 +94,7 @@ services:
- |
node-subtensor \
--base-path /tmp/blockchain \
--chain raw_testspec.json \
--chain raw_spec_testfinney.json \
--rpc-external --rpc-cors all \
--no-mdns \
--in-peers 500 --out-peers 500 \
Expand Down
103,931 changes: 0 additions & 103,931 deletions finney_plain_spec.json

This file was deleted.

26 changes: 20 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,30 @@ benchmarks:

clippy:
@echo "Running cargo clippy..."
cargo +{{RUSTV}} clippy --workspace --all-targets -- -D \
cargo +{{RUSTV}} clippy --workspace --all-targets -- \
-D clippy::todo \
-D clippy::unimplemented

clippy-fix:
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
cargo +{{RUSTV}} clippy --fix --allow-dirty --workspace --all-targets -- -A \
-A clippy::todo \
-A clippy::unimplemented
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
cargo +{{RUSTV}} clippy --fix --allow-dirty --workspace --all-targets -- \
-A clippy::todo \
-A clippy::unimplemented \
-A clippy::indexing_slicing
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
cargo +{{RUSTV}} clippy --fix --allow-dirty --workspace --all-targets -- \
-A clippy::todo \
-A clippy::unimplemented \
-A clippy::indexing_slicing
fix:
@echo "Running cargo fix..."
cargo +{{RUSTV}} fix --workspace
git diff --exit-code || (echo "There are local changes after running 'cargo fix --workspace' ❌" && exit 1)
git diff --exit-code || (echo "There are local changes after running 'cargo fix --workspace' ❌" && exit 1)

lint:
@echo "Running cargo fmt..."
just fmt
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
just clippy-fix
@echo "Running cargo clippy..."
just clippy
18 changes: 13 additions & 5 deletions node/src/chain_spec/finney.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::*;

pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
let path: PathBuf = std::path::PathBuf::from("./snapshot.json");
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
let wasm_binary = WASM_BINARY.ok_or("Development wasm not available".to_string())?;

// We mmap the file into memory first, as this is *a lot* faster than using
// `serde_json::from_reader`. See https://github.com/serde-rs/json/issues/160
Expand Down Expand Up @@ -53,14 +53,16 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
let key_account = sp_runtime::AccountId32::from(key);

processed_balances.push((key_account, *amount));
balances_issuance += *amount;
balances_issuance = balances_issuance
.checked_add(*amount)
.ok_or("Balances issuance overflowed".to_string())?;
}

// Give front-ends necessary data to present to users
let mut properties = sc_service::Properties::new();
properties.insert("tokenSymbol".into(), "TAO".into());
properties.insert("tokenDecimals".into(), 9.into());
properties.insert("ss58Format".into(), 13116.into());
properties.insert("ss58Format".into(), 42.into());

Ok(ChainSpec::builder(
wasm_binary,
Expand All @@ -70,8 +72,14 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> {
},
)
.with_name("Bittensor")
.with_protocol_id("bittensor")
.with_id("bittensor")
.with_chain_type(ChainType::Live)
.with_boot_nodes(vec![
"/dns/bootnode.finney.chain.opentensor.ai/tcp/30333/ws/p2p/12D3KooWRwbMb85RWnT8DSXSYMWQtuDwh4LJzndoRrTDotTR5gDC"
.parse()
.unwrap(),
])
.with_genesis_config_patch(finney_genesis(
// Initial PoA authorities (Validators)
// aura | grandpa
Expand Down Expand Up @@ -191,9 +199,9 @@ fn finney_genesis(
.collect::<Vec<_>>(),
},
"sudo": { "key": Some(<AccountId32 as Ss58Codec>::from_ss58check("5FCM3DBXWiGcwYYQtT8z4ZD93TqYpYxjaAfgv6aMStV1FTCT").unwrap()) },
"subtensor_module": {
"subtensorModule": {
"stakes": stakes,
"balances_issuance": balances_issuance,
"balancesIssuance": balances_issuance,
}
})
}
3 changes: 2 additions & 1 deletion node/src/chain_spec/localnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn localnet_config() -> Result<ChainSpec, String> {
let mut properties = sc_service::Properties::new();
properties.insert("tokenSymbol".into(), "TAO".into());
properties.insert("tokenDecimals".into(), 9.into());
properties.insert("ss58Format".into(), 13116.into());
properties.insert("ss58Format".into(), 42.into());

Ok(ChainSpec::builder(
wasm_binary,
Expand All @@ -26,6 +26,7 @@ pub fn localnet_config() -> Result<ChainSpec, String> {
},
)
.with_name("Bittensor")
.with_protocol_id("bittensor")
.with_id("bittensor")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(localnet_genesis(
Expand Down
Loading

0 comments on commit 4e68a5b

Please sign in to comment.