Skip to content

Commit 4a0eada

Browse files
authored
Merge pull request #694 from opentensor/devnet
Testnet Deployment 260724
2 parents ce8e91b + 6843cc7 commit 4a0eada

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+10435
-11355
lines changed

Diff for: Cargo.lock

+277-208
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+70-69
Large diffs are not rendered by default.

Diff for: justfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ lint:
4747
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
4848
just clippy-fix
4949
@echo "Running cargo clippy..."
50-
just clippy
50+
just clippy
51+
52+
production:
53+
@echo "Running cargo build with metadata-hash generation..."
54+
cargo +{{RUSTV}} build --profile production --features="runtime-benchmarks metadata-hash"

Diff for: node/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ sp-io = { workspace = true }
5454
sp-timestamp = { workspace = true }
5555
sp-inherents = { workspace = true }
5656
sp-keyring = { workspace = true }
57+
frame-metadata-hash-extension = { workspace = true }
5758
frame-system = { workspace = true }
5859
pallet-transaction-payment = { workspace = true }
5960
pallet-commitments = { path = "../pallets/commitments" }

Diff for: node/src/benchmarking.rs

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ pub fn create_benchmark_extrinsic(
136136
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
137137
pallet_subtensor::SubtensorSignedExtension::<runtime::Runtime>::new(),
138138
pallet_commitments::CommitmentsSignedExtension::<runtime::Runtime>::new(),
139+
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
139140
);
140141

141142
let raw_payload = runtime::SignedPayload::from_raw(
@@ -152,6 +153,7 @@ pub fn create_benchmark_extrinsic(
152153
(),
153154
(),
154155
(),
156+
None,
155157
),
156158
);
157159
let signature = raw_payload.using_encoded(|e| sender.sign(e));

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

+16
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,21 @@ mod benchmarks {
240240
_(RawOrigin::Root, 1u16/*netuid*/, true/*enabled*/)/*set_commit_reveal_weights_enabled*/;
241241
}
242242

243+
#[benchmark]
244+
fn sudo_set_hotkey_emission_tempo() {
245+
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*sudo_tempo*/);
246+
247+
#[extrinsic_call]
248+
_(RawOrigin::Root, 1u64/*emission_tempo*/)/*set_hotkey_emission_tempo*/;
249+
}
250+
251+
#[benchmark]
252+
fn sudo_set_network_max_stake() {
253+
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
254+
255+
#[extrinsic_call]
256+
_(RawOrigin::Root, 1u16/*netuid*/, 1_000_000_000_000_000u64/*max_stake*/)/*sudo_set_network_max_stake*/;
257+
}
258+
243259
//impl_benchmark_test_suite!(AdminUtils, crate::mock::new_test_ext(), crate::mock::Test);
244260
}

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

+83
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,87 @@ pub mod pallet {
10351035
T::Subtensor::ensure_subnet_owner_or_root(origin.clone(), netuid)?;
10361036
T::Subtensor::do_set_alpha_values(origin, netuid, alpha_low, alpha_high)
10371037
}
1038+
1039+
/// Sets the hotkey emission tempo.
1040+
///
1041+
/// This extrinsic allows the root account to set the hotkey emission tempo, which determines
1042+
/// the number of blocks before a hotkey drains accumulated emissions through to nominator staking accounts.
1043+
///
1044+
/// # Arguments
1045+
/// * `origin` - The origin of the call, which must be the root account.
1046+
/// * `emission_tempo` - The new emission tempo value to set.
1047+
///
1048+
/// # Emits
1049+
/// * `Event::HotkeyEmissionTempoSet` - When the hotkey emission tempo is successfully set.
1050+
///
1051+
/// # Errors
1052+
/// * `DispatchError::BadOrigin` - If the origin is not the root account.
1053+
// #[pallet::weight(T::WeightInfo::sudo_set_hotkey_emission_tempo())]
1054+
#[pallet::call_index(52)]
1055+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1056+
pub fn sudo_set_hotkey_emission_tempo(
1057+
origin: OriginFor<T>,
1058+
emission_tempo: u64,
1059+
) -> DispatchResult {
1060+
ensure_root(origin)?;
1061+
T::Subtensor::set_hotkey_emission_tempo(emission_tempo);
1062+
log::info!(
1063+
"HotkeyEmissionTempoSet( emission_tempo: {:?} )",
1064+
emission_tempo
1065+
);
1066+
Ok(())
1067+
}
1068+
1069+
/// Sets the maximum stake allowed for a specific network.
1070+
///
1071+
/// This function allows the root account to set the maximum stake for a given network.
1072+
/// It updates the network's maximum stake value and logs the change.
1073+
///
1074+
/// # Arguments
1075+
///
1076+
/// * `origin` - The origin of the call, which must be the root account.
1077+
/// * `netuid` - The unique identifier of the network.
1078+
/// * `max_stake` - The new maximum stake value to set.
1079+
///
1080+
/// # Returns
1081+
///
1082+
/// Returns `Ok(())` if the operation is successful, or an error if it fails.
1083+
///
1084+
/// # Example
1085+
///
1086+
///
1087+
/// # Notes
1088+
///
1089+
/// - This function can only be called by the root account.
1090+
/// - The `netuid` should correspond to an existing network.
1091+
///
1092+
/// # TODO
1093+
///
1094+
// - Consider adding a check to ensure the `netuid` corresponds to an existing network.
1095+
// - Implement a mechanism to gradually adjust the max stake to prevent sudden changes.
1096+
// #[pallet::weight(T::WeightInfo::sudo_set_network_max_stake())]
1097+
#[pallet::call_index(53)]
1098+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1099+
pub fn sudo_set_network_max_stake(
1100+
origin: OriginFor<T>,
1101+
netuid: u16,
1102+
max_stake: u64,
1103+
) -> DispatchResult {
1104+
// Ensure the call is made by the root account
1105+
ensure_root(origin)?;
1106+
1107+
// Set the new maximum stake for the specified network
1108+
T::Subtensor::set_network_max_stake(netuid, max_stake);
1109+
1110+
// Log the change
1111+
log::trace!(
1112+
"NetworkMaxStakeSet( netuid: {:?}, max_stake: {:?} )",
1113+
netuid,
1114+
max_stake
1115+
);
1116+
1117+
Ok(())
1118+
}
10381119
}
10391120
}
10401121

@@ -1137,4 +1218,6 @@ pub trait SubtensorInterface<AccountId, Balance, RuntimeOrigin> {
11371218
alpha_low: u16,
11381219
alpha_high: u16,
11391220
) -> Result<(), DispatchError>;
1221+
fn set_hotkey_emission_tempo(emission_tempo: u64);
1222+
fn set_network_max_stake(netuid: u16, max_stake: u64);
11401223
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ pub trait WeightInfo {
6262
fn sudo_set_tempo() -> Weight;
6363
fn sudo_set_commit_reveal_weights_interval() -> Weight;
6464
fn sudo_set_commit_reveal_weights_enabled() -> Weight;
65-
6665
}
6766

6867
/// Weights for `pallet_admin_utils` using the Substrate node and recommended hardware.

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

+11-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ parameter_types! {
114114
pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default
115115
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
116116
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
117-
pub const InitialBaseDifficulty: u64 = 10_000; // Base difficulty
117+
pub const InitialHotkeyEmissionTempo: u64 = 1;
118+
pub const InitialNetworkMaxStake: u64 = 500_000_000_000_000; // 500_000 TAO
118119
}
119120

120121
impl pallet_subtensor::Config for Test {
@@ -170,7 +171,8 @@ impl pallet_subtensor::Config for Test {
170171
type AlphaHigh = InitialAlphaHigh;
171172
type AlphaLow = InitialAlphaLow;
172173
type LiquidAlphaOn = InitialLiquidAlphaOn;
173-
type InitialBaseDifficulty = InitialBaseDifficulty;
174+
type InitialHotkeyEmissionTempo = InitialHotkeyEmissionTempo;
175+
type InitialNetworkMaxStake = InitialNetworkMaxStake;
174176
}
175177

176178
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
@@ -477,6 +479,13 @@ impl pallet_admin_utils::SubtensorInterface<AccountId, Balance, RuntimeOrigin> f
477479
fn set_liquid_alpha_enabled(netuid: u16, enabled: bool) {
478480
SubtensorModule::set_liquid_alpha_enabled(netuid, enabled);
479481
}
482+
fn set_hotkey_emission_tempo(emission_tempo: u64) {
483+
SubtensorModule::set_hotkey_emission_tempo(emission_tempo)
484+
}
485+
fn set_network_max_stake(netuid: u16, max_stake: u64) {
486+
SubtensorModule::set_network_max_stake(netuid, max_stake)
487+
}
488+
480489
fn do_set_alpha_values(
481490
origin: RuntimeOrigin,
482491
netuid: u16,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use frame_support::{
66
use frame_system::Config;
77
use pallet_admin_utils::Error;
88
use pallet_subtensor::Error as SubtensorError;
9-
use pallet_subtensor::{migration, Event};
9+
use pallet_subtensor::{migrations, Event};
1010
use sp_core::U256;
1111

1212
mod mock;
@@ -1232,7 +1232,7 @@ fn test_sudo_get_set_alpha() {
12321232

12331233
// Enable Liquid Alpha and setup
12341234
SubtensorModule::set_liquid_alpha_enabled(netuid, true);
1235-
migration::migrate_create_root_network::<Test>();
1235+
migrations::migrate_create_root_network::migrate_create_root_network::<Test>();
12361236
SubtensorModule::add_balance_to_coldkey_account(&coldkey, 1_000_000_000_000_000);
12371237
assert_ok!(SubtensorModule::root_register(signer.clone(), hotkey,));
12381238
assert_ok!(SubtensorModule::add_stake(signer.clone(), hotkey, 1000));

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -951,9 +951,9 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
951951
///
952952
/// If not `approved`:
953953
/// - one event deposited.
954-
/// Two removals, one mutation.
955-
/// Computation and i/o `O(P)` where:
956-
/// - `P` is number of active proposals
954+
/// - two removals, one mutation.
955+
/// - computation and i/o `O(P)` where:
956+
/// - `P` is number of active proposals
957957
fn do_approve_proposal(
958958
seats: MemberCount,
959959
yes_votes: MemberCount,

0 commit comments

Comments
 (0)