Skip to content

Commit b4ca34b

Browse files
Merge pull request #527 from opentensor/hotfix/set-root-weights
hotfix/set-root-weights
2 parents 703bdbd + 87e47c5 commit b4ca34b

File tree

15 files changed

+296
-84
lines changed

15 files changed

+296
-84
lines changed

.github/workflows/check-rust.yml

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
strategy:
7272
matrix:
7373
rust-branch:
74-
- nightly-2024-03-05
74+
- stable
7575
rust-target:
7676
- x86_64-unknown-linux-gnu
7777
# - x86_64-apple-darwin
@@ -119,55 +119,7 @@ jobs:
119119
strategy:
120120
matrix:
121121
rust-branch:
122-
- nightly-2024-03-05
123-
rust-target:
124-
- x86_64-unknown-linux-gnu
125-
# - x86_64-apple-darwin
126-
os:
127-
- ubuntu-latest
128-
# - macos-latest
129-
include:
130-
- os: ubuntu-latest
131-
# - os: macos-latest
132-
env:
133-
RELEASE_NAME: development
134-
# RUSTFLAGS: -A warnings
135-
RUSTV: ${{ matrix.rust-branch }}
136-
RUST_BACKTRACE: full
137-
RUST_BIN_DIR: target/${{ matrix.rust-target }}
138-
SKIP_WASM_BUILD: 1
139-
TARGET: ${{ matrix.rust-target }}
140-
steps:
141-
- name: Check-out repository under $GITHUB_WORKSPACE
142-
uses: actions/checkout@v2
143-
144-
- name: Install dependencies
145-
run: |
146-
sudo apt-get update &&
147-
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
148-
149-
- name: Install Rust ${{ matrix.rust-branch }}
150-
uses: actions-rs/[email protected]
151-
with:
152-
toolchain: ${{ matrix.rust-branch }}
153-
components: rustfmt, clippy
154-
profile: minimal
155-
156-
- name: Utilize Shared Rust Cache
157-
uses: Swatinem/[email protected]
158-
with:
159-
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}
160-
161-
- name: cargo clippy --workspace --all-targets --all-features -- -D warnings
162-
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
163-
164-
cargo-clippy-all-features:
165-
name: cargo clippy --all-features
166-
runs-on: SubtensorCI
167-
strategy:
168-
matrix:
169-
rust-branch:
170-
- nightly-2024-03-05
122+
- stable
171123
rust-target:
172124
- x86_64-unknown-linux-gnu
173125
# - x86_64-apple-darwin
@@ -208,15 +160,14 @@ jobs:
208160

209161
- name: cargo clippy --workspace --all-targets --all-features -- -D warnings
210162
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
211-
212163
# runs cargo test --workspace
213164
cargo-test:
214165
name: cargo test
215166
runs-on: SubtensorCI
216167
strategy:
217168
matrix:
218169
rust-branch:
219-
- nightly-2024-03-05
170+
- stable
220171
rust-target:
221172
- x86_64-unknown-linux-gnu
222173
# - x86_64-apple-darwin
@@ -265,7 +216,7 @@ jobs:
265216
strategy:
266217
matrix:
267218
rust-branch:
268-
- nightly-2024-03-05
219+
- stable
269220
rust-target:
270221
- x86_64-unknown-linux-gnu
271222
# - x86_64-apple-darwin
@@ -314,7 +265,7 @@ jobs:
314265
strategy:
315266
matrix:
316267
rust-branch:
317-
- nightly-2024-03-05
268+
- stable
318269
rust-target:
319270
- x86_64-unknown-linux-gnu
320271
# - x86_64-apple-darwin

node/src/rpc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct FullDeps<C, P, B> {
4242
/// Grandpa block import setup.
4343
pub grandpa: GrandpaDeps<B>,
4444
/// Backend used by the node.
45-
pub backend: Arc<B>,
45+
pub _backend: Arc<B>,
4646
}
4747

4848
/// Instantiate all full RPC extensions.
@@ -74,7 +74,7 @@ where
7474
pool,
7575
deny_unsafe,
7676
grandpa,
77-
backend: _,
77+
_backend: _,
7878
} = deps;
7979

8080
// Custom RPC methods for Paratensor

node/src/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
266266
subscription_executor: subscription_executor.clone(),
267267
finality_provider: finality_proof_provider.clone(),
268268
},
269-
backend: rpc_backend.clone(),
269+
_backend: rpc_backend.clone(),
270270
};
271271
crate::rpc::create_full(deps).map_err(Into::into)
272272
},

pallets/admin-utils/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub use weights::WeightInfo;
77
use sp_runtime::DispatchError;
88
use sp_runtime::{traits::Member, RuntimeAppPublic};
99

10-
#[cfg(feature = "runtime-benchmarks")]
1110
mod benchmarking;
1211

1312
#[deny(missing_docs)]

pallets/commitments/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#![cfg_attr(not(feature = "std"), no_std)]
22

3+
mod benchmarking;
34
#[cfg(test)]
45
mod tests;
56

6-
#[cfg(feature = "runtime-benchmarks")]
7-
mod benchmarking;
8-
97
pub mod types;
108
pub mod weights;
119

@@ -234,7 +232,7 @@ where
234232
pub fn get_priority_vanilla() -> u64 {
235233
// Return high priority so that every extrinsic except set_weights function will
236234
// have a higher priority than the set_weights call
237-
u64::max_value()
235+
u64::MAX
238236
}
239237
}
240238

pallets/registry/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#[cfg(test)]
44
mod tests;
55

6-
#[cfg(feature = "runtime-benchmarks")]
76
mod benchmarking;
87
pub mod types;
98
pub mod weights;

pallets/subtensor/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use sp_std::marker::PhantomData;
2929
// ============================
3030
// ==== Benchmark Imports =====
3131
// ============================
32-
#[cfg(feature = "runtime-benchmarks")]
3332
mod benchmarks;
3433

3534
// =========================
@@ -2063,7 +2062,7 @@ pub mod pallet {
20632062
let current_block_number: u64 = Self::get_current_block_as_u64();
20642063
let default_priority: u64 =
20652064
current_block_number - Self::get_last_update_for_uid(netuid, uid);
2066-
return default_priority + u32::max_value() as u64;
2065+
return default_priority + u32::MAX as u64;
20672066
}
20682067
0
20692068
}
@@ -2141,7 +2140,7 @@ where
21412140
pub fn get_priority_vanilla() -> u64 {
21422141
// Return high priority so that every extrinsic except set_weights function will
21432142
// have a higher priority than the set_weights call
2144-
u64::max_value()
2143+
u64::MAX
21452144
}
21462145

21472146
pub fn get_priority_set_weights(who: &T::AccountId, netuid: u16) -> u64 {
@@ -2219,9 +2218,9 @@ where
22192218
Err(InvalidTransaction::Call.into())
22202219
}
22212220
}
2222-
Some(Call::set_root_weights { netuid, .. }) => {
2223-
if Self::check_weights_min_stake(who) {
2224-
let priority: u64 = Self::get_priority_set_weights(who, *netuid);
2221+
Some(Call::set_root_weights { netuid, hotkey, .. }) => {
2222+
if Self::check_weights_min_stake(hotkey) {
2223+
let priority: u64 = Self::get_priority_set_weights(hotkey, *netuid);
22252224
Ok(ValidTransaction {
22262225
priority,
22272226
longevity: 1,

pallets/subtensor/src/root.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,12 +1009,12 @@ impl<T: Config> Pallet<T> {
10091009
NetworkRegisteredAt::<T>::remove(netuid);
10101010

10111011
// --- 8. Remove incentive mechanism memory.
1012-
let _ = Uids::<T>::clear_prefix(netuid, u32::max_value(), None);
1013-
let _ = Keys::<T>::clear_prefix(netuid, u32::max_value(), None);
1014-
let _ = Bonds::<T>::clear_prefix(netuid, u32::max_value(), None);
1012+
let _ = Uids::<T>::clear_prefix(netuid, u32::MAX, None);
1013+
let _ = Keys::<T>::clear_prefix(netuid, u32::MAX, None);
1014+
let _ = Bonds::<T>::clear_prefix(netuid, u32::MAX, None);
10151015

10161016
// --- 8. Removes the weights for this subnet (do not remove).
1017-
let _ = Weights::<T>::clear_prefix(netuid, u32::max_value(), None);
1017+
let _ = Weights::<T>::clear_prefix(netuid, u32::MAX, None);
10181018

10191019
// --- 9. Iterate over stored weights and fill the matrix.
10201020
for (uid_i, weights_i) in

pallets/subtensor/src/weights.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl<T: Config> Pallet<T> {
405405
return weights;
406406
}
407407
weights.iter_mut().for_each(|x| {
408-
*x = (*x as u64 * u16::max_value() as u64 / sum) as u16;
408+
*x = (*x as u64 * u16::MAX as u64 / sum) as u16;
409409
});
410410
weights
411411
}

pallets/subtensor/tests/block_step.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,9 @@ fn test_emission_based_on_registration_status() {
869869
n as usize
870870
);
871871

872+
let block: u64 = 0;
872873
// drain the emission tuples for the subnet with registration on
873-
SubtensorModule::drain_emission(next_block as u64);
874+
SubtensorModule::drain_emission(block);
874875
// Turn on registration for the subnet with registration off
875876
SubtensorModule::set_network_registration_allowed(netuid_off, true);
876877
SubtensorModule::set_network_registration_allowed(netuid_on, false);

0 commit comments

Comments
 (0)