diff --git a/Cargo.lock b/Cargo.lock index 664ef24c..33f59106 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1269,6 +1269,7 @@ dependencies = [ "sp-session", "sp-staking", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-version", "substrate-wasm-builder", diff --git a/Cargo.toml b/Cargo.toml index cccb9dc7..bf318e22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -114,6 +114,7 @@ sp-block-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", bra sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } sp-staking = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } +sp-storage = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } sp-statement-store = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } sp-version = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "release-polkadot-v1.1.0", default-features = false } diff --git a/pallets/audit/src/benchmarking.rs b/pallets/audit/src/benchmarking.rs index 2cf812f6..62208d9f 100644 --- a/pallets/audit/src/benchmarking.rs +++ b/pallets/audit/src/benchmarking.rs @@ -1,251 +1,251 @@ -// use super::*; -use crate::{Pallet as Audit, *}; -// use cp_cess_common::{IpAddress, Hash, DataType}; -// use codec::{alloc::string::ToString, Decode}; -use frame_benchmarking::{ - account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, -}; -use frame_system::RawOrigin; -// use frame_support::{ -// dispatch::UnfilteredDispatchable, -// pallet_prelude::*, -// traits::{Currency, CurrencyToVote, Get, Imbalance}, +// // use super::*; +// use crate::{Pallet as Audit, *}; +// // use cp_cess_common::{IpAddress, Hash, DataType}; +// // use codec::{alloc::string::ToString, Decode}; +// use frame_benchmarking::{ +// account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, // }; -// use pallet_cess_staking::{ -// testing_utils, Config as StakingConfig, Pallet as Staking, RewardDestination, -// }; -// use pallet_tee_worker::{Config as TeeWorkerConfig, testing_utils::add_scheduler, Pallet as -// TeeWorker}; use pallet_sminer::{Config as SminerConfig, Pallet as Sminer}; -// use sp_runtime::{ -// traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, -// Perbill, Percent, -// }; -// use sp_std::prelude::*; - // use frame_system::RawOrigin; -pub struct Pallet(Audit); -pub trait Config: - crate::Config - + pallet_cess_staking::Config - + pallet_tee_worker::benchmarking::Config - + pallet_sminer::benchmarking::Config - + pallet_file_bank::benchmarking::Config -{ -} - -const USER_SEED: u32 = 999666; - -const SEED: u32 = 2190502; - -const MINER_LIST: [&'static str; 30] = [ - "miner1", "miner2", "miner3", "miner4", "miner5", "miner6", "miner7", "miner8", "miner9", - "miner10", "miner11", "miner12", "miner13", "miner14", "miner15", "miner16", "miner17", - "miner18", "miner19", "miner20", "miner21", "miner22", "miner23", "miner24", "miner25", - "miner26", "miner27", "miner28", "miner29", "miner30", -]; - -pub fn bench_generate_challenge() { - let space_challenge_param = [ - 67_549_635, 67_864_236, 67_338_392, 67_130_229, 67_369_766, 67_193_409, 67_799_602, - 67_425_292, - ]; - let random_index_list = [ - 691, 406, 838, 480, 996, 798, 362, 456, 144, 666, 1, 018, 568, 992, 650, 729, 808, 229, - 623, 499, 671, 254, 24, 217, 698, 648, 781, 460, 298, 548, 742, 364, 183, 114, 309, 564, - 127, 154, 815, 651, 397, 576, 697, 358, 880, 73, 629, 66, - ]; - let random_list = [[55u8; 20]; 48]; - - let mut miner_snapshot_list: BoundedVec< - MinerSnapShot, BlockNumberOf>, - ::ChallengeMinerMax, - > = Default::default(); - let mut total_idle_space: u128 = u128::MIN; - let mut total_service_space: u128 = u128::MIN; - let all_miner = - ::MinerControl::get_all_miner().expect("get all miner error!"); - for miner in all_miner.into_iter() { - let (idle_space, service_space, service_bloom_filter, space_proof_info, tee_signature) = - ::MinerControl::get_miner_snapshot(&miner) - .expect("get miner snapshot failed"); - if (idle_space == 0) && (service_space == 0) { - continue - } - total_idle_space = total_idle_space.checked_add(idle_space).expect("overflow"); - total_service_space = total_service_space.checked_add(service_space).expect("overflow"); - let miner_snapshot = MinerSnapShot::, BlockNumberOf> { - miner, - idle_life: 200u32.saturated_into(), - service_life: 200u32.saturated_into(), - idle_space, - service_space, - idle_submitted: false, - service_submitted: false, - service_bloom_filter, - space_proof_info, - tee_signature, - }; - miner_snapshot_list.try_push(miner_snapshot).unwrap(); - } - - let _ = pallet_sminer::benchmarking::increase_reward::(1_000_000_000_000_000u128); - - let net_snap_shot = NetSnapShot::> { - start: 1u32.saturated_into(), - life: 2000u32.saturated_into(), - total_reward: 1_000_000_000_000_000u128, - total_idle_space, - total_service_space, - random_index_list: random_index_list.to_vec().try_into().expect("BoundedVec Error"), - random_list: random_list.to_vec().try_into().expect("BoundedVec Error"), - space_challenge_param, - }; - - let challenge_info = ChallengeInfo:: { net_snap_shot, miner_snapshot_list }; - >::put(challenge_info); - let duration: BlockNumberOf = 5000u32.saturated_into(); - >::put(duration); - let duration: BlockNumberOf = 6000u32.saturated_into(); - >::put(duration); -} - -benchmarks! { - submit_idle_proof { - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 5 { - let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; - pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; - } - bench_generate_challenge::(); - let miner: AccountOf = account("miner1", 100, SEED); - let idle_total_hash: BoundedVec = [5u8; 256].to_vec().try_into().unwrap(); - }: _(RawOrigin::Signed(miner.clone()), idle_total_hash) - verify { - let challenge_snap_shot = >::try_get().unwrap(); - let mut miner_list: Vec> = Default::default(); - for (index, miner_snapshot) in challenge_snap_shot.miner_snapshot_list.iter().enumerate() { - miner_list.push(miner_snapshot.miner.clone()); - if miner_snapshot.miner == miner { - assert_eq!(miner_snapshot.idle_submitted, true); - } - } - assert!(miner_list.contains(&miner)); - } - - submit_service_proof { - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 5 { - let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; - pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; - } - bench_generate_challenge::(); - let miner: AccountOf = account("miner1", 100, SEED); - let sigma: BoundedVec = [5u8; 2048].to_vec().try_into().unwrap(); - }: _(RawOrigin::Signed(miner.clone()), sigma) - verify { - let challenge_snap_shot = >::try_get().unwrap(); - let mut miner_list: Vec> = Default::default(); - for (index, miner_snapshot) in challenge_snap_shot.miner_snapshot_list.iter().enumerate() { - miner_list.push(miner_snapshot.miner.clone()); - if miner_snapshot.miner == miner { - assert_eq!(miner_snapshot.service_submitted, true); - } - } - assert!(miner_list.contains(&miner)); - } - - submit_verify_idle_result { - let (_, controller_acc) = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 5 { - let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; - pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; - } - bench_generate_challenge::(); - let miner: AccountOf = account("miner1", 100, SEED); - let idle_total_hash: BoundedVec = [5u8; 256].to_vec().try_into().unwrap(); - let sigma: BoundedVec = [5u8; 2048].to_vec().try_into().unwrap(); - Audit::::submit_idle_proof(RawOrigin::Signed(miner.clone()).into(), idle_total_hash.clone())?; - Audit::::submit_service_proof(RawOrigin::Signed(miner.clone()).into(), sigma.clone())?; - - let random_index_list = [691, 406, 838, 480, 996, 798, 362, 456, 144, 666, 1, 018, 568, 992, 650, 729, 808, 229, 623, 499, 671, 254, 24, 217, 698, 648, 781, 460, 298, 548, 742, 364, 183, 114, 309, 564, 127, 154, 815, 651, 397, 576, 697, 358, 880, 73, 629, 66]; - let random_list = [[55u8; 20]; 48]; - let verify_service_result = VerifyServiceResultInfo::{ - miner: miner.clone(), - tee_acc: controller_acc.clone(), - miner_prove: sigma.clone(), - result: true, - chal: QElement { - random_index_list: random_index_list.to_vec().try_into().unwrap(), - random_list: random_list.to_vec().try_into().unwrap(), - }, - service_bloom_filter: cp_bloom_filter::BloomFilter([0u64; 256]), - }; - - let sig = [51, 231, 229, 255, 95, 218, 131, 76, 213, 104, 14, 3, 79, 205, 33, 157, 39, 190, 5, 169, 27, 210, 250, 86, 103, 116, 218, 23, 255, 252, 221, 247, 82, 109, 185, 200, 134, 188, 81, 199, 219, 245, 30, 42, 228, 193, 208, 135, 209, 24, 232, 30, 104, 90, 156, 215, 174, 98, 143, 143, 119, 217, 72, 24, 247, 232, 191, 246, 205, 57, 221, 124, 234, 135, 110, 184, 208, 77, 60, 64, 169, 75, 168, 123, 244, 134, 187, 187, 65, 62, 237, 10, 246, 102, 44, 235, 68, 175, 91, 36, 58, 157, 213, 63, 184, 32, 38, 242, 57, 255, 190, 251, 214, 41, 53, 36, 190, 66, 47, 100, 153, 110, 88, 6, 221, 250, 183, 169, 76, 203, 9, 188, 187, 79, 149, 16, 145, 155, 97, 89, 56, 94, 187, 65, 197, 133, 121, 0, 73, 115, 166, 148, 177, 62, 121, 137, 96, 86, 3, 111, 153, 108, 230, 241, 190, 114, 169, 249, 118, 50, 130, 46, 190, 127, 131, 142, 253, 217, 138, 102, 215, 162, 47, 94, 83, 36, 117, 25, 24, 125, 11, 91, 112, 211, 201, 28, 64, 141, 129, 14, 117, 2, 124, 217, 229, 179, 192, 34, 0, 37, 187, 44, 38, 170, 116, 176, 175, 96, 207, 181, 144, 30, 246, 170, 98, 206, 88, 176, 141, 118, 180, 99, 107, 196, 201, 206, 144, 81, 154, 138, 115, 38, 88, 219, 8, 55, 221, 20, 222, 106, 134, 98, 184, 92, 253, 185]; - Audit::::submit_verify_service_result(RawOrigin::Signed(miner.clone()).into(), verify_service_result.result, sig, verify_service_result.service_bloom_filter, verify_service_result.tee_acc)?; - - let verify_idle_result = VerifyIdleResultInfo::{ - miner: miner.clone(), - miner_prove: idle_total_hash.clone(), - front: 0, - rear: 10000, - accumulator: [8u8; 256], - space_challenge_param: [67_549_635, 67_864_236, 67_338_392, 67_130_229, 67_369_766, 67_193_409, 67_799_602, 67_425_292], - result: true, - tee_acc: controller_acc.clone(), - }; - - let sig = [105, 84, 152, 186, 134, 202, 80, 152, 159, 223, 251, 150, 106, 226, 63, 179, 168, 182, 237, 158, 111, 17, 68, 195, 39, 255, 75, 98, 67, 232, 10, 129, 175, 254, 222, 147, 45, 182, 91, 235, 26, 246, 88, 16, 106, 100, 241, 54, 236, 205, 224, 173, 113, 54, 71, 0, 95, 157, 184, 238, 54, 114, 40, 145, 44, 87, 163, 77, 177, 34, 211, 247, 51, 174, 53, 20, 151, 186, 173, 135, 83, 150, 197, 172, 121, 181, 203, 164, 10, 104, 163, 51, 110, 231, 241, 26, 112, 214, 127, 139, 247, 33, 158, 252, 146, 157, 47, 53, 172, 50, 111, 45, 249, 109, 145, 173, 10, 228, 133, 34, 163, 4, 254, 140, 64, 252, 136, 40, 87, 242, 36, 83, 15, 23, 182, 77, 9, 197, 223, 36, 129, 3, 41, 247, 102, 143, 192, 42, 251, 16, 215, 193, 1, 19, 154, 245, 212, 209, 52, 1, 80, 248, 118, 47, 114, 202, 238, 173, 244, 154, 218, 209, 71, 185, 76, 15, 0, 56, 213, 201, 228, 193, 105, 160, 48, 247, 134, 58, 91, 121, 75, 144, 163, 89, 105, 176, 29, 30, 169, 70, 205, 202, 188, 230, 207, 171, 95, 253, 14, 103, 249, 144, 213, 44, 57, 142, 82, 252, 103, 201, 183, 218, 31, 131, 219, 108, 83, 115, 198, 3, 14, 244, 178, 48, 196, 128, 100, 53, 1, 10, 31, 37, 205, 163, 20, 181, 71, 152, 171, 180, 102, 208, 1, 241, 174, 28]; - }: _(RawOrigin::Signed(miner.clone()), verify_idle_result.miner_prove, verify_idle_result.front, verify_idle_result.rear, verify_idle_result.accumulator, verify_idle_result.result, sig, verify_idle_result.tee_acc) - verify { - let unverify_list = >::try_get(&controller_acc).unwrap(); - assert_eq!(0, unverify_list.len()); - } - - submit_verify_service_result { - let (_, controller_acc) = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 5 { - let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; - pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; - } - bench_generate_challenge::(); - let miner: AccountOf = account("miner1", 100, SEED); - let idle_total_hash: BoundedVec = [5u8; 256].to_vec().try_into().unwrap(); - let sigma: BoundedVec = [5u8; 2048].to_vec().try_into().unwrap(); - Audit::::submit_idle_proof(RawOrigin::Signed(miner.clone()).into(), idle_total_hash.clone())?; - Audit::::submit_service_proof(RawOrigin::Signed(miner.clone()).into(), sigma.clone())?; - - let verify_idle_result = VerifyIdleResultInfo::{ - miner: miner.clone(), - miner_prove: idle_total_hash.clone(), - front: 0, - rear: 10000, - accumulator: [8u8; 256], - space_challenge_param: [67_549_635, 67_864_236, 67_338_392, 67_130_229, 67_369_766, 67_193_409, 67_799_602, 67_425_292], - result: true, - tee_acc: controller_acc.clone(), - }; - let sig = [105, 84, 152, 186, 134, 202, 80, 152, 159, 223, 251, 150, 106, 226, 63, 179, 168, 182, 237, 158, 111, 17, 68, 195, 39, 255, 75, 98, 67, 232, 10, 129, 175, 254, 222, 147, 45, 182, 91, 235, 26, 246, 88, 16, 106, 100, 241, 54, 236, 205, 224, 173, 113, 54, 71, 0, 95, 157, 184, 238, 54, 114, 40, 145, 44, 87, 163, 77, 177, 34, 211, 247, 51, 174, 53, 20, 151, 186, 173, 135, 83, 150, 197, 172, 121, 181, 203, 164, 10, 104, 163, 51, 110, 231, 241, 26, 112, 214, 127, 139, 247, 33, 158, 252, 146, 157, 47, 53, 172, 50, 111, 45, 249, 109, 145, 173, 10, 228, 133, 34, 163, 4, 254, 140, 64, 252, 136, 40, 87, 242, 36, 83, 15, 23, 182, 77, 9, 197, 223, 36, 129, 3, 41, 247, 102, 143, 192, 42, 251, 16, 215, 193, 1, 19, 154, 245, 212, 209, 52, 1, 80, 248, 118, 47, 114, 202, 238, 173, 244, 154, 218, 209, 71, 185, 76, 15, 0, 56, 213, 201, 228, 193, 105, 160, 48, 247, 134, 58, 91, 121, 75, 144, 163, 89, 105, 176, 29, 30, 169, 70, 205, 202, 188, 230, 207, 171, 95, 253, 14, 103, 249, 144, 213, 44, 57, 142, 82, 252, 103, 201, 183, 218, 31, 131, 219, 108, 83, 115, 198, 3, 14, 244, 178, 48, 196, 128, 100, 53, 1, 10, 31, 37, 205, 163, 20, 181, 71, 152, 171, 180, 102, 208, 1, 241, 174, 28]; - Audit::::submit_verify_idle_result(RawOrigin::Signed(miner.clone()).into(), verify_idle_result.miner_prove, verify_idle_result.front, verify_idle_result.rear, verify_idle_result.accumulator, verify_idle_result.result, sig, verify_idle_result.tee_acc)?; - - let random_index_list = [691, 406, 838, 480, 996, 798, 362, 456, 144, 666, 1, 018, 568, 992, 650, 729, 808, 229, 623, 499, 671, 254, 24, 217, 698, 648, 781, 460, 298, 548, 742, 364, 183, 114, 309, 564, 127, 154, 815, 651, 397, 576, 697, 358, 880, 73, 629, 66]; - let random_list = [[55u8; 20]; 48]; - let verify_service_result = VerifyServiceResultInfo::{ - miner: miner.clone(), - tee_acc: controller_acc.clone(), - miner_prove: sigma.clone(), - result: true, - chal: QElement { - random_index_list: random_index_list.to_vec().try_into().unwrap(), - random_list: random_list.to_vec().try_into().unwrap(), - }, - service_bloom_filter: cp_bloom_filter::BloomFilter([0u64; 256]), - }; - - let sig = [51, 231, 229, 255, 95, 218, 131, 76, 213, 104, 14, 3, 79, 205, 33, 157, 39, 190, 5, 169, 27, 210, 250, 86, 103, 116, 218, 23, 255, 252, 221, 247, 82, 109, 185, 200, 134, 188, 81, 199, 219, 245, 30, 42, 228, 193, 208, 135, 209, 24, 232, 30, 104, 90, 156, 215, 174, 98, 143, 143, 119, 217, 72, 24, 247, 232, 191, 246, 205, 57, 221, 124, 234, 135, 110, 184, 208, 77, 60, 64, 169, 75, 168, 123, 244, 134, 187, 187, 65, 62, 237, 10, 246, 102, 44, 235, 68, 175, 91, 36, 58, 157, 213, 63, 184, 32, 38, 242, 57, 255, 190, 251, 214, 41, 53, 36, 190, 66, 47, 100, 153, 110, 88, 6, 221, 250, 183, 169, 76, 203, 9, 188, 187, 79, 149, 16, 145, 155, 97, 89, 56, 94, 187, 65, 197, 133, 121, 0, 73, 115, 166, 148, 177, 62, 121, 137, 96, 86, 3, 111, 153, 108, 230, 241, 190, 114, 169, 249, 118, 50, 130, 46, 190, 127, 131, 142, 253, 217, 138, 102, 215, 162, 47, 94, 83, 36, 117, 25, 24, 125, 11, 91, 112, 211, 201, 28, 64, 141, 129, 14, 117, 2, 124, 217, 229, 179, 192, 34, 0, 37, 187, 44, 38, 170, 116, 176, 175, 96, 207, 181, 144, 30, 246, 170, 98, 206, 88, 176, 141, 118, 180, 99, 107, 196, 201, 206, 144, 81, 154, 138, 115, 38, 88, 219, 8, 55, 221, 20, 222, 106, 134, 98, 184, 92, 253, 185]; - }: _(RawOrigin::Signed(miner.clone()), verify_service_result.result, sig, verify_service_result.service_bloom_filter, verify_service_result.tee_acc) - verify { - let unverify_list = >::try_get(&controller_acc).unwrap(); - assert_eq!(0, unverify_list.len()); - } -} +// // use frame_support::{ +// // dispatch::UnfilteredDispatchable, +// // pallet_prelude::*, +// // traits::{Currency, CurrencyToVote, Get, Imbalance}, +// // }; +// // use pallet_cess_staking::{ +// // testing_utils, Config as StakingConfig, Pallet as Staking, RewardDestination, +// // }; +// // use pallet_tee_worker::{Config as TeeWorkerConfig, testing_utils::add_scheduler, Pallet as +// // TeeWorker}; use pallet_sminer::{Config as SminerConfig, Pallet as Sminer}; +// // use sp_runtime::{ +// // traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, +// // Perbill, Percent, +// // }; +// // use sp_std::prelude::*; + +// // use frame_system::RawOrigin; +// pub struct Pallet(Audit); +// pub trait Config: +// crate::Config +// + pallet_cess_staking::Config +// + pallet_tee_worker::benchmarking::Config +// + pallet_sminer::benchmarking::Config +// + pallet_file_bank::benchmarking::Config +// { +// } + +// const USER_SEED: u32 = 999666; + +// const SEED: u32 = 2190502; + +// const MINER_LIST: [&'static str; 30] = [ +// "miner1", "miner2", "miner3", "miner4", "miner5", "miner6", "miner7", "miner8", "miner9", +// "miner10", "miner11", "miner12", "miner13", "miner14", "miner15", "miner16", "miner17", +// "miner18", "miner19", "miner20", "miner21", "miner22", "miner23", "miner24", "miner25", +// "miner26", "miner27", "miner28", "miner29", "miner30", +// ]; + +// pub fn bench_generate_challenge() { +// let space_challenge_param = [ +// 67_549_635, 67_864_236, 67_338_392, 67_130_229, 67_369_766, 67_193_409, 67_799_602, +// 67_425_292, +// ]; +// let random_index_list = [ +// 691, 406, 838, 480, 996, 798, 362, 456, 144, 666, 1, 018, 568, 992, 650, 729, 808, 229, +// 623, 499, 671, 254, 24, 217, 698, 648, 781, 460, 298, 548, 742, 364, 183, 114, 309, 564, +// 127, 154, 815, 651, 397, 576, 697, 358, 880, 73, 629, 66, +// ]; +// let random_list = [[55u8; 20]; 48]; + +// let mut miner_snapshot_list: BoundedVec< +// MinerSnapShot, BlockNumberOf>, +// ::ChallengeMinerMax, +// > = Default::default(); +// let mut total_idle_space: u128 = u128::MIN; +// let mut total_service_space: u128 = u128::MIN; +// let all_miner = +// ::MinerControl::get_all_miner().expect("get all miner error!"); +// for miner in all_miner.into_iter() { +// let (idle_space, service_space, service_bloom_filter, space_proof_info, tee_signature) = +// ::MinerControl::get_miner_snapshot(&miner) +// .expect("get miner snapshot failed"); +// if (idle_space == 0) && (service_space == 0) { +// continue +// } +// total_idle_space = total_idle_space.checked_add(idle_space).expect("overflow"); +// total_service_space = total_service_space.checked_add(service_space).expect("overflow"); +// let miner_snapshot = MinerSnapShot::, BlockNumberOf> { +// miner, +// idle_life: 200u32.saturated_into(), +// service_life: 200u32.saturated_into(), +// idle_space, +// service_space, +// idle_submitted: false, +// service_submitted: false, +// service_bloom_filter, +// space_proof_info, +// tee_signature, +// }; +// miner_snapshot_list.try_push(miner_snapshot).unwrap(); +// } + +// let _ = pallet_sminer::benchmarking::increase_reward::(1_000_000_000_000_000u128); + +// let net_snap_shot = NetSnapShot::> { +// start: 1u32.saturated_into(), +// life: 2000u32.saturated_into(), +// total_reward: 1_000_000_000_000_000u128, +// total_idle_space, +// total_service_space, +// random_index_list: random_index_list.to_vec().try_into().expect("BoundedVec Error"), +// random_list: random_list.to_vec().try_into().expect("BoundedVec Error"), +// space_challenge_param, +// }; + +// let challenge_info = ChallengeInfo:: { net_snap_shot, miner_snapshot_list }; +// >::put(challenge_info); +// let duration: BlockNumberOf = 5000u32.saturated_into(); +// >::put(duration); +// let duration: BlockNumberOf = 6000u32.saturated_into(); +// >::put(duration); +// } + +// benchmarks! { +// submit_idle_proof { +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 5 { +// let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; +// pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; +// } +// bench_generate_challenge::(); +// let miner: AccountOf = account("miner1", 100, SEED); +// let idle_total_hash: BoundedVec = [5u8; 256].to_vec().try_into().unwrap(); +// }: _(RawOrigin::Signed(miner.clone()), idle_total_hash) +// verify { +// let challenge_snap_shot = >::try_get().unwrap(); +// let mut miner_list: Vec> = Default::default(); +// for (index, miner_snapshot) in challenge_snap_shot.miner_snapshot_list.iter().enumerate() { +// miner_list.push(miner_snapshot.miner.clone()); +// if miner_snapshot.miner == miner { +// assert_eq!(miner_snapshot.idle_submitted, true); +// } +// } +// assert!(miner_list.contains(&miner)); +// } + +// submit_service_proof { +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 5 { +// let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; +// pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; +// } +// bench_generate_challenge::(); +// let miner: AccountOf = account("miner1", 100, SEED); +// let sigma: BoundedVec = [5u8; 2048].to_vec().try_into().unwrap(); +// }: _(RawOrigin::Signed(miner.clone()), sigma) +// verify { +// let challenge_snap_shot = >::try_get().unwrap(); +// let mut miner_list: Vec> = Default::default(); +// for (index, miner_snapshot) in challenge_snap_shot.miner_snapshot_list.iter().enumerate() { +// miner_list.push(miner_snapshot.miner.clone()); +// if miner_snapshot.miner == miner { +// assert_eq!(miner_snapshot.service_submitted, true); +// } +// } +// assert!(miner_list.contains(&miner)); +// } + +// submit_verify_idle_result { +// let (_, controller_acc) = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 5 { +// let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; +// pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; +// } +// bench_generate_challenge::(); +// let miner: AccountOf = account("miner1", 100, SEED); +// let idle_total_hash: BoundedVec = [5u8; 256].to_vec().try_into().unwrap(); +// let sigma: BoundedVec = [5u8; 2048].to_vec().try_into().unwrap(); +// Audit::::submit_idle_proof(RawOrigin::Signed(miner.clone()).into(), idle_total_hash.clone())?; +// Audit::::submit_service_proof(RawOrigin::Signed(miner.clone()).into(), sigma.clone())?; + +// let random_index_list = [691, 406, 838, 480, 996, 798, 362, 456, 144, 666, 1, 018, 568, 992, 650, 729, 808, 229, 623, 499, 671, 254, 24, 217, 698, 648, 781, 460, 298, 548, 742, 364, 183, 114, 309, 564, 127, 154, 815, 651, 397, 576, 697, 358, 880, 73, 629, 66]; +// let random_list = [[55u8; 20]; 48]; +// let verify_service_result = VerifyServiceResultInfo::{ +// miner: miner.clone(), +// tee_acc: controller_acc.clone(), +// miner_prove: sigma.clone(), +// result: true, +// chal: QElement { +// random_index_list: random_index_list.to_vec().try_into().unwrap(), +// random_list: random_list.to_vec().try_into().unwrap(), +// }, +// service_bloom_filter: cp_bloom_filter::BloomFilter([0u64; 256]), +// }; + +// let sig = [51, 231, 229, 255, 95, 218, 131, 76, 213, 104, 14, 3, 79, 205, 33, 157, 39, 190, 5, 169, 27, 210, 250, 86, 103, 116, 218, 23, 255, 252, 221, 247, 82, 109, 185, 200, 134, 188, 81, 199, 219, 245, 30, 42, 228, 193, 208, 135, 209, 24, 232, 30, 104, 90, 156, 215, 174, 98, 143, 143, 119, 217, 72, 24, 247, 232, 191, 246, 205, 57, 221, 124, 234, 135, 110, 184, 208, 77, 60, 64, 169, 75, 168, 123, 244, 134, 187, 187, 65, 62, 237, 10, 246, 102, 44, 235, 68, 175, 91, 36, 58, 157, 213, 63, 184, 32, 38, 242, 57, 255, 190, 251, 214, 41, 53, 36, 190, 66, 47, 100, 153, 110, 88, 6, 221, 250, 183, 169, 76, 203, 9, 188, 187, 79, 149, 16, 145, 155, 97, 89, 56, 94, 187, 65, 197, 133, 121, 0, 73, 115, 166, 148, 177, 62, 121, 137, 96, 86, 3, 111, 153, 108, 230, 241, 190, 114, 169, 249, 118, 50, 130, 46, 190, 127, 131, 142, 253, 217, 138, 102, 215, 162, 47, 94, 83, 36, 117, 25, 24, 125, 11, 91, 112, 211, 201, 28, 64, 141, 129, 14, 117, 2, 124, 217, 229, 179, 192, 34, 0, 37, 187, 44, 38, 170, 116, 176, 175, 96, 207, 181, 144, 30, 246, 170, 98, 206, 88, 176, 141, 118, 180, 99, 107, 196, 201, 206, 144, 81, 154, 138, 115, 38, 88, 219, 8, 55, 221, 20, 222, 106, 134, 98, 184, 92, 253, 185]; +// Audit::::submit_verify_service_result(RawOrigin::Signed(miner.clone()).into(), verify_service_result.result, sig, verify_service_result.service_bloom_filter, verify_service_result.tee_acc)?; + +// let verify_idle_result = VerifyIdleResultInfo::{ +// miner: miner.clone(), +// miner_prove: idle_total_hash.clone(), +// front: 0, +// rear: 10000, +// accumulator: [8u8; 256], +// space_challenge_param: [67_549_635, 67_864_236, 67_338_392, 67_130_229, 67_369_766, 67_193_409, 67_799_602, 67_425_292], +// result: true, +// tee_acc: controller_acc.clone(), +// }; + +// let sig = [105, 84, 152, 186, 134, 202, 80, 152, 159, 223, 251, 150, 106, 226, 63, 179, 168, 182, 237, 158, 111, 17, 68, 195, 39, 255, 75, 98, 67, 232, 10, 129, 175, 254, 222, 147, 45, 182, 91, 235, 26, 246, 88, 16, 106, 100, 241, 54, 236, 205, 224, 173, 113, 54, 71, 0, 95, 157, 184, 238, 54, 114, 40, 145, 44, 87, 163, 77, 177, 34, 211, 247, 51, 174, 53, 20, 151, 186, 173, 135, 83, 150, 197, 172, 121, 181, 203, 164, 10, 104, 163, 51, 110, 231, 241, 26, 112, 214, 127, 139, 247, 33, 158, 252, 146, 157, 47, 53, 172, 50, 111, 45, 249, 109, 145, 173, 10, 228, 133, 34, 163, 4, 254, 140, 64, 252, 136, 40, 87, 242, 36, 83, 15, 23, 182, 77, 9, 197, 223, 36, 129, 3, 41, 247, 102, 143, 192, 42, 251, 16, 215, 193, 1, 19, 154, 245, 212, 209, 52, 1, 80, 248, 118, 47, 114, 202, 238, 173, 244, 154, 218, 209, 71, 185, 76, 15, 0, 56, 213, 201, 228, 193, 105, 160, 48, 247, 134, 58, 91, 121, 75, 144, 163, 89, 105, 176, 29, 30, 169, 70, 205, 202, 188, 230, 207, 171, 95, 253, 14, 103, 249, 144, 213, 44, 57, 142, 82, 252, 103, 201, 183, 218, 31, 131, 219, 108, 83, 115, 198, 3, 14, 244, 178, 48, 196, 128, 100, 53, 1, 10, 31, 37, 205, 163, 20, 181, 71, 152, 171, 180, 102, 208, 1, 241, 174, 28]; +// }: _(RawOrigin::Signed(miner.clone()), verify_idle_result.miner_prove, verify_idle_result.front, verify_idle_result.rear, verify_idle_result.accumulator, verify_idle_result.result, sig, verify_idle_result.tee_acc) +// verify { +// let unverify_list = >::try_get(&controller_acc).unwrap(); +// assert_eq!(0, unverify_list.len()); +// } + +// submit_verify_service_result { +// let (_, controller_acc) = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 5 { +// let miner = pallet_sminer::benchmarking::add_miner::(MINER_LIST[i as usize])?; +// pallet_file_bank::benchmarking::add_idle_space::(miner.clone())?; +// } +// bench_generate_challenge::(); +// let miner: AccountOf = account("miner1", 100, SEED); +// let idle_total_hash: BoundedVec = [5u8; 256].to_vec().try_into().unwrap(); +// let sigma: BoundedVec = [5u8; 2048].to_vec().try_into().unwrap(); +// Audit::::submit_idle_proof(RawOrigin::Signed(miner.clone()).into(), idle_total_hash.clone())?; +// Audit::::submit_service_proof(RawOrigin::Signed(miner.clone()).into(), sigma.clone())?; + +// let verify_idle_result = VerifyIdleResultInfo::{ +// miner: miner.clone(), +// miner_prove: idle_total_hash.clone(), +// front: 0, +// rear: 10000, +// accumulator: [8u8; 256], +// space_challenge_param: [67_549_635, 67_864_236, 67_338_392, 67_130_229, 67_369_766, 67_193_409, 67_799_602, 67_425_292], +// result: true, +// tee_acc: controller_acc.clone(), +// }; +// let sig = [105, 84, 152, 186, 134, 202, 80, 152, 159, 223, 251, 150, 106, 226, 63, 179, 168, 182, 237, 158, 111, 17, 68, 195, 39, 255, 75, 98, 67, 232, 10, 129, 175, 254, 222, 147, 45, 182, 91, 235, 26, 246, 88, 16, 106, 100, 241, 54, 236, 205, 224, 173, 113, 54, 71, 0, 95, 157, 184, 238, 54, 114, 40, 145, 44, 87, 163, 77, 177, 34, 211, 247, 51, 174, 53, 20, 151, 186, 173, 135, 83, 150, 197, 172, 121, 181, 203, 164, 10, 104, 163, 51, 110, 231, 241, 26, 112, 214, 127, 139, 247, 33, 158, 252, 146, 157, 47, 53, 172, 50, 111, 45, 249, 109, 145, 173, 10, 228, 133, 34, 163, 4, 254, 140, 64, 252, 136, 40, 87, 242, 36, 83, 15, 23, 182, 77, 9, 197, 223, 36, 129, 3, 41, 247, 102, 143, 192, 42, 251, 16, 215, 193, 1, 19, 154, 245, 212, 209, 52, 1, 80, 248, 118, 47, 114, 202, 238, 173, 244, 154, 218, 209, 71, 185, 76, 15, 0, 56, 213, 201, 228, 193, 105, 160, 48, 247, 134, 58, 91, 121, 75, 144, 163, 89, 105, 176, 29, 30, 169, 70, 205, 202, 188, 230, 207, 171, 95, 253, 14, 103, 249, 144, 213, 44, 57, 142, 82, 252, 103, 201, 183, 218, 31, 131, 219, 108, 83, 115, 198, 3, 14, 244, 178, 48, 196, 128, 100, 53, 1, 10, 31, 37, 205, 163, 20, 181, 71, 152, 171, 180, 102, 208, 1, 241, 174, 28]; +// Audit::::submit_verify_idle_result(RawOrigin::Signed(miner.clone()).into(), verify_idle_result.miner_prove, verify_idle_result.front, verify_idle_result.rear, verify_idle_result.accumulator, verify_idle_result.result, sig, verify_idle_result.tee_acc)?; + +// let random_index_list = [691, 406, 838, 480, 996, 798, 362, 456, 144, 666, 1, 018, 568, 992, 650, 729, 808, 229, 623, 499, 671, 254, 24, 217, 698, 648, 781, 460, 298, 548, 742, 364, 183, 114, 309, 564, 127, 154, 815, 651, 397, 576, 697, 358, 880, 73, 629, 66]; +// let random_list = [[55u8; 20]; 48]; +// let verify_service_result = VerifyServiceResultInfo::{ +// miner: miner.clone(), +// tee_acc: controller_acc.clone(), +// miner_prove: sigma.clone(), +// result: true, +// chal: QElement { +// random_index_list: random_index_list.to_vec().try_into().unwrap(), +// random_list: random_list.to_vec().try_into().unwrap(), +// }, +// service_bloom_filter: cp_bloom_filter::BloomFilter([0u64; 256]), +// }; + +// let sig = [51, 231, 229, 255, 95, 218, 131, 76, 213, 104, 14, 3, 79, 205, 33, 157, 39, 190, 5, 169, 27, 210, 250, 86, 103, 116, 218, 23, 255, 252, 221, 247, 82, 109, 185, 200, 134, 188, 81, 199, 219, 245, 30, 42, 228, 193, 208, 135, 209, 24, 232, 30, 104, 90, 156, 215, 174, 98, 143, 143, 119, 217, 72, 24, 247, 232, 191, 246, 205, 57, 221, 124, 234, 135, 110, 184, 208, 77, 60, 64, 169, 75, 168, 123, 244, 134, 187, 187, 65, 62, 237, 10, 246, 102, 44, 235, 68, 175, 91, 36, 58, 157, 213, 63, 184, 32, 38, 242, 57, 255, 190, 251, 214, 41, 53, 36, 190, 66, 47, 100, 153, 110, 88, 6, 221, 250, 183, 169, 76, 203, 9, 188, 187, 79, 149, 16, 145, 155, 97, 89, 56, 94, 187, 65, 197, 133, 121, 0, 73, 115, 166, 148, 177, 62, 121, 137, 96, 86, 3, 111, 153, 108, 230, 241, 190, 114, 169, 249, 118, 50, 130, 46, 190, 127, 131, 142, 253, 217, 138, 102, 215, 162, 47, 94, 83, 36, 117, 25, 24, 125, 11, 91, 112, 211, 201, 28, 64, 141, 129, 14, 117, 2, 124, 217, 229, 179, 192, 34, 0, 37, 187, 44, 38, 170, 116, 176, 175, 96, 207, 181, 144, 30, 246, 170, 98, 206, 88, 176, 141, 118, 180, 99, 107, 196, 201, 206, 144, 81, 154, 138, 115, 38, 88, 219, 8, 55, 221, 20, 222, 106, 134, 98, 184, 92, 253, 185]; +// }: _(RawOrigin::Signed(miner.clone()), verify_service_result.result, sig, verify_service_result.service_bloom_filter, verify_service_result.tee_acc) +// verify { +// let unverify_list = >::try_get(&controller_acc).unwrap(); +// assert_eq!(0, unverify_list.len()); +// } +// } diff --git a/pallets/audit/src/weights_demo.rs b/pallets/audit/src/weights_demo.rs new file mode 100644 index 00000000..d0dbc245 --- /dev/null +++ b/pallets/audit/src/weights_demo.rs @@ -0,0 +1,90 @@ + +//! Autogenerated weights for `pallet_cacher` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-01-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ytqaljn-virtual-machine`, CPU: `12th Gen Intel(R) Core(TM) i5-12400` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("cess-initial-devnet")`, DB CACHE: 1024 + +// Executed Command: +// ./target/release/cess-node +// benchmark +// pallet +// --chain +// cess-initial-devnet +// --execution=wasm +// --wasm-execution=compiled +// --pallet +// pallet_cacher +// --extrinsic +// * +// --steps +// 50 +// --repeat +// 20 +// --output=./pallets/audit/src/weights_demo.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_cacher`. +pub struct WeightInfo(PhantomData); +impl pallet_cacher::WeightInfo for WeightInfo { + /// Storage: `Cacher::Cachers` (r:1 w:1) + /// Proof: `Cacher::Cachers` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `80` + // Estimated: `3580` + // Minimum execution time: 11_975_000 picoseconds. + Weight::from_parts(13_053_000, 0) + .saturating_add(Weight::from_parts(0, 3580)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Cacher::Cachers` (r:1 w:1) + /// Proof: `Cacher::Cachers` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + fn update() -> Weight { + // Proof Size summary in bytes: + // Measured: `211` + // Estimated: `3580` + // Minimum execution time: 14_386_000 picoseconds. + Weight::from_parts(18_079_000, 0) + .saturating_add(Weight::from_parts(0, 3580)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Cacher::Cachers` (r:1 w:1) + /// Proof: `Cacher::Cachers` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + fn logout() -> Weight { + // Proof Size summary in bytes: + // Measured: `185` + // Estimated: `3580` + // Minimum execution time: 12_361_000 picoseconds. + Weight::from_parts(15_192_000, 0) + .saturating_add(Weight::from_parts(0, 3580)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `v` is `[0, 10]`. + fn pay(v: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `205` + // Estimated: `6196` + // Minimum execution time: 8_558_000 picoseconds. + Weight::from_parts(15_485_833, 0) + .saturating_add(Weight::from_parts(0, 6196)) + // Standard Error: 79_154 + .saturating_add(Weight::from_parts(29_876_773, 0).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/pallets/file-bank/src/benchmarking.rs b/pallets/file-bank/src/benchmarking.rs index 39389e07..2e3bbd4c 100755 --- a/pallets/file-bank/src/benchmarking.rs +++ b/pallets/file-bank/src/benchmarking.rs @@ -1,626 +1,626 @@ -use super::*; -use crate::{Pallet as FileBank, *}; -use cp_cess_common::{Hash, IpAddress}; -use codec::{alloc::string::ToString, Decode}; -pub use frame_benchmarking::{ - account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, -}; -use frame_support::{ - dispatch::UnfilteredDispatchable, - pallet_prelude::*, - traits::{Currency, CurrencyToVote, Get, Imbalance}, -}; - -use pallet_cess_staking::{ - testing_utils, Config as StakingConfig, Pallet as Staking, RewardDestination, -}; -use pallet_tee_worker::{Config as TeeWorkerConfig, Pallet as TeeWorker}; -use pallet_sminer::{Config as SminerConfig, Pallet as Sminer}; -use pallet_storage_handler::{Pallet as StorageHandler}; -use sp_runtime::{ - traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, - Perbill, Percent, Digest, DigestItem, -}; -use sp_std::prelude::*; -use scale_info::prelude::format; -use frame_system::RawOrigin; -use sp_runtime::traits::BlakeTwo256; -use cessp_consensus_rrsc::{Slot, RRSC_ENGINE_ID}; -pub struct Pallet(FileBank); -pub trait Config: - crate::Config + pallet_sminer::benchmarking::Config + pallet_storage_handler::Config + pallet_rrsc::Config + pallet_grandpa::Config + pallet_session::Config -{ -} -type SminerBalanceOf = <::Currency as Currency< - ::AccountId, ->>::Balance; - -const SEED: u32 = 2190502; -const miner_list: [&'static str; 30] = [ - "miner1", "miner2", "miner3", "miner4", "miner5", "miner6", "miner7", "miner8", "miner9", "miner10", - "miner11", "miner12", "miner13", "miner14", "miner15", "miner16", "miner17", "miner18", "miner19", "miner20", - "miner21", "miner22", "miner23", "miner24", "miner25", "miner26", "miner27", "miner28", "miner29", "miner30", -]; -// const MAX_SPANS: u32 = 100; -pub struct DealSubmitInfo { - file_hash: Hash, - user_brief: UserBrief, - segment_list: BoundedVec, T::SegmentCount>, - file_size: u128, -} - -pub fn add_idle_space(miner: T::AccountId) -> Result<(), &'static str> { - let idle_space = ::MinerControl::add_miner_idle_space( - &miner, - [8u8; 256], - 10000, - [8u8; 256], - ).expect("add idle space failed, func add_miner_idle_space()"); - - ::StorageHandle::add_total_idle_space(idle_space).expect("add idle space failed, func add_total_idle_space()"); - - Ok(()) -} - -pub fn buy_space(user: T::AccountId) -> Result<(), &'static str> { - ::Currency::make_free_balance_be( - &user, - SminerBalanceOf::::max_value(), - ); - - StorageHandler::::buy_space(RawOrigin::Signed(user).into(), 10)?; - - Ok(()) -} - -pub fn create_deal_info(acc: AccountOf, length: u32, hash_seed: u8) -> Result, &'static str> { - let mut deal_info: BoundedVec, T::SegmentCount> = Default::default(); - let file_name = "test-file".as_bytes().to_vec(); - let bucket_name = "test-bucket1".as_bytes().to_vec(); - let file_hash: Hash = Hash([hash_seed; 64]); - let user_brief = UserBrief::{ - user: acc, - file_name: file_name.try_into().map_err(|_e| "file name convert err")?, - bucket_name: bucket_name.try_into().map_err(|_e| "bucket name convert err")?, - }; - - let mut seed = 0; - for i in 0 .. length { - let segment_list = SegmentList:: { - hash: Hash([1u8; 64]), - fragment_list: [ - Hash([97u8; 64]), - Hash([98u8; 64]), - Hash([99u8; 64]), - ].to_vec().try_into().unwrap(), - }; - - deal_info.try_push(segment_list).unwrap(); - } - - Ok(DealSubmitInfo::{ - file_hash: file_hash, - user_brief: user_brief, - segment_list: deal_info, - file_size: 123, - }) -} - -pub fn create_new_bucket(caller: T::AccountId, name: Vec) -> Result<(), &'static str> { - let name = name.try_into().map_err(|_| "create bucket convert error")?; - FileBank::::create_bucket(RawOrigin::Signed(caller.clone()).into(), caller, name)?; - Ok(()) -} - -benchmarks! { - cert_idle_space { - log::info!("start cert_idle_space"); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - let miner = pallet_sminer::benchmarking::add_miner::("miner1")?; - - let pois_key = PoISKey { - g: [2u8; 256], - n: [3u8; 256], - }; - - let space_proof_info = SpaceProofInfo::> { - miner: miner.clone(), - front: u64::MIN, - rear: 1000, - pois_key: pois_key.clone(), - accumulator: pois_key.g, - }; - - let original = space_proof_info.encode(); - let original = sp_io::hashing::sha2_256(&original); - - log::info!("original: {:?}", original); - - let tee_sig = [19, 66, 60, 64, 120, 225, 105, 244, 158, 246, 90, 112, 6, 239, 63, 152, 116, 41, 57, 4, 4, 217, 206, 100, 138, 168, 193, 247, 62, 155, 76, 164, 179, 117, 202, 77, 182, 109, 223, 103, 50, 197, 214, 153, 233, 158, 124, 138, 64, 252, 54, 62, 250, 128, 177, 239, 248, 98, 31, 77, 208, 8, 91, 241, 66, 205, 89, 240, 211, 84, 250, 194, 206, 106, 35, 25, 154, 82, 174, 156, 14, 10, 201, 1, 45, 70, 50, 89, 202, 96, 42, 93, 227, 71, 119, 211, 11, 210, 192, 113, 249, 221, 217, 116, 181, 116, 206, 56, 43, 238, 147, 157, 38, 95, 79, 73, 221, 41, 87, 203, 162, 172, 32, 9, 173, 190, 225, 160, 118, 34, 77, 121, 73, 79, 199, 66, 32, 131, 174, 158, 210, 97, 172, 72, 251, 183, 247, 74, 207, 46, 201, 97, 90, 171, 251, 245, 202, 155, 8, 168, 199, 206, 64, 97, 66, 215, 6, 251, 111, 32, 37, 56, 60, 178, 2, 155, 167, 207, 224, 56, 20, 196, 162, 9, 188, 137, 225, 48, 117, 217, 229, 183, 122, 157, 93, 12, 142, 131, 239, 44, 12, 157, 55, 246, 59, 22, 216, 112, 84, 42, 54, 226, 99, 46, 246, 5, 110, 15, 122, 247, 46, 244, 132, 195, 60, 54, 98, 232, 53, 162, 82, 107, 134, 218, 70, 71, 148, 75, 31, 65, 33, 193, 221, 20, 124, 128, 42, 9, 116, 181, 125, 77, 33, 202, 152, 179]; - - }: _(RawOrigin::Signed(miner.clone()), space_proof_info, tee_sig) - verify { - let (idle, service) = T::MinerControl::get_power(&miner)?; - assert_eq!(idle, 1000 * IDLE_SEG_SIZE); - } - - upload_declaration { - let v in 1 .. 30; - log::info!("start upload_declaration"); - // as Hooks>::on_initialize(1u32.saturated_into()); - // >::set_block_number(1u32.saturated_into()); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - - for i in 0 .. v { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - let mut deal_info: BoundedVec, T::SegmentCount> = Default::default(); - let file_name = "test-file".as_bytes().to_vec(); - let bucket_name = "test-bucket1".as_bytes().to_vec(); - let file_hash: Hash = Hash([4u8; 64]); - let user_brief = UserBrief::{ - user: caller.clone(), - file_name: file_name.try_into().map_err(|_e| "file name convert err")?, - bucket_name: bucket_name.try_into().map_err(|_e| "bucket name convert err")?, - }; - let segment_list = SegmentList:: { - hash: Hash([1u8; 64]), - fragment_list: [ - Hash([2u8; 64]), - Hash([3u8; 64]), - Hash([4u8; 64]), - ].to_vec().try_into().unwrap(), - }; - deal_info.try_push(segment_list).unwrap(); - let segment_list = SegmentList:: { - hash: Hash([2u8; 64]), - fragment_list: [ - Hash([2u8; 64]), - Hash([3u8; 64]), - Hash([4u8; 64]), - ].to_vec().try_into().unwrap(), - }; - deal_info.try_push(segment_list).unwrap(); - let segment_list = SegmentList:: { - hash: Hash([3u8; 64]), - fragment_list: [ - Hash([2u8; 64]), - Hash([3u8; 64]), - Hash([4u8; 64]), - ].to_vec().try_into().unwrap(), - }; - deal_info.try_push(segment_list).unwrap(); - }: _(RawOrigin::Signed(caller), file_hash.clone(), deal_info, user_brief, 123) - verify { - assert!(DealMap::::contains_key(&file_hash)); - } - - upload_declaration_expected_max { - let v in 1 .. 30; - log::info!("start upload_declaration_expected_max"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 30 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - if i < 27 { - pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; - } - } - buy_space::(caller.clone())?; - - let deal_info = create_deal_info::(caller.clone(), v, 4)?; - }: upload_declaration(RawOrigin::Signed(caller), deal_info.file_hash.clone(), deal_info.segment_list, deal_info.user_brief, deal_info.file_size) - verify { - assert!(DealMap::::contains_key(&deal_info.file_hash)); - } - - transfer_report { - let v in 1 .. 30; - log::info!("start transfer_report"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 3 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - - }: _(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()), deal_submit_info.file_hash) - verify { - let deal_info = DealMap::::get(deal_submit_info.file_hash).unwrap(); - assert_eq!(deal_info.complete_list.len(), 1); - } - - transfer_report_last { - let v in 1 .. 30; - log::info!("start transfer_report_last"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 15 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - if i < 12 { - pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; - } - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - }: transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()), deal_submit_info.file_hash) - verify { - assert!(File::::contains_key(&deal_submit_info.file_hash)); - } - - upload_declaration_fly_upload { - let v in 1 .. 30; - log::info!("start upload_declaration_fly_upload"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 15 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - if i < 12 { - pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; - } - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - let caller: AccountOf = account("user2", 100, SEED); - buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - }: upload_declaration(RawOrigin::Signed(caller.clone()), deal_submit_info.file_hash.clone(), deal_submit_info.segment_list, deal_submit_info.user_brief.clone(), deal_submit_info.file_size) - verify { - let file = File::::get(deal_submit_info.file_hash.clone()).unwrap(); - assert!(file.owner.contains(&deal_submit_info.user_brief)) - } - - deal_reassign_miner { - let v in 0 ..30; - log::info!("start deal_reassign_miner"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 30 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - if i < 24 { - pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; - } - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller.clone()).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - ::FScheduler::cancel_named([4u8; 64].to_vec()).expect("cancel scheduler failed"); - }: _(RawOrigin::Root, deal_submit_info.file_hash.clone(), 1, 200) - verify { - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - assert_eq!(deal_info.count, 1); - } - - deal_reassign_miner_exceed_limit { - let v in 0 ..30; - log::info!("start deal_reassign_miner_exceed_limit"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 30 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - if i < 24 { - pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; - } - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller.clone()).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - }: deal_reassign_miner(RawOrigin::Root, deal_submit_info.file_hash.clone(), 20, 200) - verify { - assert!(!DealMap::::contains_key(&deal_submit_info.file_hash)); - } - - calculate_end { - let v in 1 .. 30; - log::info!("start calculate_end"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 5 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - let file_info = File::::get(&deal_submit_info.file_hash).unwrap(); - }: _(RawOrigin::Root, deal_submit_info.file_hash) - verify { - let file_info = File::::get(&deal_submit_info.file_hash).unwrap(); - assert_eq!(FileState::Active, file_info.stat); - } - - replace_idle_space { - log::info!("start replace_idle_space"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 3 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - let miner: AccountOf = account("miner1", 100, SEED); - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - - let avail_replace_space = deal_info.assigned_miner[0].fragment_list.len() as u128 * FRAGMENT_SIZE; - let front = avail_replace_space / IDLE_SEG_SIZE; - - let pois_key = PoISKey { - g: [2u8; 256], - n: [3u8; 256], - }; - - let space_proof_info = SpaceProofInfo::> { - miner: miner.clone(), - front: front as u64, - rear: 10000, - pois_key: pois_key.clone(), - accumulator: pois_key.g, - }; - let encoding = space_proof_info.encode(); - let hashing = sp_io::hashing::sha2_256(&encoding); - log::info!("replace_idle_space hashing: {:?}", hashing); - - let tee_sig = [11, 155, 78, 85, 105, 233, 219, 127, 241, 166, 154, 21, 185, 76, 67, 196, 13, 233, 94, 42, 83, 110, 93, 124, 132, 244, 5, 233, 254, 238, 160, 73, 24, 130, 215, 13, 120, 203, 172, 10, 186, 82, 142, 3, 51, 151, 242, 175, 14, 77, 93, 167, 181, 105, 32, 108, 16, 44, 185, 159, 53, 38, 102, 134, 81, 3, 57, 100, 32, 117, 35, 157, 78, 215, 88, 41, 201, 102, 63, 28, 190, 206, 116, 140, 101, 3, 136, 177, 201, 188, 32, 56, 195, 36, 217, 238, 111, 54, 119, 70, 199, 55, 183, 252, 210, 204, 33, 29, 88, 253, 15, 29, 194, 18, 93, 170, 144, 25, 66, 120, 210, 253, 203, 236, 74, 191, 234, 84, 130, 164, 22, 142, 251, 105, 178, 69, 80, 111, 115, 54, 71, 67, 48, 215, 5, 132, 234, 26, 207, 102, 18, 62, 185, 184, 78, 9, 159, 158, 180, 78, 78, 242, 219, 229, 234, 238, 211, 103, 158, 132, 62, 219, 34, 242, 32, 254, 104, 136, 114, 210, 180, 52, 17, 17, 0, 119, 35, 129, 25, 175, 99, 37, 55, 195, 159, 157, 120, 82, 6, 38, 47, 105, 111, 114, 51, 47, 170, 123, 196, 78, 98, 128, 220, 246, 159, 237, 101, 111, 213, 219, 5, 177, 76, 150, 22, 34, 82, 59, 70, 204, 219, 38, 78, 50, 179, 36, 93, 132, 84, 24, 69, 176, 93, 230, 11, 1, 140, 53, 108, 72, 107, 200, 238, 197, 28, 59]; - }: _(RawOrigin::Signed(miner.clone()), space_proof_info, tee_sig) - verify { - let space = PendingReplacements::::get(&miner); - assert_eq!(space, avail_replace_space - (front * IDLE_SEG_SIZE)); - } - - delete_file { - let v in 0 .. 30; - log::info!("start delete_file"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 3 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller.clone()).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash.clone()); - }: _(RawOrigin::Signed(caller.clone()), caller.clone(), vec![deal_submit_info.file_hash.clone()]) - verify { - assert!(!>::contains_key(&deal_submit_info.file_hash.clone())); - } - - create_bucket { - log::info!("start create_bucket"); - let caller: AccountOf = account("user1", 100, SEED); - let name: Vec = "test-bucket1".as_bytes().to_vec(); - let name: BoundedVec = name.try_into().map_err(|_| "name convert error")?; - }: _(RawOrigin::Signed(caller.clone()), caller.clone(), name.clone()) - verify { - assert!(Bucket::::contains_key(&caller, name)); - } - - delete_bucket { - log::info!("start delete_bucket"); - let caller: AccountOf = account("user1", 100, SEED); - let name: Vec = "test-bucket1".as_bytes().to_vec(); - let name_bound: BoundedVec = name.clone().try_into().map_err(|_| "bounded_vec convert err!")?; - create_new_bucket::(caller.clone(), name.clone())?; - Bucket::::contains_key(&caller, name_bound.clone()); - }: _(RawOrigin::Signed(caller.clone()), caller.clone(), name_bound.clone()) - verify { - assert!(!Bucket::::contains_key(&caller, name_bound)); - } - - generate_restoral_order { - log::info!("start generate_restoral_order"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 4 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller.clone()).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash.clone()); - }: _(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()), deal_submit_info.file_hash, Hash([99u8; 64])) - verify { - assert!(>::contains_key(&Hash([99u8; 64]))) - } - - claim_restoral_order { - log::info!("start claim_restoral_order"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 3 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; - FileBank::::generate_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash, Hash([99u8; 64]))?; - }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), Hash([99u8; 64])) - verify { - let restoral_info = >::try_get(&Hash([99u8; 64])).unwrap(); - assert_eq!(restoral_info.miner, deal_info.assigned_miner[1].miner); - } - - restoral_order_complete { - log::info!("start restoral_order_complete"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 3 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; - FileBank::::generate_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash, Hash([99u8; 64]))?; - frame_system::pallet::Pallet::::set_block_number(2u32.saturated_into()); - FileBank::::claim_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), Hash([99u8; 64]))?; - }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), Hash([99u8; 64])) - verify { - assert!(!>::contains_key(Hash([97u8; 64]))) - } - - claim_restoral_noexist_order { - log::info!("start claim_restoral_noexist_order"); - let caller: AccountOf = account("user1", 100, SEED); - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 3 { - let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; - add_idle_space::(miner.clone())?; - } - buy_space::(caller.clone())?; - - let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; - FileBank::::upload_declaration( - RawOrigin::Signed(caller).into(), - deal_submit_info.file_hash.clone(), - deal_submit_info.segment_list, - deal_submit_info.user_brief, - deal_submit_info.file_size, - )?; - - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; - FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; - pallet_sminer::benchmarking::bench_miner_exit::(deal_info.assigned_miner[2].miner.clone())?; - }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), deal_info.assigned_miner[2].miner.clone(), deal_submit_info.file_hash, Hash([99u8; 64])) - verify { - assert!(>::contains_key(Hash([99u8; 64]))) - } -} \ No newline at end of file +// use super::*; +// use crate::{Pallet as FileBank, *}; +// use cp_cess_common::{Hash, IpAddress}; +// use codec::{alloc::string::ToString, Decode}; +// pub use frame_benchmarking::{ +// account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, +// }; +// use frame_support::{ +// dispatch::UnfilteredDispatchable, +// pallet_prelude::*, +// traits::{Currency, CurrencyToVote, Get, Imbalance}, +// }; + +// use pallet_cess_staking::{ +// testing_utils, Config as StakingConfig, Pallet as Staking, RewardDestination, +// }; +// use pallet_tee_worker::{Config as TeeWorkerConfig, Pallet as TeeWorker}; +// use pallet_sminer::{Config as SminerConfig, Pallet as Sminer}; +// use pallet_storage_handler::{Pallet as StorageHandler}; +// use sp_runtime::{ +// traits::{Bounded, One, StaticLookup, TrailingZeroInput, Zero}, +// Perbill, Percent, Digest, DigestItem, +// }; +// use sp_std::prelude::*; +// use scale_info::prelude::format; +// use frame_system::RawOrigin; +// use sp_runtime::traits::BlakeTwo256; +// use cessp_consensus_rrsc::{Slot, RRSC_ENGINE_ID}; +// pub struct Pallet(FileBank); +// pub trait Config: +// crate::Config + pallet_sminer::benchmarking::Config + pallet_storage_handler::Config + pallet_rrsc::Config + pallet_grandpa::Config + pallet_session::Config +// { +// } +// type SminerBalanceOf = <::Currency as Currency< +// ::AccountId, +// >>::Balance; + +// const SEED: u32 = 2190502; +// const miner_list: [&'static str; 30] = [ +// "miner1", "miner2", "miner3", "miner4", "miner5", "miner6", "miner7", "miner8", "miner9", "miner10", +// "miner11", "miner12", "miner13", "miner14", "miner15", "miner16", "miner17", "miner18", "miner19", "miner20", +// "miner21", "miner22", "miner23", "miner24", "miner25", "miner26", "miner27", "miner28", "miner29", "miner30", +// ]; +// // const MAX_SPANS: u32 = 100; +// pub struct DealSubmitInfo { +// file_hash: Hash, +// user_brief: UserBrief, +// segment_list: BoundedVec, T::SegmentCount>, +// file_size: u128, +// } + +// pub fn add_idle_space(miner: T::AccountId) -> Result<(), &'static str> { +// let idle_space = ::MinerControl::add_miner_idle_space( +// &miner, +// [8u8; 256], +// 10000, +// [8u8; 256], +// ).expect("add idle space failed, func add_miner_idle_space()"); + +// ::StorageHandle::add_total_idle_space(idle_space).expect("add idle space failed, func add_total_idle_space()"); + +// Ok(()) +// } + +// pub fn buy_space(user: T::AccountId) -> Result<(), &'static str> { +// ::Currency::make_free_balance_be( +// &user, +// SminerBalanceOf::::max_value(), +// ); + +// StorageHandler::::buy_space(RawOrigin::Signed(user).into(), 10)?; + +// Ok(()) +// } + +// pub fn create_deal_info(acc: AccountOf, length: u32, hash_seed: u8) -> Result, &'static str> { +// let mut deal_info: BoundedVec, T::SegmentCount> = Default::default(); +// let file_name = "test-file".as_bytes().to_vec(); +// let bucket_name = "test-bucket1".as_bytes().to_vec(); +// let file_hash: Hash = Hash([hash_seed; 64]); +// let user_brief = UserBrief::{ +// user: acc, +// file_name: file_name.try_into().map_err(|_e| "file name convert err")?, +// bucket_name: bucket_name.try_into().map_err(|_e| "bucket name convert err")?, +// }; + +// let mut seed = 0; +// for i in 0 .. length { +// let segment_list = SegmentList:: { +// hash: Hash([1u8; 64]), +// fragment_list: [ +// Hash([97u8; 64]), +// Hash([98u8; 64]), +// Hash([99u8; 64]), +// ].to_vec().try_into().unwrap(), +// }; + +// deal_info.try_push(segment_list).unwrap(); +// } + +// Ok(DealSubmitInfo::{ +// file_hash: file_hash, +// user_brief: user_brief, +// segment_list: deal_info, +// file_size: 123, +// }) +// } + +// pub fn create_new_bucket(caller: T::AccountId, name: Vec) -> Result<(), &'static str> { +// let name = name.try_into().map_err(|_| "create bucket convert error")?; +// FileBank::::create_bucket(RawOrigin::Signed(caller.clone()).into(), caller, name)?; +// Ok(()) +// } + +// benchmarks! { +// cert_idle_space { +// log::info!("start cert_idle_space"); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// let miner = pallet_sminer::benchmarking::add_miner::("miner1")?; + +// let pois_key = PoISKey { +// g: [2u8; 256], +// n: [3u8; 256], +// }; + +// let space_proof_info = SpaceProofInfo::> { +// miner: miner.clone(), +// front: u64::MIN, +// rear: 1000, +// pois_key: pois_key.clone(), +// accumulator: pois_key.g, +// }; + +// let original = space_proof_info.encode(); +// let original = sp_io::hashing::sha2_256(&original); + +// log::info!("original: {:?}", original); + +// let tee_sig = [19, 66, 60, 64, 120, 225, 105, 244, 158, 246, 90, 112, 6, 239, 63, 152, 116, 41, 57, 4, 4, 217, 206, 100, 138, 168, 193, 247, 62, 155, 76, 164, 179, 117, 202, 77, 182, 109, 223, 103, 50, 197, 214, 153, 233, 158, 124, 138, 64, 252, 54, 62, 250, 128, 177, 239, 248, 98, 31, 77, 208, 8, 91, 241, 66, 205, 89, 240, 211, 84, 250, 194, 206, 106, 35, 25, 154, 82, 174, 156, 14, 10, 201, 1, 45, 70, 50, 89, 202, 96, 42, 93, 227, 71, 119, 211, 11, 210, 192, 113, 249, 221, 217, 116, 181, 116, 206, 56, 43, 238, 147, 157, 38, 95, 79, 73, 221, 41, 87, 203, 162, 172, 32, 9, 173, 190, 225, 160, 118, 34, 77, 121, 73, 79, 199, 66, 32, 131, 174, 158, 210, 97, 172, 72, 251, 183, 247, 74, 207, 46, 201, 97, 90, 171, 251, 245, 202, 155, 8, 168, 199, 206, 64, 97, 66, 215, 6, 251, 111, 32, 37, 56, 60, 178, 2, 155, 167, 207, 224, 56, 20, 196, 162, 9, 188, 137, 225, 48, 117, 217, 229, 183, 122, 157, 93, 12, 142, 131, 239, 44, 12, 157, 55, 246, 59, 22, 216, 112, 84, 42, 54, 226, 99, 46, 246, 5, 110, 15, 122, 247, 46, 244, 132, 195, 60, 54, 98, 232, 53, 162, 82, 107, 134, 218, 70, 71, 148, 75, 31, 65, 33, 193, 221, 20, 124, 128, 42, 9, 116, 181, 125, 77, 33, 202, 152, 179]; + +// }: _(RawOrigin::Signed(miner.clone()), space_proof_info, tee_sig) +// verify { +// let (idle, service) = T::MinerControl::get_power(&miner)?; +// assert_eq!(idle, 1000 * IDLE_SEG_SIZE); +// } + +// upload_declaration { +// let v in 1 .. 30; +// log::info!("start upload_declaration"); +// // as Hooks>::on_initialize(1u32.saturated_into()); +// // >::set_block_number(1u32.saturated_into()); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; + +// for i in 0 .. v { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; +// let mut deal_info: BoundedVec, T::SegmentCount> = Default::default(); +// let file_name = "test-file".as_bytes().to_vec(); +// let bucket_name = "test-bucket1".as_bytes().to_vec(); +// let file_hash: Hash = Hash([4u8; 64]); +// let user_brief = UserBrief::{ +// user: caller.clone(), +// file_name: file_name.try_into().map_err(|_e| "file name convert err")?, +// bucket_name: bucket_name.try_into().map_err(|_e| "bucket name convert err")?, +// }; +// let segment_list = SegmentList:: { +// hash: Hash([1u8; 64]), +// fragment_list: [ +// Hash([2u8; 64]), +// Hash([3u8; 64]), +// Hash([4u8; 64]), +// ].to_vec().try_into().unwrap(), +// }; +// deal_info.try_push(segment_list).unwrap(); +// let segment_list = SegmentList:: { +// hash: Hash([2u8; 64]), +// fragment_list: [ +// Hash([2u8; 64]), +// Hash([3u8; 64]), +// Hash([4u8; 64]), +// ].to_vec().try_into().unwrap(), +// }; +// deal_info.try_push(segment_list).unwrap(); +// let segment_list = SegmentList:: { +// hash: Hash([3u8; 64]), +// fragment_list: [ +// Hash([2u8; 64]), +// Hash([3u8; 64]), +// Hash([4u8; 64]), +// ].to_vec().try_into().unwrap(), +// }; +// deal_info.try_push(segment_list).unwrap(); +// }: _(RawOrigin::Signed(caller), file_hash.clone(), deal_info, user_brief, 123) +// verify { +// assert!(DealMap::::contains_key(&file_hash)); +// } + +// upload_declaration_expected_max { +// let v in 1 .. 30; +// log::info!("start upload_declaration_expected_max"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 30 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// if i < 27 { +// pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; +// } +// } +// buy_space::(caller.clone())?; + +// let deal_info = create_deal_info::(caller.clone(), v, 4)?; +// }: upload_declaration(RawOrigin::Signed(caller), deal_info.file_hash.clone(), deal_info.segment_list, deal_info.user_brief, deal_info.file_size) +// verify { +// assert!(DealMap::::contains_key(&deal_info.file_hash)); +// } + +// transfer_report { +// let v in 1 .. 30; +// log::info!("start transfer_report"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 3 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); + +// }: _(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()), deal_submit_info.file_hash) +// verify { +// let deal_info = DealMap::::get(deal_submit_info.file_hash).unwrap(); +// assert_eq!(deal_info.complete_list.len(), 1); +// } + +// transfer_report_last { +// let v in 1 .. 30; +// log::info!("start transfer_report_last"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 15 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// if i < 12 { +// pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; +// } +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// }: transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()), deal_submit_info.file_hash) +// verify { +// assert!(File::::contains_key(&deal_submit_info.file_hash)); +// } + +// upload_declaration_fly_upload { +// let v in 1 .. 30; +// log::info!("start upload_declaration_fly_upload"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 15 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// if i < 12 { +// pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; +// } +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; +// let caller: AccountOf = account("user2", 100, SEED); +// buy_space::(caller.clone())?; +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// }: upload_declaration(RawOrigin::Signed(caller.clone()), deal_submit_info.file_hash.clone(), deal_submit_info.segment_list, deal_submit_info.user_brief.clone(), deal_submit_info.file_size) +// verify { +// let file = File::::get(deal_submit_info.file_hash.clone()).unwrap(); +// assert!(file.owner.contains(&deal_submit_info.user_brief)) +// } + +// deal_reassign_miner { +// let v in 0 ..30; +// log::info!("start deal_reassign_miner"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 30 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// if i < 24 { +// pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; +// } +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller.clone()).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// ::FScheduler::cancel_named([4u8; 64].to_vec()).expect("cancel scheduler failed"); +// }: _(RawOrigin::Root, deal_submit_info.file_hash.clone(), 1, 200) +// verify { +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// assert_eq!(deal_info.count, 1); +// } + +// deal_reassign_miner_exceed_limit { +// let v in 0 ..30; +// log::info!("start deal_reassign_miner_exceed_limit"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 30 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// if i < 24 { +// pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; +// } +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller.clone()).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; +// }: deal_reassign_miner(RawOrigin::Root, deal_submit_info.file_hash.clone(), 20, 200) +// verify { +// assert!(!DealMap::::contains_key(&deal_submit_info.file_hash)); +// } + +// calculate_end { +// let v in 1 .. 30; +// log::info!("start calculate_end"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 5 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; +// let file_info = File::::get(&deal_submit_info.file_hash).unwrap(); +// }: _(RawOrigin::Root, deal_submit_info.file_hash) +// verify { +// let file_info = File::::get(&deal_submit_info.file_hash).unwrap(); +// assert_eq!(FileState::Active, file_info.stat); +// } + +// replace_idle_space { +// log::info!("start replace_idle_space"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 3 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; +// let miner: AccountOf = account("miner1", 100, SEED); +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; + +// let avail_replace_space = deal_info.assigned_miner[0].fragment_list.len() as u128 * FRAGMENT_SIZE; +// let front = avail_replace_space / IDLE_SEG_SIZE; + +// let pois_key = PoISKey { +// g: [2u8; 256], +// n: [3u8; 256], +// }; + +// let space_proof_info = SpaceProofInfo::> { +// miner: miner.clone(), +// front: front as u64, +// rear: 10000, +// pois_key: pois_key.clone(), +// accumulator: pois_key.g, +// }; +// let encoding = space_proof_info.encode(); +// let hashing = sp_io::hashing::sha2_256(&encoding); +// log::info!("replace_idle_space hashing: {:?}", hashing); + +// let tee_sig = [11, 155, 78, 85, 105, 233, 219, 127, 241, 166, 154, 21, 185, 76, 67, 196, 13, 233, 94, 42, 83, 110, 93, 124, 132, 244, 5, 233, 254, 238, 160, 73, 24, 130, 215, 13, 120, 203, 172, 10, 186, 82, 142, 3, 51, 151, 242, 175, 14, 77, 93, 167, 181, 105, 32, 108, 16, 44, 185, 159, 53, 38, 102, 134, 81, 3, 57, 100, 32, 117, 35, 157, 78, 215, 88, 41, 201, 102, 63, 28, 190, 206, 116, 140, 101, 3, 136, 177, 201, 188, 32, 56, 195, 36, 217, 238, 111, 54, 119, 70, 199, 55, 183, 252, 210, 204, 33, 29, 88, 253, 15, 29, 194, 18, 93, 170, 144, 25, 66, 120, 210, 253, 203, 236, 74, 191, 234, 84, 130, 164, 22, 142, 251, 105, 178, 69, 80, 111, 115, 54, 71, 67, 48, 215, 5, 132, 234, 26, 207, 102, 18, 62, 185, 184, 78, 9, 159, 158, 180, 78, 78, 242, 219, 229, 234, 238, 211, 103, 158, 132, 62, 219, 34, 242, 32, 254, 104, 136, 114, 210, 180, 52, 17, 17, 0, 119, 35, 129, 25, 175, 99, 37, 55, 195, 159, 157, 120, 82, 6, 38, 47, 105, 111, 114, 51, 47, 170, 123, 196, 78, 98, 128, 220, 246, 159, 237, 101, 111, 213, 219, 5, 177, 76, 150, 22, 34, 82, 59, 70, 204, 219, 38, 78, 50, 179, 36, 93, 132, 84, 24, 69, 176, 93, 230, 11, 1, 140, 53, 108, 72, 107, 200, 238, 197, 28, 59]; +// }: _(RawOrigin::Signed(miner.clone()), space_proof_info, tee_sig) +// verify { +// let space = PendingReplacements::::get(&miner); +// assert_eq!(space, avail_replace_space - (front * IDLE_SEG_SIZE)); +// } + +// delete_file { +// let v in 0 .. 30; +// log::info!("start delete_file"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 3 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller.clone()).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash.clone()); +// }: _(RawOrigin::Signed(caller.clone()), caller.clone(), vec![deal_submit_info.file_hash.clone()]) +// verify { +// assert!(!>::contains_key(&deal_submit_info.file_hash.clone())); +// } + +// create_bucket { +// log::info!("start create_bucket"); +// let caller: AccountOf = account("user1", 100, SEED); +// let name: Vec = "test-bucket1".as_bytes().to_vec(); +// let name: BoundedVec = name.try_into().map_err(|_| "name convert error")?; +// }: _(RawOrigin::Signed(caller.clone()), caller.clone(), name.clone()) +// verify { +// assert!(Bucket::::contains_key(&caller, name)); +// } + +// delete_bucket { +// log::info!("start delete_bucket"); +// let caller: AccountOf = account("user1", 100, SEED); +// let name: Vec = "test-bucket1".as_bytes().to_vec(); +// let name_bound: BoundedVec = name.clone().try_into().map_err(|_| "bounded_vec convert err!")?; +// create_new_bucket::(caller.clone(), name.clone())?; +// Bucket::::contains_key(&caller, name_bound.clone()); +// }: _(RawOrigin::Signed(caller.clone()), caller.clone(), name_bound.clone()) +// verify { +// assert!(!Bucket::::contains_key(&caller, name_bound)); +// } + +// generate_restoral_order { +// log::info!("start generate_restoral_order"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 4 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller.clone()).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash.clone()); +// }: _(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()), deal_submit_info.file_hash, Hash([99u8; 64])) +// verify { +// assert!(>::contains_key(&Hash([99u8; 64]))) +// } + +// claim_restoral_order { +// log::info!("start claim_restoral_order"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 3 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; +// FileBank::::generate_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash, Hash([99u8; 64]))?; +// }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), Hash([99u8; 64])) +// verify { +// let restoral_info = >::try_get(&Hash([99u8; 64])).unwrap(); +// assert_eq!(restoral_info.miner, deal_info.assigned_miner[1].miner); +// } + +// restoral_order_complete { +// log::info!("start restoral_order_complete"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 3 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; +// FileBank::::generate_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash, Hash([99u8; 64]))?; +// frame_system::pallet::Pallet::::set_block_number(2u32.saturated_into()); +// FileBank::::claim_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), Hash([99u8; 64]))?; +// }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), Hash([99u8; 64])) +// verify { +// assert!(!>::contains_key(Hash([97u8; 64]))) +// } + +// claim_restoral_noexist_order { +// log::info!("start claim_restoral_noexist_order"); +// let caller: AccountOf = account("user1", 100, SEED); +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// for i in 0 .. 3 { +// let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; +// add_idle_space::(miner.clone())?; +// } +// buy_space::(caller.clone())?; + +// let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; +// FileBank::::upload_declaration( +// RawOrigin::Signed(caller).into(), +// deal_submit_info.file_hash.clone(), +// deal_submit_info.segment_list, +// deal_submit_info.user_brief, +// deal_submit_info.file_size, +// )?; + +// let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; +// FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; +// pallet_sminer::benchmarking::bench_miner_exit::(deal_info.assigned_miner[2].miner.clone())?; +// }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), deal_info.assigned_miner[2].miner.clone(), deal_submit_info.file_hash, Hash([99u8; 64])) +// verify { +// assert!(>::contains_key(Hash([99u8; 64]))) +// } +// } \ No newline at end of file diff --git a/pallets/file-bank/src/lib.rs b/pallets/file-bank/src/lib.rs index bc9bb33e..fae1b58c 100755 --- a/pallets/file-bank/src/lib.rs +++ b/pallets/file-bank/src/lib.rs @@ -117,7 +117,7 @@ pub mod pallet { type FindAuthor: FindAuthor; // Used to find out whether the schedule exists type TeeWorkerHandler: TeeWorkerHandler; - // It is used to control the computing power and space of miners + // It is used to control the computing power and space of miners type MinerControl: MinerControl>; // Interface that can generate random seeds type MyRandomness: Randomness, BlockNumberFor>; diff --git a/pallets/oss/src/benchmarking.rs b/pallets/oss/src/benchmarking.rs index 083be4a6..522d52b3 100644 --- a/pallets/oss/src/benchmarking.rs +++ b/pallets/oss/src/benchmarking.rs @@ -31,30 +31,49 @@ benchmarks! { register { let oss: AccountOf = account("oss", 100, SEED); - let peer_id = [5u8; 38]; - }: _(RawOrigin::Signed(oss.clone()), peer_id.clone()) + let domain: BoundedVec> = Default::default(); + let peer_id = [0u8; 38]; + }: _(RawOrigin::Signed(oss.clone()), peer_id.clone(), domain.clone()) verify { assert!(>::contains_key(&oss)); - let oss_ip = >::get(&oss).unwrap(); - assert_eq!(oss_ip, peer_id); + let oss_info_right = >::get(&oss).unwrap(); + let oss_info = OssInfo { + peer_id: peer_id, + domain: domain, + }; + assert_eq!(oss_info_right, oss_info); } update { let oss: AccountOf = account("oss", 100, SEED); let peer_id = [5u8; 38]; - >::insert(&oss, peer_id); + let domain: BoundedVec> = Default::default(); + let oss_info = OssInfo { + peer_id: peer_id.clone(), + domain: domain.clone(), + }; + >::insert(&oss, oss_info); let new_peer_id = [6u8; 38]; - }: _(RawOrigin::Signed(oss.clone()), new_peer_id.clone()) + }: _(RawOrigin::Signed(oss.clone()), new_peer_id.clone(), domain.clone()) verify { assert!(>::contains_key(&oss)); - let oss_peer_id = >::get(&oss).unwrap(); - assert_eq!(new_peer_id, oss_peer_id); + let oss_info = OssInfo { + peer_id: new_peer_id, + domain: domain, + }; + let cur_oss_info = >::get(&oss).unwrap(); + assert_eq!(cur_oss_info, oss_info); } destroy { let oss: AccountOf = account("oss", 100, SEED); let peer_id = [5u8; 38]; - >::insert(&oss, peer_id.clone()); + let domain: BoundedVec> = Default::default(); + let oss_info = OssInfo { + peer_id: peer_id.clone(), + domain: domain.clone(), + }; + >::insert(&oss, oss_info); }: _(RawOrigin::Signed(oss.clone())) verify { assert!(!>::contains_key(&oss)); diff --git a/pallets/sminer/src/benchmarking.rs b/pallets/sminer/src/benchmarking.rs index 79899899..e4107d67 100644 --- a/pallets/sminer/src/benchmarking.rs +++ b/pallets/sminer/src/benchmarking.rs @@ -1,235 +1,235 @@ -use super::*; -use crate::{Pallet as Sminer}; -use codec::{alloc::string::ToString, Decode}; -pub use frame_benchmarking::{ - account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, -}; -use frame_support::{ - traits::{Currency, Get}, -}; -use pallet_tee_worker::benchmarking::{Config as TeeWorkerConfig}; -use sp_runtime::{ - traits::{Bounded, CheckedMul}, -}; -use frame_system::RawOrigin; - -const SEED: u32 = 2190502; -pub struct Pallet(Sminer); -pub trait Config: - crate::Config + pallet_tee_worker::benchmarking::Config + pallet_cess_staking::Config -{ -} -// const MAX_SPANS: u32 = 100; - -pub fn increase_reward(b_reward: u128) -> Result<(), &'static str> { - let acc = T::FaucetId::get().into_account_truncating(); - - ::Currency::make_free_balance_be( - &acc, - BalanceOf::::max_value(), - ); - - let b_reward: BalanceOf = b_reward.try_into().map_err(|_| "convert error")?; - - >::mutate(|reward| { - *reward = *reward + b_reward; - }); - - Ok(()) -} - -pub fn add_miner(name: &'static str) -> Result { - // let _ = pallet_tee_worker::benchmarking::tee_register::()?; - - let caller = account(name, 100, SEED); - let peer_id: PeerId = [5u8; 38]; - let staking_val: BalanceOf = 2000u32.saturated_into(); - ::Currency::make_free_balance_be( - &caller, - BalanceOf::::max_value(), - ); - - if >::contains_key(&caller) { - Err("create miner failed, existed")?; - } - - ::Currency::reserve(&caller, staking_val)?; - - let pois_key = PoISKey { - g: [2u8; 256], - n: [3u8; 256], - }; - - let space_proof_info = SpaceProofInfo::> { - miner: caller.clone(), - front: u64::MIN, - rear: u64::MIN, - pois_key: pois_key.clone(), - accumulator: pois_key.g, - }; - - let encoding = space_proof_info.encode(); - let original_text = sp_io::hashing::sha2_256(&encoding); - MinerPublicKey::::insert(&original_text, caller.clone()); - - >::insert( - &caller, - MinerInfo:: { - beneficiary: caller.clone(), - peer_id: peer_id, - collaterals: staking_val, - debt: BalanceOf::::zero(), - state: STATE_POSITIVE.as_bytes().to_vec().try_into().unwrap(), - idle_space: u128::MIN, - service_space: u128::MIN, - lock_space: u128::MIN, - space_proof_info, - service_bloom_filter: Default::default(), - tee_signature: [8u8; 256], - }, - ); - - AllMiner::::try_mutate(|all_miner| -> DispatchResult { - all_miner - .try_push(caller.clone()) - .map_err(|_e| Error::::StorageLimitReached)?; - Ok(()) - })?; - - RewardMap::::insert( - &caller, - Reward::{ - total_reward: 0u32.saturated_into(), - reward_issued: 0u32.saturated_into(), - currently_available_reward: 0u32.saturated_into(), - order_list: Default::default() - }, - ); - - Ok(caller) -} - -pub fn freeze_miner(acc: AccountOf) -> Result<(), &'static str> { - >::try_mutate(&acc, |miner_opt| -> Result<(), &'static str> { - let miner = miner_opt.as_mut().expect("Not Miner"); - - miner.state = STATE_FROZEN.as_bytes().to_vec().try_into().unwrap(); - - Ok(()) - })?; - - Ok(()) -} - -pub fn bench_miner_exit(miner: AccountOf) -> Result<(), &'static str> { - Sminer::::miner_exit_prep(RawOrigin::Signed(miner.clone()).into()).map_err(|_| "miner exit prep failed")?; - Sminer::::miner_exit(RawOrigin::Root.into(), miner.clone()).map_err(|_| "miner exit failed")?; - - Ok(()) -} - -benchmarks! { - regnstk { - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - let caller = account("user1", 100, SEED); - let peer_id: PeerId = [5u8; 38]; - ::Currency::make_free_balance_be( - &caller, - BalanceOf::::max_value(), - ); - let pois_key = PoISKey { - g: [2u8; 256], - n: [3u8; 256], - }; - - let space_proof_info = SpaceProofInfo::> { - miner: caller.clone(), - front: u64::MIN, - rear: u64::MIN, - pois_key: pois_key.clone(), - accumulator: pois_key.g, - }; - - let encoding = space_proof_info.encode(); - let hashing = sp_io::hashing::sha2_256(&encoding); - - let sig: TeeRsaSignature = [151, 66, 19, 21, 197, 133, 110, 137, 144, 124, 158, 44, 178, 8, 38, 111, 87, 41, 21, 178, 205, 70, 94, 130, 231, 130, 118, 228, 46, 78, 165, 31, 64, 57, 105, 18, 58, 250, 170, 246, 57, 207, 14, 180, 87, 160, 68, 157, 214, 37, 103, 187, 77, 6, 41, 167, 35, 93, 134, 89, 78, 140, 196, 174, 132, 177, 75, 212, 135, 115, 79, 251, 125, 150, 226, 163, 129, 104, 74, 39, 231, 117, 87, 162, 10, 61, 189, 165, 160, 190, 111, 66, 178, 31, 11, 201, 67, 119, 99, 125, 84, 181, 25, 141, 38, 241, 180, 95, 104, 94, 46, 30, 233, 99, 73, 97, 77, 101, 226, 70, 74, 83, 233, 102, 136, 208, 142, 109, 220, 122, 95, 9, 212, 34, 227, 248, 58, 138, 24, 159, 56, 201, 46, 106, 240, 49, 172, 193, 211, 25, 108, 238, 250, 202, 79, 44, 149, 27, 231, 106, 148, 135, 245, 157, 3, 69, 196, 11, 151, 129, 136, 216, 248, 146, 119, 83, 209, 107, 196, 252, 140, 18, 123, 198, 173, 25, 18, 234, 47, 151, 133, 179, 242, 179, 10, 111, 185, 72, 247, 96, 152, 120, 19, 213, 77, 52, 149, 120, 90, 34, 22, 8, 36, 63, 74, 114, 128, 119, 254, 19, 71, 163, 21, 41, 115, 226, 52, 107, 156, 75, 6, 229, 85, 26, 84, 0, 186, 234, 94, 229, 240, 14, 3, 49, 219, 130, 160, 238, 133, 197, 17, 13, 108, 31, 135, 107]; - }: _(RawOrigin::Signed(caller.clone()), caller.clone(), peer_id, 2_000u32.into(), pois_key, sig) - verify { - assert!(>::contains_key(&caller)) - } - - increase_collateral { - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - let miner = add_miner::("user1")?; - }: _(RawOrigin::Signed(miner.clone()), 2_000u32.into()) - verify { - let miner_info = >::get(&miner).unwrap(); - assert_eq!(4000u32, miner_info.collaterals.saturated_into::()); - } - - update_beneficiary { - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - let miner = add_miner::("user1")?; - let caller: AccountOf = account("user2", 100, SEED); - }: _(RawOrigin::Signed(miner.clone()), caller.clone()) - verify { - let miner_info = >::get(&miner).unwrap(); - assert_eq!(caller, miner_info.beneficiary); - } - - update_peer_id { - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - let miner = add_miner::("user1")?; - let peer_id = [9u8; 38]; - }: _(RawOrigin::Signed(miner.clone()), peer_id.clone()) - verify { - let miner_info = >::get(&miner).unwrap(); - assert_eq!(peer_id, miner_info.peer_id); - } - - faucet_top_up { - let _ = pallet_tee_worker::benchmarking::tee_register::()?; - let caller: T::AccountId = whitelisted_caller(); - let existential_deposit = ::Currency::minimum_balance(); - ::Currency::make_free_balance_be( - &caller, - BalanceOf::::max_value(), - ); - let fa: BalanceOf = existential_deposit.checked_mul(&10u32.saturated_into()).ok_or("over flow")?; - }: _(RawOrigin::Signed(caller), fa) - verify { - let pallet_acc = ::FaucetId::get().into_account_truncating(); - let free = ::Currency::free_balance(&pallet_acc); - assert_eq!(free, fa) - } - - miner_exit_prep { - let miner: AccountOf = add_miner::("miner1")?; - }: _(RawOrigin::Signed(miner.clone())) - verify { - let miner_info = >::try_get(&miner).unwrap(); - assert_eq!(miner_info.state.to_vec(), STATE_LOCK.as_bytes().to_vec()) - } - - miner_exit { - let miner: AccountOf = add_miner::("miner1")?; - Sminer::::miner_exit_prep(RawOrigin::Signed(miner.clone()).into())?; - - }: _(RawOrigin::Root, miner.clone()) - verify { - let miner_info = >::try_get(&miner).unwrap(); - assert_eq!(miner_info.state.to_vec(), STATE_EXIT.as_bytes().to_vec()) - } - - miner_withdraw { - let miner: AccountOf = add_miner::("miner1")?; - Sminer::::miner_exit_prep(RawOrigin::Signed(miner.clone()).into())?; - Sminer::::miner_exit(RawOrigin::Root.into(), miner.clone())?; - }: _(RawOrigin::Signed(miner.clone())) - verify { - assert!(!>::contains_key(&miner)); - } -} +// use super::*; +// use crate::{Pallet as Sminer}; +// use codec::{alloc::string::ToString, Decode}; +// pub use frame_benchmarking::{ +// account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, +// }; +// use frame_support::{ +// traits::{Currency, Get}, +// }; +// use pallet_tee_worker::benchmarking::{Config as TeeWorkerConfig}; +// use sp_runtime::{ +// traits::{Bounded, CheckedMul}, +// }; +// use frame_system::RawOrigin; + +// const SEED: u32 = 2190502; +// pub struct Pallet(Sminer); +// pub trait Config: +// crate::Config + pallet_tee_worker::benchmarking::Config + pallet_cess_staking::Config +// { +// } +// // const MAX_SPANS: u32 = 100; + +// pub fn increase_reward(b_reward: u128) -> Result<(), &'static str> { +// let acc = T::FaucetId::get().into_account_truncating(); + +// ::Currency::make_free_balance_be( +// &acc, +// BalanceOf::::max_value(), +// ); + +// let b_reward: BalanceOf = b_reward.try_into().map_err(|_| "convert error")?; + +// >::mutate(|reward| { +// *reward = *reward + b_reward; +// }); + +// Ok(()) +// } + +// pub fn add_miner(name: &'static str) -> Result { +// // let _ = pallet_tee_worker::benchmarking::tee_register::()?; + +// let caller = account(name, 100, SEED); +// let peer_id: PeerId = [5u8; 38]; +// let staking_val: BalanceOf = 2000u32.saturated_into(); +// ::Currency::make_free_balance_be( +// &caller, +// BalanceOf::::max_value(), +// ); + +// if >::contains_key(&caller) { +// Err("create miner failed, existed")?; +// } + +// ::Currency::reserve(&caller, staking_val)?; + +// let pois_key = PoISKey { +// g: [2u8; 256], +// n: [3u8; 256], +// }; + +// let space_proof_info = SpaceProofInfo::> { +// miner: caller.clone(), +// front: u64::MIN, +// rear: u64::MIN, +// pois_key: pois_key.clone(), +// accumulator: pois_key.g, +// }; + +// let encoding = space_proof_info.encode(); +// let original_text = sp_io::hashing::sha2_256(&encoding); +// MinerPublicKey::::insert(&original_text, caller.clone()); + +// >::insert( +// &caller, +// MinerInfo:: { +// beneficiary: caller.clone(), +// peer_id: peer_id, +// collaterals: staking_val, +// debt: BalanceOf::::zero(), +// state: STATE_POSITIVE.as_bytes().to_vec().try_into().unwrap(), +// idle_space: u128::MIN, +// service_space: u128::MIN, +// lock_space: u128::MIN, +// space_proof_info, +// service_bloom_filter: Default::default(), +// tee_signature: [8u8; 256], +// }, +// ); + +// AllMiner::::try_mutate(|all_miner| -> DispatchResult { +// all_miner +// .try_push(caller.clone()) +// .map_err(|_e| Error::::StorageLimitReached)?; +// Ok(()) +// })?; + +// RewardMap::::insert( +// &caller, +// Reward::{ +// total_reward: 0u32.saturated_into(), +// reward_issued: 0u32.saturated_into(), +// currently_available_reward: 0u32.saturated_into(), +// order_list: Default::default() +// }, +// ); + +// Ok(caller) +// } +// pub fn freeze_miner(acc: AccountOf) -> Result<(), &'static str> { +// >::try_mutate(&acc, |miner_opt| -> Result<(), &'static str> { +// let miner = miner_opt.as_mut().expect("Not Miner"); + +// miner.state = STATE_FROZEN.as_bytes().to_vec().try_into().unwrap(); + +// Ok(()) +// })?; + +// Ok(()) +// } + +// pub fn bench_miner_exit(miner: AccountOf) -> Result<(), &'static str> { +// Sminer::::miner_exit_prep(RawOrigin::Signed(miner.clone()).into()).map_err(|_| "miner exit prep failed")?; +// Sminer::::miner_exit(RawOrigin::Root.into(), miner.clone()).map_err(|_| "miner exit failed")?; + +// Ok(()) // } + +// benchmarks! { +// regnstk { +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// let caller = account("user1", 100, SEED); +// let peer_id: PeerId = [5u8; 38]; +// ::Currency::make_free_balance_be( +// &caller, +// BalanceOf::::max_value(), +// ); +// let pois_key = PoISKey { +// g: [2u8; 256], +// n: [3u8; 256], +// }; + +// let space_proof_info = SpaceProofInfo::> { +// miner: caller.clone(), +// front: u64::MIN, +// rear: u64::MIN, +// pois_key: pois_key.clone(), +// accumulator: pois_key.g, +// }; + +// let encoding = space_proof_info.encode(); +// let hashing = sp_io::hashing::sha2_256(&encoding); + +// let sig: TeeRsaSignature = [151, 66, 19, 21, 197, 133, 110, 137, 144, 124, 158, 44, 178, 8, 38, 111, 87, 41, 21, 178, 205, 70, 94, 130, 231, 130, 118, 228, 46, 78, 165, 31, 64, 57, 105, 18, 58, 250, 170, 246, 57, 207, 14, 180, 87, 160, 68, 157, 214, 37, 103, 187, 77, 6, 41, 167, 35, 93, 134, 89, 78, 140, 196, 174, 132, 177, 75, 212, 135, 115, 79, 251, 125, 150, 226, 163, 129, 104, 74, 39, 231, 117, 87, 162, 10, 61, 189, 165, 160, 190, 111, 66, 178, 31, 11, 201, 67, 119, 99, 125, 84, 181, 25, 141, 38, 241, 180, 95, 104, 94, 46, 30, 233, 99, 73, 97, 77, 101, 226, 70, 74, 83, 233, 102, 136, 208, 142, 109, 220, 122, 95, 9, 212, 34, 227, 248, 58, 138, 24, 159, 56, 201, 46, 106, 240, 49, 172, 193, 211, 25, 108, 238, 250, 202, 79, 44, 149, 27, 231, 106, 148, 135, 245, 157, 3, 69, 196, 11, 151, 129, 136, 216, 248, 146, 119, 83, 209, 107, 196, 252, 140, 18, 123, 198, 173, 25, 18, 234, 47, 151, 133, 179, 242, 179, 10, 111, 185, 72, 247, 96, 152, 120, 19, 213, 77, 52, 149, 120, 90, 34, 22, 8, 36, 63, 74, 114, 128, 119, 254, 19, 71, 163, 21, 41, 115, 226, 52, 107, 156, 75, 6, 229, 85, 26, 84, 0, 186, 234, 94, 229, 240, 14, 3, 49, 219, 130, 160, 238, 133, 197, 17, 13, 108, 31, 135, 107]; +// }: _(RawOrigin::Signed(caller.clone()), caller.clone(), peer_id, 2_000u32.into(), pois_key, sig) +// verify { +// assert!(>::contains_key(&caller)) +// } + +// increase_collateral { +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// let miner = add_miner::("user1")?; +// }: _(RawOrigin::Signed(miner.clone()), 2_000u32.into()) +// verify { +// let miner_info = >::get(&miner).unwrap(); +// assert_eq!(4000u32, miner_info.collaterals.saturated_into::()); +// } + +// update_beneficiary { +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// let miner = add_miner::("user1")?; +// let caller: AccountOf = account("user2", 100, SEED); +// }: _(RawOrigin::Signed(miner.clone()), caller.clone()) +// verify { +// let miner_info = >::get(&miner).unwrap(); +// assert_eq!(caller, miner_info.beneficiary); +// } + +// update_peer_id { +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// let miner = add_miner::("user1")?; +// let peer_id = [9u8; 38]; +// }: _(RawOrigin::Signed(miner.clone()), peer_id.clone()) +// verify { +// let miner_info = >::get(&miner).unwrap(); +// assert_eq!(peer_id, miner_info.peer_id); +// } + +// faucet_top_up { +// let _ = pallet_tee_worker::benchmarking::tee_register::()?; +// let caller: T::AccountId = whitelisted_caller(); +// let existential_deposit = ::Currency::minimum_balance(); +// ::Currency::make_free_balance_be( +// &caller, +// BalanceOf::::max_value(), +// ); +// let fa: BalanceOf = existential_deposit.checked_mul(&10u32.saturated_into()).ok_or("over flow")?; +// }: _(RawOrigin::Signed(caller), fa) +// verify { +// let pallet_acc = ::FaucetId::get().into_account_truncating(); +// let free = ::Currency::free_balance(&pallet_acc); +// assert_eq!(free, fa) +// } + +// miner_exit_prep { +// let miner: AccountOf = add_miner::("miner1")?; +// }: _(RawOrigin::Signed(miner.clone())) +// verify { +// let miner_info = >::try_get(&miner).unwrap(); +// assert_eq!(miner_info.state.to_vec(), STATE_LOCK.as_bytes().to_vec()) +// } + +// miner_exit { +// let miner: AccountOf = add_miner::("miner1")?; +// Sminer::::miner_exit_prep(RawOrigin::Signed(miner.clone()).into())?; + +// }: _(RawOrigin::Root, miner.clone()) +// verify { +// let miner_info = >::try_get(&miner).unwrap(); +// assert_eq!(miner_info.state.to_vec(), STATE_EXIT.as_bytes().to_vec()) +// } + +// miner_withdraw { +// let miner: AccountOf = add_miner::("miner1")?; +// Sminer::::miner_exit_prep(RawOrigin::Signed(miner.clone()).into())?; +// Sminer::::miner_exit(RawOrigin::Root.into(), miner.clone())?; +// }: _(RawOrigin::Signed(miner.clone())) +// verify { +// assert!(!>::contains_key(&miner)); +// } +// } + +// // } diff --git a/pallets/storage-handler/src/benchmarking.rs b/pallets/storage-handler/src/benchmarking.rs index 76f4bbde..292dd8df 100644 --- a/pallets/storage-handler/src/benchmarking.rs +++ b/pallets/storage-handler/src/benchmarking.rs @@ -1,50 +1,50 @@ -use crate::{Pallet as StorageHandler, *}; -use frame_system::RawOrigin; -pub use frame_benchmarking::{ - account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, -}; -use sp_runtime::traits::Bounded; +// use crate::{Pallet as StorageHandler, *}; +// use frame_system::RawOrigin; +// pub use frame_benchmarking::{ +// account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, +// }; +// use sp_runtime::traits::Bounded; -const SEED: u32 = 2190502; +// const SEED: u32 = 2190502; -pub fn increase_idle_space(space: u128) { - >::mutate(|total_space| { - *total_space = *total_space + space; - }); -} +// pub fn increase_idle_space(space: u128) { +// >::mutate(|total_space| { +// *total_space = *total_space + space; +// }); +// } -benchmarks! { - buy_space { - let caller: AccountOf = account("user1", 100, SEED); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); - increase_idle_space::(100 * G_BYTE); - }: _(RawOrigin::Signed(caller.clone()), 10) - verify { - assert!(>::contains_key(&caller)) - } +// benchmarks! { +// buy_space { +// let caller: AccountOf = account("user1", 100, SEED); +// T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); +// increase_idle_space::(100 * G_BYTE); +// }: _(RawOrigin::Signed(caller.clone()), 10) +// verify { +// assert!(>::contains_key(&caller)) +// } - expansion_space { - let caller: AccountOf = account("user1", 100, SEED); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); - increase_idle_space::(100 * G_BYTE); - StorageHandler::::buy_space(RawOrigin::Signed(caller.clone()).into(), 10)?; - }: _(RawOrigin::Signed(caller.clone()), 10) - verify { - assert!(>::contains_key(&caller)); - let user_owned_space_info = >::try_get(&caller).unwrap(); - assert_eq!(user_owned_space_info.total_space, 20 * G_BYTE) - } +// expansion_space { +// let caller: AccountOf = account("user1", 100, SEED); +// T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); +// increase_idle_space::(100 * G_BYTE); +// StorageHandler::::buy_space(RawOrigin::Signed(caller.clone()).into(), 10)?; +// }: _(RawOrigin::Signed(caller.clone()), 10) +// verify { +// assert!(>::contains_key(&caller)); +// let user_owned_space_info = >::try_get(&caller).unwrap(); +// assert_eq!(user_owned_space_info.total_space, 20 * G_BYTE) +// } - renewal_space { - let caller: AccountOf = account("user1", 100, SEED); - T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); - increase_idle_space::(100 * G_BYTE); - StorageHandler::::buy_space(RawOrigin::Signed(caller.clone()).into(), 10)?; - }: _(RawOrigin::Signed(caller.clone()), 10) - verify { - assert!(>::contains_key(&caller)); - let user_owned_space_info = >::try_get(&caller).unwrap(); - assert_eq!(user_owned_space_info.deadline, (40u32 * 14400u32).saturated_into()) - } -} +// renewal_space { +// let caller: AccountOf = account("user1", 100, SEED); +// T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); +// increase_idle_space::(100 * G_BYTE); +// StorageHandler::::buy_space(RawOrigin::Signed(caller.clone()).into(), 10)?; +// }: _(RawOrigin::Signed(caller.clone()), 10) +// verify { +// assert!(>::contains_key(&caller)); +// let user_owned_space_info = >::try_get(&caller).unwrap(); +// assert_eq!(user_owned_space_info.deadline, (40u32 * 14400u32).saturated_into()) +// } +// } diff --git a/pallets/tee-worker/src/benchmarking.rs b/pallets/tee-worker/src/benchmarking.rs index caa4deb3..ab78c094 100644 --- a/pallets/tee-worker/src/benchmarking.rs +++ b/pallets/tee-worker/src/benchmarking.rs @@ -1,70 +1,70 @@ -use super::*; -use crate::{Pallet as TeeWorker}; -use codec::{alloc::string::ToString, Decode}; -pub use frame_benchmarking::{ - account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, -}; -use frame_support::{ - traits::{Currency, CurrencyToVote, Imbalance}, -}; -use frame_system::RawOrigin; +// use super::*; +// use crate::{Pallet as TeeWorker}; +// use codec::{alloc::string::ToString, Decode}; +// pub use frame_benchmarking::{ +// account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, +// }; +// use frame_support::{ +// traits::{Currency, CurrencyToVote, Imbalance}, +// }; +// use frame_system::RawOrigin; -pub struct Pallet(TeeWorker); -pub trait Config: - crate::Config + pallet_cess_staking::Config -{ -} +// pub struct Pallet(TeeWorker); +// pub trait Config: +// crate::Config + pallet_cess_staking::Config +// { +// } -const USER_SEED: u32 = 999666; -const PODR2_PBK: [u8; 270] = [48, 130, 1, 10, 2, 130, 1, 1, 0, 151, 247, 38, 216, 188, 81, 0, 64, 239, 101, 82, 181, 134, 30, 84, 171, 120, 21, 39, 196, 216, 82, 17, 10, 225, 78, 91, 35, 182, 8, 50, 1, 164, 235, 206, 201, 233, 223, 174, 125, 138, 51, 70, 14, 20, 198, 52, 199, 9, 142, 65, 183, 251, 134, 22, 114, 242, 205, 169, 28, 115, 213, 82, 82, 170, 63, 57, 24, 59, 136, 162, 231, 123, 234, 187, 175, 244, 95, 232, 254, 130, 17, 46, 163, 201, 93, 244, 240, 179, 30, 43, 221, 67, 226, 161, 22, 53, 161, 77, 221, 124, 48, 21, 62, 181, 108, 63, 10, 7, 160, 92, 170, 151, 111, 51, 112, 0, 183, 168, 219, 78, 105, 29, 47, 84, 34, 159, 17, 118, 194, 115, 4, 208, 110, 56, 76, 22, 202, 200, 104, 210, 97, 102, 183, 86, 63, 108, 50, 179, 21, 236, 147, 57, 142, 76, 67, 243, 235, 162, 202, 147, 163, 148, 237, 7, 229, 122, 250, 75, 249, 99, 242, 157, 34, 136, 175, 74, 140, 73, 145, 9, 131, 56, 88, 249, 175, 17, 26, 93, 72, 15, 50, 85, 230, 91, 124, 235, 26, 104, 200, 161, 160, 137, 249, 3, 49, 7, 119, 207, 100, 127, 108, 215, 251, 214, 228, 180, 221, 223, 12, 163, 66, 214, 185, 100, 84, 65, 6, 71, 240, 45, 247, 107, 193, 238, 68, 67, 92, 161, 223, 1, 43, 150, 137, 218, 221, 213, 232, 36, 5, 121, 32, 59, 129, 75, 5, 2, 3, 1, 0, 1]; -const PEER_ID: [u8; 38] = [0, 36, 8, 1, 18, 32, 12, 50, 93, 198, 152, 25, 126, 164, 106, 27, 26, 219, 151, 207, 191, 72, 133, 39, 20, 109, 117, 187, 165, 127, 101, 12, 167, 175, 255, 138, 213, 34]; -const NODE_PUBLIC_KEY: NodePublicKey = sp_core::ed25519::Public([12, 50, 93, 198, 152, 25, 126, 164, 106, 27, 26, 219, 151, 207, 191, 72, 133, 39, 20, 109, 117, 187, 165, 127, 101, 12, 167, 175, 255, 138, 213, 34]); +// const USER_SEED: u32 = 999666; +// const PODR2_PBK: [u8; 270] = [48, 130, 1, 10, 2, 130, 1, 1, 0, 151, 247, 38, 216, 188, 81, 0, 64, 239, 101, 82, 181, 134, 30, 84, 171, 120, 21, 39, 196, 216, 82, 17, 10, 225, 78, 91, 35, 182, 8, 50, 1, 164, 235, 206, 201, 233, 223, 174, 125, 138, 51, 70, 14, 20, 198, 52, 199, 9, 142, 65, 183, 251, 134, 22, 114, 242, 205, 169, 28, 115, 213, 82, 82, 170, 63, 57, 24, 59, 136, 162, 231, 123, 234, 187, 175, 244, 95, 232, 254, 130, 17, 46, 163, 201, 93, 244, 240, 179, 30, 43, 221, 67, 226, 161, 22, 53, 161, 77, 221, 124, 48, 21, 62, 181, 108, 63, 10, 7, 160, 92, 170, 151, 111, 51, 112, 0, 183, 168, 219, 78, 105, 29, 47, 84, 34, 159, 17, 118, 194, 115, 4, 208, 110, 56, 76, 22, 202, 200, 104, 210, 97, 102, 183, 86, 63, 108, 50, 179, 21, 236, 147, 57, 142, 76, 67, 243, 235, 162, 202, 147, 163, 148, 237, 7, 229, 122, 250, 75, 249, 99, 242, 157, 34, 136, 175, 74, 140, 73, 145, 9, 131, 56, 88, 249, 175, 17, 26, 93, 72, 15, 50, 85, 230, 91, 124, 235, 26, 104, 200, 161, 160, 137, 249, 3, 49, 7, 119, 207, 100, 127, 108, 215, 251, 214, 228, 180, 221, 223, 12, 163, 66, 214, 185, 100, 84, 65, 6, 71, 240, 45, 247, 107, 193, 238, 68, 67, 92, 161, 223, 1, 43, 150, 137, 218, 221, 213, 232, 36, 5, 121, 32, 59, 129, 75, 5, 2, 3, 1, 0, 1]; +// const PEER_ID: [u8; 38] = [0, 36, 8, 1, 18, 32, 12, 50, 93, 198, 152, 25, 126, 164, 106, 27, 26, 219, 151, 207, 191, 72, 133, 39, 20, 109, 117, 187, 165, 127, 101, 12, 167, 175, 255, 138, 213, 34]; +// const NODE_PUBLIC_KEY: NodePublicKey = sp_core::ed25519::Public([12, 50, 93, 198, 152, 25, 126, 164, 106, 27, 26, 219, 151, 207, 191, 72, 133, 39, 20, 109, 117, 187, 165, 127, 101, 12, 167, 175, 255, 138, 213, 34]); -pub fn get_report() -> SgxAttestationReport { - SgxAttestationReport { - report_json_raw: [123, 34, 105, 100, 34, 58, 34, 49, 52, 53, 48, 49, 48, 48, 56, 52, 50, 57, 55, 53, 48, 51, 56, 53, 56, 57, 54, 54, 52, 56, 56, 57, 56, 49, 53, 53, 52, 52, 51, 53, 56, 48, 48, 55, 53, 56, 34, 44, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 51, 45, 48, 56, 45, 50, 54, 84, 48, 50, 58, 48, 56, 58, 52, 51, 46, 53, 51, 52, 57, 53, 55, 34, 44, 34, 118, 101, 114, 115, 105, 111, 110, 34, 58, 52, 44, 34, 101, 112, 105, 100, 80, 115, 101, 117, 100, 111, 110, 121, 109, 34, 58, 34, 55, 43, 74, 112, 105, 53, 82, 83, 68, 117, 97, 54, 113, 49, 114, 109, 90, 72, 77, 112, 75, 100, 116, 80, 104, 102, 103, 111, 81, 106, 43, 55, 52, 85, 106, 111, 49, 49, 83, 67, 113, 118, 89, 107, 47, 85, 49, 47, 115, 48, 56, 72, 50, 109, 67, 101, 107, 110, 53, 119, 107, 82, 47, 53, 114, 71, 55, 66, 49, 122, 114, 104, 74, 49, 107, 121, 118, 101, 82, 47, 107, 72, 120, 98, 47, 71, 109, 75, 71, 51, 84, 99, 52, 83, 86, 74, 110, 78, 55, 75, 43, 47, 97, 48, 80, 110, 54, 121, 43, 106, 66, 75, 104, 106, 52, 79, 74, 101, 109, 102, 88, 75, 84, 104, 109, 49, 104, 89, 122, 52, 76, 65, 113, 53, 120, 69, 83, 82, 121, 68, 76, 89, 111, 71, 82, 89, 47, 57, 48, 118, 103, 97, 65, 89, 90, 109, 104, 53, 111, 85, 111, 48, 65, 98, 98, 111, 49, 99, 65, 102, 119, 61, 34, 44, 34, 97, 100, 118, 105, 115, 111, 114, 121, 85, 82, 76, 34, 58, 34, 104, 116, 116, 112, 115, 58, 47, 47, 115, 101, 99, 117, 114, 105, 116, 121, 45, 99, 101, 110, 116, 101, 114, 46, 105, 110, 116, 101, 108, 46, 99, 111, 109, 34, 44, 34, 97, 100, 118, 105, 115, 111, 114, 121, 73, 68, 115, 34, 58, 91, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 51, 51, 52, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 51, 56, 49, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 51, 56, 57, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 52, 55, 55, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 54, 49, 52, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 54, 49, 53, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 54, 49, 55, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 56, 50, 56, 34, 93, 44, 34, 105, 115, 118, 69, 110, 99, 108, 97, 118, 101, 81, 117, 111, 116, 101, 83, 116, 97, 116, 117, 115, 34, 58, 34, 71, 82, 79, 85, 80, 95, 79, 85, 84, 95, 79, 70, 95, 68, 65, 84, 69, 34, 44, 34, 112, 108, 97, 116, 102, 111, 114, 109, 73, 110, 102, 111, 66, 108, 111, 98, 34, 58, 34, 49, 53, 48, 50, 48, 48, 54, 53, 48, 52, 48, 48, 48, 49, 48, 48, 48, 48, 48, 70, 48, 70, 48, 50, 48, 50, 48, 49, 56, 48, 48, 69, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 68, 48, 48, 48, 48, 48, 67, 48, 48, 48, 48, 48, 48, 48, 50, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 66, 69, 52, 57, 65, 66, 51, 55, 55, 53, 56, 66, 70, 50, 67, 49, 65, 48, 70, 56, 52, 68, 66, 66, 56, 67, 67, 66, 48, 49, 52, 57, 67, 68, 50, 53, 69, 48, 51, 65, 56, 68, 66, 69, 48, 67, 50, 51, 70, 70, 66, 51, 49, 56, 66, 69, 70, 48, 68, 48, 66, 65, 49, 70, 53, 56, 51, 49, 52, 57, 55, 52, 49, 49, 67, 65, 55, 51, 70, 53, 56, 55, 49, 48, 65, 57, 52, 54, 66, 66, 70, 53, 66, 52, 56, 52, 66, 66, 66, 49, 67, 70, 69, 67, 54, 50, 49, 55, 67, 54, 55, 67, 70, 48, 56, 68, 68, 52, 69, 50, 70, 56, 67, 50, 56, 66, 69, 53, 52, 49, 66, 34, 44, 34, 105, 115, 118, 69, 110, 99, 108, 97, 118, 101, 81, 117, 111, 116, 101, 66, 111, 100, 121, 34, 58, 34, 65, 103, 65, 66, 65, 79, 81, 76, 65, 65, 65, 79, 65, 65, 52, 65, 65, 65, 65, 65, 65, 66, 54, 88, 104, 48, 69, 77, 82, 89, 43, 87, 101, 43, 48, 55, 65, 103, 99, 120, 111, 115, 85, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 103, 55, 47, 66, 119, 101, 65, 66, 103, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 119, 65, 65, 65, 65, 65, 65, 65, 65, 65, 72, 65, 65, 65, 65, 65, 65, 65, 65, 65, 75, 116, 102, 122, 78, 76, 100, 106, 54, 79, 100, 85, 99, 83, 87, 50, 77, 54, 66, 106, 83, 98, 116, 50, 79, 57, 100, 99, 122, 120, 103, 47, 111, 84, 106, 105, 51, 76, 84, 56, 87, 53, 69, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 75, 116, 109, 66, 88, 114, 66, 121, 55, 49, 74, 43, 109, 82, 100, 107, 51, 65, 73, 57, 86, 68, 70, 118, 84, 86, 97, 56, 104, 50, 43, 112, 54, 99, 57, 87, 74, 51, 51, 79, 67, 90, 81, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 68, 68, 114, 56, 121, 89, 72, 57, 57, 79, 89, 52, 111, 68, 106, 111, 57, 80, 79, 111, 51, 103, 83, 47, 56, 75, 43, 114, 48, 56, 99, 86, 66, 110, 77, 107, 110, 88, 121, 89, 117, 43, 109, 119, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 34, 125].to_vec().try_into().unwrap(), - sign: [111, 117, 80, 86, 83, 122, 54, 66, 89, 121, 86, 83, 108, 73, 71, 104, 116, 120, 57, 66, 70, 120, 43, 54, 84, 106, 105, 121, 80, 48, 97, 119, 114, 101, 74, 83, 86, 51, 111, 65, 55, 69, 84, 67, 122, 82, 67, 101, 52, 53, 115, 77, 81, 66, 52, 78, 57, 48, 105, 115, 111, 88, 86, 52, 119, 68, 74, 86, 71, 71, 71, 76, 113, 56, 99, 70, 65, 116, 48, 52, 50, 53, 57, 90, 80, 75, 111, 70, 111, 122, 77, 83, 110, 77, 111, 119, 118, 87, 113, 54, 56, 78, 68, 112, 108, 85, 105, 69, 122, 90, 118, 106, 77, 99, 82, 111, 89, 81, 75, 54, 105, 108, 117, 77, 87, 66, 98, 85, 120, 119, 89, 52, 85, 80, 43, 83, 71, 82, 108, 84, 85, 110, 84, 49, 56, 87, 100, 79, 104, 71, 71, 122, 69, 79, 78, 115, 86, 43, 69, 107, 114, 47, 48, 80, 103, 57, 81, 99, 115, 49, 84, 120, 71, 86, 43, 49, 70, 57, 120, 51, 74, 118, 90, 87, 98, 75, 84, 66, 53, 82, 47, 50, 109, 113, 77, 115, 67, 100, 105, 112, 120, 109, 120, 73, 55, 75, 65, 53, 106, 82, 113, 57, 47, 67, 77, 68, 102, 111, 52, 72, 122, 86, 79, 106, 110, 78, 118, 122, 88, 51, 110, 83, 69, 100, 122, 108, 83, 65, 85, 117, 101, 105, 73, 87, 109, 51, 47, 89, 103, 51, 80, 69, 76, 72, 117, 118, 114, 115, 56, 116, 47, 73, 66, 122, 122, 104, 47, 72, 81, 114, 52, 104, 106, 81, 68, 119, 111, 87, 65, 108, 51, 86, 97, 76, 106, 105, 107, 68, 81, 49, 75, 48, 122, 54, 90, 82, 88, 82, 79, 70, 103, 114, 97, 73, 68, 43, 112, 54, 65, 57, 68, 116, 84, 74, 119, 97, 68, 83, 101, 102, 78, 82, 97, 65, 120, 51, 87, 69, 106, 122, 113, 43, 49, 103, 85, 78, 77, 116, 65, 85, 75, 103, 61, 61].to_vec().try_into().unwrap(), - cert_der: [77, 73, 73, 69, 111, 84, 67, 67, 65, 119, 109, 103, 65, 119, 73, 66, 65, 103, 73, 74, 65, 78, 69, 72, 100, 108, 48, 121, 111, 55, 67, 87, 77, 65, 48, 71, 67, 83, 113, 71, 83, 73, 98, 51, 68, 81, 69, 66, 67, 119, 85, 65, 77, 72, 52, 120, 67, 122, 65, 74, 66, 103, 78, 86, 66, 65, 89, 84, 65, 108, 86, 84, 77, 81, 115, 119, 67, 81, 89, 68, 86, 81, 81, 73, 68, 65, 74, 68, 81, 84, 69, 85, 77, 66, 73, 71, 65, 49, 85, 69, 66, 119, 119, 76, 85, 50, 70, 117, 100, 71, 69, 103, 81, 50, 120, 104, 99, 109, 69, 120, 71, 106, 65, 89, 66, 103, 78, 86, 66, 65, 111, 77, 69, 85, 108, 117, 100, 71, 86, 115, 73, 69, 78, 118, 99, 110, 66, 118, 99, 109, 70, 48, 97, 87, 57, 117, 77, 84, 65, 119, 76, 103, 89, 68, 86, 81, 81, 68, 68, 67, 100, 74, 98, 110, 82, 108, 98, 67, 66, 84, 82, 49, 103, 103, 81, 88, 82, 48, 90, 88, 78, 48, 89, 88, 82, 112, 98, 50, 52, 103, 85, 109, 86, 119, 98, 51, 74, 48, 73, 70, 78, 112, 90, 50, 53, 112, 98, 109, 99, 103, 81, 48, 69, 119, 72, 104, 99, 78, 77, 84, 89, 120, 77, 84, 73, 121, 77, 68, 107, 122, 78, 106, 85, 52, 87, 104, 99, 78, 77, 106, 89, 120, 77, 84, 73, 119, 77, 68, 107, 122, 78, 106, 85, 52, 87, 106, 66, 55, 77, 81, 115, 119, 67, 81, 89, 68, 86, 81, 81, 71, 69, 119, 74, 86, 85, 122, 69, 76, 77, 65, 107, 71, 65, 49, 85, 69, 67, 65, 119, 67, 81, 48, 69, 120, 70, 68, 65, 83, 66, 103, 78, 86, 66, 65, 99, 77, 67, 49, 78, 104, 98, 110, 82, 104, 73, 69, 78, 115, 89, 88, 74, 104, 77, 82, 111, 119, 71, 65, 89, 68, 86, 81, 81, 75, 68, 66, 70, 74, 98, 110, 82, 108, 98, 67, 66, 68, 98, 51, 74, 119, 98, 51, 74, 104, 100, 71, 108, 118, 98, 106, 69, 116, 77, 67, 115, 71, 65, 49, 85, 69, 65, 119, 119, 107, 83, 87, 53, 48, 90, 87, 119, 103, 85, 48, 100, 89, 73, 69, 70, 48, 100, 71, 86, 122, 100, 71, 70, 48, 97, 87, 57, 117, 73, 70, 74, 108, 99, 71, 57, 121, 100, 67, 66, 84, 97, 87, 100, 117, 97, 87, 53, 110, 77, 73, 73, 66, 73, 106, 65, 78, 66, 103, 107, 113, 104, 107, 105, 71, 57, 119, 48, 66, 65, 81, 69, 70, 65, 65, 79, 67, 65, 81, 56, 65, 77, 73, 73, 66, 67, 103, 75, 67, 65, 81, 69, 65, 113, 88, 111, 116, 52, 79, 90, 117, 112, 104, 82, 56, 110, 117, 100, 70, 114, 65, 70, 105, 97, 71, 120, 120, 107, 103, 109, 97, 47, 69, 115, 47, 66, 65, 43, 116, 98, 101, 67, 84, 85, 82, 49, 48, 54, 65, 76, 49, 69, 78, 99, 87, 65, 52, 70, 88, 51, 75, 43, 69, 57, 66, 66, 76, 48, 47, 55, 88, 53, 114, 106, 53, 110, 73, 103, 88, 47, 82, 47, 49, 117, 98, 104, 107, 75, 87, 119, 57, 103, 102, 113, 80, 71, 51, 75, 101, 65, 116, 73, 100, 99, 118, 47, 117, 84, 79, 49, 121, 88, 118, 53, 48, 118, 113, 97, 80, 118, 69, 49, 67, 82, 67, 104, 118, 122, 100, 83, 47, 90, 69, 66, 113, 81, 53, 111, 86, 118, 76, 84, 80, 90, 51, 86, 69, 105, 99, 81, 106, 108, 121, 116, 75, 103, 78, 57, 99, 76, 110, 120, 98, 119, 116, 117, 118, 76, 85, 75, 55, 101, 121, 82, 80, 102, 74, 87, 47, 107, 115, 100, 100, 79, 122, 80, 56, 86, 66, 66, 110, 105, 111, 108, 89, 110, 82, 67, 68, 50, 106, 114, 77, 82, 90, 56, 110, 66, 77, 50, 90, 87, 89, 119, 110, 88, 110, 119, 89, 101, 79, 65, 72, 86, 43, 87, 57, 116, 79, 104, 65, 73, 109, 119, 82, 119, 75, 70, 47, 57, 53, 121, 65, 115, 86, 119, 100, 50, 49, 114, 121, 72, 77, 74, 66, 99, 71, 72, 55, 48, 113, 76, 97, 103, 90, 55, 84, 116, 121, 116, 43, 43, 113, 79, 47, 54, 43, 75, 65, 88, 74, 117, 75, 119, 90, 113, 106, 82, 108, 69, 116, 83, 69, 122, 56, 103, 90, 81, 101, 70, 102, 86, 89, 103, 99, 119, 83, 102, 111, 57, 54, 111, 83, 77, 65, 122, 86, 114, 55, 86, 48, 76, 54, 72, 83, 68, 76, 82, 110, 112, 98, 54, 120, 120, 109, 98, 80, 100, 113, 78, 111, 108, 52, 116, 81, 73, 68, 65, 81, 65, 66, 111, 52, 71, 107, 77, 73, 71, 104, 77, 66, 56, 71, 65, 49, 85, 100, 73, 119, 81, 89, 77, 66, 97, 65, 70, 72, 104, 68, 101, 51, 97, 109, 102, 114, 122, 81, 114, 51, 53, 67, 78, 43, 115, 49, 102, 68, 117, 72, 65, 86, 69, 56, 77, 65, 52, 71, 65, 49, 85, 100, 68, 119, 69, 66, 47, 119, 81, 69, 65, 119, 73, 71, 119, 68, 65, 77, 66, 103, 78, 86, 72, 82, 77, 66, 65, 102, 56, 69, 65, 106, 65, 65, 77, 71, 65, 71, 65, 49, 85, 100, 72, 119, 82, 90, 77, 70, 99, 119, 86, 97, 66, 84, 111, 70, 71, 71, 84, 50, 104, 48, 100, 72, 65, 54, 76, 121, 57, 48, 99, 110, 86, 122, 100, 71, 86, 107, 99, 50, 86, 121, 100, 109, 108, 106, 90, 88, 77, 117, 97, 87, 53, 48, 90, 87, 119, 117, 89, 50, 57, 116, 76, 50, 78, 118, 98, 110, 82, 108, 98, 110, 81, 118, 81, 49, 74, 77, 76, 49, 78, 72, 87, 67, 57, 66, 100, 72, 82, 108, 99, 51, 82, 104, 100, 71, 108, 118, 98, 108, 74, 108, 99, 71, 57, 121, 100, 70, 78, 112, 90, 50, 53, 112, 98, 109, 100, 68, 81, 83, 53, 106, 99, 109, 119, 119, 68, 81, 89, 74, 75, 111, 90, 73, 104, 118, 99, 78, 65, 81, 69, 76, 66, 81, 65, 68, 103, 103, 71, 66, 65, 71, 99, 73, 116, 104, 116, 99, 75, 57, 73, 86, 82, 122, 52, 114, 82, 113, 43, 90, 75, 69, 43, 55, 107, 53, 48, 47, 79, 120, 85, 115, 109, 87, 56, 97, 97, 118, 79, 122, 75, 98, 48, 105, 67, 120, 48, 55, 89, 81, 57, 114, 122, 105, 53, 110, 85, 55, 51, 116, 77, 69, 50, 121, 71, 82, 76, 122, 104, 83, 86, 105, 70, 115, 47, 76, 112, 70, 97, 57, 108, 112, 81, 76, 54, 74, 76, 49, 97, 81, 119, 109, 68, 82, 55, 52, 84, 120, 89, 71, 66, 65, 73, 105, 53, 102, 52, 73, 53, 84, 74, 111, 67, 67, 69, 113, 82, 72, 122, 57, 49, 107, 112, 71, 54, 85, 118, 121, 110, 50, 116, 76, 109, 110, 73, 100, 74, 98, 80, 69, 52, 118, 89, 118, 87, 76, 114, 116, 88, 88, 102, 70, 66, 83, 83, 80, 68, 52, 65, 102, 110, 55, 43, 51, 47, 88, 85, 103, 103, 65, 108, 99, 55, 111, 67, 84, 105, 122, 79, 102, 98, 98, 116, 79, 70, 108, 89, 65, 52, 103, 53, 75, 99, 89, 103, 83, 49, 74, 50, 90, 65, 101, 77, 81, 113, 98, 85, 100, 90, 115, 101, 90, 67, 99, 97, 90, 90, 90, 110, 54, 53, 116, 100, 113, 101, 101, 56, 85, 88, 90, 108, 68, 118, 120, 48, 43, 78, 100, 79, 48, 76, 82, 43, 53, 112, 70, 121, 43, 106, 117, 77, 48, 119, 87, 98, 117, 53, 57, 77, 118, 122, 99, 109, 84, 88, 98, 106, 115, 105, 55, 72, 89, 54, 122, 100, 53, 51, 89, 113, 53, 75, 50, 52, 52, 102, 119, 70, 72, 82, 81, 56, 101, 79, 66, 48, 73, 87, 66, 43, 52, 80, 102, 77, 55, 70, 101, 65, 65, 112, 90, 118, 108, 102, 113, 108, 75, 79, 108, 76, 99, 90, 76, 50, 117, 121, 86, 109, 122, 82, 107, 121, 82, 53, 121, 87, 55, 50, 117, 111, 57, 109, 101, 104, 88, 52, 52, 67, 105, 80, 74, 50, 102, 115, 101, 57, 89, 54, 101, 81, 116, 99, 102, 69, 104, 77, 80, 107, 109, 72, 88, 73, 48, 49, 115, 78, 43, 75, 119, 80, 98, 112, 65, 51, 57, 43, 120, 79, 115, 83, 116, 106, 104, 80, 57, 78, 49, 89, 49, 97, 50, 116, 81, 65, 86, 111, 43, 121, 86, 103, 76, 103, 86, 50, 72, 119, 115, 55, 51, 70, 99, 48, 111, 51, 119, 67, 55, 56, 113, 80, 69, 65, 43, 118, 50, 97, 82, 115, 47, 66, 101, 51, 90, 70, 68, 103, 68, 121, 103, 104, 99, 47, 49, 102, 103, 85, 43, 55, 67, 43, 80, 54, 107, 98, 113, 100, 52, 112, 111, 121, 98, 54, 73, 87, 56, 75, 67, 74, 98, 120, 102, 77, 74, 118, 107, 111, 114, 100, 78, 79, 103, 79, 85, 85, 120, 110, 100, 80, 72, 69, 105, 47, 116, 98, 47, 85, 55, 117, 76, 106, 76, 79, 103, 80, 65, 61, 61].to_vec().try_into().unwrap(), - } -} +// pub fn get_report() -> SgxAttestationReport { +// SgxAttestationReport { +// report_json_raw: [123, 34, 105, 100, 34, 58, 34, 49, 52, 53, 48, 49, 48, 48, 56, 52, 50, 57, 55, 53, 48, 51, 56, 53, 56, 57, 54, 54, 52, 56, 56, 57, 56, 49, 53, 53, 52, 52, 51, 53, 56, 48, 48, 55, 53, 56, 34, 44, 34, 116, 105, 109, 101, 115, 116, 97, 109, 112, 34, 58, 34, 50, 48, 50, 51, 45, 48, 56, 45, 50, 54, 84, 48, 50, 58, 48, 56, 58, 52, 51, 46, 53, 51, 52, 57, 53, 55, 34, 44, 34, 118, 101, 114, 115, 105, 111, 110, 34, 58, 52, 44, 34, 101, 112, 105, 100, 80, 115, 101, 117, 100, 111, 110, 121, 109, 34, 58, 34, 55, 43, 74, 112, 105, 53, 82, 83, 68, 117, 97, 54, 113, 49, 114, 109, 90, 72, 77, 112, 75, 100, 116, 80, 104, 102, 103, 111, 81, 106, 43, 55, 52, 85, 106, 111, 49, 49, 83, 67, 113, 118, 89, 107, 47, 85, 49, 47, 115, 48, 56, 72, 50, 109, 67, 101, 107, 110, 53, 119, 107, 82, 47, 53, 114, 71, 55, 66, 49, 122, 114, 104, 74, 49, 107, 121, 118, 101, 82, 47, 107, 72, 120, 98, 47, 71, 109, 75, 71, 51, 84, 99, 52, 83, 86, 74, 110, 78, 55, 75, 43, 47, 97, 48, 80, 110, 54, 121, 43, 106, 66, 75, 104, 106, 52, 79, 74, 101, 109, 102, 88, 75, 84, 104, 109, 49, 104, 89, 122, 52, 76, 65, 113, 53, 120, 69, 83, 82, 121, 68, 76, 89, 111, 71, 82, 89, 47, 57, 48, 118, 103, 97, 65, 89, 90, 109, 104, 53, 111, 85, 111, 48, 65, 98, 98, 111, 49, 99, 65, 102, 119, 61, 34, 44, 34, 97, 100, 118, 105, 115, 111, 114, 121, 85, 82, 76, 34, 58, 34, 104, 116, 116, 112, 115, 58, 47, 47, 115, 101, 99, 117, 114, 105, 116, 121, 45, 99, 101, 110, 116, 101, 114, 46, 105, 110, 116, 101, 108, 46, 99, 111, 109, 34, 44, 34, 97, 100, 118, 105, 115, 111, 114, 121, 73, 68, 115, 34, 58, 91, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 51, 51, 52, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 51, 56, 49, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 51, 56, 57, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 52, 55, 55, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 54, 49, 52, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 54, 49, 53, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 54, 49, 55, 34, 44, 34, 73, 78, 84, 69, 76, 45, 83, 65, 45, 48, 48, 56, 50, 56, 34, 93, 44, 34, 105, 115, 118, 69, 110, 99, 108, 97, 118, 101, 81, 117, 111, 116, 101, 83, 116, 97, 116, 117, 115, 34, 58, 34, 71, 82, 79, 85, 80, 95, 79, 85, 84, 95, 79, 70, 95, 68, 65, 84, 69, 34, 44, 34, 112, 108, 97, 116, 102, 111, 114, 109, 73, 110, 102, 111, 66, 108, 111, 98, 34, 58, 34, 49, 53, 48, 50, 48, 48, 54, 53, 48, 52, 48, 48, 48, 49, 48, 48, 48, 48, 48, 70, 48, 70, 48, 50, 48, 50, 48, 49, 56, 48, 48, 69, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 68, 48, 48, 48, 48, 48, 67, 48, 48, 48, 48, 48, 48, 48, 50, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 66, 69, 52, 57, 65, 66, 51, 55, 55, 53, 56, 66, 70, 50, 67, 49, 65, 48, 70, 56, 52, 68, 66, 66, 56, 67, 67, 66, 48, 49, 52, 57, 67, 68, 50, 53, 69, 48, 51, 65, 56, 68, 66, 69, 48, 67, 50, 51, 70, 70, 66, 51, 49, 56, 66, 69, 70, 48, 68, 48, 66, 65, 49, 70, 53, 56, 51, 49, 52, 57, 55, 52, 49, 49, 67, 65, 55, 51, 70, 53, 56, 55, 49, 48, 65, 57, 52, 54, 66, 66, 70, 53, 66, 52, 56, 52, 66, 66, 66, 49, 67, 70, 69, 67, 54, 50, 49, 55, 67, 54, 55, 67, 70, 48, 56, 68, 68, 52, 69, 50, 70, 56, 67, 50, 56, 66, 69, 53, 52, 49, 66, 34, 44, 34, 105, 115, 118, 69, 110, 99, 108, 97, 118, 101, 81, 117, 111, 116, 101, 66, 111, 100, 121, 34, 58, 34, 65, 103, 65, 66, 65, 79, 81, 76, 65, 65, 65, 79, 65, 65, 52, 65, 65, 65, 65, 65, 65, 66, 54, 88, 104, 48, 69, 77, 82, 89, 43, 87, 101, 43, 48, 55, 65, 103, 99, 120, 111, 115, 85, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 103, 55, 47, 66, 119, 101, 65, 66, 103, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 66, 119, 65, 65, 65, 65, 65, 65, 65, 65, 65, 72, 65, 65, 65, 65, 65, 65, 65, 65, 65, 75, 116, 102, 122, 78, 76, 100, 106, 54, 79, 100, 85, 99, 83, 87, 50, 77, 54, 66, 106, 83, 98, 116, 50, 79, 57, 100, 99, 122, 120, 103, 47, 111, 84, 106, 105, 51, 76, 84, 56, 87, 53, 69, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 67, 75, 116, 109, 66, 88, 114, 66, 121, 55, 49, 74, 43, 109, 82, 100, 107, 51, 65, 73, 57, 86, 68, 70, 118, 84, 86, 97, 56, 104, 50, 43, 112, 54, 99, 57, 87, 74, 51, 51, 79, 67, 90, 81, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 68, 68, 114, 56, 121, 89, 72, 57, 57, 79, 89, 52, 111, 68, 106, 111, 57, 80, 79, 111, 51, 103, 83, 47, 56, 75, 43, 114, 48, 56, 99, 86, 66, 110, 77, 107, 110, 88, 121, 89, 117, 43, 109, 119, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 34, 125].to_vec().try_into().unwrap(), +// sign: [111, 117, 80, 86, 83, 122, 54, 66, 89, 121, 86, 83, 108, 73, 71, 104, 116, 120, 57, 66, 70, 120, 43, 54, 84, 106, 105, 121, 80, 48, 97, 119, 114, 101, 74, 83, 86, 51, 111, 65, 55, 69, 84, 67, 122, 82, 67, 101, 52, 53, 115, 77, 81, 66, 52, 78, 57, 48, 105, 115, 111, 88, 86, 52, 119, 68, 74, 86, 71, 71, 71, 76, 113, 56, 99, 70, 65, 116, 48, 52, 50, 53, 57, 90, 80, 75, 111, 70, 111, 122, 77, 83, 110, 77, 111, 119, 118, 87, 113, 54, 56, 78, 68, 112, 108, 85, 105, 69, 122, 90, 118, 106, 77, 99, 82, 111, 89, 81, 75, 54, 105, 108, 117, 77, 87, 66, 98, 85, 120, 119, 89, 52, 85, 80, 43, 83, 71, 82, 108, 84, 85, 110, 84, 49, 56, 87, 100, 79, 104, 71, 71, 122, 69, 79, 78, 115, 86, 43, 69, 107, 114, 47, 48, 80, 103, 57, 81, 99, 115, 49, 84, 120, 71, 86, 43, 49, 70, 57, 120, 51, 74, 118, 90, 87, 98, 75, 84, 66, 53, 82, 47, 50, 109, 113, 77, 115, 67, 100, 105, 112, 120, 109, 120, 73, 55, 75, 65, 53, 106, 82, 113, 57, 47, 67, 77, 68, 102, 111, 52, 72, 122, 86, 79, 106, 110, 78, 118, 122, 88, 51, 110, 83, 69, 100, 122, 108, 83, 65, 85, 117, 101, 105, 73, 87, 109, 51, 47, 89, 103, 51, 80, 69, 76, 72, 117, 118, 114, 115, 56, 116, 47, 73, 66, 122, 122, 104, 47, 72, 81, 114, 52, 104, 106, 81, 68, 119, 111, 87, 65, 108, 51, 86, 97, 76, 106, 105, 107, 68, 81, 49, 75, 48, 122, 54, 90, 82, 88, 82, 79, 70, 103, 114, 97, 73, 68, 43, 112, 54, 65, 57, 68, 116, 84, 74, 119, 97, 68, 83, 101, 102, 78, 82, 97, 65, 120, 51, 87, 69, 106, 122, 113, 43, 49, 103, 85, 78, 77, 116, 65, 85, 75, 103, 61, 61].to_vec().try_into().unwrap(), +// cert_der: [77, 73, 73, 69, 111, 84, 67, 67, 65, 119, 109, 103, 65, 119, 73, 66, 65, 103, 73, 74, 65, 78, 69, 72, 100, 108, 48, 121, 111, 55, 67, 87, 77, 65, 48, 71, 67, 83, 113, 71, 83, 73, 98, 51, 68, 81, 69, 66, 67, 119, 85, 65, 77, 72, 52, 120, 67, 122, 65, 74, 66, 103, 78, 86, 66, 65, 89, 84, 65, 108, 86, 84, 77, 81, 115, 119, 67, 81, 89, 68, 86, 81, 81, 73, 68, 65, 74, 68, 81, 84, 69, 85, 77, 66, 73, 71, 65, 49, 85, 69, 66, 119, 119, 76, 85, 50, 70, 117, 100, 71, 69, 103, 81, 50, 120, 104, 99, 109, 69, 120, 71, 106, 65, 89, 66, 103, 78, 86, 66, 65, 111, 77, 69, 85, 108, 117, 100, 71, 86, 115, 73, 69, 78, 118, 99, 110, 66, 118, 99, 109, 70, 48, 97, 87, 57, 117, 77, 84, 65, 119, 76, 103, 89, 68, 86, 81, 81, 68, 68, 67, 100, 74, 98, 110, 82, 108, 98, 67, 66, 84, 82, 49, 103, 103, 81, 88, 82, 48, 90, 88, 78, 48, 89, 88, 82, 112, 98, 50, 52, 103, 85, 109, 86, 119, 98, 51, 74, 48, 73, 70, 78, 112, 90, 50, 53, 112, 98, 109, 99, 103, 81, 48, 69, 119, 72, 104, 99, 78, 77, 84, 89, 120, 77, 84, 73, 121, 77, 68, 107, 122, 78, 106, 85, 52, 87, 104, 99, 78, 77, 106, 89, 120, 77, 84, 73, 119, 77, 68, 107, 122, 78, 106, 85, 52, 87, 106, 66, 55, 77, 81, 115, 119, 67, 81, 89, 68, 86, 81, 81, 71, 69, 119, 74, 86, 85, 122, 69, 76, 77, 65, 107, 71, 65, 49, 85, 69, 67, 65, 119, 67, 81, 48, 69, 120, 70, 68, 65, 83, 66, 103, 78, 86, 66, 65, 99, 77, 67, 49, 78, 104, 98, 110, 82, 104, 73, 69, 78, 115, 89, 88, 74, 104, 77, 82, 111, 119, 71, 65, 89, 68, 86, 81, 81, 75, 68, 66, 70, 74, 98, 110, 82, 108, 98, 67, 66, 68, 98, 51, 74, 119, 98, 51, 74, 104, 100, 71, 108, 118, 98, 106, 69, 116, 77, 67, 115, 71, 65, 49, 85, 69, 65, 119, 119, 107, 83, 87, 53, 48, 90, 87, 119, 103, 85, 48, 100, 89, 73, 69, 70, 48, 100, 71, 86, 122, 100, 71, 70, 48, 97, 87, 57, 117, 73, 70, 74, 108, 99, 71, 57, 121, 100, 67, 66, 84, 97, 87, 100, 117, 97, 87, 53, 110, 77, 73, 73, 66, 73, 106, 65, 78, 66, 103, 107, 113, 104, 107, 105, 71, 57, 119, 48, 66, 65, 81, 69, 70, 65, 65, 79, 67, 65, 81, 56, 65, 77, 73, 73, 66, 67, 103, 75, 67, 65, 81, 69, 65, 113, 88, 111, 116, 52, 79, 90, 117, 112, 104, 82, 56, 110, 117, 100, 70, 114, 65, 70, 105, 97, 71, 120, 120, 107, 103, 109, 97, 47, 69, 115, 47, 66, 65, 43, 116, 98, 101, 67, 84, 85, 82, 49, 48, 54, 65, 76, 49, 69, 78, 99, 87, 65, 52, 70, 88, 51, 75, 43, 69, 57, 66, 66, 76, 48, 47, 55, 88, 53, 114, 106, 53, 110, 73, 103, 88, 47, 82, 47, 49, 117, 98, 104, 107, 75, 87, 119, 57, 103, 102, 113, 80, 71, 51, 75, 101, 65, 116, 73, 100, 99, 118, 47, 117, 84, 79, 49, 121, 88, 118, 53, 48, 118, 113, 97, 80, 118, 69, 49, 67, 82, 67, 104, 118, 122, 100, 83, 47, 90, 69, 66, 113, 81, 53, 111, 86, 118, 76, 84, 80, 90, 51, 86, 69, 105, 99, 81, 106, 108, 121, 116, 75, 103, 78, 57, 99, 76, 110, 120, 98, 119, 116, 117, 118, 76, 85, 75, 55, 101, 121, 82, 80, 102, 74, 87, 47, 107, 115, 100, 100, 79, 122, 80, 56, 86, 66, 66, 110, 105, 111, 108, 89, 110, 82, 67, 68, 50, 106, 114, 77, 82, 90, 56, 110, 66, 77, 50, 90, 87, 89, 119, 110, 88, 110, 119, 89, 101, 79, 65, 72, 86, 43, 87, 57, 116, 79, 104, 65, 73, 109, 119, 82, 119, 75, 70, 47, 57, 53, 121, 65, 115, 86, 119, 100, 50, 49, 114, 121, 72, 77, 74, 66, 99, 71, 72, 55, 48, 113, 76, 97, 103, 90, 55, 84, 116, 121, 116, 43, 43, 113, 79, 47, 54, 43, 75, 65, 88, 74, 117, 75, 119, 90, 113, 106, 82, 108, 69, 116, 83, 69, 122, 56, 103, 90, 81, 101, 70, 102, 86, 89, 103, 99, 119, 83, 102, 111, 57, 54, 111, 83, 77, 65, 122, 86, 114, 55, 86, 48, 76, 54, 72, 83, 68, 76, 82, 110, 112, 98, 54, 120, 120, 109, 98, 80, 100, 113, 78, 111, 108, 52, 116, 81, 73, 68, 65, 81, 65, 66, 111, 52, 71, 107, 77, 73, 71, 104, 77, 66, 56, 71, 65, 49, 85, 100, 73, 119, 81, 89, 77, 66, 97, 65, 70, 72, 104, 68, 101, 51, 97, 109, 102, 114, 122, 81, 114, 51, 53, 67, 78, 43, 115, 49, 102, 68, 117, 72, 65, 86, 69, 56, 77, 65, 52, 71, 65, 49, 85, 100, 68, 119, 69, 66, 47, 119, 81, 69, 65, 119, 73, 71, 119, 68, 65, 77, 66, 103, 78, 86, 72, 82, 77, 66, 65, 102, 56, 69, 65, 106, 65, 65, 77, 71, 65, 71, 65, 49, 85, 100, 72, 119, 82, 90, 77, 70, 99, 119, 86, 97, 66, 84, 111, 70, 71, 71, 84, 50, 104, 48, 100, 72, 65, 54, 76, 121, 57, 48, 99, 110, 86, 122, 100, 71, 86, 107, 99, 50, 86, 121, 100, 109, 108, 106, 90, 88, 77, 117, 97, 87, 53, 48, 90, 87, 119, 117, 89, 50, 57, 116, 76, 50, 78, 118, 98, 110, 82, 108, 98, 110, 81, 118, 81, 49, 74, 77, 76, 49, 78, 72, 87, 67, 57, 66, 100, 72, 82, 108, 99, 51, 82, 104, 100, 71, 108, 118, 98, 108, 74, 108, 99, 71, 57, 121, 100, 70, 78, 112, 90, 50, 53, 112, 98, 109, 100, 68, 81, 83, 53, 106, 99, 109, 119, 119, 68, 81, 89, 74, 75, 111, 90, 73, 104, 118, 99, 78, 65, 81, 69, 76, 66, 81, 65, 68, 103, 103, 71, 66, 65, 71, 99, 73, 116, 104, 116, 99, 75, 57, 73, 86, 82, 122, 52, 114, 82, 113, 43, 90, 75, 69, 43, 55, 107, 53, 48, 47, 79, 120, 85, 115, 109, 87, 56, 97, 97, 118, 79, 122, 75, 98, 48, 105, 67, 120, 48, 55, 89, 81, 57, 114, 122, 105, 53, 110, 85, 55, 51, 116, 77, 69, 50, 121, 71, 82, 76, 122, 104, 83, 86, 105, 70, 115, 47, 76, 112, 70, 97, 57, 108, 112, 81, 76, 54, 74, 76, 49, 97, 81, 119, 109, 68, 82, 55, 52, 84, 120, 89, 71, 66, 65, 73, 105, 53, 102, 52, 73, 53, 84, 74, 111, 67, 67, 69, 113, 82, 72, 122, 57, 49, 107, 112, 71, 54, 85, 118, 121, 110, 50, 116, 76, 109, 110, 73, 100, 74, 98, 80, 69, 52, 118, 89, 118, 87, 76, 114, 116, 88, 88, 102, 70, 66, 83, 83, 80, 68, 52, 65, 102, 110, 55, 43, 51, 47, 88, 85, 103, 103, 65, 108, 99, 55, 111, 67, 84, 105, 122, 79, 102, 98, 98, 116, 79, 70, 108, 89, 65, 52, 103, 53, 75, 99, 89, 103, 83, 49, 74, 50, 90, 65, 101, 77, 81, 113, 98, 85, 100, 90, 115, 101, 90, 67, 99, 97, 90, 90, 90, 110, 54, 53, 116, 100, 113, 101, 101, 56, 85, 88, 90, 108, 68, 118, 120, 48, 43, 78, 100, 79, 48, 76, 82, 43, 53, 112, 70, 121, 43, 106, 117, 77, 48, 119, 87, 98, 117, 53, 57, 77, 118, 122, 99, 109, 84, 88, 98, 106, 115, 105, 55, 72, 89, 54, 122, 100, 53, 51, 89, 113, 53, 75, 50, 52, 52, 102, 119, 70, 72, 82, 81, 56, 101, 79, 66, 48, 73, 87, 66, 43, 52, 80, 102, 77, 55, 70, 101, 65, 65, 112, 90, 118, 108, 102, 113, 108, 75, 79, 108, 76, 99, 90, 76, 50, 117, 121, 86, 109, 122, 82, 107, 121, 82, 53, 121, 87, 55, 50, 117, 111, 57, 109, 101, 104, 88, 52, 52, 67, 105, 80, 74, 50, 102, 115, 101, 57, 89, 54, 101, 81, 116, 99, 102, 69, 104, 77, 80, 107, 109, 72, 88, 73, 48, 49, 115, 78, 43, 75, 119, 80, 98, 112, 65, 51, 57, 43, 120, 79, 115, 83, 116, 106, 104, 80, 57, 78, 49, 89, 49, 97, 50, 116, 81, 65, 86, 111, 43, 121, 86, 103, 76, 103, 86, 50, 72, 119, 115, 55, 51, 70, 99, 48, 111, 51, 119, 67, 55, 56, 113, 80, 69, 65, 43, 118, 50, 97, 82, 115, 47, 66, 101, 51, 90, 70, 68, 103, 68, 121, 103, 104, 99, 47, 49, 102, 103, 85, 43, 55, 67, 43, 80, 54, 107, 98, 113, 100, 52, 112, 111, 121, 98, 54, 73, 87, 56, 75, 67, 74, 98, 120, 102, 77, 74, 118, 107, 111, 114, 100, 78, 79, 103, 79, 85, 85, 120, 110, 100, 80, 72, 69, 105, 47, 116, 98, 47, 85, 55, 117, 76, 106, 76, 79, 103, 80, 65, 61, 61].to_vec().try_into().unwrap(), +// } +// } -pub fn tee_register() -> Result<(T::AccountId, T::AccountId), &'static str> { - let (stash, controller) = pallet_cess_staking::testing_utils::create_stash_controller::(USER_SEED, 100, Default::default())?; - let sgx_att_report = get_report(); - TeeWorker::::register( - RawOrigin::Signed(controller.clone()).into(), - stash.clone(), - NODE_PUBLIC_KEY, - PEER_ID, - PODR2_PBK, - sgx_att_report - ).map_err(|_| "tee worker register error")?; - Ok((stash, controller)) -} +// pub fn tee_register() -> Result<(T::AccountId, T::AccountId), &'static str> { +// let (stash, controller) = pallet_cess_staking::testing_utils::create_stash_controller::(USER_SEED, 100, Default::default())?; +// let sgx_att_report = get_report(); +// TeeWorker::::register( +// RawOrigin::Signed(controller.clone()).into(), +// stash.clone(), +// NODE_PUBLIC_KEY, +// PEER_ID, +// PODR2_PBK, +// sgx_att_report +// ).map_err(|_| "tee worker register error")?; +// Ok((stash, controller)) +// } -benchmarks! { - register { - let (stash, controller) = pallet_cess_staking::testing_utils::create_stash_controller::(USER_SEED, 100, Default::default())?; - let sgx_att_report = get_report(); - }: _(RawOrigin::Signed(controller.clone()), stash.clone(), NODE_PUBLIC_KEY, PEER_ID, PODR2_PBK, sgx_att_report) - verify { - assert!(TeeWorkerMap::::contains_key(&controller)) - } +// benchmarks! { +// register { +// let (stash, controller) = pallet_cess_staking::testing_utils::create_stash_controller::(USER_SEED, 100, Default::default())?; +// let sgx_att_report = get_report(); +// }: _(RawOrigin::Signed(controller.clone()), stash.clone(), NODE_PUBLIC_KEY, PEER_ID, PODR2_PBK, sgx_att_report) +// verify { +// assert!(TeeWorkerMap::::contains_key(&controller)) +// } - update_whitelist { - let _ = tee_register::()?; - let mr_enclave = [5u8; 64]; - }: _(RawOrigin::Root, mr_enclave.clone()) - verify { - let mr_enclave_list = >::get(); - assert!(mr_enclave_list.contains(&mr_enclave)) - } +// update_whitelist { +// let _ = tee_register::()?; +// let mr_enclave = [5u8; 64]; +// }: _(RawOrigin::Root, mr_enclave.clone()) +// verify { +// let mr_enclave_list = >::get(); +// assert!(mr_enclave_list.contains(&mr_enclave)) +// } - exit { - let (_, controller) = tee_register::()?; - }: _(RawOrigin::Signed(controller.clone())) - verify { - assert!(!TeeWorkerMap::::contains_key(&controller)) - } -} +// exit { +// let (_, controller) = tee_register::()?; +// }: _(RawOrigin::Signed(controller.clone())) +// verify { +// assert!(!TeeWorkerMap::::contains_key(&controller)) +// } +// } diff --git a/standalone/chain/node/src/benchmarking.rs b/standalone/chain/node/src/benchmarking.rs index e00bb103..3c082c13 100644 --- a/standalone/chain/node/src/benchmarking.rs +++ b/standalone/chain/node/src/benchmarking.rs @@ -1,5 +1,3 @@ -use crate::service::Client; - use cess_node_runtime as runtime; use runtime::{AccountId, Balance, BalancesCall, SystemCall}; use sc_cli::Result; diff --git a/standalone/chain/node/src/command.rs b/standalone/chain/node/src/command.rs index 4b6fe92e..3f0f8190 100644 --- a/standalone/chain/node/src/command.rs +++ b/standalone/chain/node/src/command.rs @@ -28,7 +28,7 @@ use crate::{ eth::db_config_dir, service, }; -use cess_node_runtime::Block; +use cess_node_runtime::{Block, ExistentialDeposit}; #[cfg(feature = "runtime-benchmarks")] use crate::chain_spec::get_account_id_from_seed; diff --git a/standalone/chain/node/src/main.rs b/standalone/chain/node/src/main.rs index d082f361..00c08e0d 100755 --- a/standalone/chain/node/src/main.rs +++ b/standalone/chain/node/src/main.rs @@ -5,7 +5,6 @@ clippy::too_many_arguments, clippy::large_enum_variant )] -#![cfg_attr(feature = "runtime-benchmarks", deny(unused_crate_dependencies))] #[cfg(feature = "runtime-benchmarks")] mod benchmarking; diff --git a/standalone/chain/runtime/Cargo.toml b/standalone/chain/runtime/Cargo.toml index 6fad008a..b3726b38 100644 --- a/standalone/chain/runtime/Cargo.toml +++ b/standalone/chain/runtime/Cargo.toml @@ -31,6 +31,7 @@ sp-staking = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } +sp-storage = { workspace = true } # frame dependencies frame-benchmarking = { workspace = true, optional = true } diff --git a/standalone/chain/runtime/src/lib.rs b/standalone/chain/runtime/src/lib.rs index a7c37326..d6e544cf 100644 --- a/standalone/chain/runtime/src/lib.rs +++ b/standalone/chain/runtime/src/lib.rs @@ -1743,14 +1743,14 @@ mod benches { [frame_benchmarking, BaselineBench::] [frame_system, SystemBench::] [pallet_contracts, Contracts] - [pallet_sminer, SminerBench::] - // [pallet_oss, Oss] - [pallet_cacher, Cacher] - [pallet_storage_handler, StorageHandler] - [pallet_audit, AuditBench::] - [pallet_file_bank, FileBankBench::] - [pallet_tee_worker, TeeWorkerBench::] [pallet_oss, Oss] + [pallet_cacher, Cacher] + // [pallet_storage_handler, StorageHandler] + // [pallet_sminer, SminerBench::] + // [pallet_audit, AuditBench::] + // [pallet_file_bank, FileBankBench::] + // [pallet_tee_worker, TeeWorkerBench::] + // [pallet_oss, Oss] // [pallet_audit, Audit] [pallet_collective::, Council] [pallet_collective::, TechnicalCommittee] @@ -2305,11 +2305,11 @@ impl_runtime_apis! { use frame_benchmarking::{baseline, Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; - use pallet_tee_worker::benchmarking::Pallet as TeeWorkerBench; - use pallet_file_bank::benchmarking::Pallet as FileBankBench; + // use pallet_tee_worker::benchmarking::Pallet as TeeWorkerBench; + // use pallet_file_bank::benchmarking::Pallet as FileBankBench; + // use pallet_sminer::benchmarking::Pallet as SminerBench; + // use pallet_audit::benchmarking::Pallet as AuditBench; use pallet_evm::Pallet as PalletEvmBench; - use pallet_sminer::benchmarking::Pallet as SminerBench; - use pallet_audit::benchmarking::Pallet as AuditBench; use baseline::Pallet as BaselineBench; let mut list = Vec::::new(); @@ -2323,24 +2323,26 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch}; + use sp_storage::TrackedStorageKey; use pallet_evm::Pallet as PalletEvmBench; use frame_system_benchmarking::Pallet as SystemBench; - use pallet_tee_worker::benchmarking::Pallet as TeeWorkerBench; - use pallet_file_bank::benchmarking::Pallet as FileBankBench; - use pallet_sminer::benchmarking::Pallet as SminerBench; + // use pallet_tee_worker::benchmarking::Pallet as TeeWorkerBench; + // use pallet_file_bank::benchmarking::Pallet as FileBankBench; + // use pallet_sminer::benchmarking::Pallet as SminerBench; + // use pallet_audit::benchmarking::Pallet as AuditBench; use baseline::Pallet as BaselineBench; - use pallet_audit::benchmarking::Pallet as AuditBench; use frame_support::traits::WhitelistedStorageKeys; impl frame_system_benchmarking::Config for Runtime {} - impl pallet_tee_worker::benchmarking::Config for Runtime{} - impl pallet_sminer::benchmarking::Config for Runtime{} - impl pallet_file_bank::benchmarking::Config for Runtime{} - impl pallet_audit::benchmarking::Config for Runtime{} + // impl pallet_tee_worker::benchmarking::Config for Runtime{} + // impl pallet_sminer::benchmarking::Config for Runtime{} // impl pallet_file_bank::benchmarking::Config for Runtime{} + // impl pallet_audit::benchmarking::Config for Runtime{} impl baseline::Config for Runtime {} - let whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); + let mut whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); + let treasury_key = frame_system::Account::::hashed_key_for(Treasury::account_id()); + whitelist.push(treasury_key.to_vec().into()); let mut batches = Vec::::new(); let params = (&config, &whitelist);