Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testnet Deployment 260724 #694

Merged
merged 68 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9a179bb
feature-gate hash
camfairchild Jul 12, 2024
5039e5b
use 1.10.0-rc2
camfairchild Jul 12, 2024
322752b
add feature
camfairchild Jul 12, 2024
78a71f9
lock file update
camfairchild Jul 15, 2024
fc0ccbd
add production just target
camfairchild Jul 15, 2024
b09b3e6
fmt
camfairchild Jul 15, 2024
bddf977
save
Jul 15, 2024
f7ade4d
clean tests
Jul 15, 2024
0f8d50b
pre fix
Jul 15, 2024
fcbf662
fmt
Jul 15, 2024
4270cc4
clippy fmt
Jul 15, 2024
752f53c
merge clean
Jul 15, 2024
ad694b0
refactor everything to make it cleaner
Jul 15, 2024
5e29112
lint
Jul 15, 2024
8941385
add set sudo hotkey drain tempo
Jul 15, 2024
8eb7bd9
merge childkeys
Jul 15, 2024
7364832
clippy
camfairchild Jul 16, 2024
64aca95
benchmarking fix
camfairchild Jul 16, 2024
9ec6c4e
fmt
camfairchild Jul 16, 2024
893b1ec
use rc3 with new fix polkadot-sdk/pull/4117
camfairchild Jul 18, 2024
237634c
incl lock
camfairchild Jul 18, 2024
c80df3d
bump CI
sam0x17 Jul 18, 2024
4a4adfd
Merge branch 'main' into feat/check-metadata-hash-extension
camfairchild Jul 18, 2024
0c28f29
Merge branch 'devnet-ready' into feat/devnet-companion/check-metadata…
camfairchild Jul 19, 2024
07e46e3
initial
Jul 22, 2024
0432b53
add tests
Jul 22, 2024
7f938f7
tests pass
Jul 22, 2024
659b53c
clean the code
Jul 22, 2024
b8cfd6c
fix tests
Jul 22, 2024
6b6460d
clippy and fmt
Jul 22, 2024
fde92e4
chore: bump spec version
Jul 22, 2024
77ac802
Merge pull request #666 from opentensor/devnet-ready-rebase
unconst Jul 22, 2024
fb2484b
Merge pull request #667 from opentensor/devnet-ready
unconst Jul 22, 2024
662728b
Merge pull request #665 from opentensor/merge_hot_swap
unconst Jul 22, 2024
a00d130
bring back hotkey swap
Jul 22, 2024
9b9c594
pump to 189
Jul 22, 2024
c7563d3
Merge branch 'devnet' into merge_hot_swap
distributedstatemachine Jul 22, 2024
385f0bf
chore: lint
Jul 22, 2024
50fa9ad
Merge pull request #668 from opentensor/merge_hot_swap
unconst Jul 22, 2024
336321f
clean coldkey swap
Jul 22, 2024
da1a9d2
fix clippy warnings
camfairchild Jul 23, 2024
8e4bf4c
fmt
camfairchild Jul 23, 2024
118db38
Merge branch 'devnet-ready' of github.com:opentensor/subtensor into c…
Jul 23, 2024
751b396
Merge pull request #674 from opentensor/fix/clippy/devnet-ready/hotke…
distributedstatemachine Jul 23, 2024
cf9869d
pre merge
Jul 23, 2024
592b3ad
Merge branch 'devnet-ready' of github.com:opentensor/subtensor into c…
Jul 23, 2024
9b18c41
fmt and clippy
Jul 23, 2024
af453f4
Merge pull request #672 from opentensor/feat/devnet-companion/check-m…
unconst Jul 23, 2024
b82a101
Merge branch 'devnet-ready' of github.com:opentensor/subtensor into c…
Jul 23, 2024
6f923c9
clippy
Jul 23, 2024
a452e87
Merge pull request #677 from opentensor/clean_cold_swap
unconst Jul 23, 2024
42f7dfa
Merge pull request #678 from opentensor/devnet-ready
unconst Jul 23, 2024
4a777df
merge
Jul 23, 2024
02457c1
fix migration tests
Jul 23, 2024
bc19f08
s
Jul 23, 2024
28ba654
clippy
Jul 23, 2024
4726ec3
fix divide by zero
Jul 23, 2024
e90fc16
fix checked div error
Jul 23, 2024
4e7629f
clippy fmt
Jul 23, 2024
cd76142
Merge pull request #681 from opentensor/rebase_devnet_ready
unconst Jul 23, 2024
af50dd6
adds a doublt Tempo limit to setting childkeys
Jul 23, 2024
4f016d2
Merge pull request #682 from opentensor/devnet-ready
unconst Jul 23, 2024
efdce2e
Merge branch 'testnet' into devnet
Jul 26, 2024
c5566a7
Merge remote-tracking branch 'origin/testnet' into devnet
Jul 26, 2024
8d8a668
Merge branch 'devnet' into devnet_conflcit
Jul 26, 2024
62c1527
clippy
Jul 26, 2024
cd23ac2
chore: clippy
Jul 29, 2024
6843cc7
Merge pull request #695 from opentensor/devnet_conflcit
distributedstatemachine Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
485 changes: 277 additions & 208 deletions Cargo.lock

Large diffs are not rendered by default.

139 changes: 70 additions & 69 deletions Cargo.toml

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ lint:
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
just clippy-fix
@echo "Running cargo clippy..."
just clippy
just clippy

production:
@echo "Running cargo build with metadata-hash generation..."
cargo +{{RUSTV}} build --profile production --features="runtime-benchmarks metadata-hash"
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ sp-io = { workspace = true }
sp-timestamp = { workspace = true }
sp-inherents = { workspace = true }
sp-keyring = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-system = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-commitments = { path = "../pallets/commitments" }
Expand Down
2 changes: 2 additions & 0 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ pub fn create_benchmark_extrinsic(
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
pallet_subtensor::SubtensorSignedExtension::<runtime::Runtime>::new(),
pallet_commitments::CommitmentsSignedExtension::<runtime::Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(true),
);

let raw_payload = runtime::SignedPayload::from_raw(
Expand All @@ -152,6 +153,7 @@ pub fn create_benchmark_extrinsic(
(),
(),
(),
None,
),
);
let signature = raw_payload.using_encoded(|e| sender.sign(e));
Expand Down
16 changes: 16 additions & 0 deletions pallets/admin-utils/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,21 @@ mod benchmarks {
_(RawOrigin::Root, 1u16/*netuid*/, true/*enabled*/)/*set_commit_reveal_weights_enabled*/;
}

#[benchmark]
fn sudo_set_hotkey_emission_tempo() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*sudo_tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u64/*emission_tempo*/)/*set_hotkey_emission_tempo*/;
}

#[benchmark]
fn sudo_set_network_max_stake() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 1_000_000_000_000_000u64/*max_stake*/)/*sudo_set_network_max_stake*/;
}

//impl_benchmark_test_suite!(AdminUtils, crate::mock::new_test_ext(), crate::mock::Test);
}
83 changes: 83 additions & 0 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,87 @@ pub mod pallet {
T::Subtensor::ensure_subnet_owner_or_root(origin.clone(), netuid)?;
T::Subtensor::do_set_alpha_values(origin, netuid, alpha_low, alpha_high)
}

/// Sets the hotkey emission tempo.
///
/// This extrinsic allows the root account to set the hotkey emission tempo, which determines
/// the number of blocks before a hotkey drains accumulated emissions through to nominator staking accounts.
///
/// # Arguments
/// * `origin` - The origin of the call, which must be the root account.
/// * `emission_tempo` - The new emission tempo value to set.
///
/// # Emits
/// * `Event::HotkeyEmissionTempoSet` - When the hotkey emission tempo is successfully set.
///
/// # Errors
/// * `DispatchError::BadOrigin` - If the origin is not the root account.
// #[pallet::weight(T::WeightInfo::sudo_set_hotkey_emission_tempo())]
#[pallet::call_index(52)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_hotkey_emission_tempo(
origin: OriginFor<T>,
emission_tempo: u64,
) -> DispatchResult {
ensure_root(origin)?;
T::Subtensor::set_hotkey_emission_tempo(emission_tempo);
log::info!(
"HotkeyEmissionTempoSet( emission_tempo: {:?} )",
emission_tempo
);
Ok(())
}

/// Sets the maximum stake allowed for a specific network.
///
/// This function allows the root account to set the maximum stake for a given network.
/// It updates the network's maximum stake value and logs the change.
///
/// # Arguments
///
/// * `origin` - The origin of the call, which must be the root account.
/// * `netuid` - The unique identifier of the network.
/// * `max_stake` - The new maximum stake value to set.
///
/// # Returns
///
/// Returns `Ok(())` if the operation is successful, or an error if it fails.
///
/// # Example
///
///
/// # Notes
///
/// - This function can only be called by the root account.
/// - The `netuid` should correspond to an existing network.
///
/// # TODO
///
// - Consider adding a check to ensure the `netuid` corresponds to an existing network.
// - Implement a mechanism to gradually adjust the max stake to prevent sudden changes.
// #[pallet::weight(T::WeightInfo::sudo_set_network_max_stake())]
#[pallet::call_index(53)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_network_max_stake(
origin: OriginFor<T>,
netuid: u16,
max_stake: u64,
) -> DispatchResult {
// Ensure the call is made by the root account
ensure_root(origin)?;

// Set the new maximum stake for the specified network
T::Subtensor::set_network_max_stake(netuid, max_stake);

// Log the change
log::trace!(
"NetworkMaxStakeSet( netuid: {:?}, max_stake: {:?} )",
netuid,
max_stake
);

Ok(())
}
}
}

Expand Down Expand Up @@ -1137,4 +1218,6 @@ pub trait SubtensorInterface<AccountId, Balance, RuntimeOrigin> {
alpha_low: u16,
alpha_high: u16,
) -> Result<(), DispatchError>;
fn set_hotkey_emission_tempo(emission_tempo: u64);
fn set_network_max_stake(netuid: u16, max_stake: u64);
}
1 change: 0 additions & 1 deletion pallets/admin-utils/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ pub trait WeightInfo {
fn sudo_set_tempo() -> Weight;
fn sudo_set_commit_reveal_weights_interval() -> Weight;
fn sudo_set_commit_reveal_weights_enabled() -> Weight;

}

/// Weights for `pallet_admin_utils` using the Substrate node and recommended hardware.
Expand Down
13 changes: 11 additions & 2 deletions pallets/admin-utils/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ parameter_types! {
pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
pub const InitialBaseDifficulty: u64 = 10_000; // Base difficulty
pub const InitialHotkeyEmissionTempo: u64 = 1;
pub const InitialNetworkMaxStake: u64 = 500_000_000_000_000; // 500_000 TAO
}

impl pallet_subtensor::Config for Test {
Expand Down Expand Up @@ -170,7 +171,8 @@ impl pallet_subtensor::Config for Test {
type AlphaHigh = InitialAlphaHigh;
type AlphaLow = InitialAlphaLow;
type LiquidAlphaOn = InitialLiquidAlphaOn;
type InitialBaseDifficulty = InitialBaseDifficulty;
type InitialHotkeyEmissionTempo = InitialHotkeyEmissionTempo;
type InitialNetworkMaxStake = InitialNetworkMaxStake;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
Expand Down Expand Up @@ -477,6 +479,13 @@ impl pallet_admin_utils::SubtensorInterface<AccountId, Balance, RuntimeOrigin> f
fn set_liquid_alpha_enabled(netuid: u16, enabled: bool) {
SubtensorModule::set_liquid_alpha_enabled(netuid, enabled);
}
fn set_hotkey_emission_tempo(emission_tempo: u64) {
SubtensorModule::set_hotkey_emission_tempo(emission_tempo)
}
fn set_network_max_stake(netuid: u16, max_stake: u64) {
SubtensorModule::set_network_max_stake(netuid, max_stake)
}

fn do_set_alpha_values(
origin: RuntimeOrigin,
netuid: u16,
Expand Down
4 changes: 2 additions & 2 deletions pallets/admin-utils/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use frame_support::{
use frame_system::Config;
use pallet_admin_utils::Error;
use pallet_subtensor::Error as SubtensorError;
use pallet_subtensor::{migration, Event};
use pallet_subtensor::{migrations, Event};
use sp_core::U256;

mod mock;
Expand Down Expand Up @@ -1232,7 +1232,7 @@ fn test_sudo_get_set_alpha() {

// Enable Liquid Alpha and setup
SubtensorModule::set_liquid_alpha_enabled(netuid, true);
migration::migrate_create_root_network::<Test>();
migrations::migrate_create_root_network::migrate_create_root_network::<Test>();
SubtensorModule::add_balance_to_coldkey_account(&coldkey, 1_000_000_000_000_000);
assert_ok!(SubtensorModule::root_register(signer.clone(), hotkey,));
assert_ok!(SubtensorModule::add_stake(signer.clone(), hotkey, 1000));
Expand Down
Loading
Loading