Skip to content

Commit e8ffa80

Browse files
committed
Merge branch 'devnet-ready' into serve-axon-promethoeus
2 parents d3b97d3 + bf6896f commit e8ffa80

Some content is hidden

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

52 files changed

+3415
-2951
lines changed

.github/workflows/benchmark-weights.yml

Whitespace-only changes.

Cargo.lock

Lines changed: 741 additions & 1146 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/admin-utils/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,26 @@ pub mod pallet {
12871287
ensure_root(origin)?;
12881288
T::Grandpa::schedule_change(next_authorities, in_blocks, forced)
12891289
}
1290+
1291+
/// Enables or disables Liquid Alpha for a given subnet.
1292+
///
1293+
/// # Parameters
1294+
/// - `origin`: The origin of the call, which must be the root account or subnet owner.
1295+
/// - `netuid`: The unique identifier for the subnet.
1296+
/// - `enabled`: A boolean flag to enable or disable Liquid Alpha.
1297+
///
1298+
/// # Weight
1299+
/// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees.
1300+
#[pallet::call_index(61)]
1301+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1302+
pub fn sudo_set_toggle_transfer(
1303+
origin: OriginFor<T>,
1304+
netuid: u16,
1305+
toggle: bool,
1306+
) -> DispatchResult {
1307+
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
1308+
pallet_subtensor::Pallet::<T>::toggle_transfer(netuid, toggle)
1309+
}
12901310
}
12911311
}
12921312

pallets/admin-utils/src/tests/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ parameter_types! {
100100
pub const InitialTxDelegateTakeRateLimit: u64 = 0; // Disable rate limit for testing
101101
pub const InitialTxChildKeyTakeRateLimit: u64 = 0; // Disable rate limit for testing
102102
pub const InitialBurn: u64 = 0;
103-
pub const InitialMinBurn: u64 = 0;
103+
pub const InitialMinBurn: u64 = 500_000;
104104
pub const InitialMaxBurn: u64 = 1_000_000_000;
105105
pub const InitialValidatorPruneLen: u64 = 0;
106106
pub const InitialScalingLawPower: u16 = 50;

pallets/subtensor/rpc/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ publish = false
1212
workspace = true
1313

1414
[dependencies]
15-
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
16-
"derive",
17-
] }
15+
codec = { workspace = true }
1816
jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] }
1917
serde = { workspace = true, features = ["derive"] }
2018

pallets/subtensor/rpc/src/lib.rs

Lines changed: 128 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//! RPC interface for the custom Subtensor rpc methods
22
3+
use codec::{Decode, Encode};
34
use jsonrpsee::{
45
core::RpcResult,
56
proc_macros::rpc,
67
types::{error::ErrorObject, ErrorObjectOwned},
78
};
89
use sp_blockchain::HeaderBackend;
9-
use sp_runtime::traits::Block as BlockT;
10+
use sp_runtime::{traits::Block as BlockT, AccountId32};
1011
use std::sync::Arc;
1112

1213
use sp_api::ProvideRuntimeApi;
@@ -116,9 +117,12 @@ where
116117
let api = self.client.runtime_api();
117118
let at = at.unwrap_or_else(|| self.client.info().best_hash);
118119

119-
api.get_delegates(at).map_err(|e| {
120-
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into()
121-
})
120+
match api.get_delegates(at) {
121+
Ok(result) => Ok(result.encode()),
122+
Err(e) => {
123+
Err(Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into())
124+
}
125+
}
122126
}
123127

124128
fn get_delegate(
@@ -129,9 +133,20 @@ where
129133
let api = self.client.runtime_api();
130134
let at = at.unwrap_or_else(|| self.client.info().best_hash);
131135

132-
api.get_delegate(at, delegate_account_vec).map_err(|e| {
133-
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into()
134-
})
136+
let delegate_account = match AccountId32::decode(&mut &delegate_account_vec[..]) {
137+
Ok(delegate_account) => delegate_account,
138+
Err(e) => {
139+
return Err(
140+
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into(),
141+
)
142+
}
143+
};
144+
match api.get_delegate(at, delegate_account) {
145+
Ok(result) => Ok(result.encode()),
146+
Err(e) => {
147+
Err(Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into())
148+
}
149+
}
135150
}
136151

137152
fn get_delegated(
@@ -142,9 +157,20 @@ where
142157
let api = self.client.runtime_api();
143158
let at = at.unwrap_or_else(|| self.client.info().best_hash);
144159

145-
api.get_delegated(at, delegatee_account_vec).map_err(|e| {
146-
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into()
147-
})
160+
let delegatee_account = match AccountId32::decode(&mut &delegatee_account_vec[..]) {
161+
Ok(delegatee_account) => delegatee_account,
162+
Err(e) => {
163+
return Err(
164+
Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into(),
165+
)
166+
}
167+
};
168+
match api.get_delegated(at, delegatee_account) {
169+
Ok(result) => Ok(result.encode()),
170+
Err(e) => {
171+
Err(Error::RuntimeError(format!("Unable to get delegates info: {:?}", e)).into())
172+
}
173+
}
148174
}
149175

150176
fn get_neurons_lite(
@@ -155,9 +181,12 @@ where
155181
let api = self.client.runtime_api();
156182
let at = at.unwrap_or_else(|| self.client.info().best_hash);
157183

158-
api.get_neurons_lite(at, netuid).map_err(|e| {
159-
Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into()
160-
})
184+
match api.get_neurons_lite(at, netuid) {
185+
Ok(result) => Ok(result.encode()),
186+
Err(e) => {
187+
Err(Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into())
188+
}
189+
}
161190
}
162191

163192
fn get_neuron_lite(
@@ -169,17 +198,24 @@ where
169198
let api = self.client.runtime_api();
170199
let at = at.unwrap_or_else(|| self.client.info().best_hash);
171200

172-
api.get_neuron_lite(at, netuid, uid).map_err(|e| {
173-
Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into()
174-
})
201+
match api.get_neuron_lite(at, netuid, uid) {
202+
Ok(result) => Ok(result.encode()),
203+
Err(e) => {
204+
Err(Error::RuntimeError(format!("Unable to get neurons lite info: {:?}", e)).into())
205+
}
206+
}
175207
}
176208

177209
fn get_neurons(&self, netuid: u16, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
178210
let api = self.client.runtime_api();
179211
let at = at.unwrap_or_else(|| self.client.info().best_hash);
180212

181-
api.get_neurons(at, netuid)
182-
.map_err(|e| Error::RuntimeError(format!("Unable to get neurons info: {:?}", e)).into())
213+
match api.get_neurons(at, netuid) {
214+
Ok(result) => Ok(result.encode()),
215+
Err(e) => {
216+
Err(Error::RuntimeError(format!("Unable to get neurons info: {:?}", e)).into())
217+
}
218+
}
183219
}
184220

185221
fn get_neuron(
@@ -191,8 +227,12 @@ where
191227
let api = self.client.runtime_api();
192228
let at = at.unwrap_or_else(|| self.client.info().best_hash);
193229

194-
api.get_neuron(at, netuid, uid)
195-
.map_err(|e| Error::RuntimeError(format!("Unable to get neuron info: {:?}", e)).into())
230+
match api.get_neuron(at, netuid, uid) {
231+
Ok(result) => Ok(result.encode()),
232+
Err(e) => {
233+
Err(Error::RuntimeError(format!("Unable to get neuron info: {:?}", e)).into())
234+
}
235+
}
196236
}
197237

198238
fn get_subnet_info(
@@ -203,8 +243,12 @@ where
203243
let api = self.client.runtime_api();
204244
let at = at.unwrap_or_else(|| self.client.info().best_hash);
205245

206-
api.get_subnet_info(at, netuid)
207-
.map_err(|e| Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
246+
match api.get_subnet_info(at, netuid) {
247+
Ok(result) => Ok(result.encode()),
248+
Err(e) => {
249+
Err(Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
250+
}
251+
}
208252
}
209253

210254
fn get_subnet_hyperparams(
@@ -215,23 +259,36 @@ where
215259
let api = self.client.runtime_api();
216260
let at = at.unwrap_or_else(|| self.client.info().best_hash);
217261

218-
api.get_subnet_hyperparams(at, netuid)
219-
.map_err(|e| Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
262+
match api.get_subnet_hyperparams(at, netuid) {
263+
Ok(result) => Ok(result.encode()),
264+
Err(e) => {
265+
Err(Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
266+
}
267+
}
220268
}
221269

222270
fn get_all_dynamic_info(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
223271
let api = self.client.runtime_api();
224272
let at = at.unwrap_or_else(|| self.client.info().best_hash);
225-
api.get_all_dynamic_info(at).map_err(|e| {
226-
Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()
227-
})
273+
274+
match api.get_all_dynamic_info(at) {
275+
Ok(result) => Ok(result.encode()),
276+
Err(e) => Err(Error::RuntimeError(format!(
277+
"Unable to get dynamic subnets info: {:?}",
278+
e
279+
))
280+
.into()),
281+
}
228282
}
229283

230284
fn get_all_metagraphs(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
231285
let api = self.client.runtime_api();
232286
let at = at.unwrap_or_else(|| self.client.info().best_hash);
233-
api.get_all_metagraphs(at)
234-
.map_err(|e| Error::RuntimeError(format!("Unable to get metagraps: {:?}", e)).into())
287+
288+
match api.get_all_metagraphs(at) {
289+
Ok(result) => Ok(result.encode()),
290+
Err(e) => Err(Error::RuntimeError(format!("Unable to get metagraps: {:?}", e)).into()),
291+
}
235292
}
236293

237294
fn get_dynamic_info(
@@ -241,9 +298,15 @@ where
241298
) -> RpcResult<Vec<u8>> {
242299
let api = self.client.runtime_api();
243300
let at = at.unwrap_or_else(|| self.client.info().best_hash);
244-
api.get_dynamic_info(at, netuid).map_err(|e| {
245-
Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()
246-
})
301+
302+
match api.get_dynamic_info(at, netuid) {
303+
Ok(result) => Ok(result.encode()),
304+
Err(e) => Err(Error::RuntimeError(format!(
305+
"Unable to get dynamic subnets info: {:?}",
306+
e
307+
))
308+
.into()),
309+
}
247310
}
248311

249312
fn get_metagraph(
@@ -253,9 +316,14 @@ where
253316
) -> RpcResult<Vec<u8>> {
254317
let api = self.client.runtime_api();
255318
let at = at.unwrap_or_else(|| self.client.info().best_hash);
256-
api.get_metagraph(at, netuid).map_err(|e| {
257-
Error::RuntimeError(format!("Unable to get dynamic subnets info: {:?}", e)).into()
258-
})
319+
match api.get_metagraph(at, netuid) {
320+
Ok(result) => Ok(result.encode()),
321+
Err(e) => Err(Error::RuntimeError(format!(
322+
"Unable to get dynamic subnets info: {:?}",
323+
e
324+
))
325+
.into()),
326+
}
259327
}
260328

261329
fn get_subnet_state(
@@ -265,17 +333,25 @@ where
265333
) -> RpcResult<Vec<u8>> {
266334
let api = self.client.runtime_api();
267335
let at = at.unwrap_or_else(|| self.client.info().best_hash);
268-
api.get_subnet_state(at, netuid).map_err(|e| {
269-
Error::RuntimeError(format!("Unable to get subnet state info: {:?}", e)).into()
270-
})
336+
337+
match api.get_subnet_state(at, netuid) {
338+
Ok(result) => Ok(result.encode()),
339+
Err(e) => {
340+
Err(Error::RuntimeError(format!("Unable to get subnet state info: {:?}", e)).into())
341+
}
342+
}
271343
}
272344

273345
fn get_subnets_info(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
274346
let api = self.client.runtime_api();
275347
let at = at.unwrap_or_else(|| self.client.info().best_hash);
276348

277-
api.get_subnets_info(at)
278-
.map_err(|e| Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
349+
match api.get_subnets_info(at) {
350+
Ok(result) => Ok(result.encode()),
351+
Err(e) => {
352+
Err(Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
353+
}
354+
}
279355
}
280356

281357
fn get_subnet_info_v2(
@@ -286,16 +362,24 @@ where
286362
let api = self.client.runtime_api();
287363
let at = at.unwrap_or_else(|| self.client.info().best_hash);
288364

289-
api.get_subnet_info_v2(at, netuid)
290-
.map_err(|e| Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
365+
match api.get_subnet_info_v2(at, netuid) {
366+
Ok(result) => Ok(result.encode()),
367+
Err(e) => {
368+
Err(Error::RuntimeError(format!("Unable to get subnet info: {:?}", e)).into())
369+
}
370+
}
291371
}
292372

293373
fn get_subnets_info_v2(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<Vec<u8>> {
294374
let api = self.client.runtime_api();
295375
let at = at.unwrap_or_else(|| self.client.info().best_hash);
296376

297-
api.get_subnets_info_v2(at)
298-
.map_err(|e| Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
377+
match api.get_subnets_info_v2(at) {
378+
Ok(result) => Ok(result.encode()),
379+
Err(e) => {
380+
Err(Error::RuntimeError(format!("Unable to get subnets info: {:?}", e)).into())
381+
}
382+
}
299383
}
300384

301385
fn get_network_lock_cost(&self, at: Option<<Block as BlockT>::Hash>) -> RpcResult<u64> {

pallets/subtensor/runtime-api/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ workspace = true
1313

1414
[dependencies]
1515
sp-api = { workspace = true }
16+
sp-runtime = { workspace = true }
1617
frame-support = { workspace = true }
1718
serde = { workspace = true, features = ["derive"] }
18-
19+
codec = { workspace = true }
1920
# local
2021
pallet-subtensor = { version = "4.0.0-dev", path = "../../subtensor", default-features = false }
2122

2223
[features]
2324
default = ["std"]
2425
std = [
2526
"sp-api/std",
27+
"sp-runtime/std",
2628
"frame-support/std",
2729
"pallet-subtensor/std",
28-
"serde/std"
30+
"serde/std",
31+
"codec/std"
2932
]
3033
pow-faucet = []

0 commit comments

Comments
 (0)