Skip to content

Chain bloat #541

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

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
0281700
initial commit
Jun 15, 2024
c7a114b
initial commit
Jun 15, 2024
5ccb2bc
add comments
Jun 16, 2024
46b5522
add comments
Jun 16, 2024
2ca9071
add comments
Jun 16, 2024
7ff9b11
clean coinbase
Jun 16, 2024
d5680c3
clean chain bloat further
Jun 16, 2024
5d240fa
clean chain bloat further
Jun 16, 2024
8aca0bb
clean chain bloat further
Jun 16, 2024
aad5478
clean build no warnings
Jun 16, 2024
9bc4dca
fix unsafe math
open-junius Jun 17, 2024
45ea7f6
use safe math
open-junius Jun 17, 2024
d47590a
fix more unsafe math
open-junius Jun 17, 2024
231cc88
fix all unsafe math
open-junius Jun 17, 2024
70ec3c6
add todo
Jun 17, 2024
5b8141d
add todo
Jun 17, 2024
1062fb6
testable now
open-junius Jun 17, 2024
7fa36e4
tests
Jun 17, 2024
9d4de66
merge remote
Jun 17, 2024
15cc368
add child tests
Jun 17, 2024
ea9aa97
add children tests
Jun 18, 2024
3e97db1
fix compile errors
Jun 18, 2024
f1f1dc0
sd: children tests plus getters
Jun 18, 2024
2b040c8
chore: remove comment
Jun 18, 2024
083b5cd
add comments
Jun 18, 2024
7fb0cf6
Merge branch 'chain_bloat' of https://github.com/opentensor/subtensor…
Jun 19, 2024
ca41be6
add coinbase test
Jun 19, 2024
f6e2b8a
add coinbase test
Jun 19, 2024
784a28a
fix tests add new ones for chain bloat
Jun 19, 2024
d673a57
add owner cut
Jun 19, 2024
4802671
add safe math
Jun 19, 2024
25fae32
feat: revoke childkey , childkey extrinsics , tests , intial benchmar…
Jun 19, 2024
46eea19
feat: lints , tests , gettter , setters
Jun 20, 2024
deb4908
feat: benchmarking set_hotkey_emission_tempo, clippy
Jun 22, 2024
26908c3
feat: set children multiple + tests
Jun 23, 2024
b33f55a
feat: revoke multiple children + tests
Jun 23, 2024
03b1131
feat: started test_comprehensive_coinbase
Jun 23, 2024
576b20f
feat: check for self loops via dfs in children
Jun 24, 2024
7d26751
feat: full coinbase test
Jun 25, 2024
0d371bc
feat: caps , cap tests
Jun 26, 2024
b480518
feat: child_info rpc
Jun 27, 2024
2c5f6e6
chore: fix rpcs , tests
Jun 27, 2024
2368e61
chore: lint
Jun 27, 2024
6dceea5
feat: add Parents to child info
Jun 27, 2024
d85d11b
fix: sat maths
Jun 28, 2024
09ebd25
feat: enforce proportions to 1
Jul 1, 2024
71ca55e
add do_set_delegate_takes
open-junius Jul 1, 2024
8a56833
fix conflict
open-junius Jul 1, 2024
fb8231a
fix fmt
open-junius Jul 1, 2024
8535dcf
optimize the impl
open-junius Jul 1, 2024
e0f2c2b
fix clippy
open-junius Jul 1, 2024
17889ec
fix unit test
open-junius Jul 1, 2024
2de784a
Merge branch 'main' into chain_bloat
distributedstatemachine Jul 1, 2024
42763ae
fix compilation error
open-junius Jul 2, 2024
d5c5a77
fix test_get_children_info
open-junius Jul 2, 2024
ae628b8
add duplicate child check
open-junius Jul 2, 2024
bd0acfd
merge with main
open-junius Jul 5, 2024
feaa4b2
merge with main
open-junius Jul 5, 2024
122c021
fix clippy
open-junius Jul 5, 2024
85fafe6
fix clippy
open-junius Jul 5, 2024
b761d37
fix clippy
open-junius Jul 5, 2024
7641f15
fix unit test
open-junius Jul 5, 2024
feb1a42
fix justfile
open-junius Jul 5, 2024
7d68716
rebase code
open-junius Jul 10, 2024
8aaac52
trigger ci
open-junius Jul 11, 2024
2a94385
merge with main
open-junius Jul 16, 2024
aeeb039
remove commented code
open-junius Jul 16, 2024
3430b08
fix unit test
open-junius Jul 16, 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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Requirements:

---

## For Subnet Development
## For Subnet Development

If you are developing and testing subnet incentive mechanism, you will need to run a local subtensor node. Follow the detailed step-by-step instructions provided in the document [Running subtensor locally](./docs/running-subtensor-locally.md) to run either a lite node or an archive node. Also see the [**Subtensor Nodes** section in Bittensor Developer Documentation](https://docs.bittensor.com/subtensor-nodes).

Expand Down Expand Up @@ -216,7 +216,7 @@ If you want to see the multi-node consensus algorithm in action, refer to our
A Substrate project such as this consists of a number of components that are spread across a few
directories.

### Node Capabilities
### Node Capabilities

A blockchain node is an application that allows users to participate in a blockchain network.
Substrate-based blockchain nodes expose a number of capabilities:
Expand All @@ -232,7 +232,7 @@ Substrate-based blockchain nodes expose a number of capabilities:

**Directory structure**

There are several files in the [`node`](./node/) directory. Make a note of the following important files:
There are several files in the [`node`](./node/) directory. Make a note of the following important files:

- [`chain_spec.rs`](./node/src/chain_spec.rs): A
[chain specification](https://docs.substrate.io/main-docs/build/chain-spec/) is a
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ lint:
@echo "Running cargo clippy with automatic fixes on potentially dirty code..."
just clippy-fix
@echo "Running cargo clippy..."
just clippy
just clippy
1 change: 1 addition & 0 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ where
C::Api: subtensor_custom_rpc_runtime_api::NeuronInfoRuntimeApi<Block>,
C::Api: subtensor_custom_rpc_runtime_api::SubnetInfoRuntimeApi<Block>,
C::Api: subtensor_custom_rpc_runtime_api::SubnetRegistrationRuntimeApi<Block>,
C::Api: subtensor_custom_rpc_runtime_api::ChildrenInfoRuntimeApi<Block>,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
P: TransactionPool + 'static,
{
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);
}
81 changes: 81 additions & 0 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,85 @@ 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::call_index(52)]
#[pallet::weight(T::WeightInfo::sudo_set_hotkey_emission_tempo())]
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::call_index(53)]
#[pallet::weight(T::WeightInfo::sudo_set_network_max_stake())]
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 @@ -1130,6 +1209,8 @@ pub trait SubtensorInterface<AccountId, Balance, RuntimeOrigin> {
fn set_target_stakes_per_interval(target_stakes_per_interval: u64);
fn set_commit_reveal_weights_interval(netuid: u16, interval: u64);
fn set_commit_reveal_weights_enabled(netuid: u16, enabled: bool);
fn set_hotkey_emission_tempo(emission_tempo: u64);
fn set_network_max_stake(netuid: u16, max_stake: u64);
fn set_liquid_alpha_enabled(netuid: u16, enabled: bool);
fn do_set_alpha_values(
origin: RuntimeOrigin,
Expand Down
Loading
Loading