Skip to content

Commit 562b19e

Browse files
authored
Merge branch 'devnet-ready' into feat/roman/no-purge-flag
2 parents b003138 + a452e87 commit 562b19e

16 files changed

+3609
-3260
lines changed

Cargo.lock

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

Cargo.toml

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

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"

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" }

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));

pallets/subtensor/src/lib.rs

+34-35
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ mod registration;
4444
mod root;
4545
mod serving;
4646
mod staking;
47-
mod swap;
47+
mod swap_coldkey;
48+
mod swap_hotkey;
4849
mod uids;
4950
mod utils;
5051
mod weights;
@@ -272,7 +273,7 @@ pub mod pallet {
272273
}
273274

274275
#[pallet::storage]
275-
pub(super) type SenateRequiredStakePercentage<T> =
276+
pub type SenateRequiredStakePercentage<T> =
276277
StorageValue<_, u64, ValueQuery, DefaultSenateRequiredStakePercentage<T>>;
277278

278279
/// ============================
@@ -367,7 +368,7 @@ pub mod pallet {
367368
pub type TotalColdkeyStake<T: Config> =
368369
StorageMap<_, Identity, T::AccountId, u64, ValueQuery, DefaultAccountTake<T>>;
369370
#[pallet::storage]
370-
/// MAP (hot, cold) --> stake | Returns a tuple (u64: stakes, u64: block_number)
371+
/// MAP (hot, cold) --> u64, u64) | Returns a tuple (u64: stakes, u64: block_number)
371372
pub type TotalHotkeyColdkeyStakesThisInterval<T: Config> = StorageDoubleMap<
372373
_,
373374
Identity,
@@ -725,7 +726,7 @@ pub mod pallet {
725726
#[pallet::storage] // --- MAP ( netuid ) --> last_mechanism_step_block
726727
pub type LastMechansimStepBlock<T> =
727728
StorageMap<_, Identity, u16, u64, ValueQuery, DefaultLastMechanismStepBlock<T>>;
728-
#[pallet::storage] // --- MAP ( netuid ) --> subnet_owner
729+
#[pallet::storage] // --- MAP ( netuid ) --> (cold) subnet_owner
729730
pub type SubnetOwner<T: Config> =
730731
StorageMap<_, Identity, u16, T::AccountId, ValueQuery, DefaultSubnetOwner<T>>;
731732
#[pallet::storage] // --- MAP ( netuid ) --> subnet_locked
@@ -796,15 +797,15 @@ pub mod pallet {
796797
}
797798

798799
#[pallet::storage] // --- ITEM ( tx_rate_limit )
799-
pub(super) type TxRateLimit<T> = StorageValue<_, u64, ValueQuery, DefaultTxRateLimit<T>>;
800+
pub type TxRateLimit<T> = StorageValue<_, u64, ValueQuery, DefaultTxRateLimit<T>>;
800801
#[pallet::storage] // --- ITEM ( tx_rate_limit )
801-
pub(super) type TxDelegateTakeRateLimit<T> =
802+
pub type TxDelegateTakeRateLimit<T> =
802803
StorageValue<_, u64, ValueQuery, DefaultTxDelegateTakeRateLimit<T>>;
803-
#[pallet::storage] // --- MAP ( key ) --> last_block
804+
#[pallet::storage] // --- MAP ( hotkey ) --> last_block
804805
pub type LastTxBlock<T: Config> =
805806
StorageMap<_, Identity, T::AccountId, u64, ValueQuery, DefaultLastTxBlock<T>>;
806-
#[pallet::storage] // --- MAP ( key ) --> last_block
807-
pub(super) type LastTxBlockDelegateTake<T: Config> =
807+
#[pallet::storage] // --- MAP ( hotkey ) --> last_block
808+
pub type LastTxBlockDelegateTake<T: Config> =
808809
StorageMap<_, Identity, T::AccountId, u64, ValueQuery, DefaultLastTxBlock<T>>;
809810

810811
/// Default value for serving rate limit.
@@ -1084,41 +1085,39 @@ pub mod pallet {
10841085
StorageMap<_, Identity, u16, Vec<(T::AccountId, u64, u64)>, OptionQuery>;
10851086

10861087
#[pallet::storage] // --- DMAP ( netuid ) --> active
1087-
pub(super) type Active<T: Config> =
1088+
pub type Active<T: Config> =
10881089
StorageMap<_, Identity, u16, Vec<bool>, ValueQuery, EmptyBoolVec<T>>;
10891090
#[pallet::storage] // --- DMAP ( netuid ) --> rank
1090-
pub(super) type Rank<T: Config> =
1091-
StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
1091+
pub type Rank<T: Config> = StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
10921092
#[pallet::storage] // --- DMAP ( netuid ) --> trust
1093-
pub(super) type Trust<T: Config> =
1094-
StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
1093+
pub type Trust<T: Config> = StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
10951094
#[pallet::storage] // --- DMAP ( netuid ) --> consensus
1096-
pub(super) type Consensus<T: Config> =
1095+
pub type Consensus<T: Config> =
10971096
StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
10981097
#[pallet::storage] // --- DMAP ( netuid ) --> incentive
1099-
pub(super) type Incentive<T: Config> =
1098+
pub type Incentive<T: Config> =
11001099
StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
11011100
#[pallet::storage] // --- DMAP ( netuid ) --> dividends
1102-
pub(super) type Dividends<T: Config> =
1101+
pub type Dividends<T: Config> =
11031102
StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
11041103
#[pallet::storage] // --- DMAP ( netuid ) --> emission
1105-
pub(super) type Emission<T: Config> =
1104+
pub type Emission<T: Config> =
11061105
StorageMap<_, Identity, u16, Vec<u64>, ValueQuery, EmptyU64Vec<T>>;
11071106
#[pallet::storage] // --- DMAP ( netuid ) --> last_update
1108-
pub(super) type LastUpdate<T: Config> =
1107+
pub type LastUpdate<T: Config> =
11091108
StorageMap<_, Identity, u16, Vec<u64>, ValueQuery, EmptyU64Vec<T>>;
11101109
#[pallet::storage] // --- DMAP ( netuid ) --> validator_trust
1111-
pub(super) type ValidatorTrust<T: Config> =
1110+
pub type ValidatorTrust<T: Config> =
11121111
StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
11131112
#[pallet::storage] // --- DMAP ( netuid ) --> pruning_scores
1114-
pub(super) type PruningScores<T: Config> =
1113+
pub type PruningScores<T: Config> =
11151114
StorageMap<_, Identity, u16, Vec<u16>, ValueQuery, EmptyU16Vec<T>>;
11161115
#[pallet::storage] // --- DMAP ( netuid ) --> validator_permit
1117-
pub(super) type ValidatorPermit<T: Config> =
1116+
pub type ValidatorPermit<T: Config> =
11181117
StorageMap<_, Identity, u16, Vec<bool>, ValueQuery, EmptyBoolVec<T>>;
11191118

11201119
#[pallet::storage] // --- DMAP ( netuid, uid ) --> weights
1121-
pub(super) type Weights<T: Config> = StorageDoubleMap<
1120+
pub type Weights<T: Config> = StorageDoubleMap<
11221121
_,
11231122
Identity,
11241123
u16,
@@ -1129,7 +1128,7 @@ pub mod pallet {
11291128
DefaultWeights<T>,
11301129
>;
11311130
#[pallet::storage] // --- DMAP ( netuid, uid ) --> bonds
1132-
pub(super) type Bonds<T: Config> = StorageDoubleMap<
1131+
pub type Bonds<T: Config> = StorageDoubleMap<
11331132
_,
11341133
Identity,
11351134
u16,
@@ -2066,17 +2065,17 @@ pub mod pallet {
20662065
}
20672066

20682067
/// The extrinsic for user to change its hotkey
2069-
///#[pallet::call_index(70)]
2070-
///#[pallet::weight((Weight::from_parts(1_940_000_000, 0)
2071-
///.saturating_add(T::DbWeight::get().reads(272))
2072-
///.saturating_add(T::DbWeight::get().writes(527)), DispatchClass::Operational, Pays::No))]
2073-
///pub fn swap_hotkey(
2074-
/// origin: OriginFor<T>,
2075-
/// hotkey: T::AccountId,
2076-
/// new_hotkey: T::AccountId,
2077-
///) -> DispatchResultWithPostInfo {
2078-
/// Self::do_swap_hotkey(origin, &hotkey, &new_hotkey)
2079-
///}
2068+
#[pallet::call_index(70)]
2069+
#[pallet::weight((Weight::from_parts(1_940_000_000, 0)
2070+
.saturating_add(T::DbWeight::get().reads(272))
2071+
.saturating_add(T::DbWeight::get().writes(527)), DispatchClass::Operational, Pays::No))]
2072+
pub fn swap_hotkey(
2073+
origin: OriginFor<T>,
2074+
hotkey: T::AccountId,
2075+
new_hotkey: T::AccountId,
2076+
) -> DispatchResultWithPostInfo {
2077+
Self::do_swap_hotkey(origin, &hotkey, &new_hotkey)
2078+
}
20802079

20812080
/// The extrinsic for user to change the coldkey associated with their account.
20822081
///

0 commit comments

Comments
 (0)