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

Documentation improvement for runtime #400

Merged
merged 33 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
68ed802
add doc for call
open-junius May 8, 2024
46b350d
add comments
open-junius May 8, 2024
ebebd21
add commitments pallet
open-junius May 8, 2024
7936383
add registry pallet
open-junius May 8, 2024
81ce10e
start subtensor pallet
open-junius May 8, 2024
60f1e67
fix more docs
open-junius May 9, 2024
83dabf9
fix doc check
open-junius May 9, 2024
1260934
remove '
open-junius May 9, 2024
627ca4d
Merge branch 'development' into junius/doc-improvement
open-junius May 10, 2024
45c09da
add
open-junius May 11, 2024
3c29a06
place holder for doc
open-junius May 11, 2024
fffc6cb
correct format
open-junius May 11, 2024
f8a4839
more correct doc
open-junius May 12, 2024
79d9dc0
docs done
open-junius May 12, 2024
c4e0903
revert update
open-junius May 12, 2024
dc2396c
merge with development
open-junius May 13, 2024
81b8400
update wrong error code
open-junius May 13, 2024
ede6d4c
fix some docs
open-junius May 14, 2024
751143d
better error desc
open-junius May 14, 2024
8bd62d3
fix test
open-junius May 14, 2024
bc563ca
fix two function doc
open-junius May 14, 2024
cae140e
remove some unused errors
open-junius May 14, 2024
e905e63
remove more unused errors
open-junius May 14, 2024
d4464ed
remove unused errors
open-junius May 14, 2024
4ee2aab
more doc for function
open-junius May 14, 2024
c3450f3
add docs for function
open-junius May 14, 2024
05f922a
fix doc error
open-junius May 14, 2024
564509e
more function doc
open-junius May 14, 2024
c531371
merge with development
open-junius May 14, 2024
d77316f
correct format doc
open-junius May 14, 2024
bed6568
update wrong format doc
open-junius May 15, 2024
5cf85a9
remove tab
open-junius May 15, 2024
250625c
remove tab
open-junius May 15, 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
204 changes: 162 additions & 42 deletions pallets/admin-utils/src/lib.rs

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions pallets/admin-utils/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn test_sudo_set_min_difficulty() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_min_difficulty(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_min_difficulty(
Expand Down Expand Up @@ -107,7 +107,7 @@ fn test_sudo_set_max_difficulty() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_max_difficulty(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_max_difficulty(
Expand Down Expand Up @@ -140,7 +140,7 @@ fn test_sudo_set_weights_version_key() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_weights_version_key(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_weights_version_key(
Expand Down Expand Up @@ -173,7 +173,7 @@ fn test_sudo_set_weights_set_rate_limit() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(
SubtensorModule::get_weights_set_rate_limit(netuid),
Expand Down Expand Up @@ -212,7 +212,7 @@ fn test_sudo_set_adjustment_interval() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_adjustment_interval(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_adjustment_interval(
Expand Down Expand Up @@ -245,7 +245,7 @@ fn test_sudo_set_adjustment_alpha() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_adjustment_alpha(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_adjustment_alpha(
Expand Down Expand Up @@ -299,7 +299,7 @@ fn test_sudo_set_max_weight_limit() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_max_weight_limit(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_max_weight_limit(
Expand Down Expand Up @@ -351,7 +351,7 @@ fn test_sudo_set_immunity_period() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_immunity_period(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_immunity_period(
Expand Down Expand Up @@ -384,7 +384,7 @@ fn test_sudo_set_min_allowed_weights() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_min_allowed_weights(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_min_allowed_weights(
Expand Down Expand Up @@ -417,7 +417,7 @@ fn test_sudo_set_max_allowed_uids() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_max_allowed_uids(
Expand Down Expand Up @@ -450,7 +450,7 @@ fn test_sudo_set_and_decrease_max_allowed_uids() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_max_allowed_uids(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_max_allowed_uids(
Expand Down Expand Up @@ -487,7 +487,7 @@ fn test_sudo_set_kappa() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_kappa(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_kappa(
Expand Down Expand Up @@ -520,7 +520,7 @@ fn test_sudo_set_rho() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_rho(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_rho(
Expand Down Expand Up @@ -553,7 +553,7 @@ fn test_sudo_set_activity_cutoff() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_activity_cutoff(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_activity_cutoff(
Expand Down Expand Up @@ -586,7 +586,7 @@ fn test_sudo_set_target_registrations_per_interval() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(
SubtensorModule::get_target_registrations_per_interval(netuid),
Expand Down Expand Up @@ -625,7 +625,7 @@ fn test_sudo_set_difficulty() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_difficulty_as_u64(netuid), init_value);
assert_ok!(AdminUtils::sudo_set_difficulty(
Expand Down Expand Up @@ -658,7 +658,7 @@ fn test_sudo_set_max_allowed_validators() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(
SubtensorModule::get_max_allowed_validators(netuid),
Expand Down Expand Up @@ -718,7 +718,7 @@ fn test_sudo_set_bonds_moving_average() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(
SubtensorModule::get_bonds_moving_average(netuid),
Expand Down Expand Up @@ -758,7 +758,7 @@ fn test_sudo_set_rao_recycled() {
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_rao_recycled(netuid), init_value);

Expand Down
34 changes: 29 additions & 5 deletions pallets/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub struct Votes<AccountId, BlockNumber> {
/// The hard end time of this vote.
end: BlockNumber,
}

#[deny(missing_docs)]
#[frame_support::pallet]
pub mod pallet {
use super::*;
Expand Down Expand Up @@ -228,7 +228,9 @@ pub mod pallet {

#[pallet::genesis_config]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
/// The phantom just for type place holder.
pub phantom: PhantomData<I>,
/// The initial members of the collective.
pub members: Vec<T::AccountId>,
}

Expand Down Expand Up @@ -300,45 +302,67 @@ pub mod pallet {
/// A motion (given hash) has been proposed (by given account) with a threshold (given
/// `MemberCount`).
Proposed {
/// The account that proposed the motion.
account: T::AccountId,
/// The index of the proposal.
proposal_index: ProposalIndex,
/// The hash of the proposal.
proposal_hash: T::Hash,
/// The threshold of member for the proposal.
threshold: MemberCount,
},
/// A motion (given hash) has been voted on by given account, leaving
/// a tally (yes votes and no votes given respectively as `MemberCount`).
Voted {
/// The account that voted.
account: T::AccountId,
/// The hash of the proposal.
proposal_hash: T::Hash,
/// Whether the account voted aye.
voted: bool,
/// The number of yes votes.
yes: MemberCount,
/// The number of no votes.
no: MemberCount,
},
/// A motion was approved by the required threshold.
Approved { proposal_hash: T::Hash },
Approved {
/// The hash of the proposal.
proposal_hash: T::Hash,
},
/// A motion was not approved by the required threshold.
Disapproved { proposal_hash: T::Hash },
Disapproved {
/// The hash of the proposal.
proposal_hash: T::Hash,
},
/// A motion was executed; result will be `Ok` if it returned without error.
Executed {
/// The hash of the proposal.
proposal_hash: T::Hash,
/// The result of the execution.
result: DispatchResult,
},
/// A single member did some action; result will be `Ok` if it returned without error.
MemberExecuted {
/// The hash of the proposal.
proposal_hash: T::Hash,
/// The result of the execution.
result: DispatchResult,
},
/// A proposal was closed because its threshold was reached or after its duration was up.
Closed {
/// The hash of the proposal.
proposal_hash: T::Hash,
/// Whether the proposal was approved.
yes: MemberCount,
/// Whether the proposal was rejected.
no: MemberCount,
},
}

#[pallet::error]
pub enum Error<T, I = ()> {
/// Account is not a member
/// Account is not a member of collective
NotMember,
/// Duplicate proposals not allowed
DuplicateProposal,
Expand All @@ -348,7 +372,7 @@ pub mod pallet {
WrongIndex,
/// Duplicate vote ignored
DuplicateVote,
/// Members are already initialized!
/// Members are already initialized.
AlreadyInitialized,
/// The close call was made too early, before the end of the voting.
TooEarly,
Expand Down
19 changes: 14 additions & 5 deletions pallets/commitments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use sp_std::boxed::Box;

type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;

#[deny(missing_docs)]
#[frame_support::pallet]
pub mod pallet {
use super::*;
Expand All @@ -33,18 +33,19 @@ pub mod pallet {
// Configure the pallet by specifying the parameters and types on which it depends.
#[pallet::config]
pub trait Config: frame_system::Config {
// Because this pallet emits events, it depends on the runtime's definition of an event.
/// Because this pallet emits events, it depends on the runtime's definition of an event.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

// Currency type that will be used to place deposits on neurons
/// Currency type that will be used to place deposits on neurons
type Currency: ReservableCurrency<Self::AccountId> + Send + Sync;

// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;

/// Interface to access-limit metadata commitments
type CanCommit: CanCommit<Self::AccountId>;

/// The maximum number of additional fields that can be added to a commitment
#[pallet::constant]
type MaxFields: Get<u32>;

Expand All @@ -56,14 +57,21 @@ pub mod pallet {
#[pallet::constant]
type FieldDeposit: Get<BalanceOf<Self>>;

/// The rate limit for commitments
#[pallet::constant]
type RateLimit: Get<BlockNumberFor<Self>>;
}

#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
Commitment { netuid: u16, who: T::AccountId },
/// A commitment was set
Commitment {
/// The netuid of the commitment
netuid: u16,
/// The account
who: T::AccountId,
},
}

#[pallet::error]
Expand Down Expand Up @@ -103,6 +111,7 @@ pub mod pallet {

#[pallet::call]
impl<T: Config> Pallet<T> {
/// Set the commitment for a given netuid
#[pallet::call_index(0)]
#[pallet::weight((
T::WeightInfo::set_commitment(),
Expand Down
Loading
Loading