Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
1765b14
fix: renewal space unfreeze
ytqaljn Jan 30, 2023
c1d0851
feat: add some root extrisic
ytqaljn Feb 21, 2023
e4712cf
feat: add some root function for test
ytqaljn Feb 21, 2023
dfb5cdd
style: 0.5.4 add new field
ytqaljn Feb 21, 2023
0f6d388
style: for distinguish chain
ytqaljn Feb 21, 2023
d61d460
feat: some root function for test
ytqaljn Feb 21, 2023
19cc959
feat: for test
ytqaljn Feb 21, 2023
e362a8c
test: migration test
ytqaljn Feb 27, 2023
2ff5271
fix: fix random bug
ytqaljn Feb 27, 2023
a7f9516
Merge branch '0.5.4-test-migration' into 0.5.4-upgrade
ytqaljn Feb 27, 2023
95e55d8
Merge branch 'main' into 0.5.4-upgrade
ytqaljn Feb 27, 2023
31f0fc2
fix: index from 1 start
ytqaljn Mar 2, 2023
3666879
fix: random seed
ytqaljn Mar 2, 2023
cd9ebef
fix: random seed
ytqaljn Mar 2, 2023
54158ed
config: string limit 50000 -> 60000
ytqaljn Mar 2, 2023
c20c09c
Merge branch 'main' into 0.5.4-upgrade
ytqaljn Mar 15, 2023
c2c26d1
feat: batch delete files
ytqaljn Mar 15, 2023
43dfbfa
style: clear warning
ytqaljn Mar 16, 2023
9ef1c43
merge: frame-upgrade
ytqaljn Mar 16, 2023
6698562
fix: fix merge bug
ytqaljn Mar 16, 2023
615367b
refactor: add storage-handler pallet
ytqaljn Mar 17, 2023
2857e67
fix: fix recursing
ytqaljn Mar 17, 2023
c6c0833
refactor: file-bank pallet adapt
ytqaljn Mar 17, 2023
57b9156
refactor: adapt storage handle
ytqaljn Mar 20, 2023
808b4c5
refactor: rename file-map -> tee-worker
ytqaljn Mar 20, 2023
bb35cd0
refactor: rename file-map -> tee-worker
ytqaljn Mar 20, 2023
4422271
fix: bug
ytqaljn Mar 20, 2023
35f3d25
refactor: segment-book -> audit
ytqaljn Mar 20, 2023
30d2320
feat: upload_deal
ytqaljn Mar 21, 2023
ab5f33e
feat: upload_deal
ytqaljn Mar 22, 2023
54d9112
feat: upload_deal
ytqaljn Mar 22, 2023
8478631
feat: upload_deal
ytqaljn Mar 23, 2023
2030c5c
feat: upload deal
ytqaljn Mar 23, 2023
89ff6df
feat: tranfser_report
ytqaljn Mar 28, 2023
cc3af9c
feat: time task deal_reassign_miner
ytqaljn Mar 28, 2023
af9a311
feat: unlock space for miner
ytqaljn Mar 31, 2023
11b9a03
feat: calculate time task
ytqaljn Mar 31, 2023
d3fb741
feat: delete file
ytqaljn Apr 3, 2023
0833cf3
style: add Event
ytqaljn Apr 3, 2023
95a7018
style: fix warning
ytqaljn Apr 3, 2023
246f78c
refactor: idle space and service space change when segment add or delete
ytqaljn Apr 4, 2023
60d7dca
feat: some func for test
ytqaljn Apr 6, 2023
8958a3a
style: framework optimization
ytqaljn Apr 11, 2023
b4784ed
fix: update FragmentCount const
ytqaljn Apr 11, 2023
3ba2796
fix: fragment repeat causing BoundedVecError
ytqaljn Apr 12, 2023
b600757
refactor: tuple to struct for go-substrate-sdk
ytqaljn Apr 12, 2023
da7d4b7
fix: update lock space, miner and user
ytqaljn Apr 12, 2023
8dcebec
feat: add two new package
ytqaljn Apr 13, 2023
92c50e6
feat: tee register
ytqaljn Apr 14, 2023
d43bd84
feat: add report verify
ytqaljn Apr 17, 2023
fe5d508
feat: generate challeng(40%)
ytqaljn Apr 17, 2023
4dd5b19
tests: ed25519 verify sig
ytqaljn Apr 18, 2023
9a96863
feat: generate challenge
ytqaljn Apr 21, 2023
1a0e4ac
feat: submit prove
ytqaljn Apr 21, 2023
4264ce7
feat: challenge clear
ytqaljn Apr 24, 2023
d9f9f6a
feat: miner reward
ytqaljn Apr 24, 2023
b5774ba
feat: clear and prove punish
ytqaljn Apr 24, 2023
90ccb3d
feat: three punish
ytqaljn Apr 25, 2023
4f652dd
feat: lock miner
ytqaljn Apr 26, 2023
9857c2a
feat: miner exit
ytqaljn Apr 26, 2023
d1a54d8
feat: filter for lock miner
ytqaljn Apr 26, 2023
02fc27e
feat: update increase_collateral for debt
ytqaljn Apr 26, 2023
88c316d
feat: force miner exit
ytqaljn Apr 26, 2023
0fa234c
feat: use force exit miner
ytqaljn Apr 26, 2023
6ffae2d
feat: clear expire file
ytqaljn Apr 26, 2023
7f4242c
feat: delete file
ytqaljn Apr 27, 2023
049ff9f
fix: transfer file delete file
ytqaljn Apr 27, 2023
c8bed65
feat: test rsa verify
ytqaljn Apr 28, 2023
983abb4
style: fix warning
ytqaljn Apr 28, 2023
4a95863
style: peer id types update
ytqaljn May 5, 2023
4767a05
feat: unlock offchain
ytqaljn May 5, 2023
3363b25
feat: add punish tee worker
ytqaljn May 5, 2023
25d843a
fix: challenge select miner when miner number < 10
ytqaljn May 6, 2023
cdad4d1
fix: fix challengesnapshot bug
ytqaljn May 6, 2023
8c76ac3
fix: miner exit bug
ytqaljn May 6, 2023
139da69
style: add withdraw event
ytqaljn May 8, 2023
72cee7a
style: update type
ytqaljn May 15, 2023
15d30a9
test: add some test function
ytqaljn May 17, 2023
c295e7c
test: add update_peer_id and exit
ytqaljn May 17, 2023
b0d604f
test: purchase in mib units
ytqaljn May 17, 2023
2849a73
feat: random 0.046 chunks and random random number
ytqaljn May 17, 2023
631c6d5
feat: add new filed
ytqaljn May 17, 2023
47354f4
fix: fix bug in reassigning validation tasks
ytqaljn May 22, 2023
eb3512e
style: delete methods that are no longer in use
ytqaljn May 22, 2023
bb09ca8
feat: add methods for deleting fillers
ytqaljn May 22, 2023
f4cd9f4
style: some related modifications made for testing purposes
ytqaljn May 22, 2023
6b81f76
fix: miner exit prep error
ytqaljn May 26, 2023
66fb5f6
feat: restoral file
ytqaljn May 30, 2023
049f293
fix: fix compile error
ytqaljn May 30, 2023
a36867d
fix: fix random select miner
ytqaljn Jun 2, 2023
bab4516
style: add restoral event
ytqaljn Jun 2, 2023
8e1580e
refactor: optimize space expiration functionality
ytqaljn Jun 2, 2023
7eecf26
test: some for test function
ytqaljn Jun 2, 2023
d8d48d5
feat: add stake_score in validator election (#125)
shakawwq Jun 5, 2023
7406c62
test: test for bls
ytqaljn Jun 5, 2023
a907076
Merge branch 'main' into sprint7-file-restoral
ytqaljn Jun 5, 2023
265e07a
style: merge
ytqaljn Jun 5, 2023
2bb0f9f
Merge branch 'main' into sprint7-file-restoral
ytqaljn Jun 5, 2023
a881f3b
test: test bls
ytqaljn Jun 5, 2023
1214910
feat: restoral order storage
ytqaljn Jun 7, 2023
c03180c
feat: restoral order storage key
ytqaljn Jun 7, 2023
53fd3d5
test: update data for test
ytqaljn Jun 7, 2023
acf6433
fix: fix space expire bug
ytqaljn Jun 7, 2023
bde2559
fix: fix upload file user hold slice list
ytqaljn Jun 8, 2023
cdb202e
fix: fix random select miner
ytqaljn Jun 8, 2023
0bf0b44
test: for test add some function
ytqaljn Jun 8, 2023
5fc90a6
Make verify-bls-signatures no_std compatible (#137)
jimmychu0807 Jun 8, 2023
d349e67
Merge branch 'sprint7-file-restoral' of github.com:CESSProject/cess i…
ytqaljn Jun 8, 2023
979a8e7
fix: cancel schedule mission
ytqaljn Jun 9, 2023
d4d56cf
fix: file upload update UserBucketList
ytqaljn Jun 9, 2023
93b51d1
style: streamline code
ytqaljn Jun 9, 2023
8961d23
fix: space expired user bucket list kill
ytqaljn Jun 9, 2023
8c156af
Merge pull request #138 from CESSProject/sprint7-file-restoral
thirteenggh Jun 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into 0.5.4-upgrade
  • Loading branch information
ytqaljn committed Mar 15, 2023
commit c20c09cc51c67ff531734cc7f7c7839a006a7793
162 changes: 5 additions & 157 deletions c-pallets/segment-book/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,163 +327,11 @@ pub mod pallet {
//When there is an uncommitted space-time certificate, the corresponding miner will be
//punished and the corresponding data segment will be removed
fn on_initialize(now: BlockNumberOf<T>) -> Weight {
let _number: u128 = now.saturated_into();
let challenge_deadline = Self::challenge_duration();
let verify_deadline = Self::verify_duration();
let mut weight: Weight = 0;
//The waiting time for the challenge has reached the deadline
if now == challenge_deadline {
//After the waiting time for the challenge reaches the deadline,
//the miners who fail to complete the challenge will be punished
for (acc, challenge_list) in <ChallengeMap<T>>::iter() {
for v in challenge_list {
let result = Self::set_failure(acc.clone());
match result {
Ok(()) => log::info!("set_failure success"),
Err(e) => log::error!("set_failure failed: {:?}", e),
};
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
let weight1 = match Self::update_miner_file(
acc.clone(),
v.file_id,
v.shard_id,
v.file_size,
v.file_type,
) {
Ok(weights) => weights,
Err(e) => {
log::error!("punish error: {:?}", e);
0
},
};
weight = weight.saturating_add(weight1);
log::info!(
"challenge draw a blank, miner_acc:{:?}, file_id: {:?}",
acc.clone(),
v.file_id
);
Self::deposit_event(Event::<T>::OutstandingChallenges {
miner: acc.clone(),
file_id: v.file_id,
});
}
<ChallengeMap<T>>::remove(acc.clone());
weight = weight.saturating_add(T::DbWeight::get().writes(1 as Weight));
}
}

//Punish the scheduler who fails to verify the results for a long time
if now == verify_deadline {
let mut is_end = true;

let mut verify_list: Vec<ProveInfo<T>> = Vec::new();
for (acc, v_list) in <UnVerifyProof<T>>::iter() {
if v_list.len() > 0 {
is_end = false;
verify_list.append(&mut v_list.to_vec());
let result = T::Scheduler::punish_scheduler(acc.clone());
match result {
Ok(()) => log::info!("punish scheduler success"),
Err(e) => log::error!("punish scheduler failed: {:?}", e),
};
<UnVerifyProof<T>>::remove(&acc);
weight = weight.saturating_add(T::DbWeight::get().writes(1 as Weight));
}
}
if is_end {
for (miner, total_proof) in <MinerTotalProof<T>>::iter() {
if <FailureNumMap<T>>::contains_key(&miner) {
if <ConsecutiveFines<T>>::contains_key(&miner) {
let result = <ConsecutiveFines<T>>::try_mutate(
miner.clone(),
|s_opt| -> DispatchResult {
s_opt.checked_add(1).ok_or(Error::<T>::Overflow)?;
Ok(())
},
).map_err(|_e| Error::<T>::BoundedVecError);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
match result {
Ok(()) => log::info!("ConsecutiveFines update success"),
Err(e) => log::error!("ConsecutiveFines update failed: {:?}", e),
}
} else {
<ConsecutiveFines<T>>::insert(&miner, 1);
weight = weight.saturating_add(T::DbWeight::get().reads(1 as Weight));
}
let result = Self::punish(
miner.clone(),
<FailureNumMap<T>>::get(&miner),
total_proof,
<ConsecutiveFines<T>>::get(&miner),
).map_err(|e| e);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(6, 4));
match result {
Ok(()) => log::info!("punish success"),
Err(e) => log::error!("punish failed: {:?}", e),
};
} else {
<ConsecutiveFines<T>>::remove(&miner);
weight = weight.saturating_add(T::DbWeight::get().writes(1 as Weight));
}
}

let result = Self::start_buffer_period_schedule().map_err(|e| e);
match result {
Ok(()) => log::info!("start_buffer_period_schedule success!"),
Err(e) => log::error!("start_buffer_period_schedule failed: {:?}", e),
};
// weight = weight.staurating_add(Self::clear_failure_map(5000, None));
// weight = weight.staurating_add(Self::clear_total_proof(5000, None));
<FailureNumMap<T>>::remove_all();
weight = weight.saturating_add(T::DbWeight::get().writes(<FailureNumMap<T>>::count() as Weight));
<MinerTotalProof<T>>::remove_all();
weight = weight.saturating_add(T::DbWeight::get().writes(<MinerTotalProof<T>>::count() as Weight));

let max = Keys::<T>::get().len() as u16;
let mut index = CurAuthorityIndex::<T>::get();
if index >= max - 1 {
index = 0;
} else {
index = index + 1;
}
CurAuthorityIndex::<T>::put(index);

} else {
let result = Self::get_current_scheduler();
weight = weight.saturating_add(T::DbWeight::get().reads(1 as Weight));
match result {
Ok(cur_acc) => {
let new_deadline = match now.checked_add(&1200u32.saturated_into()).ok_or(Error::<T>::Overflow) {
Ok(new_deadline) => new_deadline,
Err(e) => {
log::error!("over flow: {:?}", e);
return 0
},
};
<VerifyDuration<T>>::put(new_deadline);
weight = weight.saturating_add(T::DbWeight::get().writes(1 as Weight));
let bound_verify_list: BoundedVec<ProveInfo<T>, T::ChallengeMaximum> = match verify_list.try_into().map_err(|_e| Error::<T>::BoundedVecError) {
Ok(bound_verify_list) => bound_verify_list,
Err(e) => {
log::error!("over flow: {:?}", e);
return 0
},
};
let result = Self::storage_prove(cur_acc, bound_verify_list);
weight = weight.saturating_add(T::DbWeight::get().writes(1 as Weight));
match result {
Ok(()) => log::info!("storage prove success"),
Err(e) => {
log::error!("storage prove failed: {:?}", e);
return 0
},
};
},
Err(_e) => log::error!("get_current_scheduler err"),
}
}
}
weight
Weight::default()
//The waiting time for the challenge has reached the deadline
.saturating_add(Self::handle_challenge_deadline(now))
//Punish the scheduler who fails to verify the results for a long time
.saturating_add(Self::handle_verify_deadline(now))
}

fn offchain_worker(now: T::BlockNumber) {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.