From 6ede050489c170d8b371cf2c2565b6faa053c8af Mon Sep 17 00:00:00 2001 From: Elden Young <59600396+ytqaljn@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:01:32 +0800 Subject: [PATCH] 0.7.5 fix bug (#268) * fix: fix bloom filter statistics error * fix: Improve the requirements for miners to exit * fix: fix warn * fix balance transfer bug * fix: temp update price * fix: file metadata generate --- c-pallets/audit/src/lib.rs | 2 +- c-pallets/file-bank/src/functions.rs | 2 ++ c-pallets/file-bank/src/lib.rs | 6 ++++-- c-pallets/sminer/src/helper.rs | 2 +- c-pallets/sminer/src/lib.rs | 3 ++- c-pallets/storage-handler/src/lib.rs | 4 ++-- runtime/src/lib.rs | 5 +---- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/c-pallets/audit/src/lib.rs b/c-pallets/audit/src/lib.rs index d2a7e63b..413e9347 100644 --- a/c-pallets/audit/src/lib.rs +++ b/c-pallets/audit/src/lib.rs @@ -325,7 +325,7 @@ pub mod pallet { pub(super) type VerifyReassignCount = StorageValue<_, u8, ValueQuery>; #[pallet::storage] - #[pallet::getter(fn chllenge_snap_shot)] + #[pallet::getter(fn challenge_snap_shot)] pub(super) type ChallengeSnapShot = StorageMap<_, Blake2_128Concat, AccountOf, ChallengeInfo>; diff --git a/c-pallets/file-bank/src/functions.rs b/c-pallets/file-bank/src/functions.rs index 756fb892..02c33be4 100644 --- a/c-pallets/file-bank/src/functions.rs +++ b/c-pallets/file-bank/src/functions.rs @@ -23,6 +23,8 @@ impl Pallet { ) -> DispatchResult { let mut segment_info_list: BoundedVec, T::SegmentCount> = Default::default(); ensure!(complete_list.len() == FRAGMENT_COUNT as usize, Error::::Unexpected); + let mut complete_list = complete_list; + complete_list.sort_by_key(|info| info.index); for segment in deal_info.iter() { let mut segment_info = SegmentInfo:: { hash: segment.hash, diff --git a/c-pallets/file-bank/src/lib.rs b/c-pallets/file-bank/src/lib.rs index 503c837d..7da094a3 100755 --- a/c-pallets/file-bank/src/lib.rs +++ b/c-pallets/file-bank/src/lib.rs @@ -585,6 +585,8 @@ pub mod pallet { ensure!(>::contains_key(&deal_hash), Error::::NonExistent); ensure!(index as u32 <= FRAGMENT_COUNT, Error::::SpecError); ensure!(index > 0, Error::::SpecError); + let is_positive = T::MinerControl::is_positive(&sender)?; + ensure!(is_positive, Error::::MinerStateError); >::try_mutate(&deal_hash, |deal_info_opt| -> DispatchResult { // can use unwrap because there was a judgment above let deal_info = deal_info_opt.as_mut().unwrap(); @@ -615,10 +617,10 @@ pub mod pallet { let deal_info = >::try_get(&deal_hash).map_err(|_| Error::::NonExistent)?; let count = deal_info.segment_list.len() as u128; - for (index, complete_info) in deal_info.complete_list.iter().enumerate() { + for complete_info in deal_info.complete_list.iter() { let mut hash_list: Vec> = Default::default(); for segment in &deal_info.segment_list { - let fragment_hash = segment.fragment_list[index as usize]; + let fragment_hash = segment.fragment_list[(complete_info.index - 1) as usize]; let hash_temp = fragment_hash.binary().map_err(|_| Error::::BugInvalid)?; hash_list.push(hash_temp); } diff --git a/c-pallets/sminer/src/helper.rs b/c-pallets/sminer/src/helper.rs index cac9397e..c5444139 100644 --- a/c-pallets/sminer/src/helper.rs +++ b/c-pallets/sminer/src/helper.rs @@ -254,7 +254,7 @@ impl Pallet { >::try_mutate(acc, |miner_opt| -> DispatchResult { let miner = miner_opt.as_mut().ok_or(Error::::Unexpected)?; - T::StorageHandle::sub_total_idle_space(miner.idle_space)?; + T::StorageHandle::sub_total_idle_space(miner.idle_space + miner.lock_space)?; Self::create_restoral_target(acc, miner.service_space)?; miner.state = Self::str_to_bound(STATE_OFFLINE)?; let space_proof_info = miner.space_proof_info.clone().ok_or(Error::::NotpositiveState)?; diff --git a/c-pallets/sminer/src/lib.rs b/c-pallets/sminer/src/lib.rs index 122e22b9..9d33d661 100644 --- a/c-pallets/sminer/src/lib.rs +++ b/c-pallets/sminer/src/lib.rs @@ -593,6 +593,7 @@ pub mod pallet { >::try_mutate(&sender, |miner_opt| -> DispatchResult { let miner = miner_opt.as_mut().ok_or(Error::::NotExisted)?; ensure!(miner.state == STATE_POSITIVE.as_bytes().to_vec(), Error::::StateError); + ensure!(miner.lock_space == 0, Error::::StateError); if miner.lock_space != 0 { Err(Error::::StateError)?; } @@ -646,7 +647,7 @@ pub mod pallet { ensure!(miner_info.state.to_vec() == STATE_LOCK.as_bytes().to_vec(), Error::::StateError); // sub network total idle space. - T::StorageHandle::sub_total_idle_space(miner_info.idle_space)?; + T::StorageHandle::sub_total_idle_space(miner_info.idle_space + miner_info.lock_space)?; Self::execute_exit(&miner)?; diff --git a/c-pallets/storage-handler/src/lib.rs b/c-pallets/storage-handler/src/lib.rs index d4de356a..3da558e3 100644 --- a/c-pallets/storage-handler/src/lib.rs +++ b/c-pallets/storage-handler/src/lib.rs @@ -350,7 +350,7 @@ pub mod pallet { #[pallet::weight(Weight::zero())] pub fn update_price(origin: OriginFor) -> DispatchResult { let _ = ensure_root(origin)?; - let default_price: BalanceOf = 30u32.saturated_into(); + let default_price: BalanceOf = 30_000_000_000_000u128.try_into().map_err(|_| Error::::Overflow)?; UnitPrice::::put(default_price); Ok(()) @@ -383,7 +383,7 @@ pub mod pallet { // minute expired: u32, ) -> DispatchResult { - let sender = ensure_signed(origin)?; + let _ = ensure_signed(origin)?; let expired: BlockNumberOf = (expired .checked_mul(6).ok_or(Error::::Overflow)?).saturated_into(); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ecf1d2fa..408cb6e4 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -168,7 +168,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 100, + spec_version: 107, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -864,9 +864,6 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = pallet_timestamp::weights::SubstrateWeight; } -/// Existential deposit. -pub const EXISTENTIAL_DEPOSIT: u128 = 10_000_000 * 1000 * 100; - parameter_types! { pub const ExistentialDeposit: Balance = 1 * DOLLARS; // For weight estimation, we assume that the most locks on an individual account will be 50.