Skip to content

Commit 77698ef

Browse files
authored
Merge pull request #903 from opentensor/devnet
testnet deploy 11-1-2024
2 parents 0c4fdfb + d70b8e2 commit 77698ef

File tree

17 files changed

+499
-155
lines changed

17 files changed

+499
-155
lines changed

Diff for: .github/workflows/check-rust.yml

+4-13
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,7 @@ jobs:
212212
cargo-audit:
213213
name: cargo audit
214214
runs-on: SubtensorCI
215-
strategy:
216-
matrix:
217-
rust-branch:
218-
- stable
219-
rust-target:
220-
- x86_64-unknown-linux-gnu
221-
# - x86_64-apple-darwin
222-
os:
223-
- ubuntu-latest
224-
# - macos-latest
215+
if: ${{ github.event_name != 'push' && !contains(github.event.pull_request.labels.*.name, 'skip-cargo-audit') }}
225216
steps:
226217
- name: Check-out repositoroy under $GITHUB_WORKSPACE
227218
uses: actions/checkout@v4
@@ -231,17 +222,17 @@ jobs:
231222
sudo apt-get update &&
232223
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
233224
234-
- name: Install Rust ${{ matrix.rust-branch }}
225+
- name: Install Rust Stable
235226
uses: actions-rs/toolchain@v1.0.6
236227
with:
237-
toolchain: ${{ matrix.rust-branch }}
228+
toolchain: stable
238229
components: rustfmt, clippy
239230
profile: minimal
240231

241232
- name: Utilize Shared Rust Cache
242233
uses: Swatinem/rust-cache@v2.2.1
243234
with:
244-
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}
235+
key: ubuntu-latest-${{ env.RUST_BIN_DIR }}
245236

246237
- name: Install cargo-audit
247238
run: cargo install cargo-audit

Diff for: pallets/admin-utils/src/benchmarking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ mod benchmarks {
228228
}
229229

230230
#[benchmark]
231-
fn sudo_set_commit_reveal_weights_periods() {
231+
fn sudo_set_commit_reveal_weights_interval() {
232232
pallet_subtensor::Pallet::<T>::init_new_network(
233233
1u16, /*netuid*/
234234
1u16, /*sudo_tempo*/
235235
);
236236

237237
#[extrinsic_call]
238-
_(RawOrigin::Root, 1u16/*netuid*/, 3u64/*interval*/)/*set_commit_reveal_weights_periods()*/;
238+
_(RawOrigin::Root, 1u16/*netuid*/, 3u64/*interval*/)/*sudo_set_commit_reveal_weights_interval()*/;
239239
}
240240

241241
#[benchmark]

Diff for: pallets/admin-utils/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1187,12 +1187,12 @@ pub mod pallet {
11871187
///
11881188
/// # Weight
11891189
/// Weight is handled by the `#[pallet::weight]` attribute.
1190-
#[pallet::call_index(56)]
1191-
#[pallet::weight(T::WeightInfo::sudo_set_commit_reveal_weights_periods())]
1192-
pub fn sudo_set_commit_reveal_weights_periods(
1190+
#[pallet::call_index(57)]
1191+
#[pallet::weight(T::WeightInfo::sudo_set_commit_reveal_weights_interval())]
1192+
pub fn sudo_set_commit_reveal_weights_interval(
11931193
origin: OriginFor<T>,
11941194
netuid: u16,
1195-
periods: u64,
1195+
interval: u64,
11961196
) -> DispatchResult {
11971197
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
11981198

@@ -1201,11 +1201,11 @@ pub mod pallet {
12011201
Error::<T>::SubnetDoesNotExist
12021202
);
12031203

1204-
pallet_subtensor::Pallet::<T>::set_reveal_period(netuid, periods);
1204+
pallet_subtensor::Pallet::<T>::set_reveal_period(netuid, interval);
12051205
log::debug!(
1206-
"SetWeightCommitPeriods( netuid: {:?}, periods: {:?} ) ",
1206+
"SetWeightCommitInterval( netuid: {:?}, interval: {:?} ) ",
12071207
netuid,
1208-
periods
1208+
interval
12091209
);
12101210
Ok(())
12111211
}

Diff for: pallets/admin-utils/src/weights.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub trait WeightInfo {
6060
fn sudo_set_min_burn() -> Weight;
6161
fn sudo_set_network_registration_allowed() -> Weight;
6262
fn sudo_set_tempo() -> Weight;
63-
fn sudo_set_commit_reveal_weights_periods() -> Weight;
63+
fn sudo_set_commit_reveal_weights_interval() -> Weight;
6464
fn sudo_set_commit_reveal_weights_enabled() -> Weight;
6565
}
6666

@@ -413,7 +413,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
413413
.saturating_add(T::DbWeight::get().reads(1_u64))
414414
.saturating_add(T::DbWeight::get().writes(1_u64))
415415
}
416-
fn sudo_set_commit_reveal_weights_periods() -> Weight {
416+
fn sudo_set_commit_reveal_weights_interval() -> Weight {
417417
// Proof Size summary in bytes:
418418
// Measured: `456`
419419
// Estimated: `3921`
@@ -781,7 +781,7 @@ impl WeightInfo for () {
781781
.saturating_add(RocksDbWeight::get().reads(1_u64))
782782
.saturating_add(RocksDbWeight::get().writes(1_u64))
783783
}
784-
fn sudo_set_commit_reveal_weights_periods() -> Weight {
784+
fn sudo_set_commit_reveal_weights_interval() -> Weight {
785785
// -- Extrinsic Time --
786786
// Model:
787787
// Time ~= 19.38

Diff for: pallets/admin-utils/tests/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1414,15 +1414,15 @@ fn test_sudo_set_dissolve_network_schedule_duration() {
14141414
}
14151415

14161416
#[test]
1417-
fn sudo_set_commit_reveal_weights_periods() {
1417+
fn sudo_set_commit_reveal_weights_interval() {
14181418
new_test_ext().execute_with(|| {
14191419
let netuid: u16 = 1;
14201420
add_network(netuid, 10);
14211421

14221422
let to_be_set = 55;
14231423
let init_value = SubtensorModule::get_reveal_period(netuid);
14241424

1425-
assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_periods(
1425+
assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_interval(
14261426
<<Test as Config>::RuntimeOrigin>::root(),
14271427
netuid,
14281428
to_be_set

Diff for: pallets/subtensor/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ pub mod pallet {
574574
0
575575
}
576576
#[pallet::type_value]
577-
/// Default minimum stake for weights.
577+
/// Default Reveal Period Epochs
578578
pub fn DefaultRevealPeriodEpochs<T: Config>() -> u64 {
579579
1
580580
}
@@ -1256,14 +1256,14 @@ pub mod pallet {
12561256
/// ITEM( weights_min_stake )
12571257
pub type WeightsMinStake<T> = StorageValue<_, u64, ValueQuery, DefaultWeightsMinStake<T>>;
12581258
#[pallet::storage]
1259-
/// --- MAP (netuid, who) --> VecDeque<(hash, commit_block)> | Stores a queue of commits for an account on a given netuid.
1259+
/// --- MAP (netuid, who) --> VecDeque<(hash, commit_block, first_reveal_block, last_reveal_block)> | Stores a queue of commits for an account on a given netuid.
12601260
pub type WeightCommits<T: Config> = StorageDoubleMap<
12611261
_,
12621262
Twox64Concat,
12631263
u16,
12641264
Twox64Concat,
12651265
T::AccountId,
1266-
VecDeque<(H256, u64)>,
1266+
VecDeque<(H256, u64, u64, u64)>,
12671267
OptionQuery,
12681268
>;
12691269
#[pallet::storage]

Diff for: pallets/subtensor/src/macros/errors.rs

+2
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,7 @@ mod errors {
188188
RevealTooEarly,
189189
/// Attempted to batch reveal weights with mismatched vector input lenghts.
190190
InputLengthsUnequal,
191+
/// A transactor exceeded the rate limit for setting weights.
192+
CommittingWeightsTooFast,
191193
}
192194
}

Diff for: pallets/subtensor/src/macros/events.rs

+20
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,25 @@ mod events {
204204
ColdkeySwapScheduleDurationSet(BlockNumberFor<T>),
205205
/// The duration of dissolve network has been set
206206
DissolveNetworkScheduleDurationSet(BlockNumberFor<T>),
207+
/// Weights have been successfully committed.
208+
///
209+
/// - **who**: The account ID of the user committing the weights.
210+
/// - **netuid**: The network identifier.
211+
/// - **commit_hash**: The hash representing the committed weights.
212+
WeightsCommitted(T::AccountId, u16, H256),
213+
214+
/// Weights have been successfully revealed.
215+
///
216+
/// - **who**: The account ID of the user revealing the weights.
217+
/// - **netuid**: The network identifier.
218+
/// - **commit_hash**: The hash of the revealed weights.
219+
WeightsRevealed(T::AccountId, u16, H256),
220+
221+
/// Weights have been successfully batch revealed.
222+
///
223+
/// - **who**: The account ID of the user revealing the weights.
224+
/// - **netuid**: The network identifier.
225+
/// - **revealed_hashes**: A vector of hashes representing each revealed weight set.
226+
WeightsBatchRevealed(T::AccountId, u16, Vec<H256>),
207227
}
208228
}

Diff for: pallets/subtensor/src/migrations/migrate_commit_reveal_v2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use scale_info::prelude::string::String;
55
use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult};
66

77
pub fn migrate_commit_reveal_2<T: Config>() -> Weight {
8-
let migration_name = b"migrate_commit_reveal_2".to_vec();
8+
let migration_name = b"migrate_commit_reveal_2_v2".to_vec();
99
let mut weight = T::DbWeight::get().reads(1);
1010

1111
if HasMigrationRun::<T>::get(&migration_name) {

Diff for: pallets/subtensor/src/rpc_info/subnet_info.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct SubnetInfov2<T: Config> {
5151
identity: Option<SubnetIdentity>,
5252
}
5353

54-
#[freeze_struct("4ceb81dfe8a8f96d")]
54+
#[freeze_struct("55b472510f10e76a")]
5555
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
5656
pub struct SubnetHyperparams {
5757
rho: Compact<u16>,
@@ -76,7 +76,7 @@ pub struct SubnetHyperparams {
7676
max_validators: Compact<u16>,
7777
adjustment_alpha: Compact<u64>,
7878
difficulty: Compact<u64>,
79-
commit_reveal_periods: Compact<u64>,
79+
commit_reveal_weights_interval: Compact<u64>,
8080
commit_reveal_weights_enabled: bool,
8181
alpha_high: Compact<u16>,
8282
alpha_low: Compact<u16>,
@@ -280,7 +280,7 @@ impl<T: Config> Pallet<T> {
280280
max_validators: max_validators.into(),
281281
adjustment_alpha: adjustment_alpha.into(),
282282
difficulty: difficulty.into(),
283-
commit_reveal_periods: commit_reveal_periods.into(),
283+
commit_reveal_weights_interval: commit_reveal_periods.into(),
284284
commit_reveal_weights_enabled,
285285
alpha_high: alpha_high.into(),
286286
alpha_low: alpha_low.into(),

0 commit comments

Comments
 (0)