Skip to content

Commit

Permalink
0.7.5 fix bug (#268)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ytqaljn authored Nov 27, 2023
1 parent 516a42d commit 6ede050
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion c-pallets/audit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ pub mod pallet {
pub(super) type VerifyReassignCount<T: Config> = StorageValue<_, u8, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn chllenge_snap_shot)]
#[pallet::getter(fn challenge_snap_shot)]
pub(super) type ChallengeSnapShot<T: Config> =
StorageMap<_, Blake2_128Concat, AccountOf<T>, ChallengeInfo<T>>;

Expand Down
2 changes: 2 additions & 0 deletions c-pallets/file-bank/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ impl<T: Config> Pallet<T> {
) -> DispatchResult {
let mut segment_info_list: BoundedVec<SegmentInfo<T>, T::SegmentCount> = Default::default();
ensure!(complete_list.len() == FRAGMENT_COUNT as usize, Error::<T>::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::<T> {
hash: segment.hash,
Expand Down
6 changes: 4 additions & 2 deletions c-pallets/file-bank/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ pub mod pallet {
ensure!(<DealMap<T>>::contains_key(&deal_hash), Error::<T>::NonExistent);
ensure!(index as u32 <= FRAGMENT_COUNT, Error::<T>::SpecError);
ensure!(index > 0, Error::<T>::SpecError);
let is_positive = T::MinerControl::is_positive(&sender)?;
ensure!(is_positive, Error::<T>::MinerStateError);
<DealMap<T>>::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();
Expand Down Expand Up @@ -615,10 +617,10 @@ pub mod pallet {

let deal_info = <DealMap<T>>::try_get(&deal_hash).map_err(|_| Error::<T>::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<Box<[u8; 256]>> = 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::<T>::BugInvalid)?;
hash_list.push(hash_temp);
}
Expand Down
2 changes: 1 addition & 1 deletion c-pallets/sminer/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl<T: Config> Pallet<T> {

<MinerItems<T>>::try_mutate(acc, |miner_opt| -> DispatchResult {
let miner = miner_opt.as_mut().ok_or(Error::<T>::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::<T>::NotpositiveState)?;
Expand Down
3 changes: 2 additions & 1 deletion c-pallets/sminer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ pub mod pallet {
<MinerItems<T>>::try_mutate(&sender, |miner_opt| -> DispatchResult {
let miner = miner_opt.as_mut().ok_or(Error::<T>::NotExisted)?;
ensure!(miner.state == STATE_POSITIVE.as_bytes().to_vec(), Error::<T>::StateError);
ensure!(miner.lock_space == 0, Error::<T>::StateError);
if miner.lock_space != 0 {
Err(Error::<T>::StateError)?;
}
Expand Down Expand Up @@ -646,7 +647,7 @@ pub mod pallet {
ensure!(miner_info.state.to_vec() == STATE_LOCK.as_bytes().to_vec(), Error::<T>::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)?;

Expand Down
4 changes: 2 additions & 2 deletions c-pallets/storage-handler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pub mod pallet {
#[pallet::weight(Weight::zero())]
pub fn update_price(origin: OriginFor<T>) -> DispatchResult {
let _ = ensure_root(origin)?;
let default_price: BalanceOf<T> = 30u32.saturated_into();
let default_price: BalanceOf<T> = 30_000_000_000_000u128.try_into().map_err(|_| Error::<T>::Overflow)?;
UnitPrice::<T>::put(default_price);

Ok(())
Expand Down Expand Up @@ -383,7 +383,7 @@ pub mod pallet {
// minute
expired: u32,
) -> DispatchResult {
let sender = ensure_signed(origin)?;
let _ = ensure_signed(origin)?;

let expired: BlockNumberOf<T> = (expired
.checked_mul(6).ok_or(Error::<T>::Overflow)?).saturated_into();
Expand Down
5 changes: 1 addition & 4 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -864,9 +864,6 @@ impl pallet_timestamp::Config for Runtime {
type WeightInfo = pallet_timestamp::weights::SubstrateWeight<Runtime>;
}

/// 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.
Expand Down

0 comments on commit 6ede050

Please sign in to comment.