Skip to content

Commit 0bcd855

Browse files
committed
merge devnet-ready
2 parents 2456428 + fd96f59 commit 0bcd855

Some content is hidden

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

57 files changed

+6173
-3381
lines changed

.github/workflows/benchmark-weights.yml

Whitespace-only changes.

Cargo.lock

Lines changed: 715 additions & 1120 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: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,26 @@ pub mod pallet {
13281328
T::Grandpa::schedule_change(next_authorities, in_blocks, forced)
13291329
}
13301330

1331+
/// Enables or disables Liquid Alpha for a given subnet.
1332+
///
1333+
/// # Parameters
1334+
/// - `origin`: The origin of the call, which must be the root account or subnet owner.
1335+
/// - `netuid`: The unique identifier for the subnet.
1336+
/// - `enabled`: A boolean flag to enable or disable Liquid Alpha.
1337+
///
1338+
/// # Weight
1339+
/// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees.
1340+
#[pallet::call_index(61)]
1341+
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
1342+
pub fn sudo_set_toggle_transfer(
1343+
origin: OriginFor<T>,
1344+
netuid: u16,
1345+
toggle: bool,
1346+
) -> DispatchResult {
1347+
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
1348+
pallet_subtensor::Pallet::<T>::toggle_transfer(netuid, toggle)
1349+
}
1350+
13311351
/// Toggles the enablement of an EVM precompile.
13321352
///
13331353
/// # Arguments
@@ -1340,7 +1360,7 @@ pub mod pallet {
13401360
///
13411361
/// # Weight
13421362
/// Weight is handled by the `#[pallet::weight]` attribute.
1343-
#[pallet::call_index(61)]
1363+
#[pallet::call_index(62)]
13441364
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
13451365
pub fn sudo_toggle_evm_precompile(
13461366
origin: OriginFor<T>,

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/collective/src/benchmarking.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ benchmarks_instance_pallet! {
315315
// Whitelist voter account from further DB operations.
316316
let voter_key = frame_system::Account::<T>::hashed_key_for(&voter);
317317
frame_benchmarking::benchmarking::add_to_whitelist(voter_key.into());
318-
}: close(SystemOrigin::Signed(voter), last_hash, index, Weight::MAX, bytes_in_storage)
318+
}: close(SystemOrigin::Root, last_hash, index, Weight::MAX, bytes_in_storage)
319319
verify {
320320
// The last proposal is removed.
321321
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
@@ -393,7 +393,7 @@ benchmarks_instance_pallet! {
393393
index, approve,
394394
)?;
395395

396-
}: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage)
396+
}: close(SystemOrigin::Root, last_hash, index, Weight::MAX, bytes_in_storage)
397397
verify {
398398
// The last proposal is removed.
399399
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
@@ -473,7 +473,7 @@ benchmarks_instance_pallet! {
473473
assert_eq!(Collective::<T, I>::proposals().len(), p as usize);
474474

475475
// Prime nay will close it as disapproved
476-
}: close(SystemOrigin::Signed(caller), last_hash, index, Weight::MAX, bytes_in_storage)
476+
}: close(SystemOrigin::Root, last_hash, index, Weight::MAX, bytes_in_storage)
477477
verify {
478478
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
479479
assert_last_event::<T, I>(Event::Disapproved { proposal_hash: last_hash }.into());
@@ -542,7 +542,7 @@ benchmarks_instance_pallet! {
542542
assert_eq!(Collective::<T, I>::proposals().len(), p as usize);
543543

544544
// Prime aye will close it as approved
545-
}: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::MAX, bytes_in_storage)
545+
}: close(SystemOrigin::Root, last_hash, p - 1, Weight::MAX, bytes_in_storage)
546546
verify {
547547
assert_eq!(Collective::<T, I>::proposals().len(), (p - 1) as usize);
548548
assert_last_event::<T, I>(Event::Executed { proposal_hash: last_hash, result: Ok(()) }.into());

pallets/collective/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ pub mod pallet {
666666
proposal_weight_bound: Weight,
667667
#[pallet::compact] length_bound: u32,
668668
) -> DispatchResultWithPostInfo {
669-
let _ = ensure_signed(origin)?;
669+
ensure_root(origin)?;
670670

671671
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
672672
}

pallets/collective/src/tests.rs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ fn close_works() {
299299
System::set_block_number(3);
300300
assert_noop!(
301301
Collective::close(
302-
RuntimeOrigin::signed(4),
302+
RuntimeOrigin::root(),
303303
hash,
304304
0,
305305
proposal_weight,
@@ -310,7 +310,7 @@ fn close_works() {
310310

311311
System::set_block_number(4);
312312
assert_ok!(Collective::close(
313-
RuntimeOrigin::signed(4),
313+
RuntimeOrigin::root(),
314314
hash,
315315
0,
316316
proposal_weight,
@@ -370,7 +370,7 @@ fn proposal_weight_limit_works_on_approve() {
370370
System::set_block_number(4);
371371
assert_noop!(
372372
Collective::close(
373-
RuntimeOrigin::signed(4),
373+
RuntimeOrigin::root(),
374374
hash,
375375
0,
376376
proposal_weight - Weight::from_parts(100, 0),
@@ -379,7 +379,7 @@ fn proposal_weight_limit_works_on_approve() {
379379
Error::<Test, Instance1>::ProposalWeightLessThanDispatchCallWeight
380380
);
381381
assert_ok!(Collective::close(
382-
RuntimeOrigin::signed(4),
382+
RuntimeOrigin::root(),
383383
hash,
384384
0,
385385
proposal_weight,
@@ -409,7 +409,7 @@ fn proposal_weight_limit_ignored_on_disapprove() {
409409
// No votes, this proposal wont pass
410410
System::set_block_number(4);
411411
assert_ok!(Collective::close(
412-
RuntimeOrigin::signed(4),
412+
RuntimeOrigin::root(),
413413
hash,
414414
0,
415415
proposal_weight - Weight::from_parts(100, 0),
@@ -442,7 +442,7 @@ fn close_with_prime_works() {
442442

443443
System::set_block_number(4);
444444
assert_ok!(Collective::close(
445-
RuntimeOrigin::signed(4),
445+
RuntimeOrigin::root(),
446446
hash,
447447
0,
448448
proposal_weight,
@@ -502,7 +502,7 @@ fn close_with_voting_prime_works() {
502502

503503
System::set_block_number(4);
504504
assert_ok!(Collective::close(
505-
RuntimeOrigin::signed(4),
505+
RuntimeOrigin::root(),
506506
hash,
507507
0,
508508
proposal_weight,
@@ -583,7 +583,7 @@ fn close_with_no_prime_but_majority_works() {
583583

584584
System::set_block_number(4);
585585
assert_ok!(CollectiveMajority::close(
586-
RuntimeOrigin::signed(4),
586+
RuntimeOrigin::root(),
587587
hash,
588588
0,
589589
proposal_weight,
@@ -1109,7 +1109,7 @@ fn motions_all_first_vote_free_works() {
11091109

11101110
let proposal_weight = proposal.get_dispatch_info().weight;
11111111
let close_rval: DispatchResultWithPostInfo = Collective::close(
1112-
RuntimeOrigin::signed(2),
1112+
RuntimeOrigin::root(),
11131113
hash,
11141114
0,
11151115
proposal_weight,
@@ -1120,7 +1120,7 @@ fn motions_all_first_vote_free_works() {
11201120
// Trying to close the proposal, which is already closed
11211121
// Error: "ProposalNotExists" with Pays::Yes.
11221122
let close_rval: DispatchResultWithPostInfo = Collective::close(
1123-
RuntimeOrigin::signed(2),
1123+
RuntimeOrigin::root(),
11241124
hash,
11251125
0,
11261126
proposal_weight,
@@ -1148,7 +1148,7 @@ fn motions_reproposing_disapproved_works() {
11481148
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false));
11491149

11501150
assert_ok!(Collective::close(
1151-
RuntimeOrigin::signed(2),
1151+
RuntimeOrigin::root(),
11521152
hash,
11531153
0,
11541154
proposal_weight,
@@ -1186,7 +1186,7 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
11861186
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true));
11871187
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true));
11881188
assert_ok!(Collective::close(
1189-
RuntimeOrigin::signed(2),
1189+
RuntimeOrigin::root(),
11901190
hash,
11911191
0,
11921192
proposal_weight,
@@ -1243,7 +1243,7 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() {
12431243
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 1, true));
12441244
assert_ok!(Collective::vote(RuntimeOrigin::signed(3), hash, 1, true));
12451245
assert_ok!(Collective::close(
1246-
RuntimeOrigin::signed(2),
1246+
RuntimeOrigin::root(),
12471247
hash,
12481248
1,
12491249
proposal_weight,
@@ -1315,7 +1315,7 @@ fn motions_disapproval_works() {
13151315
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, false));
13161316
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false));
13171317
assert_ok!(Collective::close(
1318-
RuntimeOrigin::signed(2),
1318+
RuntimeOrigin::root(),
13191319
hash,
13201320
0,
13211321
proposal_weight,
@@ -1374,7 +1374,7 @@ fn motions_approval_works() {
13741374
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, true));
13751375
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true));
13761376
assert_ok!(Collective::close(
1377-
RuntimeOrigin::signed(2),
1377+
RuntimeOrigin::root(),
13781378
hash,
13791379
0,
13801380
proposal_weight,
@@ -1448,7 +1448,7 @@ fn motion_with_no_votes_closes_with_disapproval() {
14481448
// an approving or disapproving simple majority due to the lack of votes.
14491449
assert_noop!(
14501450
Collective::close(
1451-
RuntimeOrigin::signed(2),
1451+
RuntimeOrigin::root(),
14521452
hash,
14531453
0,
14541454
proposal_weight,
@@ -1462,7 +1462,7 @@ fn motion_with_no_votes_closes_with_disapproval() {
14621462
System::set_block_number(closing_block);
14631463
// we can successfully close the motion.
14641464
assert_ok!(Collective::close(
1465-
RuntimeOrigin::signed(2),
1465+
RuntimeOrigin::root(),
14661466
hash,
14671467
0,
14681468
proposal_weight,
@@ -1507,25 +1507,19 @@ fn close_disapprove_does_not_care_about_weight_or_len() {
15071507
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, true));
15081508
// It will not close with bad weight/len information
15091509
assert_noop!(
1510-
Collective::close(RuntimeOrigin::signed(2), hash, 0, Weight::zero(), 0),
1510+
Collective::close(RuntimeOrigin::root(), hash, 0, Weight::zero(), 0),
15111511
Error::<Test, Instance1>::ProposalLengthBoundLessThanProposalLength,
15121512
);
15131513
assert_noop!(
1514-
Collective::close(
1515-
RuntimeOrigin::signed(2),
1516-
hash,
1517-
0,
1518-
Weight::zero(),
1519-
proposal_len
1520-
),
1514+
Collective::close(RuntimeOrigin::root(), hash, 0, Weight::zero(), proposal_len),
15211515
Error::<Test, Instance1>::ProposalWeightLessThanDispatchCallWeight,
15221516
);
15231517
// Now we make the proposal fail
15241518
assert_ok!(Collective::vote(RuntimeOrigin::signed(1), hash, 0, false));
15251519
assert_ok!(Collective::vote(RuntimeOrigin::signed(2), hash, 0, false));
15261520
// It can close even if the weight/len information is bad
15271521
assert_ok!(Collective::close(
1528-
RuntimeOrigin::signed(2),
1522+
RuntimeOrigin::root(),
15291523
hash,
15301524
0,
15311525
Weight::zero(),

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

0 commit comments

Comments
 (0)