Skip to content

Commit ddbf3bf

Browse files
authored
style: update event name and idle prove rate (#229)
1 parent 40c7e2b commit ddbf3bf

File tree

7 files changed

+24
-20
lines changed

7 files changed

+24
-20
lines changed

c-pallets/audit/src/constants.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
pub(super) const SERVICE_PROVE_RATE: u128 = 50_331_648;
2-
3-
pub(super) const IDLE_PROVE_RATE: u128 = 143_165_576;
1+
// miner cpu use 50%.
2+
pub(super) const SERVICE_PROVE_RATE: u128 = 25_165_824;
3+
// miner cpu use 50%.
4+
pub(super) const IDLE_PROVE_RATE: u128 = 71_582_788;
45

56
pub(super) const IDLE_VERIFY_RATE: u128 = 2_147_483_648;
67

c-pallets/audit/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,12 @@ pub mod pallet {
429429
<ChallengeDuration<T>>::put(duration);
430430
let idle_duration = duration;
431431
let one_hour = T::OneHours::get();
432+
let tee_length = T::TeeWorkerHandler::get_controller_list().len();
432433
let duration: u32 = (proposal.1.net_snap_shot.total_idle_space
433434
.checked_add(proposal.1.net_snap_shot.total_service_space).ok_or(Error::<T>::Overflow)?
434-
.checked_div(IDLE_VERIFY_RATE).ok_or(Error::<T>::Overflow)?) as u32;
435+
.checked_div(IDLE_VERIFY_RATE).ok_or(Error::<T>::Overflow)?
436+
.checked_div(tee_length as u128).ok_or(Error::<T>::Overflow)?
437+
) as u32;
435438
let v_duration = idle_duration
436439
.checked_add(&duration.saturated_into()).ok_or(Error::<T>::Overflow)?
437440
.checked_add(&one_hour).ok_or(Error::<T>::Overflow)?;
@@ -819,7 +822,7 @@ pub mod pallet {
819822
weight = weight.saturating_add(T::DbWeight::get().reads(1));
820823
for miner_snapshot in snap_shot.miner_snapshot_list.iter() {
821824
// unwrap_or(3) 3 Need to match the maximum number of consecutive penalties.
822-
let count = <CountedClear<T>>::get(&miner_snapshot.miner).checked_add(1).unwrap_or(3);
825+
let count = <CountedClear<T>>::get(&miner_snapshot.miner).checked_add(1).unwrap_or(6);
823826
weight = weight.saturating_add(T::DbWeight::get().reads(1));
824827

825828
let _ = T::MinerControl::clear_punish(
@@ -829,8 +832,8 @@ pub mod pallet {
829832
miner_snapshot.service_space
830833
);
831834
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
832-
833-
if count >= 3 {
835+
//For Testing
836+
if count >= 6 {
834837
let result = T::MinerControl::force_miner_exit(&miner_snapshot.miner);
835838
if result.is_err() {
836839
log::info!("force clear miner: {:?} failed", miner_snapshot.miner);

c-pallets/file-bank/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ pub mod pallet {
484484
let _ = ensure_root(origin)?;
485485

486486
if count < 20 {
487-
if let Err(e) = <DealMap<T>>::try_mutate(&deal_hash, |opt| -> DispatchResult {
487+
if let Err(_e) = <DealMap<T>>::try_mutate(&deal_hash, |opt| -> DispatchResult {
488488
let deal_info = opt.as_mut().ok_or(Error::<T>::NonExistent)?;
489489
// unlock mienr space
490490
let mut needed_list: BoundedVec<MinerTaskList<T>, T::FragmentCount> = Default::default();

c-pallets/sminer/src/helper.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ impl<T: Config> Pallet<T> {
201201
pub(super) fn clear_punish(miner: &AccountOf<T>, level: u8, idle_space: u128, service_space: u128) -> DispatchResult {
202202
let power = Self::calculate_power(idle_space, service_space);
203203
let limit = Self::check_collateral_limit(power)?;
204-
204+
// FOR TESTING
205205
let punish_amount = match level {
206206
1 => Perbill::from_percent(30).mul_floor(limit),
207207
2 => Perbill::from_percent(60).mul_floor(limit),
208-
3 => limit,
208+
3 | 4 | 5 | 6 => limit,
209209
_ => return Err(Error::<T>::Unexpected)?,
210210
};
211211

c-pallets/sminer/src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ pub mod pallet {
150150
Deposit {
151151
balance: BalanceOf<T>,
152152
},
153-
UpdataBeneficiary {
153+
UpdateBeneficiary {
154154
acc: AccountOf<T>,
155155
new: AccountOf<T>,
156156
},
157-
UpdataIp {
157+
UpdatePeerId {
158158
acc: AccountOf<T>,
159159
old: PeerId,
160160
new: PeerId,
@@ -412,7 +412,7 @@ pub mod pallet {
412412
<CurrencyReward<T>>::mutate(|reward| -> DispatchResult {
413413
*reward = reward.checked_add(&miner_info.debt).ok_or(Error::<T>::Overflow)?;
414414
Ok(())
415-
});
415+
})?;
416416
miner_info.debt = BalanceOf::<T>::zero();
417417
}
418418
}
@@ -439,7 +439,7 @@ pub mod pallet {
439439
Ok(())
440440
}
441441

442-
/// updata miner beneficiary.
442+
/// update miner beneficiary.
443443
///
444444
/// Parameters:
445445
/// - `beneficiary`: The beneficiary related to signer account.
@@ -459,11 +459,11 @@ pub mod pallet {
459459
Ok(())
460460
})?;
461461

462-
Self::deposit_event(Event::<T>::UpdataBeneficiary { acc: sender, new: beneficiary });
462+
Self::deposit_event(Event::<T>::UpdateBeneficiary { acc: sender, new: beneficiary });
463463
Ok(())
464464
}
465465

466-
/// updata miner IP.
466+
/// update miner IP.
467467
///
468468
/// Parameters:
469469
/// - `ip`: The registered IP of storage miner.
@@ -481,7 +481,7 @@ pub mod pallet {
481481
Ok(old)
482482
})?;
483483

484-
Self::deposit_event(Event::<T>::UpdataIp { acc: sender, old, new: peer_id.into() });
484+
Self::deposit_event(Event::<T>::UpdatePeerId { acc: sender, old, new: peer_id.into() });
485485
Ok(())
486486
}
487487

c-pallets/sminer/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn miner_register_works() {
7575
let event =
7676
Sys::events().pop().expect("Expected at least one Registered to be found").event;
7777
assert_eq!(
78-
mock::RuntimeEvent::from(Event::UpdataBeneficiary { acc: ACCOUNT1.0, new: beneficiary_new }),
78+
mock::RuntimeEvent::from(Event::UpdateBeneficiary { acc: ACCOUNT1.0, new: beneficiary_new }),
7979
event
8080
);
8181

@@ -86,7 +86,7 @@ fn miner_register_works() {
8686
let event =
8787
Sys::events().pop().expect("Expected at least one Registered to be found").event;
8888
assert_eq!(
89-
mock::RuntimeEvent::from(Event::UpdataIp { acc: ACCOUNT1.0, old: ip, new: ip_new }),
89+
mock::RuntimeEvent::from(Event::UpdatePeerId { acc: ACCOUNT1.0, old: ip, new: ip_new }),
9090
event
9191
);
9292
});

runtime/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
172172
// `spec_version`, and `authoring_version` are the same between Wasm and native.
173173
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
174174
// the compatible custom types.
175-
spec_version: 101,
175+
spec_version: 102,
176176
impl_version: 1,
177177
apis: RUNTIME_API_VERSIONS,
178178
transaction_version: 1,

0 commit comments

Comments
 (0)