Skip to content

Commit 5c66560

Browse files
authored
Merge pull request #568 from opentensor/devnet_companion_feat/liquid_alpha_2
Devnet companion feat/liquid alpha 2
2 parents ab6212a + b1c26b3 commit 5c66560

File tree

23 files changed

+4150
-2227
lines changed

23 files changed

+4150
-2227
lines changed

.github/workflows/check-devnet.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,18 @@ jobs:
3737
echo "network spec_version: $spec_version"
3838
if (( $(echo "$local_spec_version <= $spec_version" | bc -l) )); then echo "$local_spec_version ≯ $spec_version ❌"; exit 1; fi
3939
echo "$local_spec_version > $spec_version ✅"
40+
41+
check-devnet-migrations:
42+
name: check devnet migrations
43+
runs-on: ubuntu-22.04
44+
steps:
45+
- name: Checkout sources
46+
uses: actions/checkout@v3
47+
48+
- name: Run Try Runtime Checks
49+
uses: "paritytech/[email protected]"
50+
with:
51+
runtime-package: "node-subtensor-runtime"
52+
node-uri: "wss://dev.chain.opentensor.ai:443"
53+
checks: "pre-and-post"
54+
extra-args: "--disable-spec-version-check --no-weight-warnings"

.github/workflows/check-finney.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Finney Deploy Check
22

33
on:
44
pull_request:
5-
branches: [finney]
5+
branches: [finney, main]
66

77
env:
88
CARGO_TERM_COLOR: always
@@ -37,3 +37,17 @@ jobs:
3737
echo "network spec_version: $spec_version"
3838
if (( $(echo "$local_spec_version <= $spec_version" | bc -l) )); then echo "$local_spec_version ≯ $spec_version ❌"; exit 1; fi
3939
echo "$local_spec_version > $spec_version ✅"
40+
41+
check-finney-migrations:
42+
name: check finney migrations
43+
runs-on: SubtensorCI
44+
steps:
45+
- name: Checkout sources
46+
uses: actions/checkout@v4
47+
- name: Run Try Runtime Checks
48+
uses: "paritytech/[email protected]"
49+
with:
50+
runtime-package: "node-subtensor-runtime"
51+
node-uri: "wss://entrypoint-finney.opentensor.ai:443"
52+
checks: "pre-and-post"
53+
extra-args: "--disable-spec-version-check --no-weight-warnings"

.github/workflows/check-rust.yml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -339,47 +339,6 @@ jobs:
339339
- name: Check features
340340
run: zepter run check
341341

342-
check-finney-migrations:
343-
name: check finney migrations
344-
runs-on: SubtensorCI
345-
steps:
346-
- name: Checkout sources
347-
uses: actions/checkout@v4
348342

349-
- name: Run Try Runtime Checks
350-
uses: "paritytech/[email protected]"
351-
with:
352-
runtime-package: "node-subtensor-runtime"
353-
node-uri: "wss://entrypoint-finney.opentensor.ai:443"
354-
checks: "pre-and-post"
355-
extra-args: "--disable-spec-version-check --no-weight-warnings"
356-
357-
check-devnet-migrations:
358-
name: check devnet migrations
359-
runs-on: ubuntu-22.04
360-
steps:
361-
- name: Checkout sources
362-
uses: actions/checkout@v3
363343

364-
- name: Run Try Runtime Checks
365-
uses: "paritytech/[email protected]"
366-
with:
367-
runtime-package: "node-subtensor-runtime"
368-
node-uri: "wss://dev.chain.opentensor.ai:443"
369-
checks: "pre-and-post"
370-
extra-args: "--disable-spec-version-check --no-weight-warnings"
371-
372-
check-testnet-migrations:
373-
name: check testnet migrations
374-
runs-on: ubuntu-22.04
375-
steps:
376-
- name: Checkout sources
377-
uses: actions/checkout@v3
378344

379-
- name: Run Try Runtime Checks
380-
uses: "paritytech/[email protected]"
381-
with:
382-
runtime-package: "node-subtensor-runtime"
383-
node-uri: "wss://test.chain.opentensor.ai:443"
384-
checks: "pre-and-post"
385-
extra-args: "--disable-spec-version-check --no-weight-warnings"

.github/workflows/check-testnet.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,18 @@ jobs:
3737
echo "network spec_version: $spec_version"
3838
if (( $(echo "$local_spec_version <= $spec_version" | bc -l) )); then echo "$local_spec_version ≯ $spec_version ❌"; exit 1; fi
3939
echo "$local_spec_version > $spec_version ✅"
40+
41+
check-testnet-migrations:
42+
name: check testnet migrations
43+
runs-on: ubuntu-22.04
44+
steps:
45+
- name: Checkout sources
46+
uses: actions/checkout@v3
47+
48+
- name: Run Try Runtime Checks
49+
uses: "paritytech/[email protected]"
50+
with:
51+
runtime-package: "node-subtensor-runtime"
52+
node-uri: "wss://test.chain.opentensor.ai:443"
53+
checks: "pre-and-post"
54+
extra-args: "--disable-spec-version-check --no-weight-warnings"

Cargo.lock

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

justfile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export RUST_BACKTRACE := "full"
44
export SKIP_WASM_BUILD := "1"
55
export RUST_BIN_DIR := "target/x86_64-unknown-linux-gnu"
66
export TARGET := "x86_64-unknown-linux-gnu"
7-
export RUSTV := "nightly-2024-03-05"
7+
export RUSTV := "stable"
88
export RELEASE_NAME := "development"
99

1010
fmt:
@@ -25,16 +25,25 @@ benchmarks:
2525

2626
clippy:
2727
@echo "Running cargo clippy..."
28-
cargo +{{RUSTV}} clippy -- -D clippy::panic \
28+
cargo +{{RUSTV}} clippy --workspace --all-targets -- \
2929
-D clippy::todo \
3030
-D clippy::unimplemented
3131

3232
clippy-fix:
3333
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
34-
cargo +{{RUSTV}} clippy --fix --allow-dirty -- -A clippy::panic \
34+
cargo +{{RUSTV}} clippy --workspace --all-targets --fix --allow-dirty -- \
3535
-A clippy::todo \
36-
-A clippy::unimplemented
36+
-A clippy::unimplemented \
37+
-A clippy::indexing_slicing
3738
fix:
3839
@echo "Running cargo fix..."
3940
cargo +{{RUSTV}} fix --workspace
40-
git diff --exit-code || (echo "There are local changes after running 'cargo fix --workspace' ❌" && exit 1)
41+
git diff --exit-code || (echo "There are local changes after running 'cargo fix --workspace' ❌" && exit 1)
42+
43+
lint:
44+
@echo "Running cargo fmt..."
45+
just fmt
46+
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
47+
just clippy-fix
48+
@echo "Running cargo clippy..."
49+
just clippy

pallets/admin-utils/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ sp-runtime = { workspace = true }
2828
log = { workspace = true }
2929
pallet-subtensor = { version = "4.0.0-dev", default-features = false, path = "../subtensor" }
3030
sp-weights = { workspace = true }
31+
substrate-fixed = { workspace = true }
3132

3233

3334
[dev-dependencies]
@@ -54,7 +55,8 @@ std = [
5455
"sp-weights/std",
5556
"log/std",
5657
"sp-core/std",
57-
"sp-io/std"
58+
"sp-io/std",
59+
"substrate-fixed/std",
5860
]
5961
runtime-benchmarks = [
6062
"frame-benchmarking/runtime-benchmarks",

pallets/admin-utils/src/lib.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,45 @@ pub mod pallet {
996996
log::info!("ToggleSetWeightsCommitReveal( netuid: {:?} ) ", netuid);
997997
Ok(())
998998
}
999+
1000+
/// Enables or disables Liquid Alpha for a given subnet.
1001+
///
1002+
/// # Parameters
1003+
/// - `origin`: The origin of the call, which must be the root account or subnet owner.
1004+
/// - `netuid`: The unique identifier for the subnet.
1005+
/// - `enabled`: A boolean flag to enable or disable Liquid Alpha.
1006+
///
1007+
/// # Weight
1008+
/// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees.
1009+
#[pallet::call_index(50)]
1010+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1011+
pub fn sudo_set_liquid_alpha_enabled(
1012+
origin: OriginFor<T>,
1013+
netuid: u16,
1014+
enabled: bool,
1015+
) -> DispatchResult {
1016+
T::Subtensor::ensure_subnet_owner_or_root(origin, netuid)?;
1017+
T::Subtensor::set_liquid_alpha_enabled(netuid, enabled);
1018+
log::info!(
1019+
"LiquidAlphaEnableToggled( netuid: {:?}, Enabled: {:?} ) ",
1020+
netuid,
1021+
enabled
1022+
);
1023+
Ok(())
1024+
}
1025+
1026+
/// Sets values for liquid alpha
1027+
#[pallet::call_index(51)]
1028+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1029+
pub fn sudo_set_alpha_values(
1030+
origin: OriginFor<T>,
1031+
netuid: u16,
1032+
alpha_low: u16,
1033+
alpha_high: u16,
1034+
) -> DispatchResult {
1035+
T::Subtensor::ensure_subnet_owner_or_root(origin.clone(), netuid)?;
1036+
T::Subtensor::do_set_alpha_values(origin, netuid, alpha_low, alpha_high)
1037+
}
9991038
}
10001039
}
10011040

@@ -1091,4 +1130,11 @@ pub trait SubtensorInterface<AccountId, Balance, RuntimeOrigin> {
10911130
fn set_target_stakes_per_interval(target_stakes_per_interval: u64);
10921131
fn set_commit_reveal_weights_interval(netuid: u16, interval: u64);
10931132
fn set_commit_reveal_weights_enabled(netuid: u16, enabled: bool);
1133+
fn set_liquid_alpha_enabled(netuid: u16, enabled: bool);
1134+
fn do_set_alpha_values(
1135+
origin: RuntimeOrigin,
1136+
netuid: u16,
1137+
alpha_low: u16,
1138+
alpha_high: u16,
1139+
) -> Result<(), DispatchError>;
10941140
}

pallets/admin-utils/tests/mock.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ frame_support::construct_runtime!(
2424
System: frame_system,
2525
Balances: pallet_balances,
2626
AdminUtils: pallet_admin_utils,
27-
SubtensorModule: pallet_subtensor::{Pallet, Call, Storage, Event<T>},
27+
SubtensorModule: pallet_subtensor::{Pallet, Call, Storage, Event<T>, Error<T>},
2828
}
2929
);
3030

@@ -110,7 +110,9 @@ parameter_types! {
110110
pub const InitialSubnetLimit: u16 = 10; // Max 10 subnets.
111111
pub const InitialNetworkRateLimit: u64 = 0;
112112
pub const InitialTargetStakesPerInterval: u16 = 1;
113-
113+
pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default
114+
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
115+
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
114116
}
115117

116118
impl pallet_subtensor::Config for Test {
@@ -162,6 +164,9 @@ impl pallet_subtensor::Config for Test {
162164
type InitialSubnetLimit = InitialSubnetLimit;
163165
type InitialNetworkRateLimit = InitialNetworkRateLimit;
164166
type InitialTargetStakesPerInterval = InitialTargetStakesPerInterval;
167+
type AlphaHigh = InitialAlphaHigh;
168+
type AlphaLow = InitialAlphaLow;
169+
type LiquidAlphaOn = InitialLiquidAlphaOn;
165170
}
166171

167172
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
@@ -464,6 +469,18 @@ impl pallet_admin_utils::SubtensorInterface<AccountId, Balance, RuntimeOrigin> f
464469
fn set_commit_reveal_weights_enabled(netuid: u16, enabled: bool) {
465470
SubtensorModule::set_commit_reveal_weights_enabled(netuid, enabled);
466471
}
472+
473+
fn set_liquid_alpha_enabled(netuid: u16, enabled: bool) {
474+
SubtensorModule::set_liquid_alpha_enabled(netuid, enabled);
475+
}
476+
fn do_set_alpha_values(
477+
origin: RuntimeOrigin,
478+
netuid: u16,
479+
alpha_low: u16,
480+
alpha_high: u16,
481+
) -> Result<(), DispatchError> {
482+
SubtensorModule::do_set_alpha_values(origin, netuid, alpha_low, alpha_high)
483+
}
467484
}
468485

469486
impl pallet_admin_utils::Config for Test {

0 commit comments

Comments
 (0)