Skip to content

Commit 6aa04cd

Browse files
committed
fix conflict
2 parents 118be96 + cd2d306 commit 6aa04cd

File tree

5 files changed

+13
-101
lines changed

5 files changed

+13
-101
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ pub mod pallet {
731731
/// It is only callable by the root account.
732732
/// The extrinsic will call the Subtensor pallet to set the target registrations per interval.
733733
#[pallet::call_index(21)]
734-
#[pallet::weight(Weight::from_parts(44_320_000, 0)
734+
#[pallet::weight(Weight::from_parts(25_980_000, 0)
735735
.saturating_add(<T as frame_system::Config>::DbWeight::get().reads(3_u64))
736736
.saturating_add(<T as frame_system::Config>::DbWeight::get().writes(1_u64)))]
737737
pub fn sudo_set_target_registrations_per_interval(

pallets/crowdloan/src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ pub mod pallet {
547547
Ok(())
548548
}
549549

550-
/// Finalize a successful crowdloan.
550+
/// Finalize crowdloan that has reached the cap.
551551
///
552552
/// The call will transfer the raised amount to the target address if it was provided when the crowdloan was created
553553
/// and dispatch the call that was provided using the creator origin. The CurrentCrowdloanId will be set to the
@@ -565,14 +565,12 @@ pub mod pallet {
565565
#[pallet::compact] crowdloan_id: CrowdloanId,
566566
) -> DispatchResult {
567567
let who = ensure_signed(origin)?;
568-
let now = frame_system::Pallet::<T>::block_number();
569568

570569
let mut crowdloan = Self::ensure_crowdloan_exists(crowdloan_id)?;
571570

572-
// Ensure the origin is the creator of the crowdloan and the crowdloan has ended,
573-
// raised the cap and is not finalized.
571+
// Ensure the origin is the creator of the crowdloan and the crowdloan has raised the cap
572+
// and is not finalized.
574573
ensure!(who == crowdloan.creator, Error::<T>::InvalidOrigin);
575-
ensure!(now >= crowdloan.end, Error::<T>::ContributionPeriodNotEnded);
576574
ensure!(crowdloan.raised == crowdloan.cap, Error::<T>::CapNotRaised);
577575
ensure!(!crowdloan.finalized, Error::<T>::AlreadyFinalized);
578576

@@ -621,7 +619,7 @@ pub mod pallet {
621619
Ok(())
622620
}
623621

624-
/// Refund a failed crowdloan.
622+
/// Refund contributors of a non-finalized crowdloan.
625623
///
626624
/// The call will try to refund all contributors (excluding the creator) up to the limit defined by the `RefundContributorsLimit`.
627625
/// If the limit is reached, the call will stop and the crowdloan will be marked as partially refunded.
@@ -637,13 +635,11 @@ pub mod pallet {
637635
origin: OriginFor<T>,
638636
#[pallet::compact] crowdloan_id: CrowdloanId,
639637
) -> DispatchResultWithPostInfo {
640-
let now = frame_system::Pallet::<T>::block_number();
641638
ensure_signed(origin)?;
642639

643640
let mut crowdloan = Self::ensure_crowdloan_exists(crowdloan_id)?;
644641

645-
// Ensure the crowdloan has ended and is not finalized
646-
ensure!(now >= crowdloan.end, Error::<T>::ContributionPeriodNotEnded);
642+
// Ensure the crowdloan is not finalized
647643
ensure!(!crowdloan.finalized, Error::<T>::AlreadyFinalized);
648644

649645
let mut refunded_contributors: Vec<T::AccountId> = vec![];

pallets/crowdloan/src/tests.rs

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,9 +1147,6 @@ fn test_finalize_succeeds() {
11471147
amount
11481148
));
11491149

1150-
// run some more blocks past the end of the contribution period
1151-
run_to_block(60);
1152-
11531150
// finalize the crowdloan
11541151
assert_ok!(Crowdloan::finalize(
11551152
RuntimeOrigin::signed(creator),
@@ -1340,54 +1337,6 @@ fn test_finalize_fails_if_not_creator_origin() {
13401337
});
13411338
}
13421339

1343-
#[test]
1344-
fn test_finalize_fails_if_crowdloan_has_not_ended() {
1345-
TestState::default()
1346-
.with_balance(U256::from(1), 100)
1347-
.with_balance(U256::from(2), 100)
1348-
.build_and_execute(|| {
1349-
// create a crowdloan
1350-
let creator: AccountOf<Test> = U256::from(1);
1351-
let deposit: BalanceOf<Test> = 50;
1352-
let min_contribution: BalanceOf<Test> = 10;
1353-
let cap: BalanceOf<Test> = 100;
1354-
let end: BlockNumberFor<Test> = 50;
1355-
1356-
assert_ok!(Crowdloan::create(
1357-
RuntimeOrigin::signed(creator),
1358-
deposit,
1359-
min_contribution,
1360-
cap,
1361-
end,
1362-
Some(noop_call()),
1363-
None,
1364-
));
1365-
1366-
// run some blocks
1367-
run_to_block(10);
1368-
1369-
// some contribution
1370-
let crowdloan_id: CrowdloanId = 0;
1371-
let contributor: AccountOf<Test> = U256::from(2);
1372-
let amount: BalanceOf<Test> = 50;
1373-
1374-
assert_ok!(Crowdloan::contribute(
1375-
RuntimeOrigin::signed(contributor),
1376-
crowdloan_id,
1377-
amount
1378-
));
1379-
1380-
// run some more blocks before end of contribution period
1381-
run_to_block(10);
1382-
1383-
// try to finalize
1384-
assert_err!(
1385-
Crowdloan::finalize(RuntimeOrigin::signed(creator), crowdloan_id),
1386-
pallet_crowdloan::Error::<Test>::ContributionPeriodNotEnded
1387-
);
1388-
});
1389-
}
1390-
13911340
#[test]
13921341
fn test_finalize_fails_if_crowdloan_cap_is_not_raised() {
13931342
TestState::default()
@@ -1585,8 +1534,8 @@ fn test_refund_succeeds() {
15851534
.is_some_and(|c| c.contributors_count == 7)
15861535
);
15871536

1588-
// run some more blocks past the end of the contribution period
1589-
run_to_block(60);
1537+
// run some more blocks before the end of the contribution period
1538+
run_to_block(20);
15901539

15911540
// first round of refund
15921541
assert_ok!(Crowdloan::refund(
@@ -1614,7 +1563,7 @@ fn test_refund_succeeds() {
16141563
pallet_crowdloan::Event::<Test>::PartiallyRefunded { crowdloan_id }.into()
16151564
);
16161565

1617-
// run some more blocks
1566+
// run some more blocks past the end of the contribution period
16181567
run_to_block(70);
16191568

16201569
// second round of refund
@@ -1700,39 +1649,6 @@ fn test_refund_fails_if_crowdloan_does_not_exist() {
17001649
});
17011650
}
17021651

1703-
#[test]
1704-
fn test_refund_fails_if_crowdloan_has_not_ended() {
1705-
TestState::default()
1706-
.with_balance(U256::from(1), 100)
1707-
.build_and_execute(|| {
1708-
// create a crowdloan
1709-
let creator: AccountOf<Test> = U256::from(1);
1710-
let initial_deposit: BalanceOf<Test> = 50;
1711-
let min_contribution: BalanceOf<Test> = 10;
1712-
let cap: BalanceOf<Test> = 300;
1713-
let end: BlockNumberFor<Test> = 50;
1714-
assert_ok!(Crowdloan::create(
1715-
RuntimeOrigin::signed(creator),
1716-
initial_deposit,
1717-
min_contribution,
1718-
cap,
1719-
end,
1720-
Some(noop_call()),
1721-
None,
1722-
));
1723-
1724-
// run some blocks
1725-
run_to_block(10);
1726-
1727-
// try to refund
1728-
let crowdloan_id: CrowdloanId = 0;
1729-
assert_err!(
1730-
Crowdloan::refund(RuntimeOrigin::signed(creator), crowdloan_id),
1731-
pallet_crowdloan::Error::<Test>::ContributionPeriodNotEnded
1732-
);
1733-
});
1734-
}
1735-
17361652
#[test]
17371653
fn test_dissolve_succeeds() {
17381654
TestState::default()

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ mod dispatches {
10581058
/// The extrinsic for user to change its hotkey in subnet or all subnets.
10591059
#[pallet::call_index(70)]
10601060
#[pallet::weight((Weight::from_parts(275_300_000, 0)
1061-
.saturating_add(T::DbWeight::get().reads(47))
1061+
.saturating_add(T::DbWeight::get().reads(49_u64))
10621062
.saturating_add(T::DbWeight::get().writes(37)), DispatchClass::Normal, Pays::No))]
10631063
pub fn swap_hotkey(
10641064
origin: OriginFor<T>,
@@ -2293,8 +2293,8 @@ mod dispatches {
22932293
/// - The hotkey account to designate as the autostake destination.
22942294
#[pallet::call_index(114)]
22952295
#[pallet::weight((Weight::from_parts(29_930_000, 0)
2296-
.saturating_add(T::DbWeight::get().reads(3_u64))
2297-
.saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))]
2296+
.saturating_add(T::DbWeight::get().reads(4_u64))
2297+
.saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Normal, Pays::No))]
22982298
pub fn set_coldkey_auto_stake_hotkey(
22992299
origin: T::RuntimeOrigin,
23002300
netuid: NetUid,

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
223223
// `spec_version`, and `authoring_version` are the same between Wasm and native.
224224
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
225225
// the compatible custom types.
226-
spec_version: 327,
226+
spec_version: 329,
227227
impl_version: 1,
228228
apis: RUNTIME_API_VERSIONS,
229229
transaction_version: 1,

0 commit comments

Comments
 (0)